Passed
Pull Request — master (#1110)
by Aleksei
12:33
created
src/Tokenizer/src/Attribute/TargetAttribute.php 2 patches
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.
Braces   +44 added lines, -22 removed lines patch added patch discarded remove patch
@@ -45,25 +45,32 @@  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 50
             return;
50 51
         }
51 52
 
52 53
         $attribute = $attribute->newInstance();
53 54
 
54
-        foreach ($classes as $class) {
55
+        foreach ($classes as $class)
56
+        {
55 57
             // If attribute is defined on class level and class has target attribute
56 58
             // then we can add it to the list of classes
57
-            if ($attribute->flags & \Attribute::TARGET_CLASS) {
58
-                if ($reader->firstClassMetadata($class, $target->getName())) {
59
+            if ($attribute->flags & \Attribute::TARGET_CLASS)
60
+            {
61
+                if ($reader->firstClassMetadata($class, $target->getName()))
62
+                {
59 63
                     yield $class->getName();
60 64
                     continue;
61 65
                 }
62 66
 
63
-                if ($this->scanParents) {
67
+                if ($this->scanParents)
68
+                {
64 69
                     // Interfaces
65
-                    foreach ($class->getInterfaces() as $interface) {
66
-                        if ($reader->firstClassMetadata($interface, $target->getName())) {
70
+                    foreach ($class->getInterfaces() as $interface)
71
+                    {
72
+                        if ($reader->firstClassMetadata($interface, $target->getName()))
73
+                        {
67 74
                             yield $class->getName();
68 75
                             continue 2;
69 76
                         }
@@ -71,8 +78,10 @@  discard block
 block discarded – undo
71 78
 
72 79
                     // Parents
73 80
                     $parent = $class->getParentClass();
74
-                    while ($parent !== false) {
75
-                        if ($reader->firstClassMetadata($parent, $target->getName())) {
81
+                    while ($parent !== false)
82
+                    {
83
+                        if ($reader->firstClassMetadata($parent, $target->getName()))
84
+                        {
76 85
                             yield $class->getName();
77 86
                             continue 2;
78 87
                         }
@@ -83,9 +92,12 @@  discard block
 block discarded – undo
83 92
 
84 93
             // If attribute is defined on method level and class methods has target attribute
85 94
             // 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())) {
95
+            if ($attribute->flags & \Attribute::TARGET_METHOD)
96
+            {
97
+                foreach ($class->getMethods() as $method)
98
+                {
99
+                    if ($reader->firstFunctionMetadata($method, $target->getName()))
100
+                    {
89 101
                         yield $class->getName();
90 102
                         continue 2;
91 103
                     }
@@ -94,9 +106,12 @@  discard block
 block discarded – undo
94 106
 
95 107
             // If attribute is defined on property level and class properties has target attribute
96 108
             // 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())) {
109
+            if ($attribute->flags & \Attribute::TARGET_PROPERTY)
110
+            {
111
+                foreach ($class->getProperties() as $property)
112
+                {
113
+                    if ($reader->firstPropertyMetadata($property, $target->getName()))
114
+                    {
100 115
                         yield $class->getName();
101 116
                         continue 2;
102 117
                     }
@@ -106,9 +121,12 @@  discard block
 block discarded – undo
106 121
 
107 122
             // If attribute is defined on constant level and class constants has target attribute
108 123
             // 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())) {
124
+            if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT)
125
+            {
126
+                foreach ($class->getReflectionConstants() as $constant)
127
+                {
128
+                    if ($reader->firstConstantMetadata($constant, $target->getName()))
129
+                    {
112 130
                         yield $class->getName();
113 131
                         continue 2;
114 132
                     }
@@ -118,10 +136,14 @@  discard block
 block discarded – undo
118 136
 
119 137
             // If attribute is defined on method parameters level and class method parameter has target attribute
120 138
             // 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())) {
139
+            if ($attribute->flags & \Attribute::TARGET_PARAMETER)
140
+            {
141
+                foreach ($class->getMethods() as $method)
142
+                {
143
+                    foreach ($method->getParameters() as $parameter)
144
+                    {
145
+                        if ($reader->firstParameterMetadata($parameter, $target->getName()))
146
+                        {
125 147
                             yield $class->getName();
126 148
                             continue 3;
127 149
                         }
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.