N°8834 - Add compatibility with PHP 8.4 (#819)

* N°8834 - Add compatibility with PHP 8.4

* Rollback of scssphp/scssphp version upgrade due to compilation error
This commit is contained in:
Lenaick
2026-02-26 10:36:32 +01:00
committed by GitHub
parent d4821b7edc
commit fc967c06ce
961 changed files with 12298 additions and 7130 deletions

View File

@@ -36,13 +36,13 @@ class PhpFileLoader extends FileLoader
protected $autoRegisterAliasesForSinglyImplementedInterfaces = false;
private ?ConfigBuilderGeneratorInterface $generator;
public function __construct(ContainerBuilder $container, FileLocatorInterface $locator, string $env = null, ConfigBuilderGeneratorInterface $generator = null)
public function __construct(ContainerBuilder $container, FileLocatorInterface $locator, ?string $env = null, ?ConfigBuilderGeneratorInterface $generator = null)
{
parent::__construct($container, $locator, $env);
$this->generator = $generator;
}
public function load(mixed $resource, string $type = null): mixed
public function load(mixed $resource, ?string $type = null): mixed
{
// the container and loader variables are exposed to the included file below
$container = $this->container;
@@ -57,6 +57,9 @@ class PhpFileLoader extends FileLoader
return include $path;
}, $this, ProtectedPhpFileLoader::class);
$instanceof = $this->instanceof;
$this->instanceof = [];
try {
$callback = $load($path, $this->env);
@@ -64,14 +67,14 @@ class PhpFileLoader extends FileLoader
$this->executeCallback($callback, new ContainerConfigurator($this->container, $this, $this->instanceof, $path, $resource, $this->env), $path);
}
} finally {
$this->instanceof = [];
$this->instanceof = $instanceof;
$this->registerAliasesForSinglyImplementedInterfaces();
}
return null;
}
public function supports(mixed $resource, string $type = null): bool
public function supports(mixed $resource, ?string $type = null): bool
{
if (!\is_string($resource)) {
return false;
@@ -108,7 +111,7 @@ class PhpFileLoader extends FileLoader
foreach ($r->getParameters() as $parameter) {
$reflectionType = $parameter->getType();
if (!$reflectionType instanceof \ReflectionNamedType) {
throw new \InvalidArgumentException(sprintf('Could not resolve argument "$%s" for "%s". You must typehint it (for example with "%s" or "%s").', $parameter->getName(), $path, ContainerConfigurator::class, ContainerBuilder::class));
throw new \InvalidArgumentException(\sprintf('Could not resolve argument "$%s" for "%s". You must typehint it (for example with "%s" or "%s").', $parameter->getName(), $path, ContainerConfigurator::class, ContainerBuilder::class));
}
$type = $reflectionType->getName();
@@ -133,7 +136,7 @@ class PhpFileLoader extends FileLoader
try {
$configBuilder = $this->configBuilder($type);
} catch (InvalidArgumentException|\LogicException $e) {
throw new \InvalidArgumentException(sprintf('Could not resolve argument "%s" for "%s".', $type.' $'.$parameter->getName(), $path), 0, $e);
throw new \InvalidArgumentException(\sprintf('Could not resolve argument "%s" for "%s".', $type.' $'.$parameter->getName(), $path), 0, $e);
}
$configBuilders[] = $configBuilder;
$arguments[] = $configBuilder;
@@ -171,7 +174,7 @@ class PhpFileLoader extends FileLoader
// If it does not start with Symfony\Config\ we don't know how to handle this
if (!str_starts_with($namespace, 'Symfony\\Config\\')) {
throw new InvalidArgumentException(sprintf('Could not find or generate class "%s".', $namespace));
throw new InvalidArgumentException(\sprintf('Could not find or generate class "%s".', $namespace));
}
// Try to get the extension alias
@@ -183,12 +186,12 @@ class PhpFileLoader extends FileLoader
if (!$this->container->hasExtension($alias)) {
$extensions = array_filter(array_map(fn (ExtensionInterface $ext) => $ext->getAlias(), $this->container->getExtensions()));
throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s". Looked for namespace "%s", found "%s".', $namespace, $alias, $extensions ? implode('", "', $extensions) : 'none'));
throw new InvalidArgumentException(\sprintf('There is no extension able to load the configuration for "%s". Looked for namespace "%s", found "%s".', $namespace, $alias, $extensions ? implode('", "', $extensions) : 'none'));
}
$extension = $this->container->getExtension($alias);
if (!$extension instanceof ConfigurationExtensionInterface) {
throw new \LogicException(sprintf('You cannot use the config builder for "%s" because the extension does not implement "%s".', $namespace, ConfigurationExtensionInterface::class));
throw new \LogicException(\sprintf('You cannot use the config builder for "%s" because the extension does not implement "%s".', $namespace, ConfigurationExtensionInterface::class));
}
$configuration = $extension->getConfiguration([], $this->container);