@@ -21,7 +21,7 @@ |
||
21 | 21 | */ |
22 | 22 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
23 | 23 | { |
24 | - if (is_array($source)) { |
|
24 | + if (is_array($source)){ |
|
25 | 25 | $source[] = get_class($specification); |
26 | 26 | } |
27 | 27 |
@@ -21,7 +21,8 @@ |
||
21 | 21 | */ |
22 | 22 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
23 | 23 | { |
24 | - if (is_array($source)) { |
|
24 | + if (is_array($source)) |
|
25 | + { |
|
25 | 26 | $source[] = get_class($specification); |
26 | 27 | } |
27 | 28 |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
25 | 25 | { |
26 | - if (is_array($source)) { |
|
26 | + if (is_array($source)){ |
|
27 | 27 | $source[] = self::OUTPUT; |
28 | 28 | } |
29 | 29 |
@@ -23,7 +23,8 @@ |
||
23 | 23 | */ |
24 | 24 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
25 | 25 | { |
26 | - if (is_array($source)) { |
|
26 | + if (is_array($source)) |
|
27 | + { |
|
27 | 28 | $source[] = self::OUTPUT; |
28 | 29 | } |
29 | 30 |
@@ -101,7 +101,7 @@ |
||
101 | 101 | 'Key2' => 'value2', |
102 | 102 | ]; |
103 | 103 | |
104 | - if ($expectException !== null) { |
|
104 | + if ($expectException !== null){ |
|
105 | 105 | $this->expectException($expectException); |
106 | 106 | } |
107 | 107 |
@@ -101,7 +101,8 @@ |
||
101 | 101 | 'Key2' => 'value2', |
102 | 102 | ]; |
103 | 103 | |
104 | - if ($expectException !== null) { |
|
104 | + if ($expectException !== null) |
|
105 | + { |
|
105 | 106 | $this->expectException($expectException); |
106 | 107 | } |
107 | 108 |
@@ -79,7 +79,7 @@ |
||
79 | 79 | public function testWriters($source, $expected, WriterInterface ...$writers): void |
80 | 80 | { |
81 | 81 | $compiler = new Compiler(); |
82 | - foreach ($writers as $writer) { |
|
82 | + foreach ($writers as $writer){ |
|
83 | 83 | $compiler->addWriter($writer); |
84 | 84 | } |
85 | 85 | $this->assertSame($expected, $compiler->compile($source, new Filter\Equals('', ''))); |
@@ -79,7 +79,8 @@ |
||
79 | 79 | public function testWriters($source, $expected, WriterInterface ...$writers): void |
80 | 80 | { |
81 | 81 | $compiler = new Compiler(); |
82 | - foreach ($writers as $writer) { |
|
82 | + foreach ($writers as $writer) |
|
83 | + { |
|
83 | 84 | $compiler->addWriter($writer); |
84 | 85 | } |
85 | 86 | $this->assertSame($expected, $compiler->compile($source, new Filter\Equals('', ''))); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $expected, |
236 | 236 | string $expectedException = null |
237 | 237 | ): void { |
238 | - if ($expectedException !== null) { |
|
238 | + if ($expectedException !== null){ |
|
239 | 239 | $this->expectException($expectedException); |
240 | 240 | } |
241 | 241 | |
@@ -297,15 +297,15 @@ discard block |
||
297 | 297 | private function paginatorInput(int $page = null, int $limit = null): array |
298 | 298 | { |
299 | 299 | $result = []; |
300 | - if ($page === null && $limit === null) { |
|
300 | + if ($page === null && $limit === null){ |
|
301 | 301 | return $result; |
302 | 302 | } |
303 | 303 | |
304 | - if ($page !== null) { |
|
304 | + if ($page !== null){ |
|
305 | 305 | $result['page'] = $page; |
306 | 306 | } |
307 | 307 | |
308 | - if ($limit !== null) { |
|
308 | + if ($limit !== null){ |
|
309 | 309 | $result['limit'] = $limit; |
310 | 310 | } |
311 | 311 |
@@ -235,7 +235,8 @@ discard block |
||
235 | 235 | $expected, |
236 | 236 | string $expectedException = null |
237 | 237 | ): void { |
238 | - if ($expectedException !== null) { |
|
238 | + if ($expectedException !== null) |
|
239 | + { |
|
239 | 240 | $this->expectException($expectedException); |
240 | 241 | } |
241 | 242 | |
@@ -297,15 +298,18 @@ discard block |
||
297 | 298 | private function paginatorInput(int $page = null, int $limit = null): array |
298 | 299 | { |
299 | 300 | $result = []; |
300 | - if ($page === null && $limit === null) { |
|
301 | + if ($page === null && $limit === null) |
|
302 | + { |
|
301 | 303 | return $result; |
302 | 304 | } |
303 | 305 | |
304 | - if ($page !== null) { |
|
306 | + if ($page !== null) |
|
307 | + { |
|
305 | 308 | $result['page'] = $page; |
306 | 309 | } |
307 | 310 | |
308 | - if ($limit !== null) { |
|
311 | + if ($limit !== null) |
|
312 | + { |
|
309 | 313 | $result['limit'] = $limit; |
310 | 314 | } |
311 | 315 |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $grid = $grid->withView('ucfirst'); |
57 | 57 | |
58 | 58 | $iterated = []; |
59 | - foreach ($grid->getIterator() as $value) { |
|
59 | + foreach ($grid->getIterator() as $value){ |
|
60 | 60 | $iterated[] = $value; |
61 | 61 | } |
62 | 62 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $grid = $grid->withSource(['a', 'b', 'c', 'hello']); |
73 | 73 | |
74 | 74 | $iterated = []; |
75 | - foreach ($grid->getIterator() as $value) { |
|
75 | + foreach ($grid->getIterator() as $value){ |
|
76 | 76 | $iterated[] = $value; |
77 | 77 | } |
78 | 78 |
@@ -56,7 +56,8 @@ discard block |
||
56 | 56 | $grid = $grid->withView('ucfirst'); |
57 | 57 | |
58 | 58 | $iterated = []; |
59 | - foreach ($grid->getIterator() as $value) { |
|
59 | + foreach ($grid->getIterator() as $value) |
|
60 | + { |
|
60 | 61 | $iterated[] = $value; |
61 | 62 | } |
62 | 63 | |
@@ -72,7 +73,8 @@ discard block |
||
72 | 73 | $grid = $grid->withSource(['a', 'b', 'c', 'hello']); |
73 | 74 | |
74 | 75 | $iterated = []; |
75 | - foreach ($grid->getIterator() as $value) { |
|
76 | + foreach ($grid->getIterator() as $value) |
|
77 | + { |
|
76 | 78 | $iterated[] = $value; |
77 | 79 | } |
78 | 80 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | */ |
39 | 39 | public function is(array $type): bool |
40 | 40 | { |
41 | - if ($this->type === null) { |
|
41 | + if ($this->type === null){ |
|
42 | 42 | return false; |
43 | 43 | } |
44 | 44 |
@@ -38,7 +38,8 @@ |
||
38 | 38 | */ |
39 | 39 | public function is(array $type): bool |
40 | 40 | { |
41 | - if ($this->type === null) { |
|
41 | + if ($this->type === null) |
|
42 | + { |
|
42 | 43 | return false; |
43 | 44 | } |
44 | 45 |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | public function initAnnotations(ContainerInterface $container, bool $reset = false): void |
138 | 138 | { |
139 | 139 | $prototyped = $this->memory->loadData('prototyped'); |
140 | - if (!$reset && $prototyped !== null) { |
|
141 | - foreach ($prototyped as $property => $class) { |
|
140 | + if (!$reset && $prototyped !== null){ |
|
141 | + foreach ($prototyped as $property => $class){ |
|
142 | 142 | $this->bindProperty($property, $class); |
143 | 143 | } |
144 | 144 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $locator = $container->get(AnnotationLocator::class); |
150 | 150 | |
151 | 151 | $prototyped = []; |
152 | - foreach ($locator->findClasses(Prototyped::class) as $class) { |
|
152 | + foreach ($locator->findClasses(Prototyped::class) as $class){ |
|
153 | 153 | $prototyped[$class->getAnnotation()->property] = $class->getClass()->getName(); |
154 | 154 | $this->bindProperty($class->getAnnotation()->property, $class->getClass()->getName()); |
155 | 155 | } |
@@ -162,19 +162,19 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function initCycle(ContainerInterface $container): void |
164 | 164 | { |
165 | - if (!$container->has(ORM\SchemaInterface::class)) { |
|
165 | + if (!$container->has(ORM\SchemaInterface::class)){ |
|
166 | 166 | return; |
167 | 167 | } |
168 | 168 | |
169 | 169 | /** @var ORM\SchemaInterface|null $schema */ |
170 | 170 | $schema = $container->get(ORM\SchemaInterface::class); |
171 | - if ($schema === null) { |
|
171 | + if ($schema === null){ |
|
172 | 172 | return; |
173 | 173 | } |
174 | 174 | |
175 | - foreach ($schema->getRoles() as $role) { |
|
175 | + foreach ($schema->getRoles() as $role){ |
|
176 | 176 | $repository = $schema->define($role, ORM\SchemaInterface::REPOSITORY); |
177 | - if ($repository === ORM\Select\Repository::class || $repository === null) { |
|
177 | + if ($repository === ORM\Select\Repository::class || $repository === null){ |
|
178 | 178 | // default repository can not be wired |
179 | 179 | continue; |
180 | 180 | } |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | */ |
189 | 189 | private function initDefaults(ContainerInterface $container): void |
190 | 190 | { |
191 | - foreach (self::DEFAULT_SHORTCUTS as $property => $shortcut) { |
|
192 | - if (is_array($shortcut) && isset($shortcut['resolve'])) { |
|
193 | - if (isset($shortcut['with'])) { |
|
191 | + foreach (self::DEFAULT_SHORTCUTS as $property => $shortcut){ |
|
192 | + if (is_array($shortcut) && isset($shortcut['resolve'])){ |
|
193 | + if (isset($shortcut['with'])){ |
|
194 | 194 | // check dependencies |
195 | - foreach ($shortcut['with'] as $dep) { |
|
196 | - if (!class_exists($dep, true) && !interface_exists($dep, true)) { |
|
195 | + foreach ($shortcut['with'] as $dep){ |
|
196 | + if (!class_exists($dep, true) && !interface_exists($dep, true)){ |
|
197 | 197 | continue 2; |
198 | 198 | } |
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | - try { |
|
202 | + try{ |
|
203 | 203 | $target = $container->get($shortcut['resolve']); |
204 | - if (is_object($target)) { |
|
204 | + if (is_object($target)){ |
|
205 | 205 | $this->bindProperty($property, get_class($target)); |
206 | 206 | } |
207 | - } catch (ContainerExceptionInterface $e) { |
|
207 | + }catch (ContainerExceptionInterface $e){ |
|
208 | 208 | continue; |
209 | 209 | } |
210 | 210 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | is_string($shortcut) |
216 | 216 | && (class_exists($shortcut, true) |
217 | 217 | || interface_exists($shortcut, true)) |
218 | - ) { |
|
218 | + ){ |
|
219 | 219 | $this->bindProperty($property, $shortcut); |
220 | 220 | } |
221 | 221 | } |
@@ -137,8 +137,10 @@ discard block |
||
137 | 137 | public function initAnnotations(ContainerInterface $container, bool $reset = false): void |
138 | 138 | { |
139 | 139 | $prototyped = $this->memory->loadData('prototyped'); |
140 | - if (!$reset && $prototyped !== null) { |
|
141 | - foreach ($prototyped as $property => $class) { |
|
140 | + if (!$reset && $prototyped !== null) |
|
141 | + { |
|
142 | + foreach ($prototyped as $property => $class) |
|
143 | + { |
|
142 | 144 | $this->bindProperty($property, $class); |
143 | 145 | } |
144 | 146 | |
@@ -149,7 +151,8 @@ discard block |
||
149 | 151 | $locator = $container->get(AnnotationLocator::class); |
150 | 152 | |
151 | 153 | $prototyped = []; |
152 | - foreach ($locator->findClasses(Prototyped::class) as $class) { |
|
154 | + foreach ($locator->findClasses(Prototyped::class) as $class) |
|
155 | + { |
|
153 | 156 | $prototyped[$class->getAnnotation()->property] = $class->getClass()->getName(); |
154 | 157 | $this->bindProperty($class->getAnnotation()->property, $class->getClass()->getName()); |
155 | 158 | } |
@@ -162,19 +165,23 @@ discard block |
||
162 | 165 | */ |
163 | 166 | public function initCycle(ContainerInterface $container): void |
164 | 167 | { |
165 | - if (!$container->has(ORM\SchemaInterface::class)) { |
|
168 | + if (!$container->has(ORM\SchemaInterface::class)) |
|
169 | + { |
|
166 | 170 | return; |
167 | 171 | } |
168 | 172 | |
169 | 173 | /** @var ORM\SchemaInterface|null $schema */ |
170 | 174 | $schema = $container->get(ORM\SchemaInterface::class); |
171 | - if ($schema === null) { |
|
175 | + if ($schema === null) |
|
176 | + { |
|
172 | 177 | return; |
173 | 178 | } |
174 | 179 | |
175 | - foreach ($schema->getRoles() as $role) { |
|
180 | + foreach ($schema->getRoles() as $role) |
|
181 | + { |
|
176 | 182 | $repository = $schema->define($role, ORM\SchemaInterface::REPOSITORY); |
177 | - if ($repository === ORM\Select\Repository::class || $repository === null) { |
|
183 | + if ($repository === ORM\Select\Repository::class || $repository === null) |
|
184 | + { |
|
178 | 185 | // default repository can not be wired |
179 | 186 | continue; |
180 | 187 | } |
@@ -188,23 +195,32 @@ discard block |
||
188 | 195 | */ |
189 | 196 | private function initDefaults(ContainerInterface $container): void |
190 | 197 | { |
191 | - foreach (self::DEFAULT_SHORTCUTS as $property => $shortcut) { |
|
192 | - if (is_array($shortcut) && isset($shortcut['resolve'])) { |
|
193 | - if (isset($shortcut['with'])) { |
|
198 | + foreach (self::DEFAULT_SHORTCUTS as $property => $shortcut) |
|
199 | + { |
|
200 | + if (is_array($shortcut) && isset($shortcut['resolve'])) |
|
201 | + { |
|
202 | + if (isset($shortcut['with'])) |
|
203 | + { |
|
194 | 204 | // check dependencies |
195 | - foreach ($shortcut['with'] as $dep) { |
|
196 | - if (!class_exists($dep, true) && !interface_exists($dep, true)) { |
|
205 | + foreach ($shortcut['with'] as $dep) |
|
206 | + { |
|
207 | + if (!class_exists($dep, true) && !interface_exists($dep, true)) |
|
208 | + { |
|
197 | 209 | continue 2; |
198 | 210 | } |
199 | 211 | } |
200 | 212 | } |
201 | 213 | |
202 | - try { |
|
214 | + try |
|
215 | + { |
|
203 | 216 | $target = $container->get($shortcut['resolve']); |
204 | - if (is_object($target)) { |
|
217 | + if (is_object($target)) |
|
218 | + { |
|
205 | 219 | $this->bindProperty($property, get_class($target)); |
206 | 220 | } |
207 | - } catch (ContainerExceptionInterface $e) { |
|
221 | + } |
|
222 | + catch (ContainerExceptionInterface $e) |
|
223 | + { |
|
208 | 224 | continue; |
209 | 225 | } |
210 | 226 |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | ConflictResolver\Names $namesResolver, |
40 | 40 | ConflictResolver\Namespaces $namespacesResolver, |
41 | 41 | Parser $parser = null |
42 | - ) { |
|
42 | + ){ |
|
43 | 43 | $this->namesResolver = $namesResolver; |
44 | 44 | $this->namespacesResolver = $namespacesResolver; |
45 | 45 | $this->parser = $parser ?? (new ParserFactory())->create(ParserFactory::ONLY_PHP7); |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | $declarator = new DeclareClass(); |
82 | 82 | $this->traverse($filename, $declarator); |
83 | 83 | |
84 | - if (empty($declarator->getClass())) { |
|
84 | + if (empty($declarator->getClass())){ |
|
85 | 85 | throw new ClassNotDeclaredException($filename); |
86 | 86 | } |
87 | 87 | |
88 | - if ($declarator->getNamespace()) { |
|
88 | + if ($declarator->getNamespace()){ |
|
89 | 89 | return ClassNode::createWithNamespace($declarator->getClass(), $declarator->getNamespace()); |
90 | 90 | } |
91 | 91 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | { |
101 | 101 | $tr = new NodeTraverser(); |
102 | 102 | |
103 | - foreach ($visitors as $visitor) { |
|
103 | + foreach ($visitors as $visitor){ |
|
104 | 104 | $tr->addVisitor($visitor); |
105 | 105 | } |
106 | 106 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | private function fillStmts(ClassNode $definition, array $imports): void |
115 | 115 | { |
116 | - foreach ($imports as $import) { |
|
116 | + foreach ($imports as $import){ |
|
117 | 117 | $definition->addImportUsage($import['name'], $import['alias']); |
118 | 118 | } |
119 | 119 | } |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | $reflection = new \ReflectionClass("{$definition->namespace}\\{$definition->class}"); |
129 | 129 | |
130 | 130 | $constructor = $reflection->getConstructor(); |
131 | - if ($constructor !== null) { |
|
131 | + if ($constructor !== null){ |
|
132 | 132 | $definition->hasConstructor = $constructor->getDeclaringClass()->getName() === $reflection->getName(); |
133 | 133 | |
134 | - foreach ($reflection->getConstructor()->getParameters() as $parameter) { |
|
134 | + foreach ($reflection->getConstructor()->getParameters() as $parameter){ |
|
135 | 135 | $definition->addParam($parameter); |
136 | 136 | } |
137 | 137 | } |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | */ |
147 | 147 | private function fillConstructorVars(array $vars, ClassNode $definition): void |
148 | 148 | { |
149 | - foreach ($vars as $k => $var) { |
|
150 | - if (isset($definition->constructorParams[$var])) { |
|
149 | + foreach ($vars as $k => $var){ |
|
150 | + if (isset($definition->constructorParams[$var])){ |
|
151 | 151 | unset($vars[$k]); |
152 | 152 | } |
153 | 153 | } |
@@ -81,11 +81,13 @@ discard block |
||
81 | 81 | $declarator = new DeclareClass(); |
82 | 82 | $this->traverse($filename, $declarator); |
83 | 83 | |
84 | - if (empty($declarator->getClass())) { |
|
84 | + if (empty($declarator->getClass())) |
|
85 | + { |
|
85 | 86 | throw new ClassNotDeclaredException($filename); |
86 | 87 | } |
87 | 88 | |
88 | - if ($declarator->getNamespace()) { |
|
89 | + if ($declarator->getNamespace()) |
|
90 | + { |
|
89 | 91 | return ClassNode::createWithNamespace($declarator->getClass(), $declarator->getNamespace()); |
90 | 92 | } |
91 | 93 | |
@@ -100,7 +102,8 @@ discard block |
||
100 | 102 | { |
101 | 103 | $tr = new NodeTraverser(); |
102 | 104 | |
103 | - foreach ($visitors as $visitor) { |
|
105 | + foreach ($visitors as $visitor) |
|
106 | + { |
|
104 | 107 | $tr->addVisitor($visitor); |
105 | 108 | } |
106 | 109 | |
@@ -113,7 +116,8 @@ discard block |
||
113 | 116 | */ |
114 | 117 | private function fillStmts(ClassNode $definition, array $imports): void |
115 | 118 | { |
116 | - foreach ($imports as $import) { |
|
119 | + foreach ($imports as $import) |
|
120 | + { |
|
117 | 121 | $definition->addImportUsage($import['name'], $import['alias']); |
118 | 122 | } |
119 | 123 | } |
@@ -128,10 +132,12 @@ discard block |
||
128 | 132 | $reflection = new \ReflectionClass("{$definition->namespace}\\{$definition->class}"); |
129 | 133 | |
130 | 134 | $constructor = $reflection->getConstructor(); |
131 | - if ($constructor !== null) { |
|
135 | + if ($constructor !== null) |
|
136 | + { |
|
132 | 137 | $definition->hasConstructor = $constructor->getDeclaringClass()->getName() === $reflection->getName(); |
133 | 138 | |
134 | - foreach ($reflection->getConstructor()->getParameters() as $parameter) { |
|
139 | + foreach ($reflection->getConstructor()->getParameters() as $parameter) |
|
140 | + { |
|
135 | 141 | $definition->addParam($parameter); |
136 | 142 | } |
137 | 143 | } |
@@ -146,8 +152,10 @@ discard block |
||
146 | 152 | */ |
147 | 153 | private function fillConstructorVars(array $vars, ClassNode $definition): void |
148 | 154 | { |
149 | - foreach ($vars as $k => $var) { |
|
150 | - if (isset($definition->constructorParams[$var])) { |
|
155 | + foreach ($vars as $k => $var) |
|
156 | + { |
|
157 | + if (isset($definition->constructorParams[$var])) |
|
158 | + { |
|
151 | 159 | unset($vars[$k]); |
152 | 160 | } |
153 | 161 | } |