Updates to vendors etc

This commit is contained in:
Chris Hunt
2025-07-11 15:57:48 +01:00
parent d972cbcd0a
commit 8fb6438254
8043 changed files with 248005 additions and 189479 deletions

View File

@@ -17,24 +17,23 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\ErrorHandler\DebugClassLoader;
use Symfony\Component\HttpKernel\Kernel;
trigger_deprecation('symfony/http-kernel', '7.1', 'The "%s" class is deprecated since Symfony 7.1 and will be removed in 8.0.', AddAnnotatedClassesToCachePass::class);
/**
* Sets the classes to compile in the cache for the container.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since Symfony 7.1, to be removed in 8.0
*/
class AddAnnotatedClassesToCachePass implements CompilerPassInterface
{
private Kernel $kernel;
public function __construct(Kernel $kernel)
{
$this->kernel = $kernel;
public function __construct(
private Kernel $kernel,
) {
}
/**
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$annotatedClasses = [];
foreach ($container->getExtensions() as $extension) {

View File

@@ -34,8 +34,6 @@ abstract class ConfigurableExtension extends Extension
/**
* Configures the passed container according to the merged configuration.
*
* @return void
*/
abstract protected function loadInternal(array $mergedConfig, ContainerBuilder $container);
abstract protected function loadInternal(array $mergedConfig, ContainerBuilder $container): void;
}

View File

@@ -30,10 +30,7 @@ class ControllerArgumentValueResolverPass implements CompilerPassInterface
{
use PriorityTaggedServiceTrait;
/**
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition('argument_resolver')) {
return;

View File

@@ -17,6 +17,8 @@ use Symfony\Component\DependencyInjection\Extension\Extension as BaseExtension;
* Allow adding classes to the class cache.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @internal since Symfony 7.1, to be deprecated in 8.1; use Symfony\Component\DependencyInjection\Extension\Extension instead
*/
abstract class Extension extends BaseExtension
{
@@ -24,21 +26,29 @@ abstract class Extension extends BaseExtension
/**
* Gets the annotated classes to cache.
*
* @return string[]
*
* @deprecated since Symfony 7.1, to be removed in 8.0
*/
public function getAnnotatedClassesToCompile(): array
{
trigger_deprecation('symfony/http-kernel', '7.1', 'The "%s()" method is deprecated since Symfony 7.1 and will be removed in 8.0.', __METHOD__);
return $this->annotatedClasses;
}
/**
* Adds annotated classes to the class cache.
*
* @param array $annotatedClasses An array of class patterns
* @param string[] $annotatedClasses An array of class patterns
*
* @return void
* @deprecated since Symfony 7.1, to be removed in 8.0
*/
public function addAnnotatedClassesToCompile(array $annotatedClasses)
public function addAnnotatedClassesToCompile(array $annotatedClasses): void
{
trigger_deprecation('symfony/http-kernel', '7.1', 'The "%s()" method is deprecated since Symfony 7.1 and will be removed in 8.0.', __METHOD__);
$this->annotatedClasses = array_merge($this->annotatedClasses, $annotatedClasses);
}
}

View File

@@ -25,10 +25,7 @@ use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;
*/
class FragmentRendererPass implements CompilerPassInterface
{
/**
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition('fragment.handler')) {
return;
@@ -41,10 +38,10 @@ class FragmentRendererPass implements CompilerPassInterface
$class = $container->getParameterBag()->resolveValue($def->getClass());
if (!$r = $container->getReflectionClass($class)) {
throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
throw new InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
}
if (!$r->isSubclassOf(FragmentRendererInterface::class)) {
throw new InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, FragmentRendererInterface::class));
throw new InvalidArgumentException(\sprintf('Service "%s" must implement interface "%s".', $id, FragmentRendererInterface::class));
}
foreach ($tags as $tag) {

View File

@@ -23,17 +23,16 @@ use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
*/
class LazyLoadingFragmentHandler extends FragmentHandler
{
private ContainerInterface $container;
/**
* @var array<string, bool>
*/
private array $initialized = [];
public function __construct(ContainerInterface $container, RequestStack $requestStack, bool $debug = false)
{
$this->container = $container;
public function __construct(
private ContainerInterface $container,
RequestStack $requestStack,
bool $debug = false,
) {
parent::__construct($requestStack, [], $debug);
}

View File

@@ -25,12 +25,11 @@ use Symfony\Component\HttpKernel\Log\Logger;
*/
class LoggerPass implements CompilerPassInterface
{
/**
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$container->setAlias(LoggerInterface::class, 'logger');
if (!$container->has(LoggerInterface::class)) {
$container->setAlias(LoggerInterface::class, 'logger');
}
if ($container->has('logger')) {
return;

View File

@@ -21,14 +21,12 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
*/
class MergeExtensionConfigurationPass extends BaseMergeExtensionConfigurationPass
{
private array $extensions;
/**
* @param string[] $extensions
*/
public function __construct(array $extensions)
{
$this->extensions = $extensions;
public function __construct(
private array $extensions,
) {
}
public function process(ContainerBuilder $container): void

View File

@@ -34,10 +34,7 @@ use Symfony\Component\VarExporter\ProxyHelper;
*/
class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
{
/**
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition('argument_resolver.service') && !$container->hasDefinition('argument_resolver.not_tagged_controller')) {
return;
@@ -45,6 +42,7 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
$parameterBag = $container->getParameterBag();
$controllers = [];
$controllerClasses = [];
$publicAliases = [];
foreach ($container->getAliases() as $id => $alias) {
@@ -53,11 +51,10 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
}
}
$emptyAutowireAttributes = class_exists(Autowire::class) ? null : [];
foreach ($container->findTaggedServiceIds('controller.service_arguments', true) as $id => $tags) {
$def = $container->getDefinition($id);
$def->setPublic(true);
$def->setLazy(false);
$class = $def->getClass();
$autowire = $def->isAutowired();
$bindings = $def->getBindings();
@@ -71,9 +68,11 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
$class = $parameterBag->resolveValue($class);
if (!$r = $container->getReflectionClass($class)) {
throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
throw new InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
}
$controllerClasses[] = $class;
// get regular public methods
$methods = [];
$arguments = [];
@@ -94,11 +93,11 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
}
foreach (['action', 'argument', 'id'] as $k) {
if (!isset($attributes[$k][0])) {
throw new InvalidArgumentException(sprintf('Missing "%s" attribute on tag "controller.service_arguments" %s for service "%s".', $k, json_encode($attributes, \JSON_UNESCAPED_UNICODE), $id));
throw new InvalidArgumentException(\sprintf('Missing "%s" attribute on tag "controller.service_arguments" %s for service "%s".', $k, json_encode($attributes, \JSON_UNESCAPED_UNICODE), $id));
}
}
if (!isset($methods[$action = strtolower($attributes['action'])])) {
throw new InvalidArgumentException(sprintf('Invalid "action" attribute on tag "controller.service_arguments" for service "%s": no public "%s()" method found on class "%s".', $id, $attributes['action'], $class));
throw new InvalidArgumentException(\sprintf('Invalid "action" attribute on tag "controller.service_arguments" for service "%s": no public "%s()" method found on class "%s".', $id, $attributes['action'], $class));
}
[$r, $parameters] = $methods[$action];
$found = false;
@@ -114,7 +113,7 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
}
if (!$found) {
throw new InvalidArgumentException(sprintf('Invalid "controller.service_arguments" tag for service "%s": method "%s()" has no "%s" argument on class "%s".', $id, $r->name, $attributes['argument'], $class));
throw new InvalidArgumentException(\sprintf('Invalid "controller.service_arguments" tag for service "%s": method "%s()" has no "%s" argument on class "%s".', $id, $r->name, $attributes['argument'], $class));
}
}
@@ -123,11 +122,12 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
// create a per-method map of argument-names to service/type-references
$args = [];
$erroredIds = 0;
foreach ($parameters as $p) {
/** @var \ReflectionParameter $p */
$type = preg_replace('/(^|[(|&])\\\\/', '\1', $target = ltrim(ProxyHelper::exportType($p) ?? '', '?'));
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
$autowireAttributes = $autowire ? $emptyAutowireAttributes : [];
$autowireAttributes = null;
$parsedName = $p->name;
$k = null;
@@ -135,8 +135,8 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
$target = $arguments[$r->name][$p->name];
if ('?' !== $target[0]) {
$invalidBehavior = ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE;
} elseif ('' === $target = (string) substr($target, 1)) {
throw new InvalidArgumentException(sprintf('A "controller.service_arguments" tag must have non-empty "id" attributes for service "%s".', $id));
} elseif ('' === $target = substr($target, 1)) {
throw new InvalidArgumentException(\sprintf('A "controller.service_arguments" tag must have non-empty "id" attributes for service "%s".', $id));
} elseif ($p->allowsNull() && !$p->isOptional()) {
$invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
}
@@ -153,9 +153,9 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
$args[$p->name] = $bindingValue;
continue;
} elseif (!$autowire || (!($autowireAttributes ??= $p->getAttributes(Autowire::class, \ReflectionAttribute::IS_INSTANCEOF)) && (!$type || '\\' !== $target[0]))) {
} elseif (!$autowire || (!($autowireAttributes = $p->getAttributes(Autowire::class, \ReflectionAttribute::IS_INSTANCEOF)) && (!$type || '\\' !== $target[0]))) {
continue;
} elseif (is_subclass_of($type, \UnitEnum::class)) {
} elseif (!$autowireAttributes && is_subclass_of($type, \UnitEnum::class)) {
// do not attempt to register enum typed arguments if not already present in bindings
continue;
} elseif (!$p->allowsNull()) {
@@ -171,10 +171,8 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
$value = $parameterBag->resolveValue($attribute->value);
if ($attribute instanceof AutowireCallable) {
$value = $attribute->buildDefinition($value, $type, $p);
}
if ($value instanceof Reference) {
$args[$p->name] = $attribute->buildDefinition($value, $type, $p);
} elseif ($value instanceof Reference) {
$args[$p->name] = $type ? new TypedReference($value, $type, $invalidBehavior, $p->name) : new Reference($value, $invalidBehavior);
} else {
$args[$p->name] = new Reference('.value.'.$container->hash($value));
@@ -187,7 +185,7 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
}
if ($type && !$p->isOptional() && !$p->allowsNull() && !class_exists($type) && !interface_exists($type, false)) {
$message = sprintf('Cannot determine controller argument for "%s::%s()": the $%s argument is type-hinted with the non-existent class or interface: "%s".', $class, $r->name, $p->name, $type);
$message = \sprintf('Cannot determine controller argument for "%s::%s()": the $%s argument is type-hinted with the non-existent class or interface: "%s".', $class, $r->name, $p->name, $type);
// see if the type-hint lives in the same namespace as the controller
if (0 === strncmp($type, $class, strrpos($class, '\\'))) {
@@ -198,6 +196,7 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
->addError($message);
$args[$p->name] = new Reference($erroredId, ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE);
++$erroredIds;
} else {
$target = preg_replace('/(^|[(|&])\\\\/', '\1', $target);
$args[$p->name] = $type ? new TypedReference($target, $type, $invalidBehavior, Target::parseName($p)) : new Reference($target, $invalidBehavior);
@@ -205,7 +204,7 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
}
// register the maps as a per-method service-locators
if ($args) {
$controllers[$id.'::'.$r->name] = ServiceLocatorTagPass::register($container, $args);
$controllers[$id.'::'.$r->name] = ServiceLocatorTagPass::register($container, $args, \count($args) !== $erroredIds ? $id.'::'.$r->name.'()' : null);
foreach ($publicAliases[$id] ?? [] as $alias) {
$controllers[$alias.'::'.$r->name] = clone $controllers[$id.'::'.$r->name];
@@ -227,5 +226,10 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
}
$container->setAlias('argument_resolver.controller_locator', (string) $controllerLocatorRef);
if ($container->hasDefinition('controller_resolver')) {
$container->getDefinition('controller_resolver')
->addMethodCall('allowControllers', [array_unique($controllerClasses)]);
}
}
}

View File

@@ -23,10 +23,7 @@ use Symfony\Component\DependencyInjection\Reference;
*/
class RegisterLocaleAwareServicesPass implements CompilerPassInterface
{
/**
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition('locale_aware_listener')) {
return;

View File

@@ -21,10 +21,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
*/
class RemoveEmptyControllerArgumentLocatorsPass implements CompilerPassInterface
{
/**
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$controllerLocator = $container->findDefinition('argument_resolver.controller_locator');
$controllers = $controllerLocator->getArgument(0);
@@ -32,9 +29,13 @@ class RemoveEmptyControllerArgumentLocatorsPass implements CompilerPassInterface
foreach ($controllers as $controller => $argumentRef) {
$argumentLocator = $container->getDefinition((string) $argumentRef->getValues()[0]);
if ($argumentLocator->getFactory()) {
$argumentLocator = $container->getDefinition($argumentLocator->getFactory()[0]);
}
if (!$argumentLocator->getArgument(0)) {
// remove empty argument locators
$reason = sprintf('Removing service-argument resolver for controller "%s": no corresponding services exist for the referenced types.', $controller);
$reason = \sprintf('Removing service-argument resolver for controller "%s": no corresponding services exist for the referenced types.', $controller);
} else {
// any methods listed for call-at-instantiation cannot be actions
$reason = false;
@@ -47,7 +48,7 @@ class RemoveEmptyControllerArgumentLocatorsPass implements CompilerPassInterface
$controllerDef = $container->getDefinition($id);
foreach ($controllerDef->getMethodCalls() as [$method]) {
if (0 === strcasecmp($action, $method)) {
$reason = sprintf('Removing method "%s" of service "%s" from controller candidates: the method is called at instantiation, thus cannot be an action.', $action, $id);
$reason = \sprintf('Removing method "%s" of service "%s" from controller candidates: the method is called at instantiation, thus cannot be an action.', $action, $id);
break;
}
}

View File

@@ -23,10 +23,7 @@ use Symfony\Component\DependencyInjection\Reference;
*/
class ResettableServicePass implements CompilerPassInterface
{
/**
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->has('services_resetter')) {
return;
@@ -39,7 +36,7 @@ class ResettableServicePass implements CompilerPassInterface
foreach ($tags as $attributes) {
if (!isset($attributes['method'])) {
throw new RuntimeException(sprintf('Tag "kernel.reset" requires the "method" attribute to be set on service "%s".', $id));
throw new RuntimeException(\sprintf('Tag "kernel.reset" requires the "method" attribute to be set on service "%s".', $id));
}
if (!isset($methods[$id])) {

View File

@@ -13,7 +13,6 @@ namespace Symfony\Component\HttpKernel\DependencyInjection;
use ProxyManager\Proxy\LazyLoadingInterface;
use Symfony\Component\VarExporter\LazyObjectInterface;
use Symfony\Contracts\Service\ResetInterface;
/**
* Resets provided services.
@@ -21,21 +20,18 @@ use Symfony\Contracts\Service\ResetInterface;
* @author Alexander M. Turek <me@derrabus.de>
* @author Nicolas Grekas <p@tchwork.com>
*
* @internal
* @final since Symfony 7.2
*/
class ServicesResetter implements ResetInterface
class ServicesResetter implements ServicesResetterInterface
{
private \Traversable $resettableServices;
private array $resetMethods;
/**
* @param \Traversable<string, object> $resettableServices
* @param array<string, string|string[]> $resetMethods
*/
public function __construct(\Traversable $resettableServices, array $resetMethods)
{
$this->resettableServices = $resettableServices;
$this->resetMethods = $resetMethods;
public function __construct(
private \Traversable $resettableServices,
private array $resetMethods,
) {
}
public function reset(): void
@@ -49,6 +45,10 @@ class ServicesResetter implements ResetInterface
continue;
}
if (\PHP_VERSION_ID >= 80400 && (new \ReflectionClass($service))->isUninitializedLazyObject($service)) {
continue;
}
foreach ((array) $this->resetMethods[$id] as $resetMethod) {
if ('?' === $resetMethod[0] && !method_exists($service, $resetMethod = substr($resetMethod, 1))) {
continue;

View File

@@ -0,0 +1,21 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\DependencyInjection;
use Symfony\Contracts\Service\ResetInterface;
/**
* Resets provided services.
*/
interface ServicesResetterInterface extends ResetInterface
{
}