@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | ?string $scope = null, |
| 27 | 27 | private readonly bool $useAnnotations = false, |
| 28 | 28 | private readonly bool $namedArguments = true, |
| 29 | - ) { |
|
| 29 | + ){ |
|
| 30 | 30 | parent::__construct($scope); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -41,27 +41,27 @@ discard block |
||
| 41 | 41 | ? (new Factory())->create() |
| 42 | 42 | : new AttributeReader($this->namedArguments ? new NamedArgumentsInstantiator() : null); |
| 43 | 43 | |
| 44 | - if ($attribute === null) { |
|
| 44 | + if ($attribute === null){ |
|
| 45 | 45 | return; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $attribute = $attribute->newInstance(); |
| 49 | 49 | |
| 50 | - foreach ($classes as $class) { |
|
| 50 | + foreach ($classes as $class){ |
|
| 51 | 51 | // If attribute is defined on class level and class has target attribute |
| 52 | 52 | // then we can add it to the list of classes |
| 53 | 53 | if (($attribute->flags & \Attribute::TARGET_CLASS) |
| 54 | 54 | && $reader->firstClassMetadata($class, $target->getName()) |
| 55 | - ) { |
|
| 55 | + ){ |
|
| 56 | 56 | yield $class->getName(); |
| 57 | 57 | continue; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // If attribute is defined on method level and class methods has target attribute |
| 61 | 61 | // then we can add it to the list of classes |
| 62 | - if ($attribute->flags & \Attribute::TARGET_METHOD) { |
|
| 63 | - foreach ($class->getMethods() as $method) { |
|
| 64 | - if ($reader->firstFunctionMetadata($method, $target->getName())) { |
|
| 62 | + if ($attribute->flags & \Attribute::TARGET_METHOD){ |
|
| 63 | + foreach ($class->getMethods() as $method){ |
|
| 64 | + if ($reader->firstFunctionMetadata($method, $target->getName())){ |
|
| 65 | 65 | yield $class->getName(); |
| 66 | 66 | continue 2; |
| 67 | 67 | } |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | // If attribute is defined on property level and class properties has target attribute |
| 72 | 72 | // then we can add it to the list of classes |
| 73 | - if ($attribute->flags & \Attribute::TARGET_PROPERTY) { |
|
| 74 | - foreach ($class->getProperties() as $property) { |
|
| 75 | - if ($reader->firstPropertyMetadata($property, $target->getName())) { |
|
| 73 | + if ($attribute->flags & \Attribute::TARGET_PROPERTY){ |
|
| 74 | + foreach ($class->getProperties() as $property){ |
|
| 75 | + if ($reader->firstPropertyMetadata($property, $target->getName())){ |
|
| 76 | 76 | yield $class->getName(); |
| 77 | 77 | continue 2; |
| 78 | 78 | } |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | // If attribute is defined on constant level and class constants has target attribute |
| 84 | 84 | // then we can add it to the list of classes |
| 85 | - if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) { |
|
| 86 | - foreach ($class->getReflectionConstants() as $constant) { |
|
| 87 | - if ($reader->firstConstantMetadata($constant, $target->getName())) { |
|
| 85 | + if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT){ |
|
| 86 | + foreach ($class->getReflectionConstants() as $constant){ |
|
| 87 | + if ($reader->firstConstantMetadata($constant, $target->getName())){ |
|
| 88 | 88 | yield $class->getName(); |
| 89 | 89 | continue 2; |
| 90 | 90 | } |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | // If attribute is defined on method parameters level and class method parameter has target attribute |
| 96 | 96 | // then we can add it to the list of classes |
| 97 | - if ($attribute->flags & \Attribute::TARGET_PARAMETER) { |
|
| 98 | - foreach ($class->getMethods() as $method) { |
|
| 99 | - foreach ($method->getParameters() as $parameter) { |
|
| 100 | - if ($reader->firstParameterMetadata($parameter, $target->getName())) { |
|
| 97 | + if ($attribute->flags & \Attribute::TARGET_PARAMETER){ |
|
| 98 | + foreach ($class->getMethods() as $method){ |
|
| 99 | + foreach ($method->getParameters() as $parameter){ |
|
| 100 | + if ($reader->firstParameterMetadata($parameter, $target->getName())){ |
|
| 101 | 101 | yield $class->getName(); |
| 102 | 102 | continue 3; |
| 103 | 103 | } |
@@ -41,13 +41,15 @@ discard block |
||
| 41 | 41 | ? (new Factory())->create() |
| 42 | 42 | : new AttributeReader($this->namedArguments ? new NamedArgumentsInstantiator() : null); |
| 43 | 43 | |
| 44 | - if ($attribute === null) { |
|
| 44 | + if ($attribute === null) |
|
| 45 | + { |
|
| 45 | 46 | return; |
| 46 | 47 | } |
| 47 | 48 | |
| 48 | 49 | $attribute = $attribute->newInstance(); |
| 49 | 50 | |
| 50 | - foreach ($classes as $class) { |
|
| 51 | + foreach ($classes as $class) |
|
| 52 | + { |
|
| 51 | 53 | // If attribute is defined on class level and class has target attribute |
| 52 | 54 | // then we can add it to the list of classes |
| 53 | 55 | if (($attribute->flags & \Attribute::TARGET_CLASS) |
@@ -59,9 +61,12 @@ discard block |
||
| 59 | 61 | |
| 60 | 62 | // If attribute is defined on method level and class methods has target attribute |
| 61 | 63 | // then we can add it to the list of classes |
| 62 | - if ($attribute->flags & \Attribute::TARGET_METHOD) { |
|
| 63 | - foreach ($class->getMethods() as $method) { |
|
| 64 | - if ($reader->firstFunctionMetadata($method, $target->getName())) { |
|
| 64 | + if ($attribute->flags & \Attribute::TARGET_METHOD) |
|
| 65 | + { |
|
| 66 | + foreach ($class->getMethods() as $method) |
|
| 67 | + { |
|
| 68 | + if ($reader->firstFunctionMetadata($method, $target->getName())) |
|
| 69 | + { |
|
| 65 | 70 | yield $class->getName(); |
| 66 | 71 | continue 2; |
| 67 | 72 | } |
@@ -70,9 +75,12 @@ discard block |
||
| 70 | 75 | |
| 71 | 76 | // If attribute is defined on property level and class properties has target attribute |
| 72 | 77 | // then we can add it to the list of classes |
| 73 | - if ($attribute->flags & \Attribute::TARGET_PROPERTY) { |
|
| 74 | - foreach ($class->getProperties() as $property) { |
|
| 75 | - if ($reader->firstPropertyMetadata($property, $target->getName())) { |
|
| 78 | + if ($attribute->flags & \Attribute::TARGET_PROPERTY) |
|
| 79 | + { |
|
| 80 | + foreach ($class->getProperties() as $property) |
|
| 81 | + { |
|
| 82 | + if ($reader->firstPropertyMetadata($property, $target->getName())) |
|
| 83 | + { |
|
| 76 | 84 | yield $class->getName(); |
| 77 | 85 | continue 2; |
| 78 | 86 | } |
@@ -82,9 +90,12 @@ discard block |
||
| 82 | 90 | |
| 83 | 91 | // If attribute is defined on constant level and class constants has target attribute |
| 84 | 92 | // then we can add it to the list of classes |
| 85 | - if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) { |
|
| 86 | - foreach ($class->getReflectionConstants() as $constant) { |
|
| 87 | - if ($reader->firstConstantMetadata($constant, $target->getName())) { |
|
| 93 | + if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) |
|
| 94 | + { |
|
| 95 | + foreach ($class->getReflectionConstants() as $constant) |
|
| 96 | + { |
|
| 97 | + if ($reader->firstConstantMetadata($constant, $target->getName())) |
|
| 98 | + { |
|
| 88 | 99 | yield $class->getName(); |
| 89 | 100 | continue 2; |
| 90 | 101 | } |
@@ -94,10 +105,14 @@ discard block |
||
| 94 | 105 | |
| 95 | 106 | // If attribute is defined on method parameters level and class method parameter has target attribute |
| 96 | 107 | // then we can add it to the list of classes |
| 97 | - if ($attribute->flags & \Attribute::TARGET_PARAMETER) { |
|
| 98 | - foreach ($class->getMethods() as $method) { |
|
| 99 | - foreach ($method->getParameters() as $parameter) { |
|
| 100 | - if ($reader->firstParameterMetadata($parameter, $target->getName())) { |
|
| 108 | + if ($attribute->flags & \Attribute::TARGET_PARAMETER) |
|
| 109 | + { |
|
| 110 | + foreach ($class->getMethods() as $method) |
|
| 111 | + { |
|
| 112 | + foreach ($method->getParameters() as $parameter) |
|
| 113 | + { |
|
| 114 | + if ($reader->firstParameterMetadata($parameter, $target->getName())) |
|
| 115 | + { |
|
| 101 | 116 | yield $class->getName(); |
| 102 | 117 | continue 3; |
| 103 | 118 | } |
@@ -15,10 +15,10 @@ |
||
| 15 | 15 | public function testToString(): void |
| 16 | 16 | { |
| 17 | 17 | $attribute = new TargetAttribute('foo'); |
| 18 | - $this->assertSame('d8d66e598d7117a26f6268ea9780774f', (string) $attribute); |
|
| 18 | + $this->assertSame('d8d66e598d7117a26f6268ea9780774f', (string)$attribute); |
|
| 19 | 19 | |
| 20 | 20 | $attribute = new TargetAttribute('foo', 'bar'); |
| 21 | - $this->assertSame('5bd549fe54f1e987a4fbfc8513d2dc68', (string) $attribute); |
|
| 21 | + $this->assertSame('5bd549fe54f1e987a4fbfc8513d2dc68', (string)$attribute); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public function testFilter(): void |
@@ -10,6 +10,6 @@ |
||
| 10 | 10 | public function __construct( |
| 11 | 11 | private string $foo, |
| 12 | 12 | private string $bar, |
| 13 | - ) { |
|
| 13 | + ){ |
|
| 14 | 14 | } |
| 15 | 15 | } |