Test Failed
Pull Request — master (#917)
by Maxim
07:57
created
src/Prototype/tests/ClassNode/ConflictResolver/ConflictResolverTest.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     {
25 25
         $i = new Injector();
26 26
 
27
-        $filename = __DIR__ . '/Fixtures/TestClass.php';
27
+        $filename = __DIR__.'/Fixtures/TestClass.php';
28 28
         $r = $i->injectDependencies(
29 29
             file_get_contents($filename),
30 30
             $this->getDefinition(
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
             )
38 38
         );
39 39
 
40
-        $this->assertStringContainsString(Fixtures\Test::class . ';', $r);
40
+        $this->assertStringContainsString(Fixtures\Test::class.';', $r);
41 41
         $this->assertStringContainsString('private Test $test', $r);
42 42
 
43
-        $this->assertStringContainsString(Fixtures\SubFolder\Test::class . ' as Test2;', $r);
44
-        $this->assertStringNotContainsString(Fixtures\SubFolder\Test::class . ';', $r);
43
+        $this->assertStringContainsString(Fixtures\SubFolder\Test::class.' as Test2;', $r);
44
+        $this->assertStringNotContainsString(Fixtures\SubFolder\Test::class.';', $r);
45 45
         $this->assertStringContainsString('private Test2 $test2', $r);
46 46
 
47
-        $this->assertStringContainsString(Fixtures\ATest3::class . ';', $r);
47
+        $this->assertStringContainsString(Fixtures\ATest3::class.';', $r);
48 48
         $this->assertStringContainsString('private ATest3 $test3', $r);
49 49
     }
50 50
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     {
56 56
         $i = new Injector();
57 57
 
58
-        $filename = __DIR__ . '/Fixtures/TestClassWithImports.php';
58
+        $filename = __DIR__.'/Fixtures/TestClassWithImports.php';
59 59
         $r = $i->injectDependencies(
60 60
             file_get_contents($filename),
61 61
             $this->getDefinition(
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
             )
69 69
         );
70 70
 
71
-        $this->assertStringContainsString(Fixtures\Test::class . ' as FTest;', $r);
72
-        $this->assertStringNotContainsString(Fixtures\Test::class . ';', $r);
71
+        $this->assertStringContainsString(Fixtures\Test::class.' as FTest;', $r);
72
+        $this->assertStringNotContainsString(Fixtures\Test::class.';', $r);
73 73
         $this->assertStringContainsString('private FTest $test', $r);
74 74
 
75
-        $this->assertStringContainsString(Fixtures\SubFolder\Test::class . ' as TestAlias;', $r);
76
-        $this->assertStringNotContainsString(Fixtures\SubFolder\Test::class . ';', $r);
75
+        $this->assertStringContainsString(Fixtures\SubFolder\Test::class.' as TestAlias;', $r);
76
+        $this->assertStringNotContainsString(Fixtures\SubFolder\Test::class.';', $r);
77 77
         $this->assertStringContainsString('private TestAlias $test2', $r);
78 78
 
79
-        $this->assertStringContainsString(Fixtures\ATest3::class . ' as ATest;', $r);
80
-        $this->assertStringNotContainsString(Fixtures\ATest3::class . ';', $r);
79
+        $this->assertStringContainsString(Fixtures\ATest3::class.' as ATest;', $r);
80
+        $this->assertStringNotContainsString(Fixtures\ATest3::class.';', $r);
81 81
         $this->assertStringContainsString('private ATest $test3', $r);
82 82
     }
83 83
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     {
89 89
         $i = new Injector();
90 90
 
91
-        $filename = __DIR__ . '/Fixtures/ChildClass.php';
91
+        $filename = __DIR__.'/Fixtures/ChildClass.php';
92 92
         $r = $i->injectDependencies(
93 93
             file_get_contents($filename),
94 94
             $this->getDefinition(
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
             )
102 102
         );
103 103
 
104
-        $this->assertStringContainsString(Fixtures\Test::class . ';', $r);
104
+        $this->assertStringContainsString(Fixtures\Test::class.';', $r);
105 105
         $this->assertStringContainsString('private Test $test', $r);
106 106
 
107
-        $this->assertStringContainsString(Fixtures\SubFolder\Test::class . ' as Test2;', $r);
108
-        $this->assertStringNotContainsString(Fixtures\SubFolder\Test::class . ';', $r);
107
+        $this->assertStringContainsString(Fixtures\SubFolder\Test::class.' as Test2;', $r);
108
+        $this->assertStringNotContainsString(Fixtures\SubFolder\Test::class.';', $r);
109 109
         $this->assertStringContainsString('private Test2 $test2', $r);
110 110
 
111
-        $this->assertStringContainsString(Fixtures\ATest3::class . ' as ATestAlias;', $r);
112
-        $this->assertStringNotContainsString(Fixtures\ATest3::class . ';', $r);
111
+        $this->assertStringContainsString(Fixtures\ATest3::class.' as ATestAlias;', $r);
112
+        $this->assertStringNotContainsString(Fixtures\ATest3::class.';', $r);
113 113
         $this->assertStringContainsString('private ATestAlias $test3', $r);
114 114
     }
115 115
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     {
118 118
         $i = new Injector();
119 119
 
120
-        $filename = __DIR__ . '/Fixtures/DuplicatePropertyClass.php';
120
+        $filename = __DIR__.'/Fixtures/DuplicatePropertyClass.php';
121 121
         $r = $i->injectDependencies(
122 122
             file_get_contents($filename),
123 123
             $this->getDefinition(
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
             )
129 129
         );
130 130
 
131
-        $this->assertStringContainsString(Fixtures\Test::class . ';', $r);
131
+        $this->assertStringContainsString(Fixtures\Test::class.';', $r);
132 132
         $this->assertStringContainsString('__construct(private Test $test)', $r);
133 133
     }
134 134
 
Please login to merge, or discard this patch.
src/Prototype/tests/InjectorTest.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     public function setUp(): void
23 23
     {
24
-        if ((string)ini_get('zend.assertions') === 1) {
24
+        if ((string)ini_get('zend.assertions') === 1){
25 25
             ini_set('zend.assertions', 0);
26 26
         }
27 27
     }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     {
35 35
         $i = new Injector();
36 36
 
37
-        $filename = __DIR__ . '/Fixtures/TestClass.php';
37
+        $filename = __DIR__.'/Fixtures/TestClass.php';
38 38
         $printed = $i->injectDependencies(
39 39
             file_get_contents($filename),
40 40
             $this->getDefinition($filename, ['testClass' => TestClass::class])
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     {
48 48
         $i = new Injector();
49 49
 
50
-        $filename = __DIR__ . '/Fixtures/WithPromotedProperty.php';
50
+        $filename = __DIR__.'/Fixtures/WithPromotedProperty.php';
51 51
         $printed = $i->injectDependencies(
52 52
             file_get_contents($filename),
53 53
             $this->getDefinition($filename, ['two' => InjectionTwo::class])
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     {
68 68
         $i = new Injector();
69 69
 
70
-        $filename = __DIR__ . '/Fixtures/TestEmptyClass.php';
70
+        $filename = __DIR__.'/Fixtures/TestEmptyClass.php';
71 71
         $content = file_get_contents($filename);
72 72
         $printed = $i->injectDependencies(
73 73
             file_get_contents($filename),
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     {
86 86
         $i = new Injector();
87 87
 
88
-        $filename = __DIR__ . '/Fixtures/TestClass.php';
88
+        $filename = __DIR__.'/Fixtures/TestClass.php';
89 89
         $r = $i->injectDependencies(
90 90
             file_get_contents($filename),
91 91
             $this->getDefinition($filename, ['testClass' => TestClass::class])
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     {
111 111
         $i = new Injector();
112 112
 
113
-        $filename = __DIR__ . '/Fixtures/ChildClass.php';
113
+        $filename = __DIR__.'/Fixtures/ChildClass.php';
114 114
         $r = $i->injectDependencies(
115 115
             file_get_contents($filename),
116 116
             $this->getDefinition($filename, ['testClass' => TestClass::class])
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
     {
129 129
         $i = new Injector();
130 130
 
131
-        $filename = __DIR__ . '/Fixtures/ChildWithConstructorClass.php';
131
+        $filename = __DIR__.'/Fixtures/ChildWithConstructorClass.php';
132 132
         $r = $i->injectDependencies(
133 133
             file_get_contents($filename),
134 134
             $this->getDefinition($filename, ['testClass' => TestClass::class])
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public function testModifyConstructor(): void
146 146
     {
147
-        $filename = __DIR__ . '/Fixtures/WithConstructor.php';
147
+        $filename = __DIR__.'/Fixtures/WithConstructor.php';
148 148
         $extractor = new Traverse\Extractor();
149 149
 
150 150
         $parameters = $extractor->extractFromFilename($filename);
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public function testPriorOptionalConstructorParameters(): void
172 172
     {
173
-        $filename = __DIR__ . '/Fixtures/OptionalConstructorArgsClass.php';
173
+        $filename = __DIR__.'/Fixtures/OptionalConstructorArgsClass.php';
174 174
         $extractor = new Traverse\Extractor();
175 175
 
176 176
         $parameters = $extractor->extractFromFilename($filename);
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
     {
202 202
         $i = new Injector();
203 203
 
204
-        $filename = __DIR__ . '/ClassNode/ConflictResolver/Fixtures/ChildClass.php';
204
+        $filename = __DIR__.'/ClassNode/ConflictResolver/Fixtures/ChildClass.php';
205 205
         $printed = $i->injectDependencies(
206 206
             file_get_contents($filename),
207 207
             $this->getDefinition(
Please login to merge, or discard this patch.
src/Prototype/src/Injector.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     public function __construct(
29 29
         Lexer $lexer = null,
30 30
         private readonly PrettyPrinterAbstract $printer = new Standard()
31
-    ) {
31
+    ){
32 32
         $this->lexer = $lexer ?? new Lexer\Emulative([
33 33
             'usedAttributes' => [
34 34
                 'comments',
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function injectDependencies(string $code, ClassNode $node, bool $removeTrait = false): string
53 53
     {
54
-        if (empty($node->dependencies)) {
55
-            if ($removeTrait) {
54
+        if (empty($node->dependencies)){
55
+            if ($removeTrait){
56 56
                 $tr = new NodeTraverser();
57 57
                 $tr->addVisitor(new RemoveUse());
58 58
                 $tr->addVisitor(new RemoveTrait());
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $tr = new NodeTraverser();
67 67
         $tr->addVisitor(new AddUse($node));
68 68
 
69
-        if ($removeTrait) {
69
+        if ($removeTrait){
70 70
             $tr->addVisitor(new RemoveUse());
71 71
             $tr->addVisitor(new RemoveTrait());
72 72
         }
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/LocateProperties.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,26 +39,26 @@
 block discarded – undo
39 39
             $node->var instanceof Node\Expr\Variable &&
40 40
             $node->var->name === 'this' &&
41 41
             $node->name instanceof Node\Identifier
42
-        ) {
42
+        ){
43 43
             $this->requested[$node->name->name] = $node->name->name;
44 44
         }
45 45
 
46
-        if ($node instanceof Node\Stmt\Property) {
47
-            foreach ($node->props as $prop) {
48
-                if ($prop instanceof Node\Stmt\PropertyProperty) {
46
+        if ($node instanceof Node\Stmt\Property){
47
+            foreach ($node->props as $prop){
48
+                if ($prop instanceof Node\Stmt\PropertyProperty){
49 49
                     $this->properties[$prop->name->name] = $prop->name->name;
50 50
                 }
51 51
             }
52 52
         }
53 53
 
54
-        if ($this->isPromotedProperty($node)) {
54
+        if ($this->isPromotedProperty($node)){
55 55
             $this->properties[$node->var->name] = $node->var->name;
56 56
         }
57 57
     }
58 58
 
59 59
     private function isPromotedProperty(Node $node): bool
60 60
     {
61
-        if (!$node instanceof Node\Param) {
61
+        if (!$node instanceof Node\Param){
62 62
             return false;
63 63
         }
64 64
 
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/UpdateConstructor.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -20,18 +20,18 @@  discard block
 block discarded – undo
20 20
 {
21 21
     public function __construct(
22 22
         private readonly ClassNode $definition
23
-    ) {
23
+    ){
24 24
     }
25 25
 
26
-    public function leaveNode(Node $node): int|Node|null
26
+    public function leaveNode(Node $node): int | Node | null
27 27
     {
28
-        if (!$node instanceof Node\Stmt\Class_) {
28
+        if (!$node instanceof Node\Stmt\Class_){
29 29
             return null;
30 30
         }
31 31
 
32 32
         $constructor = $this->getConstructorAttribute($node);
33 33
         $this->addDependencies($constructor);
34
-        if (!$this->definition->hasConstructor && $this->definition->constructorParams) {
34
+        if (!$this->definition->hasConstructor && $this->definition->constructorParams){
35 35
             $this->addParentConstructorCall($constructor);
36 36
         }
37 37
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     private function addDependencies(Node\Stmt\ClassMethod $constructor): void
45 45
     {
46
-        foreach ($this->definition->dependencies as $dependency) {
46
+        foreach ($this->definition->dependencies as $dependency){
47 47
             \array_unshift($constructor->params, $this->buildConstructorParam($dependency));
48 48
         }
49 49
     }
@@ -60,34 +60,34 @@  discard block
 block discarded – undo
60 60
     private function addParentConstructorCall(Node\Stmt\ClassMethod $constructor): void
61 61
     {
62 62
         $parentConstructorDependencies = [];
63
-        foreach ($this->definition->constructorParams as $param) {
63
+        foreach ($this->definition->constructorParams as $param){
64 64
             $parentConstructorDependencies[] = new Node\Arg(new Node\Expr\Variable($param->name));
65 65
 
66 66
             $cp = new Param($param->name);
67
-            if (!empty($param->type)) {
67
+            if (!empty($param->type)){
68 68
                 $type = $this->getParamType($param);
69
-                if ($param->nullable) {
69
+                if ($param->nullable){
70 70
                     $type = \sprintf('?%s', $type);
71 71
                 }
72 72
 
73 73
                 $cp->setType(new Node\Name($type));
74 74
             }
75 75
 
76
-            if ($param->byRef) {
76
+            if ($param->byRef){
77 77
                 $cp->makeByRef();
78 78
             }
79 79
 
80
-            if ($param->isVariadic) {
80
+            if ($param->isVariadic){
81 81
                 $cp->makeVariadic();
82 82
             }
83 83
 
84
-            if ($param->hasDefault) {
84
+            if ($param->hasDefault){
85 85
                 $cp->setDefault($param->default);
86 86
             }
87 87
             $constructor->params[] = $cp->getNode();
88 88
         }
89 89
 
90
-        if ($parentConstructorDependencies !== []) {
90
+        if ($parentConstructorDependencies !== []){
91 91
             \array_unshift(
92 92
                 $constructor->stmts,
93 93
                 new Node\Stmt\Expression(
@@ -115,18 +115,18 @@  discard block
 block discarded – undo
115 115
 
116 116
         $params = [];
117 117
 
118
-        foreach ($this->definition->dependencies as $dependency) {
118
+        foreach ($this->definition->dependencies as $dependency){
119 119
             $params[] = new Annotation\Line(
120 120
                 \sprintf('%s $%s', $this->getPropertyType($dependency), $dependency->var),
121 121
                 'param'
122 122
             );
123 123
         }
124 124
 
125
-        if (!$this->definition->hasConstructor) {
126
-            foreach ($this->definition->constructorParams as $param) {
127
-                if (!empty($param->type)) {
125
+        if (!$this->definition->hasConstructor){
126
+            foreach ($this->definition->constructorParams as $param){
127
+                if (!empty($param->type)){
128 128
                     $type = $this->getParamType($param);
129
-                    if ($param->nullable) {
129
+                    if ($param->nullable){
130 130
                         $type = \sprintf('%s|null', $type);
131 131
                     }
132 132
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                         \sprintf($param->isVariadic ? '%s ...$%s' : '%s $%s', $type, $param->name),
135 135
                         'param'
136 136
                     );
137
-                } else {
137
+                }else{
138 138
                     $params[] = new Annotation\Line(
139 139
                         \sprintf('$%s', $param->name),
140 140
                         'param'
@@ -145,12 +145,12 @@  discard block
 block discarded – undo
145 145
 
146 146
         $placementID = 0;
147 147
         $previous = null;
148
-        foreach ($an->lines as $index => $line) {
148
+        foreach ($an->lines as $index => $line){
149 149
             // always next node
150 150
             $placementID = $index + 1;
151 151
 
152 152
             // inject before this parameters
153
-            if ($line->is(['throws', 'return'])) {
153
+            if ($line->is(['throws', 'return'])){
154 154
                 // insert before given node
155 155
                 $placementID--;
156 156
                 break;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             $previous = $line;
160 160
         }
161 161
 
162
-        if ($previous !== null && !$previous->isEmpty()) {
162
+        if ($previous !== null && !$previous->isEmpty()){
163 163
             $placementID++;
164 164
         }
165 165
 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 
171 171
     private function getPropertyType(Dependency $dependency): string
172 172
     {
173
-        foreach ($this->definition->getStmts() as $stmt) {
174
-            if ($stmt->name === $dependency->type->fullName && $stmt->alias) {
173
+        foreach ($this->definition->getStmts() as $stmt){
174
+            if ($stmt->name === $dependency->type->fullName && $stmt->alias){
175 175
                 return $stmt->alias;
176 176
             }
177 177
         }
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
 
182 182
     private function getParamType(ClassNode\ConstructorParam $param): string
183 183
     {
184
-        foreach ($this->definition->getStmts() as $stmt) {
185
-            if ($stmt->name === $param->type->fullName && $stmt->alias) {
184
+        foreach ($this->definition->getStmts() as $stmt){
185
+            if ($stmt->name === $param->type->fullName && $stmt->alias){
186 186
                 return $stmt->alias;
187 187
             }
188 188
         }
189 189
 
190
-        if ($param->type->alias) {
190
+        if ($param->type->alias){
191 191
             return $param->type->alias;
192 192
         }
193 193
 
Please login to merge, or discard this patch.