You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #20 [framework-bundle] use typehints when possible (dunglas)
This PR was squashed before being merged into the master branch (closes#20).
Discussion
----------
[framework-bundle] use typehints when possible
This PR targets PHP 7, but switching to PHP 7.1 would allow to generate stricter code:
```php
<?php
namespace App;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder;
/**
* @author Fabien Potencier <fabien@symfony.com>
*/
class Kernel extends BaseKernel
{
use MicroKernelTrait;
private const CONFIG_EXTS = '.{php,xml,yaml,yml}';
public function getCacheDir(): string
{
return dirname(__DIR__).'/var/cache/'.$this->environment;
}
public function getLogDir(): string
{
return dirname(__DIR__).'/var/logs';
}
public function registerBundles(): iterable
{
$contents = require dirname(__DIR__).'/etc/bundles.php';
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->getEnvironment()])) {
yield new $class();
}
}
}
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
$confDir = dirname(__DIR__).'/etc';
$loader->import($confDir.'/packages/*'.self::CONFIG_EXTS, 'glob');
if (is_dir($confDir.'/packages/'.$this->getEnvironment())) {
$loader->import($confDir.'/packages/'.$this->getEnvironment().'/**/*'.self::CONFIG_EXTS, 'glob');
}
$loader->import($confDir.'/container'.self::CONFIG_EXTS, 'glob');
}
protected function configureRoutes(RouteCollectionBuilder $routes): void
{
$confDir = dirname(__DIR__).'/etc';
if (is_dir($confDir.'/routing/')) {
$routes->import($confDir.'/routing/*'.self::CONFIG_EXTS, '/', 'glob');
}
if (is_dir($confDir.'/routing/'.$this->getEnvironment())) {
$routes->import($confDir.'/routing/'.$this->getEnvironment().'/**/*'.self::CONFIG_EXTS, '/', 'glob');
}
$routes->import($confDir.'/routing'.self::CONFIG_EXTS, '/', 'glob');
}
}
```
Commits
-------
6a7468d [framework-bundle] use typehints when possible
0 commit comments