Passed
Pull Request — master (#357)
by Valentin
06:06 queued 01:39
created
src/Prototype/src/Injector.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function __construct(Lexer $lexer = null, PrettyPrinterAbstract $printer = null)
49 49
     {
50
-        if ($lexer === null) {
50
+        if ($lexer === null){
51 51
             $lexer = new Lexer\Emulative([
52 52
                 'usedAttributes' => [
53 53
                     'comments',
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
         bool $useTypedProperties = false,
87 87
         bool $noPhpDoc = false
88 88
     ): string {
89
-        if (empty($node->dependencies)) {
90
-            if ($removeTrait) {
89
+        if (empty($node->dependencies)){
90
+            if ($removeTrait){
91 91
                 $tr = new NodeTraverser();
92 92
                 $tr->addVisitor(new RemoveUse());
93 93
                 $tr->addVisitor(new RemoveTrait());
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         $tr = new NodeTraverser();
102 102
         $tr->addVisitor(new AddUse($node));
103 103
 
104
-        if ($removeTrait) {
104
+        if ($removeTrait){
105 105
             $tr->addVisitor(new RemoveUse());
106 106
             $tr->addVisitor(new RemoveTrait());
107 107
         }
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,8 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function __construct(Lexer $lexer = null, PrettyPrinterAbstract $printer = null)
49 49
     {
50
-        if ($lexer === null) {
50
+        if ($lexer === null)
51
+        {
51 52
             $lexer = new Lexer\Emulative([
52 53
                 'usedAttributes' => [
53 54
                     'comments',
@@ -86,8 +87,10 @@  discard block
 block discarded – undo
86 87
         bool $useTypedProperties = false,
87 88
         bool $noPhpDoc = false
88 89
     ): string {
89
-        if (empty($node->dependencies)) {
90
-            if ($removeTrait) {
90
+        if (empty($node->dependencies))
91
+        {
92
+            if ($removeTrait)
93
+            {
91 94
                 $tr = new NodeTraverser();
92 95
                 $tr->addVisitor(new RemoveUse());
93 96
                 $tr->addVisitor(new RemoveTrait());
@@ -101,7 +104,8 @@  discard block
 block discarded – undo
101 104
         $tr = new NodeTraverser();
102 105
         $tr->addVisitor(new AddUse($node));
103 106
 
104
-        if ($removeTrait) {
107
+        if ($removeTrait)
108
+        {
105 109
             $tr->addVisitor(new RemoveUse());
106 110
             $tr->addVisitor(new RemoveTrait());
107 111
         }
Please login to merge, or discard this patch.
src/Prototype/tests/BackwardCompatibilityTrait.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      */
20 20
     public static function assertRegExp(string $pattern, string $string, string $message = ''): void
21 21
     {
22
-        if (\method_exists(Assert::class, 'assertMatchesRegularExpression')) {
22
+        if (\method_exists(Assert::class, 'assertMatchesRegularExpression')){
23 23
             Assert::assertMatchesRegularExpression($pattern, $string, $message);
24 24
 
25 25
             return;
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public static function assertNotRegExp(string $pattern, string $string, string $message = ''): void
37 37
     {
38
-        if (\method_exists(Assert::class, 'assertDoesNotMatchRegularExpression')) {
38
+        if (\method_exists(Assert::class, 'assertDoesNotMatchRegularExpression')){
39 39
             Assert::assertDoesNotMatchRegularExpression($pattern, $string, $message);
40 40
 
41 41
             return;
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,8 @@  discard block
 block discarded – undo
19 19
      */
20 20
     public static function assertRegExp(string $pattern, string $string, string $message = ''): void
21 21
     {
22
-        if (\method_exists(Assert::class, 'assertMatchesRegularExpression')) {
22
+        if (\method_exists(Assert::class, 'assertMatchesRegularExpression'))
23
+        {
23 24
             Assert::assertMatchesRegularExpression($pattern, $string, $message);
24 25
 
25 26
             return;
@@ -35,7 +36,8 @@  discard block
 block discarded – undo
35 36
      */
36 37
     public static function assertNotRegExp(string $pattern, string $string, string $message = ''): void
37 38
     {
38
-        if (\method_exists(Assert::class, 'assertDoesNotMatchRegularExpression')) {
39
+        if (\method_exists(Assert::class, 'assertDoesNotMatchRegularExpression'))
40
+        {
39 41
             Assert::assertDoesNotMatchRegularExpression($pattern, $string, $message);
40 42
 
41 43
             return;
Please login to merge, or discard this patch.
src/Prototype/tests/InjectorTest.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
     public function setUp(): void
29 29
     {
30
-        if ((string)ini_get('zend.assertions') === 1) {
30
+        if ((string)ini_get('zend.assertions') === 1){
31 31
             ini_set('zend.assertions', 0);
32 32
         }
33 33
     }
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     {
41 41
         $i = new Injector();
42 42
 
43
-        $filename = __DIR__ . '/Fixtures/TestClass.php';
43
+        $filename = __DIR__.'/Fixtures/TestClass.php';
44 44
         $printed = $i->injectDependencies(
45 45
             file_get_contents($filename),
46 46
             $this->getDefinition($filename, ['testClass' => TestClass::class])
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     ): void {
67 67
         $i = new Injector();
68 68
 
69
-        $filename = __DIR__ . '/Fixtures/TestClass.php';
69
+        $filename = __DIR__.'/Fixtures/TestClass.php';
70 70
         $printed = $i->injectDependencies(
71 71
             file_get_contents($filename),
72 72
             $this->getDefinition($filename, ['testClass' => TestClass::class]),
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
             $noPhpDoc
76 76
         );
77 77
 
78
-        if ($expectedTypedProperty) {
78
+        if ($expectedTypedProperty){
79 79
             $this->assertStringContainsString('private TestClass $testClass;', $printed);
80
-        } else {
80
+        }else{
81 81
             $this->assertStringNotContainsString('private TestClass $testClass;', $printed);
82 82
         }
83 83
 
84
-        if ($expectedPhpDoc) {
84
+        if ($expectedPhpDoc){
85 85
             $this->assertRegExp('/@var TestClass[\s|\r\n]/', $printed);
86
-        } else {
86
+        }else{
87 87
             $this->assertNotRegExp('/@var TestClass[\s|\r\n]/', $printed);
88 88
         }
89 89
     }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     {
107 107
         $i = new Injector();
108 108
 
109
-        $filename = __DIR__ . '/Fixtures/TestEmptyClass.php';
109
+        $filename = __DIR__.'/Fixtures/TestEmptyClass.php';
110 110
         $content = file_get_contents($filename);
111 111
         $printed = $i->injectDependencies(
112 112
             file_get_contents($filename),
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     {
125 125
         $i = new Injector();
126 126
 
127
-        $filename = __DIR__ . '/Fixtures/TestClass.php';
127
+        $filename = __DIR__.'/Fixtures/TestClass.php';
128 128
         $r = $i->injectDependencies(
129 129
             file_get_contents($filename),
130 130
             $this->getDefinition($filename, ['testClass' => TestClass::class])
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     {
150 150
         $i = new Injector();
151 151
 
152
-        $filename = __DIR__ . '/Fixtures/ChildClass.php';
152
+        $filename = __DIR__.'/Fixtures/ChildClass.php';
153 153
         $r = $i->injectDependencies(
154 154
             file_get_contents($filename),
155 155
             $this->getDefinition($filename, ['testClass' => TestClass::class])
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     {
168 168
         $i = new Injector();
169 169
 
170
-        $filename = __DIR__ . '/Fixtures/ChildWithConstructorClass.php';
170
+        $filename = __DIR__.'/Fixtures/ChildWithConstructorClass.php';
171 171
         $r = $i->injectDependencies(
172 172
             file_get_contents($filename),
173 173
             $this->getDefinition($filename, ['testClass' => TestClass::class])
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
      */
184 184
     public function testModifyConstructor(): void
185 185
     {
186
-        $filename = __DIR__ . '/Fixtures/WithConstructor.php';
186
+        $filename = __DIR__.'/Fixtures/WithConstructor.php';
187 187
         $traverser = new Traverse\Extractor();
188 188
 
189 189
         $parameters = $traverser->extractFromFilename($filename);
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
      */
210 210
     public function testPriorOptionalConstructorParameters(): void
211 211
     {
212
-        $filename = __DIR__ . '/Fixtures/OptionalConstructorArgsClass.php';
212
+        $filename = __DIR__.'/Fixtures/OptionalConstructorArgsClass.php';
213 213
         $traverser = new Traverse\Extractor();
214 214
 
215 215
         $parameters = $traverser->extractFromFilename($filename);
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
     {
241 241
         $i = new Injector();
242 242
 
243
-        $filename = __DIR__ . '/ClassNode/ConflictResolver/Fixtures/ChildClass.php';
243
+        $filename = __DIR__.'/ClassNode/ConflictResolver/Fixtures/ChildClass.php';
244 244
         $printed = $i->injectDependencies(
245 245
             file_get_contents($filename),
246 246
             $this->getDefinition(
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,8 @@  discard block
 block discarded – undo
27 27
 
28 28
     public function setUp(): void
29 29
     {
30
-        if ((string)ini_get('zend.assertions') === 1) {
30
+        if ((string)ini_get('zend.assertions') === 1)
31
+        {
31 32
             ini_set('zend.assertions', 0);
32 33
         }
33 34
     }
@@ -75,15 +76,21 @@  discard block
 block discarded – undo
75 76
             $noPhpDoc
76 77
         );
77 78
 
78
-        if ($expectedTypedProperty) {
79
+        if ($expectedTypedProperty)
80
+        {
79 81
             $this->assertStringContainsString('private TestClass $testClass;', $printed);
80
-        } else {
82
+        }
83
+        else
84
+        {
81 85
             $this->assertStringNotContainsString('private TestClass $testClass;', $printed);
82 86
         }
83 87
 
84
-        if ($expectedPhpDoc) {
88
+        if ($expectedPhpDoc)
89
+        {
85 90
             $this->assertRegExp('/@var TestClass[\s|\r\n]/', $printed);
86
-        } else {
91
+        }
92
+        else
93
+        {
87 94
             $this->assertNotRegExp('/@var TestClass[\s|\r\n]/', $printed);
88 95
         }
89 96
     }
Please login to merge, or discard this patch.
src/Prototype/tests/ClassNode/ConflictResolver/ConflictResolverTest.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     {
24 24
         $i = new Injector();
25 25
 
26
-        $filename = __DIR__ . '/Fixtures/TestClass.php';
26
+        $filename = __DIR__.'/Fixtures/TestClass.php';
27 27
         $r = $i->injectDependencies(
28 28
             file_get_contents($filename),
29 29
             $this->getDefinition(
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
36 36
             )
37 37
         );
38 38
 
39
-        $this->assertStringContainsString(Fixtures\Test::class . ';', $r);
39
+        $this->assertStringContainsString(Fixtures\Test::class.';', $r);
40 40
         $this->assertRegExp('/@var Test[\s|\r\n]/', $r);
41 41
         $this->assertStringContainsString('@param 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->assertRegExp('/@var Test2[\s|\r\n]/', $r);
46 46
         $this->assertStringContainsString('@param Test2 $test2', $r);
47 47
 
48
-        $this->assertStringContainsString(Fixtures\ATest3::class . ';', $r);
48
+        $this->assertStringContainsString(Fixtures\ATest3::class.';', $r);
49 49
         $this->assertRegExp('/@var ATest3[\s|\r\n]/', $r);
50 50
         $this->assertStringContainsString('@param ATest3 $test3', $r);
51 51
     }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     {
58 58
         $i = new Injector();
59 59
 
60
-        $filename = __DIR__ . '/Fixtures/TestClassWithImports.php';
60
+        $filename = __DIR__.'/Fixtures/TestClassWithImports.php';
61 61
         $r = $i->injectDependencies(
62 62
             file_get_contents($filename),
63 63
             $this->getDefinition(
@@ -70,18 +70,18 @@  discard block
 block discarded – undo
70 70
             )
71 71
         );
72 72
 
73
-        $this->assertStringContainsString(Fixtures\Test::class . ' as FTest;', $r);
74
-        $this->assertStringNotContainsString(Fixtures\Test::class . ';', $r);
73
+        $this->assertStringContainsString(Fixtures\Test::class.' as FTest;', $r);
74
+        $this->assertStringNotContainsString(Fixtures\Test::class.';', $r);
75 75
         $this->assertRegExp('/@var FTest[\s|\r\n]/', $r);
76 76
         $this->assertStringContainsString('@param FTest $test', $r);
77 77
 
78
-        $this->assertStringContainsString(Fixtures\SubFolder\Test::class . ' as TestAlias;', $r);
79
-        $this->assertStringNotContainsString(Fixtures\SubFolder\Test::class . ';', $r);
78
+        $this->assertStringContainsString(Fixtures\SubFolder\Test::class.' as TestAlias;', $r);
79
+        $this->assertStringNotContainsString(Fixtures\SubFolder\Test::class.';', $r);
80 80
         $this->assertRegExp('/@var TestAlias[\s|\r\n]/', $r);
81 81
         $this->assertStringContainsString('@param TestAlias $test2', $r);
82 82
 
83
-        $this->assertStringContainsString(Fixtures\ATest3::class . ' as ATest;', $r);
84
-        $this->assertStringNotContainsString(Fixtures\ATest3::class . ';', $r);
83
+        $this->assertStringContainsString(Fixtures\ATest3::class.' as ATest;', $r);
84
+        $this->assertStringNotContainsString(Fixtures\ATest3::class.';', $r);
85 85
         $this->assertRegExp('/@var ATest[\s|\r\n]/', $r);
86 86
         $this->assertStringContainsString('@param ATest $test3', $r);
87 87
     }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     {
94 94
         $i = new Injector();
95 95
 
96
-        $filename = __DIR__ . '/Fixtures/ChildClass.php';
96
+        $filename = __DIR__.'/Fixtures/ChildClass.php';
97 97
         $r = $i->injectDependencies(
98 98
             file_get_contents($filename),
99 99
             $this->getDefinition(
@@ -106,17 +106,17 @@  discard block
 block discarded – undo
106 106
             )
107 107
         );
108 108
 
109
-        $this->assertStringContainsString(Fixtures\Test::class . ';', $r);
109
+        $this->assertStringContainsString(Fixtures\Test::class.';', $r);
110 110
         $this->assertRegExp('/@var Test[\s|\r\n]/', $r);
111 111
         $this->assertStringContainsString('@param Test $test', $r);
112 112
 
113
-        $this->assertStringContainsString(Fixtures\SubFolder\Test::class . ' as Test2;', $r);
114
-        $this->assertStringNotContainsString(Fixtures\SubFolder\Test::class . ';', $r);
113
+        $this->assertStringContainsString(Fixtures\SubFolder\Test::class.' as Test2;', $r);
114
+        $this->assertStringNotContainsString(Fixtures\SubFolder\Test::class.';', $r);
115 115
         $this->assertRegExp('/@var Test2[\s|\r\n]/', $r);
116 116
         $this->assertStringContainsString('@param Test2 $test2', $r);
117 117
 
118
-        $this->assertStringContainsString(Fixtures\ATest3::class . ' as ATestAlias;', $r);
119
-        $this->assertStringNotContainsString(Fixtures\ATest3::class . ';', $r);
118
+        $this->assertStringContainsString(Fixtures\ATest3::class.' as ATestAlias;', $r);
119
+        $this->assertStringNotContainsString(Fixtures\ATest3::class.';', $r);
120 120
         $this->assertRegExp('/@var ATestAlias[\s|\r\n]/', $r);
121 121
         $this->assertStringContainsString('@param ATestAlias $test3', $r);
122 122
     }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     {
126 126
         $i = new Injector();
127 127
 
128
-        $filename = __DIR__ . '/Fixtures/DuplicatePropertyClass.php';
128
+        $filename = __DIR__.'/Fixtures/DuplicatePropertyClass.php';
129 129
         $r = $i->injectDependencies(
130 130
             file_get_contents($filename),
131 131
             $this->getDefinition(
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             )
137 137
         );
138 138
 
139
-        $this->assertStringContainsString(Fixtures\Test::class . ';', $r);
139
+        $this->assertStringContainsString(Fixtures\Test::class.';', $r);
140 140
         $this->assertRegExp('/@var Test[\s|\r\n]/', $r);
141 141
         $this->assertStringContainsString('@param Test $test', $r);
142 142
         $this->assertStringContainsString('__construct(Test $test)', $r);
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/AddProperty.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function leaveNode(Node $node)
48 48
     {
49
-        if (!$node instanceof Node\Stmt\Class_) {
49
+        if (!$node instanceof Node\Stmt\Class_){
50 50
             return null;
51 51
         }
52 52
 
53 53
         $nodes = [];
54
-        foreach ($this->definition->dependencies as $dependency) {
54
+        foreach ($this->definition->dependencies as $dependency){
55 55
             $nodes[] = $this->buildProperty($dependency);
56 56
         }
57 57
 
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
      */
68 68
     private function definePlacementID(Node\Stmt\Class_ $node): int
69 69
     {
70
-        foreach ($node->stmts as $index => $child) {
71
-            if ($child instanceof Node\Stmt\ClassMethod || $child instanceof Node\Stmt\Property) {
70
+        foreach ($node->stmts as $index => $child){
71
+            if ($child instanceof Node\Stmt\ClassMethod || $child instanceof Node\Stmt\Property){
72 72
                 return $index;
73 73
             }
74 74
         }
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
         $b = new Property($dependency->property);
86 86
         $b->makePrivate();
87 87
 
88
-        if ($this->useTypedProperty()) {
88
+        if ($this->useTypedProperty()){
89 89
             $b->setType($this->getPropertyType($dependency));
90 90
         }
91 91
 
92
-        if ($this->renderDoc()) {
92
+        if ($this->renderDoc()){
93 93
             $b->setDocComment(new Doc(sprintf('/** @var %s */', $this->getPropertyType($dependency))));
94 94
         }
95 95
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
      */
113 113
     private function getPropertyType(Dependency $dependency): string
114 114
     {
115
-        foreach ($this->definition->getStmts() as $stmt) {
116
-            if (($stmt->name === $dependency->type->fullName) && $stmt->alias) {
115
+        foreach ($this->definition->getStmts() as $stmt){
116
+            if (($stmt->name === $dependency->type->fullName) && $stmt->alias){
117 117
                 return $stmt->alias;
118 118
             }
119 119
         }
Please login to merge, or discard this patch.
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,12 +46,14 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function leaveNode(Node $node)
48 48
     {
49
-        if (!$node instanceof Node\Stmt\Class_) {
49
+        if (!$node instanceof Node\Stmt\Class_)
50
+        {
50 51
             return null;
51 52
         }
52 53
 
53 54
         $nodes = [];
54
-        foreach ($this->definition->dependencies as $dependency) {
55
+        foreach ($this->definition->dependencies as $dependency)
56
+        {
55 57
             $nodes[] = $this->buildProperty($dependency);
56 58
         }
57 59
 
@@ -67,8 +69,10 @@  discard block
 block discarded – undo
67 69
      */
68 70
     private function definePlacementID(Node\Stmt\Class_ $node): int
69 71
     {
70
-        foreach ($node->stmts as $index => $child) {
71
-            if ($child instanceof Node\Stmt\ClassMethod || $child instanceof Node\Stmt\Property) {
72
+        foreach ($node->stmts as $index => $child)
73
+        {
74
+            if ($child instanceof Node\Stmt\ClassMethod || $child instanceof Node\Stmt\Property)
75
+            {
72 76
                 return $index;
73 77
             }
74 78
         }
@@ -85,11 +89,13 @@  discard block
 block discarded – undo
85 89
         $b = new Property($dependency->property);
86 90
         $b->makePrivate();
87 91
 
88
-        if ($this->useTypedProperty()) {
92
+        if ($this->useTypedProperty())
93
+        {
89 94
             $b->setType($this->getPropertyType($dependency));
90 95
         }
91 96
 
92
-        if ($this->renderDoc()) {
97
+        if ($this->renderDoc())
98
+        {
93 99
             $b->setDocComment(new Doc(sprintf('/** @var %s */', $this->getPropertyType($dependency))));
94 100
         }
95 101
 
@@ -112,8 +118,10 @@  discard block
 block discarded – undo
112 118
      */
113 119
     private function getPropertyType(Dependency $dependency): string
114 120
     {
115
-        foreach ($this->definition->getStmts() as $stmt) {
116
-            if (($stmt->name === $dependency->type->fullName) && $stmt->alias) {
121
+        foreach ($this->definition->getStmts() as $stmt)
122
+        {
123
+            if (($stmt->name === $dependency->type->fullName) && $stmt->alias)
124
+            {
117 125
                 return $stmt->alias;
118 126
             }
119 127
         }
Please login to merge, or discard this patch.