@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | private readonly ContainerInterface $container, |
| 46 | 46 | private readonly StemplerConfig $config, |
| 47 | 47 | private readonly ?StemplerCache $cache = null |
| 48 | - ) { |
|
| 48 | + ){ |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | public function getContainer(): ContainerInterface |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | public function getLoader(): LoaderInterface |
| 66 | 66 | { |
| 67 | - if ($this->loader === null) { |
|
| 67 | + if ($this->loader === null){ |
|
| 68 | 68 | throw new EngineException('No associated loader found'); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -76,13 +76,13 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function getBuilder(ContextInterface $context): Builder |
| 78 | 78 | { |
| 79 | - if ($this->builder === null) { |
|
| 79 | + if ($this->builder === null){ |
|
| 80 | 80 | throw new EngineException('No associated builder found'); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // since view source support pre-processing we must ensure that context is always set |
| 84 | 84 | $loader = $this->builder->getLoader(); |
| 85 | - if ($loader instanceof StemplerLoader) { |
|
| 85 | + if ($loader instanceof StemplerLoader){ |
|
| 86 | 86 | $loader->setContext($context); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -100,20 +100,20 @@ discard block |
||
| 100 | 100 | // cache key |
| 101 | 101 | $key = $this->cacheKey($view, $context); |
| 102 | 102 | |
| 103 | - if ($this->cache !== null && $this->cache->isFresh($key)) { |
|
| 103 | + if ($this->cache !== null && $this->cache->isFresh($key)){ |
|
| 104 | 104 | $this->cache->load($key); |
| 105 | - } elseif (!\class_exists($class)) { |
|
| 106 | - try { |
|
| 105 | + } elseif (!\class_exists($class)){ |
|
| 106 | + try{ |
|
| 107 | 107 | $builder = $this->getBuilder($context); |
| 108 | 108 | |
| 109 | 109 | $result = $builder->compile($path); |
| 110 | - } catch (Throwable $e) { |
|
| 110 | + }catch (Throwable $e){ |
|
| 111 | 111 | throw new CompileException($e); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | $compiled = $this->compileClass($class, $result); |
| 115 | 115 | |
| 116 | - if ($this->cache !== null) { |
|
| 116 | + if ($this->cache !== null){ |
|
| 117 | 117 | $this->cache->write( |
| 118 | 118 | $key, |
| 119 | 119 | $compiled, |
@@ -126,13 +126,13 @@ discard block |
||
| 126 | 126 | $this->cache->load($key); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - if (!\class_exists($class)) { |
|
| 129 | + if (!\class_exists($class)){ |
|
| 130 | 130 | // runtime initialization |
| 131 | - eval('?>' . $compiled); |
|
| 131 | + eval('?>'.$compiled); |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - if (!\class_exists($class) || !\is_subclass_of($class, ViewInterface::class)) { |
|
| 135 | + if (!\class_exists($class) || !\is_subclass_of($class, ViewInterface::class)){ |
|
| 136 | 136 | throw new EngineException(\sprintf('Unable to load `%s`, cache might be corrupted.', $path)); |
| 137 | 137 | } |
| 138 | 138 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | public function reset(string $path, ContextInterface $context): void |
| 143 | 143 | { |
| 144 | - if ($this->cache === null) { |
|
| 144 | + if ($this->cache === null){ |
|
| 145 | 145 | return; |
| 146 | 146 | } |
| 147 | 147 | |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | public function makeSourceMap(string $path, ContextInterface $context): ?SourceMap |
| 162 | 162 | { |
| 163 | - try { |
|
| 163 | + try{ |
|
| 164 | 164 | $builder = $this->getBuilder($context); |
| 165 | 165 | |
| 166 | 166 | // there is no need to cache sourcemaps since they are used during the exception only |
| 167 | 167 | return $builder->compile($path)->getSourceMap($builder->getLoader()); |
| 168 | - } catch (Throwable) { |
|
| 168 | + }catch (Throwable){ |
|
| 169 | 169 | return null; |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | private function className(ViewSource $source, ContextInterface $context): string |
| 203 | 203 | { |
| 204 | 204 | /** @psalm-suppress LessSpecificReturnStatement */ |
| 205 | - return $this->classPrefix . $this->cacheKey($source, $context); |
|
| 205 | + return $this->classPrefix.$this->cacheKey($source, $context); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | private function cacheKey(ViewSource $source, ContextInterface $context): string |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | $builder = new Builder($loader); |
| 223 | 223 | |
| 224 | 224 | $directivesGroup = new DirectiveGroup(); |
| 225 | - foreach ($this->getDirectives() as $directive) { |
|
| 225 | + foreach ($this->getDirectives() as $directive){ |
|
| 226 | 226 | $directivesGroup->addDirective($directive); |
| 227 | 227 | } |
| 228 | 228 | |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | $builder->getCompiler()->addRenderer(new DynamicRenderer(new DirectiveGroup($this->getDirectives()))); |
| 254 | 254 | |
| 255 | 255 | // ATS modifications |
| 256 | - foreach ($this->getVisitors(Builder::STAGE_PREPARE) as $visitor) { |
|
| 256 | + foreach ($this->getVisitors(Builder::STAGE_PREPARE) as $visitor){ |
|
| 257 | 257 | $builder->addVisitor($visitor, Builder::STAGE_PREPARE); |
| 258 | 258 | } |
| 259 | 259 | |
@@ -266,15 +266,15 @@ discard block |
||
| 266 | 266 | $builder->addVisitor(new ResolveImports($builder), Builder::STAGE_TRANSFORM); |
| 267 | 267 | $builder->addVisitor(new ExtendsParent($builder), Builder::STAGE_TRANSFORM); |
| 268 | 268 | |
| 269 | - foreach ($this->getVisitors(Builder::STAGE_TRANSFORM) as $visitor) { |
|
| 269 | + foreach ($this->getVisitors(Builder::STAGE_TRANSFORM) as $visitor){ |
|
| 270 | 270 | $builder->addVisitor($visitor, Builder::STAGE_TRANSFORM); |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - foreach ($this->getVisitors(Builder::STAGE_FINALIZE) as $visitor) { |
|
| 273 | + foreach ($this->getVisitors(Builder::STAGE_FINALIZE) as $visitor){ |
|
| 274 | 274 | $builder->addVisitor($visitor, Builder::STAGE_FINALIZE); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - foreach ($this->getVisitors(Builder::STAGE_COMPILE) as $visitor) { |
|
| 277 | + foreach ($this->getVisitors(Builder::STAGE_COMPILE) as $visitor){ |
|
| 278 | 278 | $builder->addVisitor($visitor, Builder::STAGE_COMPILE); |
| 279 | 279 | } |
| 280 | 280 | |
@@ -287,8 +287,8 @@ discard block |
||
| 287 | 287 | private function getVisitors(int $stage): iterable |
| 288 | 288 | { |
| 289 | 289 | $result = []; |
| 290 | - foreach ($this->config->getVisitors($stage) as $visitor) { |
|
| 291 | - if ($visitor instanceof Autowire) { |
|
| 290 | + foreach ($this->config->getVisitors($stage) as $visitor){ |
|
| 291 | + if ($visitor instanceof Autowire){ |
|
| 292 | 292 | $result[] = $visitor->resolve($this->container->get(FactoryInterface::class)); |
| 293 | 293 | continue; |
| 294 | 294 | } |
@@ -305,8 +305,8 @@ discard block |
||
| 305 | 305 | private function getProcessors(): iterable |
| 306 | 306 | { |
| 307 | 307 | $result = []; |
| 308 | - foreach ($this->config->getProcessors() as $processor) { |
|
| 309 | - if ($processor instanceof Autowire) { |
|
| 308 | + foreach ($this->config->getProcessors() as $processor){ |
|
| 309 | + if ($processor instanceof Autowire){ |
|
| 310 | 310 | $result[] = $processor->resolve($this->container->get(FactoryInterface::class)); |
| 311 | 311 | continue; |
| 312 | 312 | } |
@@ -323,8 +323,8 @@ discard block |
||
| 323 | 323 | private function getDirectives(): iterable |
| 324 | 324 | { |
| 325 | 325 | $result = []; |
| 326 | - foreach ($this->config->getDirectives() as $directive) { |
|
| 327 | - if ($directive instanceof Autowire) { |
|
| 326 | + foreach ($this->config->getDirectives() as $directive){ |
|
| 327 | + if ($directive instanceof Autowire){ |
|
| 328 | 328 | $result[] = $directive->resolve($this->container->get(FactoryInterface::class)); |
| 329 | 329 | continue; |
| 330 | 330 | } |
@@ -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 | } |
@@ -43,25 +43,25 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | protected function mapDirectories(array $directories): array |
| 45 | 45 | { |
| 46 | - if (!isset($directories['root'])) { |
|
| 46 | + if (!isset($directories['root'])){ |
|
| 47 | 47 | throw new BootException('Missing required directory `root`.'); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if (!isset($directories['app'])) { |
|
| 51 | - $directories['app'] = $directories['root'] . '/app/'; |
|
| 50 | + if (!isset($directories['app'])){ |
|
| 51 | + $directories['app'] = $directories['root'].'/app/'; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | return array_merge([ |
| 55 | 55 | // public root |
| 56 | - 'public' => $directories['root'] . '/public/', |
|
| 56 | + 'public' => $directories['root'].'/public/', |
|
| 57 | 57 | |
| 58 | 58 | // data directories |
| 59 | - 'runtime' => $directories['root'] . '/runtime/', |
|
| 60 | - 'cache' => $directories['root'] . '/runtime/cache/', |
|
| 59 | + 'runtime' => $directories['root'].'/runtime/', |
|
| 60 | + 'cache' => $directories['root'].'/runtime/cache/', |
|
| 61 | 61 | |
| 62 | 62 | // application directories |
| 63 | - 'config' => $directories['app'] . '/config/', |
|
| 64 | - 'resources' => $directories['app'] . '/resources/', |
|
| 63 | + 'config' => $directories['app'].'/config/', |
|
| 64 | + 'resources' => $directories['app'].'/resources/', |
|
| 65 | 65 | ], $directories); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -42,7 +42,7 @@ 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 | public $fired = false; |
| 47 | 47 | |
| 48 | 48 | public function canServe(): bool |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | 'root' => __DIR__, |
| 72 | 72 | ])->run(); |
| 73 | 73 | |
| 74 | - $d = new class() implements DispatcherInterface { |
|
| 74 | + $d = new class() implements DispatcherInterface{ |
|
| 75 | 75 | public function canServe(): bool |
| 76 | 76 | { |
| 77 | 77 | return true; |
@@ -109,19 +109,19 @@ discard block |
||
| 109 | 109 | 'root' => __DIR__, |
| 110 | 110 | ]); |
| 111 | 111 | |
| 112 | - $kernel->booting(static function (TestCore $core) { |
|
| 112 | + $kernel->booting(static function (TestCore $core){ |
|
| 113 | 113 | $core->getContainer()->bind('abc', 'foo'); |
| 114 | 114 | }); |
| 115 | 115 | |
| 116 | - $kernel->booting(static function (TestCore $core) { |
|
| 116 | + $kernel->booting(static function (TestCore $core){ |
|
| 117 | 117 | $core->getContainer()->bind('bcd', 'foo'); |
| 118 | 118 | }); |
| 119 | 119 | |
| 120 | - $kernel->booted( static function (TestCore $core) { |
|
| 120 | + $kernel->booted(static function (TestCore $core){ |
|
| 121 | 121 | $core->getContainer()->bind('cde', 'foo'); |
| 122 | 122 | }); |
| 123 | 123 | |
| 124 | - $kernel->booted( static function (TestCore $core) { |
|
| 124 | + $kernel->booted(static function (TestCore $core){ |
|
| 125 | 125 | $core->getContainer()->bind('def', 'foo'); |
| 126 | 126 | }); |
| 127 | 127 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | public function testEventsShouldBeDispatched(): void |
| 146 | 146 | { |
| 147 | - $testDispatcher = new class implements DispatcherInterface { |
|
| 147 | + $testDispatcher = new class implements DispatcherInterface{ |
|
| 148 | 148 | public function canServe(): bool |
| 149 | 149 | { |
| 150 | 150 | return true; |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | }; |
| 157 | 157 | |
| 158 | 158 | $container = new Container(); |
| 159 | - $kernel = TestCore::create(directories: ['root' => __DIR__,], container: $container) |
|
| 159 | + $kernel = TestCore::create(directories: ['root' => __DIR__, ], container: $container) |
|
| 160 | 160 | ->addDispatcher($testDispatcher); |
| 161 | 161 | |
| 162 | 162 | $dispatcher = $this->createMock(EventDispatcherInterface::class); |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | public function testDispatcherNotFoundEventShouldBeDispatched(): void |
| 178 | 178 | { |
| 179 | 179 | $container = new Container(); |
| 180 | - $kernel = TestCore::create(directories: ['root' => __DIR__,], container: $container); |
|
| 180 | + $kernel = TestCore::create(directories: ['root' => __DIR__, ], container: $container); |
|
| 181 | 181 | |
| 182 | 182 | $dispatcher = $this->createMock(EventDispatcherInterface::class); |
| 183 | 183 | $dispatcher |
@@ -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,7 @@ 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 | $this->invokeListeners($class); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -44,14 +44,14 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | private function invokeListeners(\ReflectionClass $class): void |
| 46 | 46 | { |
| 47 | - foreach ($this->listeners as $listener) { |
|
| 47 | + foreach ($this->listeners as $listener){ |
|
| 48 | 48 | $listener->listen($class); |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | private function finalize(): void |
| 53 | 53 | { |
| 54 | - foreach ($this->listeners as $listener) { |
|
| 54 | + foreach ($this->listeners as $listener){ |
|
| 55 | 55 | $listener->finalize(); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -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 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | public function __construct( |
| 17 | 17 | private readonly InvokerInterface $invoker |
| 18 | - ) { |
|
| 18 | + ){ |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 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 | throw new ValidationException(\sprintf('Validation with name `%s` is not registered.', $name)); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -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 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | public function __construct( |
| 17 | 17 | private InputManager $input |
| 18 | - ) { |
|
| 18 | + ){ |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function withPrefix(string $prefix, bool $add = true): InputInterface |
@@ -28,7 +28,7 @@ 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 | throw new InputException(\sprintf('Undefined input source %s', $source)); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | public function hasValue(string $source, string $name): bool |
| 39 | 39 | { |
| 40 | - if (!$this->input->hasBag($source)) { |
|
| 40 | + if (!$this->input->hasBag($source)){ |
|
| 41 | 41 | return false; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -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 | |
@@ -23,25 +23,25 @@ |
||
| 23 | 23 | private string $path, |
| 24 | 24 | private ?string $prefix = null, |
| 25 | 25 | Context $context = null |
| 26 | - ) { |
|
| 26 | + ){ |
|
| 27 | 27 | $this->context = $context; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public function resolve(Builder $builder, string $name): ?Template |
| 31 | 31 | { |
| 32 | - if ($this->template === null) { |
|
| 32 | + if ($this->template === null){ |
|
| 33 | 33 | $this->template = $builder->load($this->path); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $path = $name; |
| 37 | - if ($this->prefix !== null) { |
|
| 37 | + if ($this->prefix !== null){ |
|
| 38 | 38 | $path = \substr($path, \strlen($this->prefix) + 1); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** @var ImportInterface $import */ |
| 42 | - foreach ($this->template->getAttribute(ImportContext::class, []) as $import) { |
|
| 42 | + foreach ($this->template->getAttribute(ImportContext::class, []) as $import){ |
|
| 43 | 43 | $tpl = $import->resolve($builder, $path); |
| 44 | - if ($tpl !== null) { |
|
| 44 | + if ($tpl !== null){ |
|
| 45 | 45 | return $tpl; |
| 46 | 46 | } |
| 47 | 47 | } |