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

@@ -13,8 +13,8 @@ namespace Symfony\Component\HttpKernel\Bundle;
use Symfony\Component\Console\Application;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
/**
@@ -24,32 +24,35 @@ use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
*/
abstract class Bundle implements BundleInterface
{
use ContainerAwareTrait;
protected $name;
protected $extension;
protected $path;
private $namespace;
private string $namespace;
/**
* {@inheritdoc}
* @var ContainerInterface|null
*/
protected $container;
/**
* @return void
*/
public function boot()
{
}
/**
* {@inheritdoc}
* @return void
*/
public function shutdown()
{
}
/**
* {@inheritdoc}
*
* This method can be overridden to register compilation passes,
* other extensions, ...
*
* @return void
*/
public function build(ContainerBuilder $container)
{
@@ -58,13 +61,11 @@ abstract class Bundle implements BundleInterface
/**
* Returns the bundle's container extension.
*
* @return ExtensionInterface|null
*
* @throws \LogicException
*/
public function getContainerExtension()
public function getContainerExtension(): ?ExtensionInterface
{
if (null === $this->extension) {
if (!isset($this->extension)) {
$extension = $this->createContainerExtension();
if (null !== $extension) {
@@ -89,24 +90,18 @@ abstract class Bundle implements BundleInterface
return $this->extension ?: null;
}
/**
* {@inheritdoc}
*/
public function getNamespace()
public function getNamespace(): string
{
if (null === $this->namespace) {
if (!isset($this->namespace)) {
$this->parseClassName();
}
return $this->namespace;
}
/**
* {@inheritdoc}
*/
public function getPath()
public function getPath(): string
{
if (null === $this->path) {
if (!isset($this->path)) {
$reflected = new \ReflectionObject($this);
$this->path = \dirname($reflected->getFileName());
}
@@ -119,23 +114,24 @@ abstract class Bundle implements BundleInterface
*/
final public function getName(): string
{
if (null === $this->name) {
if (!isset($this->name)) {
$this->parseClassName();
}
return $this->name;
}
/**
* @return void
*/
public function registerCommands(Application $application)
{
}
/**
* Returns the bundle's container extension class.
*
* @return string
*/
protected function getContainerExtensionClass()
protected function getContainerExtensionClass(): string
{
$basename = preg_replace('/Bundle$/', '', $this->getName());
@@ -144,20 +140,21 @@ abstract class Bundle implements BundleInterface
/**
* Creates the bundle's container extension.
*
* @return ExtensionInterface|null
*/
protected function createContainerExtension()
protected function createContainerExtension(): ?ExtensionInterface
{
return class_exists($class = $this->getContainerExtensionClass()) ? new $class() : null;
}
private function parseClassName()
private function parseClassName(): void
{
$pos = strrpos(static::class, '\\');
$this->namespace = false === $pos ? '' : substr(static::class, 0, $pos);
if (null === $this->name) {
$this->name = false === $pos ? static::class : substr(static::class, $pos + 1);
}
$this->name ??= false === $pos ? static::class : substr(static::class, $pos + 1);
}
public function setContainer(?ContainerInterface $container): void
{
$this->container = $container;
}
}