@@ -19,7 +19,7 @@ discard block |
||
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 |
||
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; |
@@ -19,7 +19,8 @@ discard block |
||
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 |
||
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; |
@@ -27,7 +27,8 @@ discard block |
||
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 |
||
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 | } |
@@ -27,7 +27,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
183 | 183 | */ |
184 | 184 | public function testModifyConstructor(): void |
185 | 185 | { |
186 | - $filename = __DIR__ . '/Fixtures/WithConstructor.php'; |
|
186 | + $filename = __DIR__.'/Fixtures/WithConstructor.php'; |
|
187 | 187 | $extractor = new Traverse\Extractor(); |
188 | 188 | |
189 | 189 | $parameters = $extractor->extractFromFilename($filename); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function testPriorOptionalConstructorParameters(): void |
211 | 211 | { |
212 | - $filename = __DIR__ . '/Fixtures/OptionalConstructorArgsClass.php'; |
|
212 | + $filename = __DIR__.'/Fixtures/OptionalConstructorArgsClass.php'; |
|
213 | 213 | $extractor = new Traverse\Extractor(); |
214 | 214 | |
215 | 215 | $parameters = $extractor->extractFromFilename($filename); |
@@ -240,7 +240,7 @@ discard block |
||
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( |
@@ -23,7 +23,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -112,30 +112,30 @@ |
||
112 | 112 | */ |
113 | 113 | final protected function validate(): void |
114 | 114 | { |
115 | - if ($this->errors !== []) { |
|
115 | + if ($this->errors !== []){ |
|
116 | 116 | // already validated |
117 | 117 | return; |
118 | 118 | } |
119 | 119 | |
120 | 120 | $this->errors = []; |
121 | 121 | |
122 | - foreach ($this->rules as $field => $rules) { |
|
122 | + foreach ($this->rules as $field => $rules){ |
|
123 | 123 | $hasValue = $this->hasValue($field); |
124 | 124 | $value = $this->getValue($field); |
125 | 125 | |
126 | - foreach ($this->provider->getRules($rules) as $rule) { |
|
127 | - if (!$hasValue && $rule->ignoreEmpty($value) && !$rule->hasConditions()) { |
|
126 | + foreach ($this->provider->getRules($rules) as $rule){ |
|
127 | + if (!$hasValue && $rule->ignoreEmpty($value) && !$rule->hasConditions()){ |
|
128 | 128 | continue; |
129 | 129 | } |
130 | 130 | |
131 | - foreach ($rule->getConditions() as $condition) { |
|
132 | - if (!$condition->isMet($this, $field, $value)) { |
|
131 | + foreach ($rule->getConditions() as $condition){ |
|
132 | + if (!$condition->isMet($this, $field, $value)){ |
|
133 | 133 | // condition is not met, skipping validation |
134 | 134 | continue 2; |
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | - if (!$rule->validate($this, $field, $value)) { |
|
138 | + if (!$rule->validate($this, $field, $value)){ |
|
139 | 139 | // got error, jump to next field |
140 | 140 | $this->errors[$field] = $rule->getMessage($field, $value); |
141 | 141 | break; |
@@ -112,30 +112,37 @@ |
||
112 | 112 | */ |
113 | 113 | final protected function validate(): void |
114 | 114 | { |
115 | - if ($this->errors !== []) { |
|
115 | + if ($this->errors !== []) |
|
116 | + { |
|
116 | 117 | // already validated |
117 | 118 | return; |
118 | 119 | } |
119 | 120 | |
120 | 121 | $this->errors = []; |
121 | 122 | |
122 | - foreach ($this->rules as $field => $rules) { |
|
123 | + foreach ($this->rules as $field => $rules) |
|
124 | + { |
|
123 | 125 | $hasValue = $this->hasValue($field); |
124 | 126 | $value = $this->getValue($field); |
125 | 127 | |
126 | - foreach ($this->provider->getRules($rules) as $rule) { |
|
127 | - if (!$hasValue && $rule->ignoreEmpty($value) && !$rule->hasConditions()) { |
|
128 | + foreach ($this->provider->getRules($rules) as $rule) |
|
129 | + { |
|
130 | + if (!$hasValue && $rule->ignoreEmpty($value) && !$rule->hasConditions()) |
|
131 | + { |
|
128 | 132 | continue; |
129 | 133 | } |
130 | 134 | |
131 | - foreach ($rule->getConditions() as $condition) { |
|
132 | - if (!$condition->isMet($this, $field, $value)) { |
|
135 | + foreach ($rule->getConditions() as $condition) |
|
136 | + { |
|
137 | + if (!$condition->isMet($this, $field, $value)) |
|
138 | + { |
|
133 | 139 | // condition is not met, skipping validation |
134 | 140 | continue 2; |
135 | 141 | } |
136 | 142 | } |
137 | 143 | |
138 | - if (!$rule->validate($this, $field, $value)) { |
|
144 | + if (!$rule->validate($this, $field, $value)) |
|
145 | + { |
|
139 | 146 | // got error, jump to next field |
140 | 147 | $this->errors[$field] = $rule->getMessage($field, $value); |
141 | 148 | break; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | $value = $this->data[$field] ?? $default; |
57 | 57 | |
58 | - if (is_object($value) && method_exists($value, 'getValue')) { |
|
58 | + if (is_object($value) && method_exists($value, 'getValue')){ |
|
59 | 59 | return $value->getValue(); |
60 | 60 | } |
61 | 61 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function hasValue(string $field): bool |
69 | 69 | { |
70 | - if (is_array($this->data)) { |
|
70 | + if (is_array($this->data)){ |
|
71 | 71 | return array_key_exists($field, $this->data); |
72 | 72 | } |
73 | 73 |
@@ -55,7 +55,8 @@ discard block |
||
55 | 55 | { |
56 | 56 | $value = $this->data[$field] ?? $default; |
57 | 57 | |
58 | - if (is_object($value) && method_exists($value, 'getValue')) { |
|
58 | + if (is_object($value) && method_exists($value, 'getValue')) |
|
59 | + { |
|
59 | 60 | return $value->getValue(); |
60 | 61 | } |
61 | 62 | |
@@ -67,7 +68,8 @@ discard block |
||
67 | 68 | */ |
68 | 69 | public function hasValue(string $field): bool |
69 | 70 | { |
70 | - if (is_array($this->data)) { |
|
71 | + if (is_array($this->data)) |
|
72 | + { |
|
71 | 73 | return array_key_exists($field, $this->data); |
72 | 74 | } |
73 | 75 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public function perform(): void |
23 | 23 | { |
24 | 24 | $prototyped = $this->locator->getTargetClasses(); |
25 | - if ($prototyped === []) { |
|
25 | + if ($prototyped === []){ |
|
26 | 26 | $this->writeln('<comment>No prototyped classes found.</comment>'); |
27 | 27 | |
28 | 28 | return; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | $grid = $this->table(['Class:', 'Property:', 'Target:']); |
32 | 32 | |
33 | - foreach ($prototyped as $class) { |
|
33 | + foreach ($prototyped as $class){ |
|
34 | 34 | $proto = $this->getPrototypeProperties($class, $prototyped); |
35 | 35 | |
36 | 36 | $grid->addRow([$class->getName(), $this->mergeNames($proto), $this->mergeTargets($proto)]); |
@@ -22,7 +22,8 @@ discard block |
||
22 | 22 | public function perform(): void |
23 | 23 | { |
24 | 24 | $prototyped = $this->locator->getTargetClasses(); |
25 | - if ($prototyped === []) { |
|
25 | + if ($prototyped === []) |
|
26 | + { |
|
26 | 27 | $this->writeln('<comment>No prototyped classes found.</comment>'); |
27 | 28 | |
28 | 29 | return; |
@@ -30,7 +31,8 @@ discard block |
||
30 | 31 | |
31 | 32 | $grid = $this->table(['Class:', 'Property:', 'Target:']); |
32 | 33 | |
33 | - foreach ($prototyped as $class) { |
|
34 | + foreach ($prototyped as $class) |
|
35 | + { |
|
34 | 36 | $proto = $this->getPrototypeProperties($class, $prototyped); |
35 | 37 | |
36 | 38 | $grid->addRow([$class->getName(), $this->mergeNames($proto), $this->mergeTargets($proto)]); |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | ['emails' => ['[email protected]']] |
76 | 76 | ); |
77 | 77 | |
78 | - try { |
|
78 | + try{ |
|
79 | 79 | $this->getHandler()->handle( |
80 | 80 | MailQueue::JOB_NAME, |
81 | 81 | 'id', |
82 | 82 | json_encode(MessageSerializer::pack($this->getMail())) |
83 | 83 | ); |
84 | - } catch (TransportException $e) { |
|
84 | + }catch (TransportException $e){ |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | $this->logger->mockery_verify(); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | private function expectRenderer(Email $email): void |
99 | 99 | { |
100 | 100 | $this->renderer->expects('render')->withArgs( |
101 | - function (Message $message) { |
|
101 | + function (Message $message){ |
|
102 | 102 | $this->assertSame($message->getSubject(), 'test'); |
103 | 103 | return true; |
104 | 104 | } |
@@ -75,13 +75,16 @@ discard block |
||
75 | 75 | ['emails' => ['[email protected]']] |
76 | 76 | ); |
77 | 77 | |
78 | - try { |
|
78 | + try |
|
79 | + { |
|
79 | 80 | $this->getHandler()->handle( |
80 | 81 | MailQueue::JOB_NAME, |
81 | 82 | 'id', |
82 | 83 | json_encode(MessageSerializer::pack($this->getMail())) |
83 | 84 | ); |
84 | - } catch (TransportException $e) { |
|
85 | + } |
|
86 | + catch (TransportException $e) |
|
87 | + { |
|
85 | 88 | } |
86 | 89 | |
87 | 90 | $this->logger->mockery_verify(); |
@@ -98,7 +101,8 @@ discard block |
||
98 | 101 | private function expectRenderer(Email $email): void |
99 | 102 | { |
100 | 103 | $this->renderer->expects('render')->withArgs( |
101 | - function (Message $message) { |
|
104 | + function (Message $message) |
|
105 | + { |
|
102 | 106 | $this->assertSame($message->getSubject(), 'test'); |
103 | 107 | return true; |
104 | 108 | } |
@@ -55,7 +55,8 @@ discard block |
||
55 | 55 | public function perform(): void |
56 | 56 | { |
57 | 57 | $prototyped = $this->locator->getTargetClasses(); |
58 | - if ($prototyped === []) { |
|
58 | + if ($prototyped === []) |
|
59 | + { |
|
59 | 60 | $this->writeln('<comment>No prototyped classes found.</comment>'); |
60 | 61 | |
61 | 62 | return; |
@@ -63,18 +64,23 @@ discard block |
||
63 | 64 | |
64 | 65 | $targets = []; |
65 | 66 | |
66 | - foreach ($prototyped as $class) { |
|
67 | + foreach ($prototyped as $class) |
|
68 | + { |
|
67 | 69 | $proto = $this->getPrototypeProperties($class, $prototyped); |
68 | - if (empty($proto)) { |
|
70 | + if (empty($proto)) |
|
71 | + { |
|
69 | 72 | $modified = $this->modify($class, $proto); |
70 | - if ($modified !== null) { |
|
73 | + if ($modified !== null) |
|
74 | + { |
|
71 | 75 | $targets[] = $modified; |
72 | 76 | } |
73 | 77 | continue; |
74 | 78 | } |
75 | 79 | |
76 | - foreach ($proto as $target) { |
|
77 | - if ($target instanceof \Throwable) { |
|
80 | + foreach ($proto as $target) |
|
81 | + { |
|
82 | + if ($target instanceof \Throwable) |
|
83 | + { |
|
78 | 84 | $targets[] = [ |
79 | 85 | $class->getName(), |
80 | 86 | $target->getMessage(), |
@@ -83,7 +89,8 @@ discard block |
||
83 | 89 | continue 2; |
84 | 90 | } |
85 | 91 | |
86 | - if ($target === null) { |
|
92 | + if ($target === null) |
|
93 | + { |
|
87 | 94 | continue 2; |
88 | 95 | } |
89 | 96 | } |
@@ -91,14 +98,17 @@ discard block |
||
91 | 98 | $targets[] = [$class->getName(), $this->mergeNames($proto), $this->mergeTargets($proto)]; |
92 | 99 | |
93 | 100 | $modified = $this->modify($class, $proto); |
94 | - if ($modified !== null) { |
|
101 | + if ($modified !== null) |
|
102 | + { |
|
95 | 103 | $targets[] = $modified; |
96 | 104 | } |
97 | 105 | } |
98 | 106 | |
99 | - if (!empty($targets)) { |
|
107 | + if (!empty($targets)) |
|
108 | + { |
|
100 | 109 | $grid = $this->table(['Class:', 'Property:', 'Target:']); |
101 | - foreach ($targets as $target) { |
|
110 | + foreach ($targets as $target) |
|
111 | + { |
|
102 | 112 | $grid->addRow($target); |
103 | 113 | } |
104 | 114 | |
@@ -109,7 +119,8 @@ discard block |
||
109 | 119 | private function modify(\ReflectionClass $class, array $proto): ?array |
110 | 120 | { |
111 | 121 | $classDefinition = $this->extractor->extract($class->getFilename(), $proto); |
112 | - try { |
|
122 | + try |
|
123 | + { |
|
113 | 124 | $modified = $this->injector->injectDependencies( |
114 | 125 | file_get_contents($class->getFileName()), |
115 | 126 | $classDefinition, |
@@ -120,7 +131,9 @@ discard block |
||
120 | 131 | |
121 | 132 | file_put_contents($class->getFileName(), $modified); |
122 | 133 | return null; |
123 | - } catch (\Throwable $e) { |
|
134 | + } |
|
135 | + catch (\Throwable $e) |
|
136 | + { |
|
124 | 137 | return [$class->getName(), $e->getMessage(), "{$e->getFile()}:L{$e->getLine()}"]; |
125 | 138 | } |
126 | 139 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | public function perform(): void |
52 | 52 | { |
53 | 53 | $prototyped = $this->locator->getTargetClasses(); |
54 | - if ($prototyped === []) { |
|
54 | + if ($prototyped === []){ |
|
55 | 55 | $this->writeln('<comment>No prototyped classes found.</comment>'); |
56 | 56 | |
57 | 57 | return; |
@@ -59,18 +59,18 @@ discard block |
||
59 | 59 | |
60 | 60 | $targets = []; |
61 | 61 | |
62 | - foreach ($prototyped as $class) { |
|
62 | + foreach ($prototyped as $class){ |
|
63 | 63 | $proto = $this->getPrototypeProperties($class, $prototyped); |
64 | - if (empty($proto)) { |
|
64 | + if (empty($proto)){ |
|
65 | 65 | $modified = $this->modify($class, $proto); |
66 | - if ($modified !== null) { |
|
66 | + if ($modified !== null){ |
|
67 | 67 | $targets[] = $modified; |
68 | 68 | } |
69 | 69 | continue; |
70 | 70 | } |
71 | 71 | |
72 | - foreach ($proto as $target) { |
|
73 | - if ($target instanceof \Throwable) { |
|
72 | + foreach ($proto as $target){ |
|
73 | + if ($target instanceof \Throwable){ |
|
74 | 74 | $targets[] = [ |
75 | 75 | $class->getName(), |
76 | 76 | $target->getMessage(), |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | continue 2; |
80 | 80 | } |
81 | 81 | |
82 | - if ($target === null) { |
|
82 | + if ($target === null){ |
|
83 | 83 | continue 2; |
84 | 84 | } |
85 | 85 | } |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | $targets[] = [$class->getName(), $this->mergeNames($proto), $this->mergeTargets($proto)]; |
88 | 88 | |
89 | 89 | $modified = $this->modify($class, $proto); |
90 | - if ($modified !== null) { |
|
90 | + if ($modified !== null){ |
|
91 | 91 | $targets[] = $modified; |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - if (!empty($targets)) { |
|
95 | + if (!empty($targets)){ |
|
96 | 96 | $grid = $this->table(['Class:', 'Property:', 'Target:']); |
97 | - foreach ($targets as $target) { |
|
97 | + foreach ($targets as $target){ |
|
98 | 98 | $grid->addRow($target); |
99 | 99 | } |
100 | 100 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | private function modify(\ReflectionClass $class, array $proto): ?array |
106 | 106 | { |
107 | 107 | $classDefinition = $this->extractor->extract($class->getFilename(), $proto); |
108 | - try { |
|
108 | + try{ |
|
109 | 109 | $modified = $this->injector->injectDependencies( |
110 | 110 | file_get_contents($class->getFileName()), |
111 | 111 | $classDefinition, |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | file_put_contents($class->getFileName(), $modified); |
118 | 118 | return null; |
119 | - } catch (\Throwable $e) { |
|
119 | + }catch (\Throwable $e){ |
|
120 | 120 | return [$class->getName(), $e->getMessage(), "{$e->getFile()}:L{$e->getLine()}"]; |
121 | 121 | } |
122 | 122 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ['view' => $view, 'source' => $source] = $this->applySorters($view, $source, $schema); |
109 | 109 | ['view' => $view, 'source' => $source] = $this->applyPaginator($view, $source, $schema); |
110 | 110 | |
111 | - if (!is_iterable($source)) { |
|
111 | + if (!is_iterable($source)){ |
|
112 | 112 | throw new GridViewException('GridView expects the source to be iterable after all.'); |
113 | 113 | } |
114 | 114 | |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | protected function getFilters($source, GridSchema $schema): array |
127 | 127 | { |
128 | 128 | $filters = []; |
129 | - foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value) { |
|
130 | - if ($schema->hasFilter($name)) { |
|
129 | + foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value){ |
|
130 | + if ($schema->hasFilter($name)){ |
|
131 | 131 | $filter = $schema->getFilter($name)->withValue($value); |
132 | 132 | |
133 | - if ($filter !== null) { |
|
133 | + if ($filter !== null){ |
|
134 | 134 | $source = $this->compiler->compile($source, $filter); |
135 | 135 | $filters[$name] = $filter->getValue(); |
136 | 136 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | protected function applyCounter(GridInterface $view, $source, GridSchema $schema): array |
144 | 144 | { |
145 | - if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)) { |
|
145 | + if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)){ |
|
146 | 146 | $view = $view->withOption(GridInterface::COUNT, ($this->count)($source)); |
147 | 147 | } |
148 | 148 | |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | protected function getSorters($source, GridSchema $schema): array |
161 | 161 | { |
162 | 162 | $sorters = []; |
163 | - foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value) { |
|
164 | - if ($schema->hasSorter($name)) { |
|
163 | + foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value){ |
|
164 | + if ($schema->hasSorter($name)){ |
|
165 | 165 | $sorter = $schema->getSorter($name)->withDirection($value); |
166 | 166 | |
167 | - if ($sorter !== null) { |
|
167 | + if ($sorter !== null){ |
|
168 | 168 | $source = $this->compiler->compile($source, $sorter); |
169 | 169 | $sorters[$name] = $sorter->getValue(); |
170 | 170 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | protected function applyPaginator(GridInterface $view, $source, GridSchema $schema): array |
178 | 178 | { |
179 | - if ($schema->getPaginator() !== null) { |
|
179 | + if ($schema->getPaginator() !== null){ |
|
180 | 180 | ['source' => $source, 'paginator' => $paginator] = $this->getPaginator($source, $schema); |
181 | 181 | $view = $view->withOption(GridInterface::PAGINATOR, $paginator); |
182 | 182 | } |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | protected function getPaginator($source, GridSchema $schema): array |
188 | 188 | { |
189 | 189 | $paginator = $schema->getPaginator(); |
190 | - if (!$paginator instanceof FilterInterface) { |
|
190 | + if (!$paginator instanceof FilterInterface){ |
|
191 | 191 | throw new CompilerException('Paginator can not be null'); |
192 | 192 | } |
193 | 193 | |
194 | 194 | $withValue = $paginator->withValue($this->getOption(static::KEY_PAGINATE)); |
195 | - if ($withValue === null) { |
|
195 | + if ($withValue === null){ |
|
196 | 196 | throw new CompilerException('Paginator can not be null'); |
197 | 197 | } |
198 | 198 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | protected function getOptionArray(string $option): array |
212 | 212 | { |
213 | 213 | $result = $this->getOption($option); |
214 | - if (!is_array($result)) { |
|
214 | + if (!is_array($result)){ |
|
215 | 215 | return []; |
216 | 216 | } |
217 | 217 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function getOption(string $option) |
228 | 228 | { |
229 | - if ($this->input->hasValue($option)) { |
|
229 | + if ($this->input->hasValue($option)){ |
|
230 | 230 | return $this->input->getValue($option); |
231 | 231 | } |
232 | 232 |
@@ -108,7 +108,8 @@ discard block |
||
108 | 108 | ['view' => $view, 'source' => $source] = $this->applySorters($view, $source, $schema); |
109 | 109 | ['view' => $view, 'source' => $source] = $this->applyPaginator($view, $source, $schema); |
110 | 110 | |
111 | - if (!is_iterable($source)) { |
|
111 | + if (!is_iterable($source)) |
|
112 | + { |
|
112 | 113 | throw new GridViewException('GridView expects the source to be iterable after all.'); |
113 | 114 | } |
114 | 115 | |
@@ -126,11 +127,14 @@ discard block |
||
126 | 127 | protected function getFilters($source, GridSchema $schema): array |
127 | 128 | { |
128 | 129 | $filters = []; |
129 | - foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value) { |
|
130 | - if ($schema->hasFilter($name)) { |
|
130 | + foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value) |
|
131 | + { |
|
132 | + if ($schema->hasFilter($name)) |
|
133 | + { |
|
131 | 134 | $filter = $schema->getFilter($name)->withValue($value); |
132 | 135 | |
133 | - if ($filter !== null) { |
|
136 | + if ($filter !== null) |
|
137 | + { |
|
134 | 138 | $source = $this->compiler->compile($source, $filter); |
135 | 139 | $filters[$name] = $filter->getValue(); |
136 | 140 | } |
@@ -142,7 +146,8 @@ discard block |
||
142 | 146 | |
143 | 147 | protected function applyCounter(GridInterface $view, $source, GridSchema $schema): array |
144 | 148 | { |
145 | - if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)) { |
|
149 | + if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)) |
|
150 | + { |
|
146 | 151 | $view = $view->withOption(GridInterface::COUNT, ($this->count)($source)); |
147 | 152 | } |
148 | 153 | |
@@ -160,11 +165,14 @@ discard block |
||
160 | 165 | protected function getSorters($source, GridSchema $schema): array |
161 | 166 | { |
162 | 167 | $sorters = []; |
163 | - foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value) { |
|
164 | - if ($schema->hasSorter($name)) { |
|
168 | + foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value) |
|
169 | + { |
|
170 | + if ($schema->hasSorter($name)) |
|
171 | + { |
|
165 | 172 | $sorter = $schema->getSorter($name)->withDirection($value); |
166 | 173 | |
167 | - if ($sorter !== null) { |
|
174 | + if ($sorter !== null) |
|
175 | + { |
|
168 | 176 | $source = $this->compiler->compile($source, $sorter); |
169 | 177 | $sorters[$name] = $sorter->getValue(); |
170 | 178 | } |
@@ -176,7 +184,8 @@ discard block |
||
176 | 184 | |
177 | 185 | protected function applyPaginator(GridInterface $view, $source, GridSchema $schema): array |
178 | 186 | { |
179 | - if ($schema->getPaginator() !== null) { |
|
187 | + if ($schema->getPaginator() !== null) |
|
188 | + { |
|
180 | 189 | ['source' => $source, 'paginator' => $paginator] = $this->getPaginator($source, $schema); |
181 | 190 | $view = $view->withOption(GridInterface::PAGINATOR, $paginator); |
182 | 191 | } |
@@ -187,12 +196,14 @@ discard block |
||
187 | 196 | protected function getPaginator($source, GridSchema $schema): array |
188 | 197 | { |
189 | 198 | $paginator = $schema->getPaginator(); |
190 | - if (!$paginator instanceof FilterInterface) { |
|
199 | + if (!$paginator instanceof FilterInterface) |
|
200 | + { |
|
191 | 201 | throw new CompilerException('Paginator can not be null'); |
192 | 202 | } |
193 | 203 | |
194 | 204 | $withValue = $paginator->withValue($this->getOption(static::KEY_PAGINATE)); |
195 | - if ($withValue === null) { |
|
205 | + if ($withValue === null) |
|
206 | + { |
|
196 | 207 | throw new CompilerException('Paginator can not be null'); |
197 | 208 | } |
198 | 209 | |
@@ -211,7 +222,8 @@ discard block |
||
211 | 222 | protected function getOptionArray(string $option): array |
212 | 223 | { |
213 | 224 | $result = $this->getOption($option); |
214 | - if (!is_array($result)) { |
|
225 | + if (!is_array($result)) |
|
226 | + { |
|
215 | 227 | return []; |
216 | 228 | } |
217 | 229 | |
@@ -226,7 +238,8 @@ discard block |
||
226 | 238 | */ |
227 | 239 | protected function getOption(string $option) |
228 | 240 | { |
229 | - if ($this->input->hasValue($option)) { |
|
241 | + if ($this->input->hasValue($option)) |
|
242 | + { |
|
230 | 243 | return $this->input->getValue($option); |
231 | 244 | } |
232 | 245 |