| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Gbere\SimpleAuth; |
||
| 6 | |||
| 7 | use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
||
| 8 | use Symfony\Component\Config\Loader\LoaderInterface; |
||
| 9 | use Symfony\Component\Config\Resource\FileResource; |
||
| 10 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
||
| 11 | use Symfony\Component\HttpKernel\Kernel as BaseKernel; |
||
| 12 | use Symfony\Component\Routing\RouteCollectionBuilder; |
||
| 13 | |||
| 14 | class Kernel extends BaseKernel |
||
| 15 | { |
||
| 16 | use MicroKernelTrait; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 17 | |||
| 18 | private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; |
||
| 19 | |||
| 20 | public function registerBundles(): iterable |
||
| 21 | { |
||
| 22 | $contents = require $this->getProjectDir().'/config/bundles.php'; |
||
| 23 | foreach ($contents as $class => $envs) { |
||
| 24 | if ($envs[$this->environment] ?? $envs['all'] ?? false) { |
||
| 25 | yield new $class(); |
||
|
0 ignored issues
–
show
The expression
yield new $class() returns the type Generator which is incompatible with the return type mandated by Symfony\Component\HttpKe...face::registerBundles() of Symfony\Component\HttpKe...dleInterface[]|iterable.
In the issue above, the returned value is violating the contract defined by the mentioned interface. Let's take a look at an example: interface HasName {
/** @return string */
public function getName();
}
class Name {
public $name;
}
class User implements HasName {
/** @return string|Name */
public function getName() {
return new Name('foo'); // This is a violation of the ``HasName`` interface
// which only allows a string value to be returned.
}
}
Loading history...
|
|||
| 26 | } |
||
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | public function getProjectDir(): string |
||
| 31 | { |
||
| 32 | return \dirname(__DIR__); |
||
| 33 | } |
||
| 34 | |||
| 35 | protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void |
||
| 36 | { |
||
| 37 | $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php')); |
||
| 38 | $container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400 || $this->debug); |
||
| 39 | $container->setParameter('container.dumper.inline_factories', true); |
||
| 40 | $confDir = $this->getProjectDir().'/config'; |
||
| 41 | |||
| 42 | $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob'); |
||
| 43 | $loader->load($confDir.'/{packages}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob'); |
||
| 44 | $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob'); |
||
| 45 | $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob'); |
||
| 46 | } |
||
| 47 | |||
| 48 | protected function configureRoutes(RouteCollectionBuilder $routes): void |
||
| 49 | { |
||
| 50 | $confDir = $this->getProjectDir().'/config'; |
||
| 51 | |||
| 52 | $routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS, '/', 'glob'); |
||
| 53 | $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob'); |
||
| 54 | $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob'); |
||
| 55 | } |
||
| 56 | } |
||
| 57 |