N°6934 - Symfony 6.4 - upgrade Symfony bundles to 6.4 (#580)

* Update Symfony lib to version ~6.4.0
* Update code missing return type
* Add an iTop general configuration entry to store application secret (Symfony mandatory parameter)
* Use dependency injection in ExceptionListener & UserProvider classes
This commit is contained in:
bdalsass
2023-12-05 13:56:56 +01:00
committed by GitHub
parent 863ab4560c
commit 27ce51ab07
1392 changed files with 44869 additions and 27799 deletions

View File

@@ -20,7 +20,6 @@ use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Routing\Loader\PhpFileLoader as RoutingPhpFileLoader;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RouteCollectionBuilder;
/**
* A Kernel that provides configuration hooks.
@@ -51,14 +50,15 @@ trait MicroKernelTrait
{
$configDir = $this->getConfigDir();
$container->import($configDir.'/{packages}/*.yaml');
$container->import($configDir.'/{packages}/'.$this->environment.'/*.yaml');
$container->import($configDir.'/{packages}/*.{php,yaml}');
$container->import($configDir.'/{packages}/'.$this->environment.'/*.{php,yaml}');
if (is_file($configDir.'/services.yaml')) {
$container->import($configDir.'/services.yaml');
$container->import($configDir.'/{services}_'.$this->environment.'.yaml');
} else {
$container->import($configDir.'/{services}.php');
$container->import($configDir.'/{services}_'.$this->environment.'.php');
}
}
@@ -75,14 +75,18 @@ trait MicroKernelTrait
{
$configDir = $this->getConfigDir();
$routes->import($configDir.'/{routes}/'.$this->environment.'/*.yaml');
$routes->import($configDir.'/{routes}/*.yaml');
$routes->import($configDir.'/{routes}/'.$this->environment.'/*.{php,yaml}');
$routes->import($configDir.'/{routes}/*.{php,yaml}');
if (is_file($configDir.'/routes.yaml')) {
$routes->import($configDir.'/routes.yaml');
} else {
$routes->import($configDir.'/{routes}.php');
}
if (false !== ($fileName = (new \ReflectionObject($this))->getFileName())) {
$routes->import($fileName, 'attribute');
}
}
/**
@@ -101,9 +105,6 @@ trait MicroKernelTrait
return $this->getConfigDir().'/bundles.php';
}
/**
* {@inheritdoc}
*/
public function getCacheDir(): string
{
if (isset($_SERVER['APP_CACHE_DIR'])) {
@@ -113,17 +114,20 @@ trait MicroKernelTrait
return parent::getCacheDir();
}
/**
* {@inheritdoc}
*/
public function getBuildDir(): string
{
if (isset($_SERVER['APP_BUILD_DIR'])) {
return $_SERVER['APP_BUILD_DIR'].'/'.$this->environment;
}
return parent::getBuildDir();
}
public function getLogDir(): string
{
return $_SERVER['APP_LOG_DIR'] ?? parent::getLogDir();
}
/**
* {@inheritdoc}
*/
public function registerBundles(): iterable
{
$contents = require $this->getBundlesPath();
@@ -135,7 +139,7 @@ trait MicroKernelTrait
}
/**
* {@inheritdoc}
* @return void
*/
public function registerContainerConfiguration(LoaderInterface $loader)
{
@@ -147,7 +151,7 @@ trait MicroKernelTrait
],
]);
$kernelClass = false !== strpos(static::class, "@anonymous\0") ? parent::class : static::class;
$kernelClass = str_contains(static::class, "@anonymous\0") ? parent::class : static::class;
if (!$container->hasDefinition('kernel')) {
$container->register('kernel', $kernelClass)
@@ -177,12 +181,10 @@ trait MicroKernelTrait
/* @var ContainerPhpFileLoader $kernelLoader */
$kernelLoader = $loader->getResolver()->resolve($file);
$kernelLoader->setCurrentDir(\dirname($file));
$instanceof = &\Closure::bind(function &() { return $this->instanceof; }, $kernelLoader, $kernelLoader)();
$instanceof = &\Closure::bind(fn &() => $this->instanceof, $kernelLoader, $kernelLoader)();
$valuePreProcessor = AbstractConfigurator::$valuePreProcessor;
AbstractConfigurator::$valuePreProcessor = function ($value) {
return $this === $value ? new Reference('kernel') : $value;
};
AbstractConfigurator::$valuePreProcessor = fn ($value) => $this === $value ? new Reference('kernel') : $value;
try {
$configureContainer->getClosure($this)(new ContainerConfigurator($container, $kernelLoader, $instanceof, $file, $file, $this->getEnvironment()), $loader, $container);
@@ -208,17 +210,6 @@ trait MicroKernelTrait
$collection = new RouteCollection();
$configureRoutes = new \ReflectionMethod($this, 'configureRoutes');
$configuratorClass = $configureRoutes->getNumberOfParameters() > 0 && ($type = $configureRoutes->getParameters()[0]->getType()) instanceof \ReflectionNamedType && !$type->isBuiltin() ? $type->getName() : null;
if ($configuratorClass && !is_a(RoutingConfigurator::class, $configuratorClass, true)) {
trigger_deprecation('symfony/framework-bundle', '5.1', 'Using type "%s" for argument 1 of method "%s:configureRoutes()" is deprecated, use "%s" instead.', RouteCollectionBuilder::class, self::class, RoutingConfigurator::class);
$routes = new RouteCollectionBuilder($loader);
$this->configureRoutes($routes);
return $routes->build();
}
$configureRoutes->getClosure($this)(new RoutingConfigurator($collection, $kernelLoader, $file, $file, $this->getEnvironment()));
foreach ($collection as $route) {
@@ -226,6 +217,8 @@ trait MicroKernelTrait
if (\is_array($controller) && [0, 1] === array_keys($controller) && $this === $controller[0]) {
$route->setDefault('_controller', ['kernel', $controller[1]]);
} elseif ($controller instanceof \Closure && $this === ($r = new \ReflectionFunction($controller))->getClosureThis() && !str_contains($r->name, '{closure}')) {
$route->setDefault('_controller', ['kernel', $r->name]);
}
}