@@ -64,7 +64,8 @@ discard block |
||
64 | 64 | |
65 | 65 | public function getLoader(): LoaderInterface |
66 | 66 | { |
67 | - if ($this->loader === null) { |
|
67 | + if ($this->loader === null) |
|
68 | + { |
|
68 | 69 | throw new EngineException('No associated loader found'); |
69 | 70 | } |
70 | 71 | |
@@ -76,13 +77,15 @@ discard block |
||
76 | 77 | */ |
77 | 78 | public function getBuilder(ContextInterface $context): Builder |
78 | 79 | { |
79 | - if ($this->builder === null) { |
|
80 | + if ($this->builder === null) |
|
81 | + { |
|
80 | 82 | throw new EngineException('No associated builder found'); |
81 | 83 | } |
82 | 84 | |
83 | 85 | // since view source support pre-processing we must ensure that context is always set |
84 | 86 | $loader = $this->builder->getLoader(); |
85 | - if ($loader instanceof StemplerLoader) { |
|
87 | + if ($loader instanceof StemplerLoader) |
|
88 | + { |
|
86 | 89 | $loader->setContext($context); |
87 | 90 | } |
88 | 91 | |
@@ -100,20 +103,27 @@ discard block |
||
100 | 103 | // cache key |
101 | 104 | $key = $this->cacheKey($view, $context); |
102 | 105 | |
103 | - if ($this->cache !== null && $this->cache->isFresh($key)) { |
|
106 | + if ($this->cache !== null && $this->cache->isFresh($key)) |
|
107 | + { |
|
104 | 108 | $this->cache->load($key); |
105 | - } elseif (!\class_exists($class)) { |
|
106 | - try { |
|
109 | + } |
|
110 | + elseif (!\class_exists($class)) |
|
111 | + { |
|
112 | + try |
|
113 | + { |
|
107 | 114 | $builder = $this->getBuilder($context); |
108 | 115 | |
109 | 116 | $result = $builder->compile($path); |
110 | - } catch (Throwable $e) { |
|
117 | + } |
|
118 | + catch (Throwable $e) |
|
119 | + { |
|
111 | 120 | throw new CompileException($e); |
112 | 121 | } |
113 | 122 | |
114 | 123 | $compiled = $this->compileClass($class, $result); |
115 | 124 | |
116 | - if ($this->cache !== null) { |
|
125 | + if ($this->cache !== null) |
|
126 | + { |
|
117 | 127 | $this->cache->write( |
118 | 128 | $key, |
119 | 129 | $compiled, |
@@ -126,13 +136,15 @@ discard block |
||
126 | 136 | $this->cache->load($key); |
127 | 137 | } |
128 | 138 | |
129 | - if (!\class_exists($class)) { |
|
139 | + if (!\class_exists($class)) |
|
140 | + { |
|
130 | 141 | // runtime initialization |
131 | 142 | eval('?>' . $compiled); |
132 | 143 | } |
133 | 144 | } |
134 | 145 | |
135 | - if (!\class_exists($class) || !\is_subclass_of($class, ViewInterface::class)) { |
|
146 | + if (!\class_exists($class) || !\is_subclass_of($class, ViewInterface::class)) |
|
147 | + { |
|
136 | 148 | throw new EngineException(\sprintf('Unable to load `%s`, cache might be corrupted.', $path)); |
137 | 149 | } |
138 | 150 | |
@@ -141,7 +153,8 @@ discard block |
||
141 | 153 | |
142 | 154 | public function reset(string $path, ContextInterface $context): void |
143 | 155 | { |
144 | - if ($this->cache === null) { |
|
156 | + if ($this->cache === null) |
|
157 | + { |
|
145 | 158 | return; |
146 | 159 | } |
147 | 160 | |
@@ -160,12 +173,15 @@ discard block |
||
160 | 173 | */ |
161 | 174 | public function makeSourceMap(string $path, ContextInterface $context): ?SourceMap |
162 | 175 | { |
163 | - try { |
|
176 | + try |
|
177 | + { |
|
164 | 178 | $builder = $this->getBuilder($context); |
165 | 179 | |
166 | 180 | // there is no need to cache sourcemaps since they are used during the exception only |
167 | 181 | return $builder->compile($path)->getSourceMap($builder->getLoader()); |
168 | - } catch (Throwable) { |
|
182 | + } |
|
183 | + catch (Throwable) |
|
184 | + { |
|
169 | 185 | return null; |
170 | 186 | } |
171 | 187 | } |
@@ -222,7 +238,8 @@ discard block |
||
222 | 238 | $builder = new Builder($loader); |
223 | 239 | |
224 | 240 | $directivesGroup = new DirectiveGroup(); |
225 | - foreach ($this->getDirectives() as $directive) { |
|
241 | + foreach ($this->getDirectives() as $directive) |
|
242 | + { |
|
226 | 243 | $directivesGroup->addDirective($directive); |
227 | 244 | } |
228 | 245 | |
@@ -253,7 +270,8 @@ discard block |
||
253 | 270 | $builder->getCompiler()->addRenderer(new DynamicRenderer(new DirectiveGroup($this->getDirectives()))); |
254 | 271 | |
255 | 272 | // ATS modifications |
256 | - foreach ($this->getVisitors(Builder::STAGE_PREPARE) as $visitor) { |
|
273 | + foreach ($this->getVisitors(Builder::STAGE_PREPARE) as $visitor) |
|
274 | + { |
|
257 | 275 | $builder->addVisitor($visitor, Builder::STAGE_PREPARE); |
258 | 276 | } |
259 | 277 | |
@@ -266,15 +284,18 @@ discard block |
||
266 | 284 | $builder->addVisitor(new ResolveImports($builder), Builder::STAGE_TRANSFORM); |
267 | 285 | $builder->addVisitor(new ExtendsParent($builder), Builder::STAGE_TRANSFORM); |
268 | 286 | |
269 | - foreach ($this->getVisitors(Builder::STAGE_TRANSFORM) as $visitor) { |
|
287 | + foreach ($this->getVisitors(Builder::STAGE_TRANSFORM) as $visitor) |
|
288 | + { |
|
270 | 289 | $builder->addVisitor($visitor, Builder::STAGE_TRANSFORM); |
271 | 290 | } |
272 | 291 | |
273 | - foreach ($this->getVisitors(Builder::STAGE_FINALIZE) as $visitor) { |
|
292 | + foreach ($this->getVisitors(Builder::STAGE_FINALIZE) as $visitor) |
|
293 | + { |
|
274 | 294 | $builder->addVisitor($visitor, Builder::STAGE_FINALIZE); |
275 | 295 | } |
276 | 296 | |
277 | - foreach ($this->getVisitors(Builder::STAGE_COMPILE) as $visitor) { |
|
297 | + foreach ($this->getVisitors(Builder::STAGE_COMPILE) as $visitor) |
|
298 | + { |
|
278 | 299 | $builder->addVisitor($visitor, Builder::STAGE_COMPILE); |
279 | 300 | } |
280 | 301 | |
@@ -287,8 +308,10 @@ discard block |
||
287 | 308 | private function getVisitors(int $stage): iterable |
288 | 309 | { |
289 | 310 | $result = []; |
290 | - foreach ($this->config->getVisitors($stage) as $visitor) { |
|
291 | - if ($visitor instanceof Autowire) { |
|
311 | + foreach ($this->config->getVisitors($stage) as $visitor) |
|
312 | + { |
|
313 | + if ($visitor instanceof Autowire) |
|
314 | + { |
|
292 | 315 | $result[] = $visitor->resolve($this->container->get(FactoryInterface::class)); |
293 | 316 | continue; |
294 | 317 | } |
@@ -305,8 +328,10 @@ discard block |
||
305 | 328 | private function getProcessors(): iterable |
306 | 329 | { |
307 | 330 | $result = []; |
308 | - foreach ($this->config->getProcessors() as $processor) { |
|
309 | - if ($processor instanceof Autowire) { |
|
331 | + foreach ($this->config->getProcessors() as $processor) |
|
332 | + { |
|
333 | + if ($processor instanceof Autowire) |
|
334 | + { |
|
310 | 335 | $result[] = $processor->resolve($this->container->get(FactoryInterface::class)); |
311 | 336 | continue; |
312 | 337 | } |
@@ -323,8 +348,10 @@ discard block |
||
323 | 348 | private function getDirectives(): iterable |
324 | 349 | { |
325 | 350 | $result = []; |
326 | - foreach ($this->config->getDirectives() as $directive) { |
|
327 | - if ($directive instanceof Autowire) { |
|
351 | + foreach ($this->config->getDirectives() as $directive) |
|
352 | + { |
|
353 | + if ($directive instanceof Autowire) |
|
354 | + { |
|
328 | 355 | $result[] = $directive->resolve($this->container->get(FactoryInterface::class)); |
329 | 356 | continue; |
330 | 357 | } |
@@ -42,7 +42,8 @@ discard block |
||
42 | 42 | 'root' => __DIR__, |
43 | 43 | ])->run(); |
44 | 44 | |
45 | - $d = new class() implements DispatcherInterface { |
|
45 | + $d = new class() implements DispatcherInterface |
|
46 | + { |
|
46 | 47 | public $fired = false; |
47 | 48 | |
48 | 49 | public function canServe(): bool |
@@ -71,7 +72,8 @@ discard block |
||
71 | 72 | 'root' => __DIR__, |
72 | 73 | ])->run(); |
73 | 74 | |
74 | - $d = new class() implements DispatcherInterface { |
|
75 | + $d = new class() implements DispatcherInterface |
|
76 | + { |
|
75 | 77 | public function canServe(): bool |
76 | 78 | { |
77 | 79 | return true; |
@@ -109,19 +111,23 @@ discard block |
||
109 | 111 | 'root' => __DIR__, |
110 | 112 | ]); |
111 | 113 | |
112 | - $kernel->booting(static function (TestCore $core) { |
|
114 | + $kernel->booting(static function (TestCore $core) |
|
115 | + { |
|
113 | 116 | $core->getContainer()->bind('abc', 'foo'); |
114 | 117 | }); |
115 | 118 | |
116 | - $kernel->booting(static function (TestCore $core) { |
|
119 | + $kernel->booting(static function (TestCore $core) |
|
120 | + { |
|
117 | 121 | $core->getContainer()->bind('bcd', 'foo'); |
118 | 122 | }); |
119 | 123 | |
120 | - $kernel->booted( static function (TestCore $core) { |
|
124 | + $kernel->booted( static function (TestCore $core) |
|
125 | + { |
|
121 | 126 | $core->getContainer()->bind('cde', 'foo'); |
122 | 127 | }); |
123 | 128 | |
124 | - $kernel->booted( static function (TestCore $core) { |
|
129 | + $kernel->booted( static function (TestCore $core) |
|
130 | + { |
|
125 | 131 | $core->getContainer()->bind('def', 'foo'); |
126 | 132 | }); |
127 | 133 | |
@@ -144,7 +150,8 @@ discard block |
||
144 | 150 | |
145 | 151 | public function testEventsShouldBeDispatched(): void |
146 | 152 | { |
147 | - $testDispatcher = new class implements DispatcherInterface { |
|
153 | + $testDispatcher = new class implements DispatcherInterface |
|
154 | + { |
|
148 | 155 | public function canServe(): bool |
149 | 156 | { |
150 | 157 | return true; |
@@ -34,7 +34,8 @@ discard block |
||
34 | 34 | public function boot(AbstractKernel $kernel): void |
35 | 35 | { |
36 | 36 | $kernel->bootstrapped(function (ClassesInterface $classes): void { |
37 | - foreach ($classes->getClasses() as $class) { |
|
37 | + foreach ($classes->getClasses() as $class) |
|
38 | + { |
|
38 | 39 | $this->invokeListeners($class); |
39 | 40 | } |
40 | 41 | |
@@ -44,14 +45,16 @@ discard block |
||
44 | 45 | |
45 | 46 | private function invokeListeners(\ReflectionClass $class): void |
46 | 47 | { |
47 | - foreach ($this->listeners as $listener) { |
|
48 | + foreach ($this->listeners as $listener) |
|
49 | + { |
|
48 | 50 | $listener->listen($class); |
49 | 51 | } |
50 | 52 | } |
51 | 53 | |
52 | 54 | private function finalize(): void |
53 | 55 | { |
54 | - foreach ($this->listeners as $listener) { |
|
56 | + foreach ($this->listeners as $listener) |
|
57 | + { |
|
55 | 58 | $listener->finalize(); |
56 | 59 | } |
57 | 60 |
@@ -31,7 +31,8 @@ |
||
31 | 31 | */ |
32 | 32 | public function getValidation(string $name, array $params = []): ValidationInterface |
33 | 33 | { |
34 | - if (!isset($this->resolvers[$name])) { |
|
34 | + if (!isset($this->resolvers[$name])) |
|
35 | + { |
|
35 | 36 | throw new ValidationException(\sprintf('Validation with name `%s` is not registered.', $name)); |
36 | 37 | } |
37 | 38 |
@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | |
29 | 29 | public function getValue(string $source, mixed $name = null): mixed |
30 | 30 | { |
31 | - if ($source !== 'input' && !$this->input->hasBag($source)) { |
|
31 | + if ($source !== 'input' && !$this->input->hasBag($source)) |
|
32 | + { |
|
32 | 33 | throw new InputException(\sprintf('Undefined input source %s', $source)); |
33 | 34 | } |
34 | 35 | |
@@ -37,7 +38,8 @@ discard block |
||
37 | 38 | |
38 | 39 | public function hasValue(string $source, string $name): bool |
39 | 40 | { |
40 | - if (!$this->input->hasBag($source)) { |
|
41 | + if (!$this->input->hasBag($source)) |
|
42 | + { |
|
41 | 43 | return false; |
42 | 44 | } |
43 | 45 |