-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify class scanner even more, prepare to add caching for optimal …
…development experience
- Loading branch information
1 parent
43642d9
commit 58f58b7
Showing
15 changed files
with
412 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
declare(strict_types=1); | ||
/** | ||
* | ||
* This file is part of Aura for PHP. | ||
* | ||
* @license http://opensource.org/licenses/MIT MIT | ||
* | ||
*/ | ||
|
||
namespace Aura\Di\Attribute; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_CLASS)] | ||
class DefineAttribute | ||
{ | ||
private string $className; | ||
|
||
public function __construct(string $className) | ||
{ | ||
$this->className = $className; | ||
} | ||
|
||
public function getClassName(): string | ||
{ | ||
return $this->className; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Aura\Di\ClassScanner; | ||
|
||
final class AnnotatedAttribute | ||
{ | ||
private object $attributeInstance; | ||
private string $className; | ||
private int $attributeTarget; | ||
private array $targetConfig; | ||
|
||
public function __construct( | ||
object $attributeInstance, | ||
string $className, | ||
int $attributeTarget, | ||
array $targetConfig = [], | ||
) | ||
{ | ||
$this->attributeInstance = $attributeInstance; | ||
$this->className = $className; | ||
$this->attributeTarget = $attributeTarget; | ||
$this->targetConfig = $targetConfig; | ||
} | ||
|
||
public function getAttributeInstance(): object | ||
{ | ||
return $this->attributeInstance; | ||
} | ||
|
||
public function getClassName(): string | ||
{ | ||
return $this->className; | ||
} | ||
|
||
public function getAttributeTarget(): int | ||
{ | ||
return $this->attributeTarget; | ||
} | ||
|
||
public function getTargetConfig(): array | ||
{ | ||
return $this->targetConfig; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Aura\Di\ClassScanner; | ||
|
||
final class ClassMap | ||
{ | ||
private array $classes = []; | ||
|
||
public function addClass(string $class, string $filename, array $annotatedAttributes): void | ||
{ | ||
$this->classes[$filename][$class] = $annotatedAttributes; | ||
} | ||
|
||
/** | ||
* @return array<class-string, array<int, AnnotatedAttribute>> | ||
*/ | ||
public function getClassMap(): array | ||
{ | ||
return \array_merge([], ...\array_values($this->classes)); | ||
} | ||
} |
Oops, something went wrong.