Passed
Pull Request — master (#1110)
by Aleksei
12:33
created
src/Tokenizer/src/Attribute/TargetAttribute.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         private readonly bool $useAnnotations = false,
30 30
         private readonly bool $namedArguments = true,
31 31
         private readonly bool $scanParents = false,
32
-    ) {
32
+    ){
33 33
         parent::__construct($scope);
34 34
     }
35 35
 
@@ -45,25 +45,25 @@  discard block
 block discarded – undo
45 45
             ? (new Factory())->create()
46 46
             : new AttributeReader($this->namedArguments ? new NamedArgumentsInstantiator() : null);
47 47
 
48
-        if ($attribute === null) {
48
+        if ($attribute === null){
49 49
             return;
50 50
         }
51 51
 
52 52
         $attribute = $attribute->newInstance();
53 53
 
54
-        foreach ($classes as $class) {
54
+        foreach ($classes as $class){
55 55
             // If attribute is defined on class level and class has target attribute
56 56
             // then we can add it to the list of classes
57
-            if ($attribute->flags & \Attribute::TARGET_CLASS) {
58
-                if ($reader->firstClassMetadata($class, $target->getName())) {
57
+            if ($attribute->flags & \Attribute::TARGET_CLASS){
58
+                if ($reader->firstClassMetadata($class, $target->getName())){
59 59
                     yield $class->getName();
60 60
                     continue;
61 61
                 }
62 62
 
63
-                if ($this->scanParents) {
63
+                if ($this->scanParents){
64 64
                     // Interfaces
65
-                    foreach ($class->getInterfaces() as $interface) {
66
-                        if ($reader->firstClassMetadata($interface, $target->getName())) {
65
+                    foreach ($class->getInterfaces() as $interface){
66
+                        if ($reader->firstClassMetadata($interface, $target->getName())){
67 67
                             yield $class->getName();
68 68
                             continue 2;
69 69
                         }
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 
72 72
                     // Parents
73 73
                     $parent = $class->getParentClass();
74
-                    while ($parent !== false) {
75
-                        if ($reader->firstClassMetadata($parent, $target->getName())) {
74
+                    while ($parent !== false){
75
+                        if ($reader->firstClassMetadata($parent, $target->getName())){
76 76
                             yield $class->getName();
77 77
                             continue 2;
78 78
                         }
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
 
84 84
             // If attribute is defined on method level and class methods has target attribute
85 85
             // then we can add it to the list of classes
86
-            if ($attribute->flags & \Attribute::TARGET_METHOD) {
87
-                foreach ($class->getMethods() as $method) {
88
-                    if ($reader->firstFunctionMetadata($method, $target->getName())) {
86
+            if ($attribute->flags & \Attribute::TARGET_METHOD){
87
+                foreach ($class->getMethods() as $method){
88
+                    if ($reader->firstFunctionMetadata($method, $target->getName())){
89 89
                         yield $class->getName();
90 90
                         continue 2;
91 91
                     }
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 
95 95
             // If attribute is defined on property level and class properties has target attribute
96 96
             // then we can add it to the list of classes
97
-            if ($attribute->flags & \Attribute::TARGET_PROPERTY) {
98
-                foreach ($class->getProperties() as $property) {
99
-                    if ($reader->firstPropertyMetadata($property, $target->getName())) {
97
+            if ($attribute->flags & \Attribute::TARGET_PROPERTY){
98
+                foreach ($class->getProperties() as $property){
99
+                    if ($reader->firstPropertyMetadata($property, $target->getName())){
100 100
                         yield $class->getName();
101 101
                         continue 2;
102 102
                     }
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 
107 107
             // If attribute is defined on constant level and class constants has target attribute
108 108
             // then we can add it to the list of classes
109
-            if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) {
110
-                foreach ($class->getReflectionConstants() as $constant) {
111
-                    if ($reader->firstConstantMetadata($constant, $target->getName())) {
109
+            if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT){
110
+                foreach ($class->getReflectionConstants() as $constant){
111
+                    if ($reader->firstConstantMetadata($constant, $target->getName())){
112 112
                         yield $class->getName();
113 113
                         continue 2;
114 114
                     }
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 
119 119
             // If attribute is defined on method parameters level and class method parameter has target attribute
120 120
             // then we can add it to the list of classes
121
-            if ($attribute->flags & \Attribute::TARGET_PARAMETER) {
122
-                foreach ($class->getMethods() as $method) {
123
-                    foreach ($method->getParameters() as $parameter) {
124
-                        if ($reader->firstParameterMetadata($parameter, $target->getName())) {
121
+            if ($attribute->flags & \Attribute::TARGET_PARAMETER){
122
+                foreach ($class->getMethods() as $method){
123
+                    foreach ($method->getParameters() as $parameter){
124
+                        if ($reader->firstParameterMetadata($parameter, $target->getName())){
125 125
                             yield $class->getName();
126 126
                             continue 3;
127 127
                         }
Please login to merge, or discard this patch.
src/Tokenizer/tests/Attribute/TargetAttributeTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@
 block discarded – undo
20 20
     public function testToString(): void
21 21
     {
22 22
         $attribute = new TargetAttribute('foo');
23
-        $this->assertSame('3dc18b19eed74479a03c069dec2e8724', (string) $attribute);
23
+        $this->assertSame('3dc18b19eed74479a03c069dec2e8724', (string)$attribute);
24 24
 
25 25
         $attribute = new TargetAttribute('foo', 'bar');
26
-        $this->assertSame('52ec767c53f3898bf6de6f6e88125dc8', (string) $attribute);
26
+        $this->assertSame('52ec767c53f3898bf6de6f6e88125dc8', (string)$attribute);
27 27
     }
28 28
 
29 29
     public function testFilterAttrWithArgs(): void
Please login to merge, or discard this patch.