From 82ea297196ef46b223b71cb748395d0de19affd7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 23 May 2023 16:35:28 +0200 Subject: [PATCH 001/210] Bump version to 7.0 --- Kernel.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Kernel.php b/Kernel.php index c2d67c0f17..76205bc0b8 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,15 +76,15 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.4.0-DEV'; - public const VERSION_ID = 60400; - public const MAJOR_VERSION = 6; - public const MINOR_VERSION = 4; + public const VERSION = '7.0.0-DEV'; + public const VERSION_ID = 70000; + public const MAJOR_VERSION = 0; + public const MINOR_VERSION = 0; public const RELEASE_VERSION = 0; public const EXTRA_VERSION = 'DEV'; - public const END_OF_MAINTENANCE = '11/2026'; - public const END_OF_LIFE = '11/2027'; + public const END_OF_MAINTENANCE = '07/2024'; + public const END_OF_LIFE = '07/2024'; public function __construct(string $environment, bool $debug) { From 7410cffc188ff2ac2a11bc3b823973ddb92020a6 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 23 May 2023 17:24:39 +0200 Subject: [PATCH 002/210] [7.0] Bump to PHP 8.2 minimum --- DataCollector/RequestDataCollector.php | 2 +- Event/ControllerEvent.php | 2 +- composer.json | 70 +++++++++++++------------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index 094683ccce..91e17358a0 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -507,7 +507,7 @@ private function parseController(array|object|string|null $controller): array|st } $controller['method'] = $r->name; - if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) { + if ($class = $r->getClosureCalledClass()) { $controller['class'] = $class->name; } else { return $r->name; diff --git a/Event/ControllerEvent.php b/Event/ControllerEvent.php index d07d886db0..ed76864c2e 100644 --- a/Event/ControllerEvent.php +++ b/Event/ControllerEvent.php @@ -92,7 +92,7 @@ public function getAttributes(): array } elseif (\is_string($this->controller) && false !== $i = strpos($this->controller, '::')) { $class = new \ReflectionClass(substr($this->controller, 0, $i)); } else { - $class = str_contains($this->controllerReflector->name, '{closure}') ? null : (\PHP_VERSION_ID >= 80111 ? $this->controllerReflector->getClosureCalledClass() : $this->controllerReflector->getClosureScopeClass()); + $class = str_contains($this->controllerReflector->name, '{closure}') ? null : $this->controllerReflector->getClosureCalledClass(); } $this->attributes = []; diff --git a/composer.json b/composer.json index 2e91304613..fc5a94b1fb 100644 --- a/composer.json +++ b/composer.json @@ -16,35 +16,35 @@ } ], "require": { - "php": ">=8.1", + "php": ">=8.2", "symfony/deprecation-contracts": "^2.5|^3", - "symfony/error-handler": "^6.3|^7.0", - "symfony/event-dispatcher": "^5.4|^6.0|^7.0", - "symfony/http-foundation": "^6.2.7|^7.0", + "symfony/error-handler": "^6.4|^7.0", + "symfony/event-dispatcher": "^6.4|^7.0", + "symfony/http-foundation": "^6.4|^7.0", "symfony/polyfill-ctype": "^1.8", "psr/log": "^1|^2|^3" }, "require-dev": { - "symfony/browser-kit": "^5.4|^6.0|^7.0", - "symfony/clock": "^6.2|^7.0", - "symfony/config": "^6.1|^7.0", - "symfony/console": "^5.4|^6.0|^7.0", - "symfony/css-selector": "^5.4|^6.0|^7.0", - "symfony/dependency-injection": "^6.3|^7.0", - "symfony/dom-crawler": "^5.4|^6.0|^7.0", - "symfony/expression-language": "^5.4|^6.0|^7.0", - "symfony/finder": "^5.4|^6.0|^7.0", + "symfony/browser-kit": "^6.4|^7.0", + "symfony/clock": "^6.4|^7.0", + "symfony/config": "^6.4|^7.0", + "symfony/console": "^6.4|^7.0", + "symfony/css-selector": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/dom-crawler": "^6.4|^7.0", + "symfony/expression-language": "^6.4|^7.0", + "symfony/finder": "^6.4|^7.0", "symfony/http-client-contracts": "^2.5|^3", - "symfony/process": "^5.4|^6.0|^7.0", - "symfony/property-access": "^5.4.5|^6.0.5|^7.0", - "symfony/routing": "^5.4|^6.0|^7.0", - "symfony/serializer": "^6.3|^7.0", - "symfony/stopwatch": "^5.4|^6.0|^7.0", - "symfony/translation": "^5.4|^6.0|^7.0", + "symfony/process": "^6.4|^7.0", + "symfony/property-access": "^6.4|^7.0", + "symfony/routing": "^6.4|^7.0", + "symfony/serializer": "^6.4|^7.0", + "symfony/stopwatch": "^6.4|^7.0", + "symfony/translation": "^6.4|^7.0", "symfony/translation-contracts": "^2.5|^3", - "symfony/uid": "^5.4|^6.0|^7.0", - "symfony/validator": "^6.3|^7.0", - "symfony/var-exporter": "^6.2|^7.0", + "symfony/uid": "^6.4|^7.0", + "symfony/validator": "^6.4|^7.0", + "symfony/var-exporter": "^6.4|^7.0", "psr/cache": "^1.0|^2.0|^3.0", "twig/twig": "^2.13|^3.0.4" }, @@ -52,21 +52,21 @@ "psr/log-implementation": "1.0|2.0|3.0" }, "conflict": { - "symfony/browser-kit": "<5.4", - "symfony/cache": "<5.4", - "symfony/config": "<6.1", - "symfony/console": "<5.4", - "symfony/form": "<5.4", - "symfony/dependency-injection": "<6.3", - "symfony/doctrine-bridge": "<5.4", - "symfony/http-client": "<5.4", + "symfony/browser-kit": "<6.4", + "symfony/cache": "<6.4", + "symfony/config": "<6.4", + "symfony/console": "<6.4", + "symfony/form": "<6.4", + "symfony/dependency-injection": "<6.4", + "symfony/doctrine-bridge": "<6.4", + "symfony/http-client": "<6.4", "symfony/http-client-contracts": "<2.5", - "symfony/mailer": "<5.4", - "symfony/messenger": "<5.4", - "symfony/translation": "<5.4", + "symfony/mailer": "<6.4", + "symfony/messenger": "<6.4", + "symfony/translation": "<6.4", "symfony/translation-contracts": "<2.5", - "symfony/twig-bridge": "<5.4", - "symfony/validator": "<5.4", + "symfony/twig-bridge": "<6.4", + "symfony/validator": "<6.4", "twig/twig": "<2.13" }, "autoload": { From fd0a173dd2b51d18a9a7e7a874ab8280e3c995af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 14 Jun 2023 15:02:10 +0200 Subject: [PATCH 003/210] Make some classes final --- Controller/ArgumentResolver/BackedEnumValueResolver.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Controller/ArgumentResolver/BackedEnumValueResolver.php b/Controller/ArgumentResolver/BackedEnumValueResolver.php index 4f0ca76d30..95205dfd0a 100644 --- a/Controller/ArgumentResolver/BackedEnumValueResolver.php +++ b/Controller/ArgumentResolver/BackedEnumValueResolver.php @@ -22,10 +22,8 @@ * leading to a 404 Not Found if the attribute value isn't a valid backing value for the enum type. * * @author Maxime Steinhausser - * - * @final since Symfony 6.2 */ -class BackedEnumValueResolver implements ArgumentValueResolverInterface, ValueResolverInterface +final class BackedEnumValueResolver implements ArgumentValueResolverInterface, ValueResolverInterface { /** * @deprecated since Symfony 6.2, use resolve() instead From b4c7b1bd924040e8ff4b7e9f0ae0f858de5cae1f Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Tue, 6 Jun 2023 15:19:43 +0200 Subject: [PATCH 004/210] [DependencyInjection] Remove deprecations across the component --- Bundle/BundleInterface.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Bundle/BundleInterface.php b/Bundle/BundleInterface.php index fe200629f4..400a9e0c92 100644 --- a/Bundle/BundleInterface.php +++ b/Bundle/BundleInterface.php @@ -11,7 +11,6 @@ namespace Symfony\Component\HttpKernel\Bundle; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; @@ -21,7 +20,7 @@ * * @author Fabien Potencier */ -interface BundleInterface extends ContainerAwareInterface +interface BundleInterface { /** * Boots the Bundle. From d9a0912458f0dd1416e676f248ad8c96aff1ce61 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 30 Jun 2023 18:53:02 +0200 Subject: [PATCH 005/210] Remove BC layers related to new methods and new parameters --- CHANGELOG.md | 5 +++++ Controller/ArgumentResolverInterface.php | 4 +--- Controller/TraceableArgumentResolver.php | 6 +----- ControllerMetadata/ArgumentMetadataFactoryInterface.php | 4 +--- Tests/Controller/TraceableArgumentResolverTest.php | 2 +- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdb4e5a06b..2fa31e8350 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +7.0 +--- + + * Add argument `$reflector` to `ArgumentResolverInterface::getArguments()` and `ArgumentMetadataFactoryInterface::createArgumentMetadata()` + 6.4 --- diff --git a/Controller/ArgumentResolverInterface.php b/Controller/ArgumentResolverInterface.php index 33d3ce2985..a1f999fd49 100644 --- a/Controller/ArgumentResolverInterface.php +++ b/Controller/ArgumentResolverInterface.php @@ -24,9 +24,7 @@ interface ArgumentResolverInterface /** * Returns the arguments to pass to the controller. * - * @param \ReflectionFunctionAbstract|null $reflector - * * @throws \RuntimeException When no value could be provided for a required argument */ - public function getArguments(Request $request, callable $controller/* , \ReflectionFunctionAbstract $reflector = null */): array; + public function getArguments(Request $request, callable $controller, \ReflectionFunctionAbstract $reflector = null): array; } diff --git a/Controller/TraceableArgumentResolver.php b/Controller/TraceableArgumentResolver.php index 27cc8fb1ae..a71d8db5c9 100644 --- a/Controller/TraceableArgumentResolver.php +++ b/Controller/TraceableArgumentResolver.php @@ -28,12 +28,8 @@ public function __construct(ArgumentResolverInterface $resolver, Stopwatch $stop $this->stopwatch = $stopwatch; } - /** - * @param \ReflectionFunctionAbstract|null $reflector - */ - public function getArguments(Request $request, callable $controller/* , \ReflectionFunctionAbstract $reflector = null */): array + public function getArguments(Request $request, callable $controller, \ReflectionFunctionAbstract $reflector = null): array { - $reflector = 2 < \func_num_args() ? func_get_arg(2) : null; $e = $this->stopwatch->start('controller.get_arguments'); try { diff --git a/ControllerMetadata/ArgumentMetadataFactoryInterface.php b/ControllerMetadata/ArgumentMetadataFactoryInterface.php index 954f901ef2..f54c7e2ba8 100644 --- a/ControllerMetadata/ArgumentMetadataFactoryInterface.php +++ b/ControllerMetadata/ArgumentMetadataFactoryInterface.php @@ -19,9 +19,7 @@ interface ArgumentMetadataFactoryInterface { /** - * @param \ReflectionFunctionAbstract|null $reflector - * * @return ArgumentMetadata[] */ - public function createArgumentMetadata(string|object|array $controller/* , \ReflectionFunctionAbstract $reflector = null */): array; + public function createArgumentMetadata(string|object|array $controller, \ReflectionFunctionAbstract $reflector = null): array; } diff --git a/Tests/Controller/TraceableArgumentResolverTest.php b/Tests/Controller/TraceableArgumentResolverTest.php index 43bbb13e6b..71c9b799c0 100644 --- a/Tests/Controller/TraceableArgumentResolverTest.php +++ b/Tests/Controller/TraceableArgumentResolverTest.php @@ -29,7 +29,7 @@ public function testStopwatchEventIsStoppedWhenResolverThrows() $stopwatch->method('start')->willReturn($stopwatchEvent); $resolver = new class() implements ArgumentResolverInterface { - public function getArguments(Request $request, callable $controller): array + public function getArguments(Request $request, callable $controller, ?\ReflectionFunctionAbstract $reflector = null): array { throw new \Exception(); } From 08c086685907353c42bd79cd205d717abd3b2189 Mon Sep 17 00:00:00 2001 From: Frank Fiebig Date: Tue, 4 Jul 2023 11:21:50 +0200 Subject: [PATCH 006/210] [Lock] 7.0 remove deprecations in Lock Component --- CHANGELOG.md | 6 ++ Controller/ArgumentResolver.php | 12 +--- .../BackedEnumValueResolver.php | 25 +-------- .../DateTimeValueResolver.php | 13 +---- .../ArgumentResolver/DefaultValueResolver.php | 13 +---- .../NotTaggedControllerValueResolver.php | 37 ++---------- .../RequestAttributeValueResolver.php | 13 +---- .../ArgumentResolver/RequestValueResolver.php | 13 +---- .../ArgumentResolver/ServiceValueResolver.php | 29 +--------- .../ArgumentResolver/SessionValueResolver.php | 22 +------- .../TraceableValueResolver.php | 33 ++--------- .../ArgumentResolver/UidValueResolver.php | 16 +----- .../VariadicValueResolver.php | 13 +---- Controller/ArgumentValueResolverInterface.php | 35 ------------ DataCollector/ConfigDataCollector.php | 6 +- EventListener/StreamedResponseListener.php | 55 ------------------ HttpCache/AbstractSurrogate.php | 8 --- HttpCache/HttpCache.php | 10 +--- HttpKernelInterface.php | 6 -- Kernel.php | 20 +------ .../BackedEnumValueResolverTest.php | 9 +-- .../DateTimeValueResolverTest.php | 20 ------- .../NotTaggedControllerValueResolverTest.php | 30 ---------- .../ServiceValueResolverTest.php | 6 -- .../TraceableValueResolverTest.php | 25 +-------- .../ArgumentResolver/UidValueResolverTest.php | 12 +--- Tests/Controller/ArgumentResolverTest.php | 20 ------- Tests/HttpCache/HttpCacheTest.php | 56 +------------------ Tests/HttpKernelTest.php | 6 +- Tests/KernelTest.php | 44 --------------- composer.json | 1 - 31 files changed, 39 insertions(+), 575 deletions(-) delete mode 100644 Controller/ArgumentValueResolverInterface.php delete mode 100644 EventListener/StreamedResponseListener.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fa31e8350..3a15ecfd0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,16 @@ CHANGELOG --- * Add argument `$reflector` to `ArgumentResolverInterface::getArguments()` and `ArgumentMetadataFactoryInterface::createArgumentMetadata()` + * Remove `ArgumentValueResolverInterface`, use `ValueResolverInterface` instead + * Remove `StreamedResponseListener` + * Remove `AbstractSurrogate::$phpEscapeMap` + * Remove `HttpKernelInterface::MASTER_REQUEST` + * Remove `terminate_on_cache_hit` option from `HttpCache` 6.4 --- + * `BundleInterface` no longer extends `ContainerAwareInterface` * Add optional `$className` parameter to `ControllerEvent::getAttributes()` 6.3 diff --git a/Controller/ArgumentResolver.php b/Controller/ArgumentResolver.php index 3b0f89509f..58131225a6 100644 --- a/Controller/ArgumentResolver.php +++ b/Controller/ArgumentResolver.php @@ -18,7 +18,6 @@ use Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestAttributeValueResolver; use Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestValueResolver; use Symfony\Component\HttpKernel\Controller\ArgumentResolver\SessionValueResolver; -use Symfony\Component\HttpKernel\Controller\ArgumentResolver\TraceableValueResolver; use Symfony\Component\HttpKernel\Controller\ArgumentResolver\VariadicValueResolver; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadataFactory; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadataFactoryInterface; @@ -37,7 +36,7 @@ final class ArgumentResolver implements ArgumentResolverInterface private ?ContainerInterface $namedResolvers; /** - * @param iterable $argumentValueResolvers + * @param iterable $argumentValueResolvers */ public function __construct(ArgumentMetadataFactoryInterface $argumentMetadataFactory = null, iterable $argumentValueResolvers = [], ContainerInterface $namedResolvers = null) { @@ -79,9 +78,6 @@ public function getArguments(Request $request, callable $controller, \Reflection } foreach ($argumentValueResolvers as $name => $resolver) { - if ((!$resolver instanceof ValueResolverInterface || $resolver instanceof TraceableValueResolver) && !$resolver->supports($request, $metadata)) { - continue; - } if (isset($disabledResolvers[\is_int($name) ? $resolver::class : $name])) { continue; } @@ -100,10 +96,6 @@ public function getArguments(Request $request, callable $controller, \Reflection // continue to the next controller argument continue 2; } - - if (!$resolver instanceof ValueResolverInterface) { - throw new \InvalidArgumentException(sprintf('"%s::resolve()" must yield at least one value.', get_debug_type($resolver))); - } } throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or there is a non-optional argument after this one.', $this->getPrettyName($controller), $metadata->getName())); @@ -113,7 +105,7 @@ public function getArguments(Request $request, callable $controller, \Reflection } /** - * @return iterable + * @return iterable */ public static function getDefaultArgumentValueResolvers(): iterable { diff --git a/Controller/ArgumentResolver/BackedEnumValueResolver.php b/Controller/ArgumentResolver/BackedEnumValueResolver.php index 95205dfd0a..e5c9a91b95 100644 --- a/Controller/ArgumentResolver/BackedEnumValueResolver.php +++ b/Controller/ArgumentResolver/BackedEnumValueResolver.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\Controller\ArgumentResolver; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -23,30 +22,8 @@ * * @author Maxime Steinhausser */ -final class BackedEnumValueResolver implements ArgumentValueResolverInterface, ValueResolverInterface +final class BackedEnumValueResolver implements ValueResolverInterface { - /** - * @deprecated since Symfony 6.2, use resolve() instead - */ - public function supports(Request $request, ArgumentMetadata $argument): bool - { - @trigger_deprecation('symfony/http-kernel', '6.2', 'The "%s()" method is deprecated, use "resolve()" instead.', __METHOD__); - - if (!is_subclass_of($argument->getType(), \BackedEnum::class)) { - return false; - } - - if ($argument->isVariadic()) { - // only target route path parameters, which cannot be variadic. - return false; - } - - // do not support if no value can be resolved at all - // letting the \Symfony\Component\HttpKernel\Controller\ArgumentResolver\DefaultValueResolver be used - // or \Symfony\Component\HttpKernel\Controller\ArgumentResolver fail with a meaningful error. - return $request->attributes->has($argument->getName()); - } - public function resolve(Request $request, ArgumentMetadata $argument): iterable { if (!is_subclass_of($argument->getType(), \BackedEnum::class)) { diff --git a/Controller/ArgumentResolver/DateTimeValueResolver.php b/Controller/ArgumentResolver/DateTimeValueResolver.php index 0cfd42badc..981ebf60a7 100644 --- a/Controller/ArgumentResolver/DateTimeValueResolver.php +++ b/Controller/ArgumentResolver/DateTimeValueResolver.php @@ -14,7 +14,6 @@ use Psr\Clock\ClockInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Attribute\MapDateTime; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -25,23 +24,13 @@ * @author Benjamin Eberlei * @author Tim Goudriaan */ -final class DateTimeValueResolver implements ArgumentValueResolverInterface, ValueResolverInterface +final class DateTimeValueResolver implements ValueResolverInterface { public function __construct( private readonly ?ClockInterface $clock = null, ) { } - /** - * @deprecated since Symfony 6.2, use resolve() instead - */ - public function supports(Request $request, ArgumentMetadata $argument): bool - { - @trigger_deprecation('symfony/http-kernel', '6.2', 'The "%s()" method is deprecated, use "resolve()" instead.', __METHOD__); - - return is_a($argument->getType(), \DateTimeInterface::class, true) && $request->attributes->has($argument->getName()); - } - public function resolve(Request $request, ArgumentMetadata $argument): array { if (!is_a($argument->getType(), \DateTimeInterface::class, true) || !$request->attributes->has($argument->getName())) { diff --git a/Controller/ArgumentResolver/DefaultValueResolver.php b/Controller/ArgumentResolver/DefaultValueResolver.php index eb9769c09a..bf114f3f31 100644 --- a/Controller/ArgumentResolver/DefaultValueResolver.php +++ b/Controller/ArgumentResolver/DefaultValueResolver.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\Controller\ArgumentResolver; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; @@ -21,18 +20,8 @@ * * @author Iltar van der Berg */ -final class DefaultValueResolver implements ArgumentValueResolverInterface, ValueResolverInterface +final class DefaultValueResolver implements ValueResolverInterface { - /** - * @deprecated since Symfony 6.2, use resolve() instead - */ - public function supports(Request $request, ArgumentMetadata $argument): bool - { - @trigger_deprecation('symfony/http-kernel', '6.2', 'The "%s()" method is deprecated, use "resolve()" instead.', __METHOD__); - - return $argument->hasDefaultValue() || (null !== $argument->getType() && $argument->isNullable() && !$argument->isVariadic()); - } - public function resolve(Request $request, ArgumentMetadata $argument): array { if ($argument->hasDefaultValue()) { diff --git a/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php b/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php index 2640361288..547580e1f8 100644 --- a/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php +++ b/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php @@ -14,7 +14,6 @@ use Psr\Container\ContainerInterface; use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; @@ -23,39 +22,11 @@ * * @author Simeon Kolev */ -final class NotTaggedControllerValueResolver implements ArgumentValueResolverInterface, ValueResolverInterface +final class NotTaggedControllerValueResolver implements ValueResolverInterface { - private ContainerInterface $container; - - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - /** - * @deprecated since Symfony 6.2, use resolve() instead - */ - public function supports(Request $request, ArgumentMetadata $argument): bool - { - @trigger_deprecation('symfony/http-kernel', '6.2', 'The "%s()" method is deprecated, use "resolve()" instead.', __METHOD__); - - $controller = $request->attributes->get('_controller'); - - if (\is_array($controller) && \is_callable($controller, true) && \is_string($controller[0])) { - $controller = $controller[0].'::'.$controller[1]; - } elseif (!\is_string($controller) || '' === $controller) { - return false; - } - - if ('\\' === $controller[0]) { - $controller = ltrim($controller, '\\'); - } - - if (!$this->container->has($controller) && false !== $i = strrpos($controller, ':')) { - $controller = substr($controller, 0, $i).strtolower(substr($controller, $i)); - } - - return false === $this->container->has($controller); + public function __construct( + private ContainerInterface $container, + ) { } public function resolve(Request $request, ArgumentMetadata $argument): array diff --git a/Controller/ArgumentResolver/RequestAttributeValueResolver.php b/Controller/ArgumentResolver/RequestAttributeValueResolver.php index 370e414451..2a8d48ee30 100644 --- a/Controller/ArgumentResolver/RequestAttributeValueResolver.php +++ b/Controller/ArgumentResolver/RequestAttributeValueResolver.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\Controller\ArgumentResolver; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; @@ -21,18 +20,8 @@ * * @author Iltar van der Berg */ -final class RequestAttributeValueResolver implements ArgumentValueResolverInterface, ValueResolverInterface +final class RequestAttributeValueResolver implements ValueResolverInterface { - /** - * @deprecated since Symfony 6.2, use resolve() instead - */ - public function supports(Request $request, ArgumentMetadata $argument): bool - { - @trigger_deprecation('symfony/http-kernel', '6.2', 'The "%s()" method is deprecated, use "resolve()" instead.', __METHOD__); - - return !$argument->isVariadic() && $request->attributes->has($argument->getName()); - } - public function resolve(Request $request, ArgumentMetadata $argument): array { return !$argument->isVariadic() && $request->attributes->has($argument->getName()) ? [$request->attributes->get($argument->getName())] : []; diff --git a/Controller/ArgumentResolver/RequestValueResolver.php b/Controller/ArgumentResolver/RequestValueResolver.php index 6347f70196..bf2d2a0af6 100644 --- a/Controller/ArgumentResolver/RequestValueResolver.php +++ b/Controller/ArgumentResolver/RequestValueResolver.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\Controller\ArgumentResolver; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; @@ -21,18 +20,8 @@ * * @author Iltar van der Berg */ -final class RequestValueResolver implements ArgumentValueResolverInterface, ValueResolverInterface +final class RequestValueResolver implements ValueResolverInterface { - /** - * @deprecated since Symfony 6.2, use resolve() instead - */ - public function supports(Request $request, ArgumentMetadata $argument): bool - { - @trigger_deprecation('symfony/http-kernel', '6.2', 'The "%s()" method is deprecated, use "resolve()" instead.', __METHOD__); - - return Request::class === $argument->getType() || is_subclass_of($argument->getType(), Request::class); - } - public function resolve(Request $request, ArgumentMetadata $argument): array { return Request::class === $argument->getType() || is_subclass_of($argument->getType(), Request::class) ? [$request] : []; diff --git a/Controller/ArgumentResolver/ServiceValueResolver.php b/Controller/ArgumentResolver/ServiceValueResolver.php index 96e0337d6a..5953257ff5 100644 --- a/Controller/ArgumentResolver/ServiceValueResolver.php +++ b/Controller/ArgumentResolver/ServiceValueResolver.php @@ -14,7 +14,6 @@ use Psr\Container\ContainerInterface; use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; @@ -23,7 +22,7 @@ * * @author Nicolas Grekas */ -final class ServiceValueResolver implements ArgumentValueResolverInterface, ValueResolverInterface +final class ServiceValueResolver implements ValueResolverInterface { private ContainerInterface $container; @@ -32,32 +31,6 @@ public function __construct(ContainerInterface $container) $this->container = $container; } - /** - * @deprecated since Symfony 6.2, use resolve() instead - */ - public function supports(Request $request, ArgumentMetadata $argument): bool - { - @trigger_deprecation('symfony/http-kernel', '6.2', 'The "%s()" method is deprecated, use "resolve()" instead.', __METHOD__); - - $controller = $request->attributes->get('_controller'); - - if (\is_array($controller) && \is_callable($controller, true) && \is_string($controller[0])) { - $controller = $controller[0].'::'.$controller[1]; - } elseif (!\is_string($controller) || '' === $controller) { - return false; - } - - if ('\\' === $controller[0]) { - $controller = ltrim($controller, '\\'); - } - - if (!$this->container->has($controller) && false !== $i = strrpos($controller, ':')) { - $controller = substr($controller, 0, $i).strtolower(substr($controller, $i)); - } - - return $this->container->has($controller) && $this->container->get($controller)->has($argument->getName()); - } - public function resolve(Request $request, ArgumentMetadata $argument): array { $controller = $request->attributes->get('_controller'); diff --git a/Controller/ArgumentResolver/SessionValueResolver.php b/Controller/ArgumentResolver/SessionValueResolver.php index c8e7575d53..30b7f1d749 100644 --- a/Controller/ArgumentResolver/SessionValueResolver.php +++ b/Controller/ArgumentResolver/SessionValueResolver.php @@ -13,7 +13,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; @@ -22,27 +21,8 @@ * * @author Iltar van der Berg */ -final class SessionValueResolver implements ArgumentValueResolverInterface, ValueResolverInterface +final class SessionValueResolver implements ValueResolverInterface { - /** - * @deprecated since Symfony 6.2, use resolve() instead - */ - public function supports(Request $request, ArgumentMetadata $argument): bool - { - @trigger_deprecation('symfony/http-kernel', '6.2', 'The "%s()" method is deprecated, use "resolve()" instead.', __METHOD__); - - if (!$request->hasSession()) { - return false; - } - - $type = $argument->getType(); - if (SessionInterface::class !== $type && !is_subclass_of($type, SessionInterface::class)) { - return false; - } - - return $request->getSession() instanceof $type; - } - public function resolve(Request $request, ArgumentMetadata $argument): array { if (!$request->hasSession()) { diff --git a/Controller/ArgumentResolver/TraceableValueResolver.php b/Controller/ArgumentResolver/TraceableValueResolver.php index 0cb4703b29..41fd1d9ae9 100644 --- a/Controller/ArgumentResolver/TraceableValueResolver.php +++ b/Controller/ArgumentResolver/TraceableValueResolver.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\Controller\ArgumentResolver; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; use Symfony\Component\Stopwatch\Stopwatch; @@ -22,34 +21,12 @@ * * @author Iltar van der Berg */ -final class TraceableValueResolver implements ArgumentValueResolverInterface, ValueResolverInterface +final class TraceableValueResolver implements ValueResolverInterface { - private ArgumentValueResolverInterface|ValueResolverInterface $inner; - private Stopwatch $stopwatch; - - public function __construct(ArgumentValueResolverInterface|ValueResolverInterface $inner, Stopwatch $stopwatch) - { - $this->inner = $inner; - $this->stopwatch = $stopwatch; - } - - /** - * @deprecated since Symfony 6.2, use resolve() instead - */ - public function supports(Request $request, ArgumentMetadata $argument): bool - { - if ($this->inner instanceof ValueResolverInterface) { - return true; - } - - $method = $this->inner::class.'::'.__FUNCTION__; - $this->stopwatch->start($method, 'controller.argument_value_resolver'); - - $return = $this->inner->supports($request, $argument); - - $this->stopwatch->stop($method); - - return $return; + public function __construct( + private ValueResolverInterface $inner, + private Stopwatch $stopwatch, + ) { } public function resolve(Request $request, ArgumentMetadata $argument): iterable diff --git a/Controller/ArgumentResolver/UidValueResolver.php b/Controller/ArgumentResolver/UidValueResolver.php index 437b770a70..a6f06b5df4 100644 --- a/Controller/ArgumentResolver/UidValueResolver.php +++ b/Controller/ArgumentResolver/UidValueResolver.php @@ -12,27 +12,13 @@ namespace Symfony\Component\HttpKernel\Controller\ArgumentResolver; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Uid\AbstractUid; -final class UidValueResolver implements ArgumentValueResolverInterface, ValueResolverInterface +final class UidValueResolver implements ValueResolverInterface { - /** - * @deprecated since Symfony 6.2, use resolve() instead - */ - public function supports(Request $request, ArgumentMetadata $argument): bool - { - @trigger_deprecation('symfony/http-kernel', '6.2', 'The "%s()" method is deprecated, use "resolve()" instead.', __METHOD__); - - return !$argument->isVariadic() - && \is_string($request->attributes->get($argument->getName())) - && null !== $argument->getType() - && is_subclass_of($argument->getType(), AbstractUid::class, true); - } - public function resolve(Request $request, ArgumentMetadata $argument): array { if ($argument->isVariadic() diff --git a/Controller/ArgumentResolver/VariadicValueResolver.php b/Controller/ArgumentResolver/VariadicValueResolver.php index 4f6cba729e..1297cca42e 100644 --- a/Controller/ArgumentResolver/VariadicValueResolver.php +++ b/Controller/ArgumentResolver/VariadicValueResolver.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\Controller\ArgumentResolver; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; @@ -21,18 +20,8 @@ * * @author Iltar van der Berg */ -final class VariadicValueResolver implements ArgumentValueResolverInterface, ValueResolverInterface +final class VariadicValueResolver implements ValueResolverInterface { - /** - * @deprecated since Symfony 6.2, use resolve() instead - */ - public function supports(Request $request, ArgumentMetadata $argument): bool - { - @trigger_deprecation('symfony/http-kernel', '6.2', 'The "%s()" method is deprecated, use "resolve()" instead.', __METHOD__); - - return $argument->isVariadic() && $request->attributes->has($argument->getName()); - } - public function resolve(Request $request, ArgumentMetadata $argument): array { if (!$argument->isVariadic() || !$request->attributes->has($argument->getName())) { diff --git a/Controller/ArgumentValueResolverInterface.php b/Controller/ArgumentValueResolverInterface.php deleted file mode 100644 index 9c3b1a0162..0000000000 --- a/Controller/ArgumentValueResolverInterface.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Controller; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; - -/** - * Responsible for resolving the value of an argument based on its metadata. - * - * @author Iltar van der Berg - * - * @deprecated since Symfony 6.2, implement ValueResolverInterface instead - */ -interface ArgumentValueResolverInterface -{ - /** - * Whether this resolver can resolve the value for the given ArgumentMetadata. - */ - public function supports(Request $request, ArgumentMetadata $argument): bool; - - /** - * Returns the possible value(s). - */ - public function resolve(Request $request, ArgumentMetadata $argument): iterable; -} diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index d229ba3be3..012a45b5be 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -30,12 +30,8 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte /** * Sets the Kernel associated with this Request. */ - public function setKernel(KernelInterface $kernel = null): void + public function setKernel(KernelInterface $kernel): void { - if (1 > \func_num_args()) { - trigger_deprecation('symfony/http-kernel', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); - } - $this->kernel = $kernel; } diff --git a/EventListener/StreamedResponseListener.php b/EventListener/StreamedResponseListener.php deleted file mode 100644 index 312d5ee23b..0000000000 --- a/EventListener/StreamedResponseListener.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\StreamedResponse; -use Symfony\Component\HttpKernel\Event\ResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; - -trigger_deprecation('symfony/http-kernel', '6.1', 'The "%s" class is deprecated.', StreamedResponseListener::class); - -/** - * StreamedResponseListener is responsible for sending the Response - * to the client. - * - * @author Fabien Potencier - * - * @final - * - * @deprecated since Symfony 6.1 - */ -class StreamedResponseListener implements EventSubscriberInterface -{ - /** - * Filters the Response. - */ - public function onKernelResponse(ResponseEvent $event): void - { - if (!$event->isMainRequest()) { - return; - } - - $response = $event->getResponse(); - - if ($response instanceof StreamedResponse) { - $response->send(); - } - } - - public static function getSubscribedEvents(): array - { - return [ - KernelEvents::RESPONSE => ['onKernelResponse', -1024], - ]; - } -} diff --git a/HttpCache/AbstractSurrogate.php b/HttpCache/AbstractSurrogate.php index 95518bed2b..e3f4d9552d 100644 --- a/HttpCache/AbstractSurrogate.php +++ b/HttpCache/AbstractSurrogate.php @@ -25,14 +25,6 @@ abstract class AbstractSurrogate implements SurrogateInterface { protected $contentTypes; - /** - * @deprecated since Symfony 6.3 - */ - protected $phpEscapeMap = [ - ['', '', '', ''], - ]; - /** * @param array $contentTypes An array of content-type that should be parsed for Surrogate information * (default: text/html, text/xml, application/xhtml+xml, and application/xml) diff --git a/HttpCache/HttpCache.php b/HttpCache/HttpCache.php index eabacfec62..1698c3d21f 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -83,11 +83,6 @@ class HttpCache implements HttpKernelInterface, TerminableInterface * the cache can serve a stale response when an error is encountered (default: 60). * This setting is overridden by the stale-if-error HTTP Cache-Control extension * (see RFC 5861). - * - * * terminate_on_cache_hit Specifies if the kernel.terminate event should be dispatched even when the cache - * was hit (default: true). - * Unless your application needs to process events on cache hits, it is recommended - * to set this to false to avoid having to bootstrap the Symfony framework on a cache hit. */ public function __construct(HttpKernelInterface $kernel, StoreInterface $store, SurrogateInterface $surrogate = null, array $options = []) { @@ -109,7 +104,6 @@ public function __construct(HttpKernelInterface $kernel, StoreInterface $store, 'stale_if_error' => 60, 'trace_level' => 'none', 'trace_header' => 'X-Symfony-Cache', - 'terminate_on_cache_hit' => true, ], $options); if (!isset($options['trace_level'])) { @@ -250,9 +244,7 @@ public function terminate(Request $request, Response $response) // Do not call any listeners in case of a cache hit. // This ensures identical behavior as if you had a separate // reverse caching proxy such as Varnish and the like. - if ($this->options['terminate_on_cache_hit']) { - trigger_deprecation('symfony/http-kernel', '6.2', 'Setting "terminate_on_cache_hit" to "true" is deprecated and will be changed to "false" in Symfony 7.0.'); - } elseif (\in_array('fresh', $this->traces[$this->getTraceKey($request)] ?? [], true)) { + if (\in_array('fresh', $this->traces[$this->getTraceKey($request)] ?? [], true)) { return; } diff --git a/HttpKernelInterface.php b/HttpKernelInterface.php index f6c017a4c5..e9415677f7 100644 --- a/HttpKernelInterface.php +++ b/HttpKernelInterface.php @@ -24,12 +24,6 @@ interface HttpKernelInterface public const MAIN_REQUEST = 1; public const SUB_REQUEST = 2; - /** - * @deprecated since symfony/http-kernel 5.3, use MAIN_REQUEST instead. - * To ease the migration, this constant won't be removed until Symfony 7.0. - */ - public const MASTER_REQUEST = self::MAIN_REQUEST; - /** * Handles a Request to convert it to a Response. * diff --git a/Kernel.php b/Kernel.php index 76205bc0b8..563b663262 100644 --- a/Kernel.php +++ b/Kernel.php @@ -678,30 +678,14 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container } } - $inlineFactories = false; - if (isset($buildParameters['.container.dumper.inline_factories'])) { - $inlineFactories = $buildParameters['.container.dumper.inline_factories']; - } elseif ($container->hasParameter('container.dumper.inline_factories')) { - trigger_deprecation('symfony/http-kernel', '6.3', 'Parameter "%s" is deprecated, use ".%1$s" instead.', 'container.dumper.inline_factories'); - $inlineFactories = $container->getParameter('container.dumper.inline_factories'); - } - - $inlineClassLoader = $this->debug; - if (isset($buildParameters['.container.dumper.inline_class_loader'])) { - $inlineClassLoader = $buildParameters['.container.dumper.inline_class_loader']; - } elseif ($container->hasParameter('container.dumper.inline_class_loader')) { - trigger_deprecation('symfony/http-kernel', '6.3', 'Parameter "%s" is deprecated, use ".%1$s" instead.', 'container.dumper.inline_class_loader'); - $inlineClassLoader = $container->getParameter('container.dumper.inline_class_loader'); - } - $content = $dumper->dump([ 'class' => $class, 'base_class' => $baseClass, 'file' => $cache->getPath(), 'as_files' => true, 'debug' => $this->debug, - 'inline_factories' => $inlineFactories, - 'inline_class_loader' => $inlineClassLoader, + 'inline_factories' => $buildParameters['.container.dumper.inline_factories'] ?? false, + 'inline_class_loader' => $buildParameters['.container.dumper.inline_class_loader'] ?? $this->debug, 'build_time' => $container->hasParameter('kernel.container_build_time') ? $container->getParameter('kernel.container_build_time') : time(), 'preload_classes' => array_map('get_class', $this->bundles), ]); diff --git a/Tests/Controller/ArgumentResolver/BackedEnumValueResolverTest.php b/Tests/Controller/ArgumentResolver/BackedEnumValueResolverTest.php index 9e29862736..5c6b5d0657 100644 --- a/Tests/Controller/ArgumentResolver/BackedEnumValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/BackedEnumValueResolverTest.php @@ -21,20 +21,13 @@ class BackedEnumValueResolverTest extends TestCase { /** - * In Symfony 7, keep this test case but remove the call to supports(). - * - * @group legacy - * * @dataProvider provideTestSupportsData */ public function testSupports(Request $request, ArgumentMetadata $metadata, bool $expectedSupport) { $resolver = new BackedEnumValueResolver(); - if (!$expectedSupport) { - $this->assertSame([], $resolver->resolve($request, $metadata)); - } - self::assertSame($expectedSupport, $resolver->supports($request, $metadata)); + $this->assertCount((int) $expectedSupport, $resolver->resolve($request, $metadata)); } public static function provideTestSupportsData(): iterable diff --git a/Tests/Controller/ArgumentResolver/DateTimeValueResolverTest.php b/Tests/Controller/ArgumentResolver/DateTimeValueResolverTest.php index 6529ca9f76..636c811f98 100644 --- a/Tests/Controller/ArgumentResolver/DateTimeValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/DateTimeValueResolverTest.php @@ -50,26 +50,6 @@ public static function getClasses() yield [FooDateTime::class]; } - /** - * @group legacy - */ - public function testSupports() - { - $resolver = new DateTimeValueResolver(); - - $argument = new ArgumentMetadata('dummy', \DateTime::class, false, false, null); - $request = self::requestWithAttributes(['dummy' => 'now']); - $this->assertTrue($resolver->supports($request, $argument)); - - $argument = new ArgumentMetadata('dummy', FooDateTime::class, false, false, null); - $request = self::requestWithAttributes(['dummy' => 'now']); - $this->assertTrue($resolver->supports($request, $argument)); - - $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); - $request = self::requestWithAttributes(['dummy' => 'now']); - $this->assertFalse($resolver->supports($request, $argument)); - } - public function testUnsupportedArgument() { $resolver = new DateTimeValueResolver(); diff --git a/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php b/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php index e28f8d5130..3fc74a1d70 100644 --- a/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php @@ -20,23 +20,6 @@ class NotTaggedControllerValueResolverTest extends TestCase { - /** - * @group legacy - */ - public function testDoSupportWhenControllerDoNotExists() - { - $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); - $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); - $request = $this->requestWithAttributes(['_controller' => 'my_controller']); - - $this->assertTrue($resolver->supports($request, $argument)); - } - - /** - * In Symfony 7, keep this test case but remove the call to supports(). - * - * @group legacy - */ public function testDoNotSupportWhenControllerExists() { $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([ @@ -47,21 +30,14 @@ public function testDoNotSupportWhenControllerExists() $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); $request = $this->requestWithAttributes(['_controller' => 'App\\Controller\\Mine::method']); $this->assertSame([], $resolver->resolve($request, $argument)); - $this->assertFalse($resolver->supports($request, $argument)); } - /** - * In Symfony 7, keep this test case but remove the call to supports(). - * - * @group legacy - */ public function testDoNotSupportEmptyController() { $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); $request = $this->requestWithAttributes(['_controller' => '']); $this->assertSame([], $resolver->resolve($request, $argument)); - $this->assertFalse($resolver->supports($request, $argument)); } public function testController() @@ -104,11 +80,6 @@ public function testControllerNameIsAnArray() $resolver->resolve($request, $argument); } - /** - * In Symfony 7, keep this test case but remove the call to supports(). - * - * @group legacy - */ public function testInvokableController() { $this->expectException(RuntimeException::class); @@ -116,7 +87,6 @@ public function testInvokableController() $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); $request = $this->requestWithAttributes(['_controller' => 'App\Controller\Mine']); - $this->assertTrue($resolver->supports($request, $argument)); $resolver->resolve($request, $argument); } diff --git a/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php b/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php index 63a35b4124..df248047d0 100644 --- a/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php @@ -22,11 +22,6 @@ class ServiceValueResolverTest extends TestCase { - /** - * In Symfony 7, keep this test case but remove the call to supports(). - * - * @group legacy - */ public function testDoNotSupportWhenControllerDoNotExists() { $resolver = new ServiceValueResolver(new ServiceLocator([])); @@ -34,7 +29,6 @@ public function testDoNotSupportWhenControllerDoNotExists() $request = $this->requestWithAttributes(['_controller' => 'my_controller']); $this->assertSame([], $resolver->resolve($request, $argument)); - $this->assertFalse($resolver->supports($request, $argument)); } public function testExistingController() diff --git a/Tests/Controller/ArgumentResolver/TraceableValueResolverTest.php b/Tests/Controller/ArgumentResolver/TraceableValueResolverTest.php index bf5c42f8c2..5ede33ccb3 100644 --- a/Tests/Controller/ArgumentResolver/TraceableValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/TraceableValueResolverTest.php @@ -14,28 +14,12 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ArgumentResolver\TraceableValueResolver; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; +use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; use Symfony\Component\Stopwatch\Stopwatch; class TraceableValueResolverTest extends TestCase { - /** - * @group legacy - */ - public function testTimingsInSupports() - { - $stopwatch = new Stopwatch(); - $resolver = new TraceableValueResolver(new ResolverStub(), $stopwatch); - $argument = new ArgumentMetadata('dummy', 'string', false, false, null); - $request = new Request(); - - $this->assertTrue($resolver->supports($request, $argument)); - - $event = $stopwatch->getEvent(ResolverStub::class.'::supports'); - $this->assertCount(1, $event->getPeriods()); - } - public function testTimingsInResolve() { $stopwatch = new Stopwatch(); @@ -64,13 +48,8 @@ public function testTimingsInResolve() } } -class ResolverStub implements ArgumentValueResolverInterface +class ResolverStub implements ValueResolverInterface { - public function supports(Request $request, ArgumentMetadata $argument): bool - { - return true; - } - public function resolve(Request $request, ArgumentMetadata $argument): iterable { yield 'first'; diff --git a/Tests/Controller/ArgumentResolver/UidValueResolverTest.php b/Tests/Controller/ArgumentResolver/UidValueResolverTest.php index cc43417508..1da4d976a2 100644 --- a/Tests/Controller/ArgumentResolver/UidValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/UidValueResolverTest.php @@ -25,19 +25,11 @@ class UidValueResolverTest extends TestCase { /** - * In Symfony 7, keep this test case but remove the call to supports(). - * - * @group legacy - * * @dataProvider provideSupports */ public function testSupports(bool $expected, Request $request, ArgumentMetadata $argument) { - if (!$expected) { - $this->assertSame([], (new UidValueResolver())->resolve($request, $argument)); - } - - $this->assertSame($expected, (new UidValueResolver())->supports($request, $argument)); + $this->assertCount((int) $expected, (new UidValueResolver())->resolve($request, $argument)); } public static function provideSupports() @@ -50,10 +42,8 @@ public static function provideSupports() 'Argument type is not a class' => [false, new Request([], [], ['foo' => (string) $uuidV4]), new ArgumentMetadata('foo', 'string', false, false, null)], 'Argument type is not a subclass of AbstractUid' => [false, new Request([], [], ['foo' => (string) $uuidV4]), new ArgumentMetadata('foo', UlidFactory::class, false, false, null)], 'AbstractUid is not supported' => [false, new Request([], [], ['foo' => (string) $uuidV4]), new ArgumentMetadata('foo', AbstractUid::class, false, false, null)], - 'Custom abstract subclass is supported but will fail in resolve' => [true, new Request([], [], ['foo' => (string) $uuidV4]), new ArgumentMetadata('foo', TestAbstractCustomUid::class, false, false, null)], 'Known subclass' => [true, new Request([], [], ['foo' => (string) $uuidV4]), new ArgumentMetadata('foo', UuidV4::class, false, false, null)], 'Format does not matter' => [true, new Request([], [], ['foo' => (string) $uuidV4]), new ArgumentMetadata('foo', Ulid::class, false, false, null)], - 'Custom subclass' => [true, new Request([], [], ['foo' => '01FPND7BD15ZV07X5VGDXAJ8VD']), new ArgumentMetadata('foo', TestCustomUid::class, false, false, null)], ]; } diff --git a/Tests/Controller/ArgumentResolverTest.php b/Tests/Controller/ArgumentResolverTest.php index ef44f45bae..34c0028d15 100644 --- a/Tests/Controller/ArgumentResolverTest.php +++ b/Tests/Controller/ArgumentResolverTest.php @@ -21,7 +21,6 @@ use Symfony\Component\HttpKernel\Controller\ArgumentResolver; use Symfony\Component\HttpKernel\Controller\ArgumentResolver\DefaultValueResolver; use Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestAttributeValueResolver; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadataFactory; use Symfony\Component\HttpKernel\Exception\ResolverNotFoundException; use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\ExtendingRequest; @@ -176,25 +175,6 @@ public function testGetVariadicArgumentsWithoutArrayInRequest() self::getResolver()->getArguments($request, $controller); } - /** - * @group legacy - */ - public function testGetArgumentWithoutArray() - { - $this->expectException(\InvalidArgumentException::class); - $valueResolver = $this->createMock(ArgumentValueResolverInterface::class); - $resolver = self::getResolver([$valueResolver]); - - $valueResolver->expects($this->any())->method('supports')->willReturn(true); - $valueResolver->expects($this->any())->method('resolve')->willReturn([]); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $request->attributes->set('bar', 'foo'); - $controller = $this->controllerWithFooAndDefaultBar(...); - $resolver->getArguments($request, $controller); - } - public function testIfExceptionIsThrownWhenMissingAnArgument() { $this->expectException(\RuntimeException::class); diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index ae1ff9e2a5..b3e096d11e 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -37,7 +37,7 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() // does not implement TerminableInterface $kernel = new TestKernel(); - $httpCache = new HttpCache($kernel, $storeMock, null, ['terminate_on_cache_hit' => false]); + $httpCache = new HttpCache($kernel, $storeMock); $httpCache->terminate(Request::create('/'), new Response()); $this->assertFalse($kernel->terminateCalled, 'terminate() is never called if the kernel class does not implement TerminableInterface'); @@ -51,7 +51,7 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() $kernelMock->expects($this->once()) ->method('terminate'); - $kernel = new HttpCache($kernelMock, $storeMock, null, ['terminate_on_cache_hit' => false]); + $kernel = new HttpCache($kernelMock, $storeMock); $kernel->terminate(Request::create('/'), new Response()); } @@ -101,58 +101,6 @@ public function testDoesNotCallTerminateOnFreshResponse() $this->assertCount(1, $terminateEvents); } - /** - * @group legacy - */ - public function testDoesCallTerminateOnFreshResponseIfConfigured() - { - $this->expectDeprecation('Since symfony/http-kernel 6.2: Setting "terminate_on_cache_hit" to "true" is deprecated and will be changed to "false" in Symfony 7.0.'); - - $terminateEvents = []; - - $eventDispatcher = $this->createMock(EventDispatcher::class); - $eventDispatcher - ->expects($this->any()) - ->method('dispatch') - ->with($this->callback(function ($event) use (&$terminateEvents) { - if ($event instanceof TerminateEvent) { - $terminateEvents[] = $event; - } - - return true; - })); - - $this->setNextResponse( - 200, - [ - 'ETag' => '1234', - 'Cache-Control' => 'public, s-maxage=60', - ], - 'Hello World', - null, - $eventDispatcher - ); - $this->cacheConfig['terminate_on_cache_hit'] = true; - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->cache->terminate($this->request, $this->response); - - sleep(2); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('fresh'); - $this->assertEquals(2, $this->response->headers->get('Age')); - $this->cache->terminate($this->request, $this->response); - - $this->assertCount(2, $terminateEvents); - } - public function testPassesOnNonGetHeadRequests() { $this->setNextResponse(200); diff --git a/Tests/HttpKernelTest.php b/Tests/HttpKernelTest.php index a5a240a626..7fc0e49ef0 100644 --- a/Tests/HttpKernelTest.php +++ b/Tests/HttpKernelTest.php @@ -51,7 +51,7 @@ public function testRequestStackIsNotBrokenWhenControllerThrowsAnExceptionAndCat $kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new \RuntimeException(); }, $requestStack); try { - $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); + $kernel->handle(new Request(), HttpKernelInterface::MAIN_REQUEST, true); } catch (\Throwable $exception) { } @@ -64,7 +64,7 @@ public function testRequestStackIsNotBrokenWhenControllerThrowsAnExceptionAndCat $kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new \RuntimeException(); }, $requestStack); try { - $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, false); + $kernel->handle(new Request(), HttpKernelInterface::MAIN_REQUEST, false); } catch (\Throwable $exception) { } @@ -77,7 +77,7 @@ public function testRequestStackIsNotBrokenWhenControllerThrowsAnThrowable() $kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new \Error(); }, $requestStack); try { - $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); + $kernel->handle(new Request(), HttpKernelInterface::MAIN_REQUEST, true); } catch (\Throwable $exception) { } diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 7ec9fa3313..92cb6fcbbf 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -13,14 +13,11 @@ use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; -use Symfony\Component\Config\ConfigCache; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; -use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Request; @@ -39,8 +36,6 @@ class KernelTest extends TestCase { - use ExpectDeprecationTrait; - protected function tearDown(): void { try { @@ -628,45 +623,6 @@ public function getContainerClass(): string $this->assertMatchesRegularExpression('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*TestDebugContainer$/', $kernel->getContainerClass()); } - /** - * @group legacy - */ - public function testKernelWithParameterDeprecation() - { - $kernel = new class('test', true) extends Kernel { - public function __construct(string $env, bool $debug) - { - $this->container = new ContainerBuilder(new ParameterBag(['container.dumper.inline_factories' => true, 'container.dumper.inline_class_loader' => true])); - parent::__construct($env, $debug); - } - - public function registerBundles(): iterable - { - return []; - } - - public function registerContainerConfiguration(LoaderInterface $loader): void - { - } - - public function boot(): void - { - $this->container->compile(); - parent::dumpContainer(new ConfigCache(tempnam(sys_get_temp_dir(), 'symfony-kernel-deprecated-parameter'), true), $this->container, Container::class, $this->getContainerBaseClass()); - } - - public function getContainerClass(): string - { - return parent::getContainerClass(); - } - }; - - $this->expectDeprecation('Since symfony/http-kernel 6.3: Parameter "container.dumper.inline_factories" is deprecated, use ".container.dumper.inline_factories" instead.'); - $this->expectDeprecation('Since symfony/http-kernel 6.3: Parameter "container.dumper.inline_class_loader" is deprecated, use ".container.dumper.inline_class_loader" instead.'); - - $kernel->boot(); - } - /** * Returns a mock for the BundleInterface. */ diff --git a/composer.json b/composer.json index 2c8475f00b..ccebe6d793 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,6 @@ ], "require": { "php": ">=8.2", - "symfony/deprecation-contracts": "^2.5|^3", "symfony/error-handler": "^6.4|^7.0", "symfony/event-dispatcher": "^6.4|^7.0", "symfony/http-foundation": "^6.4|^7.0", From 973ec741b52dfbe381e006c59a28baf7fc3a9143 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 4 Jul 2023 14:50:59 +0200 Subject: [PATCH 007/210] [7.0] Remove remaining deprecated code paths --- CHANGELOG.md | 1 + Tests/HttpCache/HttpCacheTest.php | 3 --- Tests/KernelTest.php | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a15ecfd0d..0f4e3482d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ CHANGELOG * Remove `AbstractSurrogate::$phpEscapeMap` * Remove `HttpKernelInterface::MASTER_REQUEST` * Remove `terminate_on_cache_hit` option from `HttpCache` + * Require explicit argument when calling `ConfigDataCollector::setKernel()`, `RouterListener::setCurrentRequest()` 6.4 --- diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index b3e096d11e..9cb77b4cad 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\HttpKernel\Tests\HttpCache; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -27,8 +26,6 @@ */ class HttpCacheTest extends HttpCacheTestCase { - use ExpectDeprecationTrait; - public function testTerminateDelegatesTerminationOnlyForTerminableInterface() { $storeMock = $this->getMockBuilder(StoreInterface::class) diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 92cb6fcbbf..3417565755 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\Tests; use PHPUnit\Framework\TestCase; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; From 34cbd3eea1a6405789d5e92f26fbffafbdd40e8d Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sun, 2 Jul 2023 23:52:21 +0200 Subject: [PATCH 008/210] [Components] Convert to native return types --- Bundle/Bundle.php | 19 ++---- Bundle/BundleInterface.php | 5 +- CacheClearer/CacheClearerInterface.php | 4 +- CacheClearer/Psr6CacheClearer.php | 5 +- CacheWarmer/CacheWarmer.php | 5 +- CacheWarmer/CacheWarmerInterface.php | 4 +- CacheWarmer/WarmableInterface.php | 2 +- DataCollector/DataCollector.php | 7 +-- DataCollector/DataCollectorInterface.php | 8 +-- DataCollector/LateDataCollectorInterface.php | 4 +- DataCollector/RequestDataCollector.php | 60 ++++--------------- DataCollector/RouterDataCollector.php | 14 +---- Debug/FileLinkFormatter.php | 5 +- Debug/TraceableEventDispatcher.php | 10 +--- .../AddAnnotatedClassesToCachePass.php | 5 +- DependencyInjection/ConfigurableExtension.php | 4 +- .../ControllerArgumentValueResolverPass.php | 5 +- DependencyInjection/Extension.php | 4 +- DependencyInjection/FragmentRendererPass.php | 5 +- DependencyInjection/LoggerPass.php | 5 +- .../MergeExtensionConfigurationPass.php | 5 +- ...RegisterControllerArgumentLocatorsPass.php | 5 +- .../RegisterLocaleAwareServicesPass.php | 5 +- ...oveEmptyControllerArgumentLocatorsPass.php | 5 +- DependencyInjection/ResettableServicePass.php | 5 +- Event/RequestEvent.php | 4 +- EventListener/CacheAttributeListener.php | 8 +-- EventListener/DumpListener.php | 5 +- EventListener/ErrorListener.php | 15 +---- Exception/HttpException.php | 5 +- Fragment/FragmentHandler.php | 4 +- Fragment/InlineFragmentRenderer.php | 5 +- Fragment/RoutableFragmentRenderer.php | 4 +- HttpCache/AbstractSurrogate.php | 9 +-- HttpCache/Esi.php | 5 +- HttpCache/HttpCache.php | 18 ++---- HttpCache/ResponseCacheStrategy.php | 10 +--- HttpCache/ResponseCacheStrategyInterface.php | 8 +-- HttpCache/Ssi.php | 5 +- HttpCache/Store.php | 13 +--- HttpCache/StoreInterface.php | 8 +-- HttpCache/SurrogateInterface.php | 8 +-- HttpKernel.php | 5 +- HttpKernelBrowser.php | 17 ++---- Kernel.php | 45 ++++---------- KernelInterface.php | 12 +--- Log/DebugLoggerInterface.php | 10 +--- Profiler/FileProfilerStorage.php | 10 +--- Profiler/Profile.php | 50 ++++------------ Profiler/Profiler.php | 25 ++------ Profiler/ProfilerStorageInterface.php | 4 +- RebootableInterface.php | 4 +- TerminableInterface.php | 4 +- .../TraceableArgumentResolverTest.php | 2 +- 54 files changed, 118 insertions(+), 409 deletions(-) diff --git a/Bundle/Bundle.php b/Bundle/Bundle.php index af21469b1c..2a517d73c9 100644 --- a/Bundle/Bundle.php +++ b/Bundle/Bundle.php @@ -34,27 +34,19 @@ abstract class Bundle implements BundleInterface */ protected $container; - /** - * @return void - */ - public function boot() + public function boot(): void { } - /** - * @return void - */ - public function shutdown() + public function shutdown(): void { } /** * This method can be overridden to register compilation passes, * other extensions, ... - * - * @return void */ - public function build(ContainerBuilder $container) + public function build(ContainerBuilder $container): void { } @@ -121,10 +113,7 @@ final public function getName(): string return $this->name; } - /** - * @return void - */ - public function registerCommands(Application $application) + public function registerCommands(Application $application): void { } diff --git a/Bundle/BundleInterface.php b/Bundle/BundleInterface.php index 400a9e0c92..36502e8962 100644 --- a/Bundle/BundleInterface.php +++ b/Bundle/BundleInterface.php @@ -67,8 +67,5 @@ public function getNamespace(): string; */ public function getPath(): string; - /** - * @return void - */ - public function setContainer(?ContainerInterface $container); + public function setContainer(?ContainerInterface $container): void; } diff --git a/CacheClearer/CacheClearerInterface.php b/CacheClearer/CacheClearerInterface.php index 5ca4265624..f40ad9b562 100644 --- a/CacheClearer/CacheClearerInterface.php +++ b/CacheClearer/CacheClearerInterface.php @@ -20,8 +20,6 @@ interface CacheClearerInterface { /** * Clears any caches necessary. - * - * @return void */ - public function clear(string $cacheDir); + public function clear(string $cacheDir): void; } diff --git a/CacheClearer/Psr6CacheClearer.php b/CacheClearer/Psr6CacheClearer.php index 3c99b74af3..50bf4e0901 100644 --- a/CacheClearer/Psr6CacheClearer.php +++ b/CacheClearer/Psr6CacheClearer.php @@ -57,10 +57,7 @@ public function clearPool(string $name): bool return $this->pools[$name]->clear(); } - /** - * @return void - */ - public function clear(string $cacheDir) + public function clear(string $cacheDir): void { foreach ($this->pools as $pool) { $pool->clear(); diff --git a/CacheWarmer/CacheWarmer.php b/CacheWarmer/CacheWarmer.php index f940ba4a72..2707e460aa 100644 --- a/CacheWarmer/CacheWarmer.php +++ b/CacheWarmer/CacheWarmer.php @@ -18,10 +18,7 @@ */ abstract class CacheWarmer implements CacheWarmerInterface { - /** - * @return void - */ - protected function writeCacheFile(string $file, $content) + protected function writeCacheFile(string $file, $content): void { $tmpFile = @tempnam(\dirname($file), basename($file)); if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) { diff --git a/CacheWarmer/CacheWarmerInterface.php b/CacheWarmer/CacheWarmerInterface.php index 1f1740b7e2..d1c5101869 100644 --- a/CacheWarmer/CacheWarmerInterface.php +++ b/CacheWarmer/CacheWarmerInterface.php @@ -25,8 +25,6 @@ interface CacheWarmerInterface extends WarmableInterface * * A warmer should return true if the cache can be * generated incrementally and on-demand. - * - * @return bool */ - public function isOptional(); + public function isOptional(): bool; } diff --git a/CacheWarmer/WarmableInterface.php b/CacheWarmer/WarmableInterface.php index 2f442cb536..d98909cfae 100644 --- a/CacheWarmer/WarmableInterface.php +++ b/CacheWarmer/WarmableInterface.php @@ -23,5 +23,5 @@ interface WarmableInterface * * @return string[] A list of classes or files to preload on PHP 7.4+ */ - public function warmUp(string $cacheDir); + public function warmUp(string $cacheDir): array; } diff --git a/DataCollector/DataCollector.php b/DataCollector/DataCollector.php index 9a419c6791..aa14dfd220 100644 --- a/DataCollector/DataCollector.php +++ b/DataCollector/DataCollector.php @@ -58,7 +58,7 @@ protected function cloneVar(mixed $var): Data /** * @return callable[] The casters to add to the cloner */ - protected function getCasters() + protected function getCasters(): array { $casters = [ '*' => function ($v, array $a, Stub $s, $isNested) { @@ -82,10 +82,7 @@ public function __sleep(): array return ['data']; } - /** - * @return void - */ - public function __wakeup() + public function __wakeup(): void { } diff --git a/DataCollector/DataCollectorInterface.php b/DataCollector/DataCollectorInterface.php index 8df94ccb8f..1230b42c25 100644 --- a/DataCollector/DataCollectorInterface.php +++ b/DataCollector/DataCollectorInterface.php @@ -24,15 +24,11 @@ interface DataCollectorInterface extends ResetInterface { /** * Collects data for the given Request and Response. - * - * @return void */ - public function collect(Request $request, Response $response, \Throwable $exception = null); + public function collect(Request $request, Response $response, \Throwable $exception = null): void; /** * Returns the name of the collector. - * - * @return string */ - public function getName(); + public function getName(): string; } diff --git a/DataCollector/LateDataCollectorInterface.php b/DataCollector/LateDataCollectorInterface.php index efa1a4f737..d17cd7768d 100644 --- a/DataCollector/LateDataCollectorInterface.php +++ b/DataCollector/LateDataCollectorInterface.php @@ -20,8 +20,6 @@ interface LateDataCollectorInterface { /** * Collects data as late as possible. - * - * @return void */ - public function lateCollect(); + public function lateCollect(): void; } diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index 4431c6f5e1..03f0b2807f 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -195,74 +195,47 @@ public function getPathInfo(): string return $this->data['path_info']; } - /** - * @return ParameterBag - */ - public function getRequestRequest() + public function getRequestRequest(): ParameterBag { return new ParameterBag($this->data['request_request']->getValue()); } - /** - * @return ParameterBag - */ - public function getRequestQuery() + public function getRequestQuery(): ParameterBag { return new ParameterBag($this->data['request_query']->getValue()); } - /** - * @return ParameterBag - */ - public function getRequestFiles() + public function getRequestFiles(): ParameterBag { return new ParameterBag($this->data['request_files']->getValue()); } - /** - * @return ParameterBag - */ - public function getRequestHeaders() + public function getRequestHeaders(): ParameterBag { return new ParameterBag($this->data['request_headers']->getValue()); } - /** - * @return ParameterBag - */ - public function getRequestServer(bool $raw = false) + public function getRequestServer(bool $raw = false): ParameterBag { return new ParameterBag($this->data['request_server']->getValue($raw)); } - /** - * @return ParameterBag - */ - public function getRequestCookies(bool $raw = false) + public function getRequestCookies(bool $raw = false): ParameterBag { return new ParameterBag($this->data['request_cookies']->getValue($raw)); } - /** - * @return ParameterBag - */ - public function getRequestAttributes() + public function getRequestAttributes(): ParameterBag { return new ParameterBag($this->data['request_attributes']->getValue()); } - /** - * @return ParameterBag - */ - public function getResponseHeaders() + public function getResponseHeaders(): ParameterBag { return new ParameterBag($this->data['response_headers']->getValue()); } - /** - * @return ParameterBag - */ - public function getResponseCookies() + public function getResponseCookies(): ParameterBag { return new ParameterBag($this->data['response_cookies']->getValue()); } @@ -300,18 +273,12 @@ public function getContent() return $this->data['content']; } - /** - * @return bool - */ - public function isJsonRequest() + public function isJsonRequest(): bool { return 1 === preg_match('{^application/(?:\w+\++)*json$}i', $this->data['request_headers']['content-type']); } - /** - * @return string|null - */ - public function getPrettyJson() + public function getPrettyJson(): ?string { $decoded = json_decode($this->getContent()); @@ -343,10 +310,7 @@ public function getLocale(): string return $this->data['locale']; } - /** - * @return ParameterBag - */ - public function getDotenvVars() + public function getDotenvVars(): ParameterBag { return new ParameterBag($this->data['dotenv_vars']->getValue()); } diff --git a/DataCollector/RouterDataCollector.php b/DataCollector/RouterDataCollector.php index 444138da70..fc9ded2699 100644 --- a/DataCollector/RouterDataCollector.php +++ b/DataCollector/RouterDataCollector.php @@ -48,10 +48,7 @@ public function collect(Request $request, Response $response, \Throwable $except unset($this->controllers[$request]); } - /** - * @return void - */ - public function reset() + public function reset(): void { $this->controllers = new \SplObjectStorage(); @@ -62,20 +59,15 @@ public function reset() ]; } - /** - * @return string - */ - protected function guessRoute(Request $request, string|object|array $controller) + protected function guessRoute(Request $request, string|object|array $controller): string { return 'n/a'; } /** * Remembers the controller associated to each request. - * - * @return void */ - public function onKernelController(ControllerEvent $event) + public function onKernelController(ControllerEvent $event): void { $this->controllers[$event->getRequest()] = $event->getController(); } diff --git a/Debug/FileLinkFormatter.php b/Debug/FileLinkFormatter.php index fcb100859f..3a2400f45e 100644 --- a/Debug/FileLinkFormatter.php +++ b/Debug/FileLinkFormatter.php @@ -49,10 +49,7 @@ public function __construct(string|array $fileLinkFormat = null, RequestStack $r $this->urlFormat = $urlFormat; } - /** - * @return string|false - */ - public function format(string $file, int $line): string|bool + public function format(string $file, int $line): string|false { if ($fmt = $this->getFileLinkFormat()) { for ($i = 1; isset($fmt[$i]); ++$i) { diff --git a/Debug/TraceableEventDispatcher.php b/Debug/TraceableEventDispatcher.php index 4f6c34bc74..d31ce75816 100644 --- a/Debug/TraceableEventDispatcher.php +++ b/Debug/TraceableEventDispatcher.php @@ -23,10 +23,7 @@ */ class TraceableEventDispatcher extends BaseTraceableEventDispatcher { - /** - * @return void - */ - protected function beforeDispatch(string $eventName, object $event) + protected function beforeDispatch(string $eventName, object $event): void { switch ($eventName) { case KernelEvents::REQUEST: @@ -58,10 +55,7 @@ protected function beforeDispatch(string $eventName, object $event) } } - /** - * @return void - */ - protected function afterDispatch(string $eventName, object $event) + protected function afterDispatch(string $eventName, object $event): void { switch ($eventName) { case KernelEvents::CONTROLLER_ARGUMENTS: diff --git a/DependencyInjection/AddAnnotatedClassesToCachePass.php b/DependencyInjection/AddAnnotatedClassesToCachePass.php index 1924b1ddb0..9aacdc97a4 100644 --- a/DependencyInjection/AddAnnotatedClassesToCachePass.php +++ b/DependencyInjection/AddAnnotatedClassesToCachePass.php @@ -31,10 +31,7 @@ public function __construct(Kernel $kernel) $this->kernel = $kernel; } - /** - * @return void - */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { $annotatedClasses = []; foreach ($container->getExtensions() as $extension) { diff --git a/DependencyInjection/ConfigurableExtension.php b/DependencyInjection/ConfigurableExtension.php index 12d468cf04..714fdb7195 100644 --- a/DependencyInjection/ConfigurableExtension.php +++ b/DependencyInjection/ConfigurableExtension.php @@ -34,8 +34,6 @@ final public function load(array $configs, ContainerBuilder $container): void /** * 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; } diff --git a/DependencyInjection/ControllerArgumentValueResolverPass.php b/DependencyInjection/ControllerArgumentValueResolverPass.php index d3b157418e..d760e3bcc1 100644 --- a/DependencyInjection/ControllerArgumentValueResolverPass.php +++ b/DependencyInjection/ControllerArgumentValueResolverPass.php @@ -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; diff --git a/DependencyInjection/Extension.php b/DependencyInjection/Extension.php index d72efa1724..ea8ae3acb6 100644 --- a/DependencyInjection/Extension.php +++ b/DependencyInjection/Extension.php @@ -34,10 +34,8 @@ public function getAnnotatedClassesToCompile(): array * Adds annotated classes to the class cache. * * @param array $annotatedClasses An array of class patterns - * - * @return void */ - public function addAnnotatedClassesToCompile(array $annotatedClasses) + public function addAnnotatedClassesToCompile(array $annotatedClasses): void { $this->annotatedClasses = array_merge($this->annotatedClasses, $annotatedClasses); } diff --git a/DependencyInjection/FragmentRendererPass.php b/DependencyInjection/FragmentRendererPass.php index f41d58b81b..1d49c2453d 100644 --- a/DependencyInjection/FragmentRendererPass.php +++ b/DependencyInjection/FragmentRendererPass.php @@ -25,10 +25,7 @@ */ class FragmentRendererPass implements CompilerPassInterface { - /** - * @return void - */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { if (!$container->hasDefinition('fragment.handler')) { return; diff --git a/DependencyInjection/LoggerPass.php b/DependencyInjection/LoggerPass.php index 2b6cb00793..9d43714545 100644 --- a/DependencyInjection/LoggerPass.php +++ b/DependencyInjection/LoggerPass.php @@ -25,10 +25,7 @@ */ class LoggerPass implements CompilerPassInterface { - /** - * @return void - */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { $container->setAlias(LoggerInterface::class, 'logger') ->setPublic(false); diff --git a/DependencyInjection/MergeExtensionConfigurationPass.php b/DependencyInjection/MergeExtensionConfigurationPass.php index cec23e1970..d65dbbab03 100644 --- a/DependencyInjection/MergeExtensionConfigurationPass.php +++ b/DependencyInjection/MergeExtensionConfigurationPass.php @@ -31,10 +31,7 @@ public function __construct(array $extensions) $this->extensions = $extensions; } - /** - * @return void - */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { foreach ($this->extensions as $extension) { if (!\count($container->getExtensionConfig($extension))) { diff --git a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index d0e05340d8..dba9bd1293 100644 --- a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -33,10 +33,7 @@ */ 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; diff --git a/DependencyInjection/RegisterLocaleAwareServicesPass.php b/DependencyInjection/RegisterLocaleAwareServicesPass.php index 2a01365bd3..3c7d5ac3c9 100644 --- a/DependencyInjection/RegisterLocaleAwareServicesPass.php +++ b/DependencyInjection/RegisterLocaleAwareServicesPass.php @@ -23,10 +23,7 @@ */ class RegisterLocaleAwareServicesPass implements CompilerPassInterface { - /** - * @return void - */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { if (!$container->hasDefinition('locale_aware_listener')) { return; diff --git a/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php b/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php index 7a21fe0e59..f9b16befbd 100644 --- a/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php @@ -21,10 +21,7 @@ */ 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); diff --git a/DependencyInjection/ResettableServicePass.php b/DependencyInjection/ResettableServicePass.php index da9f8d6320..7a09418a63 100644 --- a/DependencyInjection/ResettableServicePass.php +++ b/DependencyInjection/ResettableServicePass.php @@ -23,10 +23,7 @@ */ class ResettableServicePass implements CompilerPassInterface { - /** - * @return void - */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { if (!$container->has('services_resetter')) { return; diff --git a/Event/RequestEvent.php b/Event/RequestEvent.php index b81a79b780..8b5c084b00 100644 --- a/Event/RequestEvent.php +++ b/Event/RequestEvent.php @@ -36,10 +36,8 @@ public function getResponse(): ?Response /** * Sets a response and stops event propagation. - * - * @return void */ - public function setResponse(Response $response) + public function setResponse(Response $response): void { $this->response = $response; diff --git a/EventListener/CacheAttributeListener.php b/EventListener/CacheAttributeListener.php index 723e758cd0..f428ea9462 100644 --- a/EventListener/CacheAttributeListener.php +++ b/EventListener/CacheAttributeListener.php @@ -46,10 +46,8 @@ public function __construct( /** * Handles HTTP validation headers. - * - * @return void */ - public function onKernelControllerArguments(ControllerArgumentsEvent $event) + public function onKernelControllerArguments(ControllerArgumentsEvent $event): void { $request = $event->getRequest(); @@ -92,10 +90,8 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event) /** * Modifies the response to apply HTTP cache headers when needed. - * - * @return void */ - public function onKernelResponse(ResponseEvent $event) + public function onKernelResponse(ResponseEvent $event): void { $request = $event->getRequest(); diff --git a/EventListener/DumpListener.php b/EventListener/DumpListener.php index b10bd37f43..72fc5ca6b4 100644 --- a/EventListener/DumpListener.php +++ b/EventListener/DumpListener.php @@ -36,10 +36,7 @@ public function __construct(ClonerInterface $cloner, DataDumperInterface $dumper $this->connection = $connection; } - /** - * @return void - */ - public function configure() + public function configure(): void { $cloner = $this->cloner; $dumper = $this->dumper; diff --git a/EventListener/ErrorListener.php b/EventListener/ErrorListener.php index cc6936cfda..62e63743bd 100644 --- a/EventListener/ErrorListener.php +++ b/EventListener/ErrorListener.php @@ -51,10 +51,7 @@ public function __construct(string|object|array|null $controller, LoggerInterfac $this->exceptionsMapping = $exceptionsMapping; } - /** - * @return void - */ - public function logKernelException(ExceptionEvent $event) + public function logKernelException(ExceptionEvent $event): void { $throwable = $event->getThrowable(); $logLevel = $this->resolveLogLevel($throwable); @@ -92,10 +89,7 @@ public function logKernelException(ExceptionEvent $event) $this->logException($throwable, sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), $e->getFile(), $e->getLine()), $logLevel); } - /** - * @return void - */ - public function onKernelException(ExceptionEvent $event) + public function onKernelException(ExceptionEvent $event): void { if (null === $this->controller) { return; @@ -138,10 +132,7 @@ public function removeCspHeader(ResponseEvent $event): void } } - /** - * @return void - */ - public function onControllerArguments(ControllerArgumentsEvent $event) + public function onControllerArguments(ControllerArgumentsEvent $event): void { $e = $event->getRequest()->attributes->get('exception'); diff --git a/Exception/HttpException.php b/Exception/HttpException.php index e12abce004..f95f77bcaf 100644 --- a/Exception/HttpException.php +++ b/Exception/HttpException.php @@ -39,10 +39,7 @@ public function getHeaders(): array return $this->headers; } - /** - * @return void - */ - public function setHeaders(array $headers) + public function setHeaders(array $headers): void { $this->headers = $headers; } diff --git a/Fragment/FragmentHandler.php b/Fragment/FragmentHandler.php index 62b21e6d4e..77e33f48f3 100644 --- a/Fragment/FragmentHandler.php +++ b/Fragment/FragmentHandler.php @@ -48,10 +48,8 @@ public function __construct(RequestStack $requestStack, array $renderers = [], b /** * Adds a renderer. - * - * @return void */ - public function addRenderer(FragmentRendererInterface $renderer) + public function addRenderer(FragmentRendererInterface $renderer): void { $this->renderers[$renderer->getName()] = $renderer; } diff --git a/Fragment/InlineFragmentRenderer.php b/Fragment/InlineFragmentRenderer.php index d563182f96..c74200af6d 100644 --- a/Fragment/InlineFragmentRenderer.php +++ b/Fragment/InlineFragmentRenderer.php @@ -103,10 +103,7 @@ public function render(string|ControllerReference $uri, Request $request, array } } - /** - * @return Request - */ - protected function createSubRequest(string $uri, Request $request) + protected function createSubRequest(string $uri, Request $request): Request { $cookies = $request->cookies->all(); $server = $request->server->all(); diff --git a/Fragment/RoutableFragmentRenderer.php b/Fragment/RoutableFragmentRenderer.php index 47027233a7..14ff9a92b5 100644 --- a/Fragment/RoutableFragmentRenderer.php +++ b/Fragment/RoutableFragmentRenderer.php @@ -31,10 +31,8 @@ abstract class RoutableFragmentRenderer implements FragmentRendererInterface * Sets the fragment path that triggers the fragment listener. * * @see FragmentListener - * - * @return void */ - public function setFragmentPath(string $path) + public function setFragmentPath(string $path): void { $this->fragmentPath = $path; } diff --git a/HttpCache/AbstractSurrogate.php b/HttpCache/AbstractSurrogate.php index e3f4d9552d..a2b298f77b 100644 --- a/HttpCache/AbstractSurrogate.php +++ b/HttpCache/AbstractSurrogate.php @@ -51,10 +51,7 @@ public function hasSurrogateCapability(Request $request): bool return str_contains($value, sprintf('%s/1.0', strtoupper($this->getName()))); } - /** - * @return void - */ - public function addSurrogateCapability(Request $request) + public function addSurrogateCapability(Request $request): void { $current = $request->headers->get('Surrogate-Capability'); $new = sprintf('symfony="%s/1.0"', strtoupper($this->getName())); @@ -100,10 +97,8 @@ public function handle(HttpCache $cache, string $uri, string $alt, bool $ignoreE /** * Remove the Surrogate from the Surrogate-Control header. - * - * @return void */ - protected function removeFromControl(Response $response) + protected function removeFromControl(Response $response): void { if (!$response->headers->has('Surrogate-Control')) { return; diff --git a/HttpCache/Esi.php b/HttpCache/Esi.php index 5db840a802..1fe20cbf37 100644 --- a/HttpCache/Esi.php +++ b/HttpCache/Esi.php @@ -32,10 +32,7 @@ public function getName(): string return 'esi'; } - /** - * @return void - */ - public function addSurrogateControl(Response $response) + public function addSurrogateControl(Response $response): void { if (str_contains($response->getContent(), 'headers->set('Surrogate-Control', 'content="ESI/1.0"'); diff --git a/HttpCache/HttpCache.php b/HttpCache/HttpCache.php index 1698c3d21f..a560661afb 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -236,10 +236,7 @@ public function handle(Request $request, int $type = HttpKernelInterface::MAIN_R return $response; } - /** - * @return void - */ - public function terminate(Request $request, Response $response) + public function terminate(Request $request, Response $response): void { // Do not call any listeners in case of a cache hit. // This ensures identical behavior as if you had a separate @@ -454,10 +451,8 @@ protected function fetch(Request $request, bool $catch = false): Response * * @param bool $catch Whether to catch exceptions or not * @param Response|null $entry A Response instance (the stale entry if present, null otherwise) - * - * @return Response */ - protected function forward(Request $request, bool $catch = false, Response $entry = null) + protected function forward(Request $request, bool $catch = false, Response $entry = null): Response { $this->surrogate?->addSurrogateCapability($request); @@ -587,11 +582,9 @@ protected function lock(Request $request, Response $entry): bool /** * Writes the Response to the cache. * - * @return void - * * @throws \Exception */ - protected function store(Request $request, Response $response) + protected function store(Request $request, Response $response): void { try { $restoreHeaders = []; @@ -666,10 +659,7 @@ private function restoreResponseBody(Request $request, Response $response): void $response->headers->remove('X-Body-File'); } - /** - * @return void - */ - protected function processResponseBody(Request $request, Response $response) + protected function processResponseBody(Request $request, Response $response): void { if ($this->surrogate?->needsParsing($response)) { $this->surrogate->process($request, $response); diff --git a/HttpCache/ResponseCacheStrategy.php b/HttpCache/ResponseCacheStrategy.php index 57b5d21961..52c34fbdc8 100644 --- a/HttpCache/ResponseCacheStrategy.php +++ b/HttpCache/ResponseCacheStrategy.php @@ -54,10 +54,7 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface 'expires' => null, ]; - /** - * @return void - */ - public function add(Response $response) + public function add(Response $response): void { ++$this->embeddedResponses; @@ -98,10 +95,7 @@ public function add(Response $response) } } - /** - * @return void - */ - public function update(Response $response) + public function update(Response $response): void { // if we have no embedded Response, do nothing if (0 === $this->embeddedResponses) { diff --git a/HttpCache/ResponseCacheStrategyInterface.php b/HttpCache/ResponseCacheStrategyInterface.php index 33c8bd9412..6143a13c83 100644 --- a/HttpCache/ResponseCacheStrategyInterface.php +++ b/HttpCache/ResponseCacheStrategyInterface.php @@ -27,15 +27,11 @@ interface ResponseCacheStrategyInterface { /** * Adds a Response. - * - * @return void */ - public function add(Response $response); + public function add(Response $response): void; /** * Updates the Response HTTP headers based on the embedded Responses. - * - * @return void */ - public function update(Response $response); + public function update(Response $response): void; } diff --git a/HttpCache/Ssi.php b/HttpCache/Ssi.php index b17c90ac60..f436fed749 100644 --- a/HttpCache/Ssi.php +++ b/HttpCache/Ssi.php @@ -26,10 +26,7 @@ public function getName(): string return 'ssi'; } - /** - * @return void - */ - public function addSurrogateControl(Response $response) + public function addSurrogateControl(Response $response): void { if (str_contains($response->getContent(), '', $uri); + return \sprintf('', $uri); } public function process(Request $request, Response $response): Response diff --git a/HttpCache/Store.php b/HttpCache/Store.php index a4a709aeff..9c790f6d82 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -44,7 +44,7 @@ public function __construct( private array $options = [], ) { if (!is_dir($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) { - throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root)); + throw new \RuntimeException(\sprintf('Unable to create the store directory (%s).', $this->root)); } $this->keyCache = new \SplObjectStorage(); $this->options['private_headers'] ??= ['Set-Cookie']; diff --git a/HttpCache/SubRequestHandler.php b/HttpCache/SubRequestHandler.php index 253071f07d..4caf3daf2e 100644 --- a/HttpCache/SubRequestHandler.php +++ b/HttpCache/SubRequestHandler.php @@ -51,16 +51,16 @@ public static function handle(HttpKernelInterface $kernel, Request $request, int $trustedValues = []; foreach (array_reverse($request->getClientIps()) as $ip) { $trustedIps[] = $ip; - $trustedValues[] = sprintf('for="%s"', $ip); + $trustedValues[] = \sprintf('for="%s"', $ip); } if ($ip !== $remoteAddr) { $trustedIps[] = $remoteAddr; - $trustedValues[] = sprintf('for="%s"', $remoteAddr); + $trustedValues[] = \sprintf('for="%s"', $remoteAddr); } // set trusted values, reusing as much as possible the global trusted settings if (Request::HEADER_FORWARDED & $trustedHeaderSet) { - $trustedValues[0] .= sprintf(';host="%s";proto=%s', $request->getHttpHost(), $request->getScheme()); + $trustedValues[0] .= \sprintf(';host="%s";proto=%s', $request->getHttpHost(), $request->getScheme()); $request->headers->set('Forwarded', $v = implode(', ', $trustedValues)); $request->server->set('HTTP_FORWARDED', $v); } diff --git a/HttpClientKernel.php b/HttpClientKernel.php index 7c719e8e61..ebda2750da 100644 --- a/HttpClientKernel.php +++ b/HttpClientKernel.php @@ -36,7 +36,7 @@ final class HttpClientKernel implements HttpKernelInterface public function __construct(?HttpClientInterface $client = null) { if (null === $client && !class_exists(HttpClient::class)) { - throw new \LogicException(sprintf('You cannot use "%s" as the HttpClient component is not installed. Try running "composer require symfony/http-client".', __CLASS__)); + throw new \LogicException(\sprintf('You cannot use "%s" as the HttpClient component is not installed. Try running "composer require symfony/http-client".', __CLASS__)); } $this->client = $client ?? HttpClient::create(); diff --git a/HttpKernel.php b/HttpKernel.php index c3715f03f2..91764366cd 100644 --- a/HttpKernel.php +++ b/HttpKernel.php @@ -164,7 +164,7 @@ private function handleRaw(Request $request, int $type = self::MAIN_REQUEST): Re // load controller if (false === $controller = $this->resolver->getController($request)) { - throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". The route is wrongly configured.', $request->getPathInfo())); + throw new NotFoundHttpException(\sprintf('Unable to find the controller for path "%s". The route is wrongly configured.', $request->getPathInfo())); } $event = new ControllerEvent($this, $controller, $request, $type); @@ -190,7 +190,7 @@ private function handleRaw(Request $request, int $type = self::MAIN_REQUEST): Re if ($event->hasResponse()) { $response = $event->getResponse(); } else { - $msg = sprintf('The controller must return a "Symfony\Component\HttpFoundation\Response" object but it returned %s.', $this->varToString($response)); + $msg = \sprintf('The controller must return a "Symfony\Component\HttpFoundation\Response" object but it returned %s.', $this->varToString($response)); // the user may have forgotten to return something if (null === $response) { @@ -280,20 +280,20 @@ private function handleThrowable(\Throwable $e, Request $request, int $type): Re private function varToString(mixed $var): string { if (\is_object($var)) { - return sprintf('an object of type %s', $var::class); + return \sprintf('an object of type %s', $var::class); } if (\is_array($var)) { $a = []; foreach ($var as $k => $v) { - $a[] = sprintf('%s => ...', $k); + $a[] = \sprintf('%s => ...', $k); } - return sprintf('an array ([%s])', mb_substr(implode(', ', $a), 0, 255)); + return \sprintf('an array ([%s])', mb_substr(implode(', ', $a), 0, 255)); } if (\is_resource($var)) { - return sprintf('a resource (%s)', get_resource_type($var)); + return \sprintf('a resource (%s)', get_resource_type($var)); } if (null === $var) { @@ -309,11 +309,11 @@ private function varToString(mixed $var): string } if (\is_string($var)) { - return sprintf('a string ("%s%s")', mb_substr($var, 0, 255), mb_strlen($var) > 255 ? '...' : ''); + return \sprintf('a string ("%s%s")', mb_substr($var, 0, 255), mb_strlen($var) > 255 ? '...' : ''); } if (is_numeric($var)) { - return sprintf('a number (%s)', (string) $var); + return \sprintf('a number (%s)', (string) $var); } return (string) $var; diff --git a/Kernel.php b/Kernel.php index 985c5e9f6f..819e9f63ee 100644 --- a/Kernel.php +++ b/Kernel.php @@ -88,7 +88,7 @@ public function __construct( protected bool $debug, ) { if (!$environment) { - throw new \InvalidArgumentException(sprintf('Invalid environment provided to "%s": the environment cannot be empty.', get_debug_type($this))); + throw new \InvalidArgumentException(\sprintf('Invalid environment provided to "%s": the environment cannot be empty.', get_debug_type($this))); } } @@ -201,7 +201,7 @@ public function getBundles(): array public function getBundle(string $name): BundleInterface { if (!isset($this->bundles[$name])) { - throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the "registerBundles()" method of your "%s.php" file?', $name, get_debug_type($this))); + throw new \InvalidArgumentException(\sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the "registerBundles()" method of your "%s.php" file?', $name, get_debug_type($this))); } return $this->bundles[$name]; @@ -210,11 +210,11 @@ public function getBundle(string $name): BundleInterface public function locateResource(string $name): string { if ('@' !== $name[0]) { - throw new \InvalidArgumentException(sprintf('A resource name must start with @ ("%s" given).', $name)); + throw new \InvalidArgumentException(\sprintf('A resource name must start with @ ("%s" given).', $name)); } if (str_contains($name, '..')) { - throw new \RuntimeException(sprintf('File name "%s" contains invalid characters (..).', $name)); + throw new \RuntimeException(\sprintf('File name "%s" contains invalid characters (..).', $name)); } $bundleName = substr($name, 1); @@ -228,7 +228,7 @@ public function locateResource(string $name): string return $file; } - throw new \InvalidArgumentException(sprintf('Unable to find file "%s".', $name)); + throw new \InvalidArgumentException(\sprintf('Unable to find file "%s".', $name)); } public function getEnvironment(): string @@ -250,7 +250,7 @@ public function getProjectDir(): string $r = new \ReflectionObject($this); if (!is_file($dir = $r->getFileName())) { - throw new \LogicException(sprintf('Cannot auto-detect project dir for kernel of class "%s".', $r->name)); + throw new \LogicException(\sprintf('Cannot auto-detect project dir for kernel of class "%s".', $r->name)); } $dir = $rootDir = \dirname($dir); @@ -284,7 +284,7 @@ public function setAnnotatedClassCache(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__); - file_put_contents(($this->warmupDir ?: $this->getBuildDir()).'/annotations.map', sprintf('warmupDir ?: $this->getBuildDir()).'/annotations.map', \sprintf('registerBundles() as $bundle) { $name = $bundle->getName(); if (isset($this->bundles[$name])) { - throw new \LogicException(sprintf('Trying to register two bundles with the same name "%s".', $name)); + throw new \LogicException(\sprintf('Trying to register two bundles with the same name "%s".', $name)); } $this->bundles[$name] = $bundle; } @@ -366,7 +366,7 @@ protected function getContainerClass(): string $class = str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container'; if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $class)) { - throw new \InvalidArgumentException(sprintf('The environment "%s" contains invalid characters, it can only contain characters allowed in PHP class names.', $this->environment)); + throw new \InvalidArgumentException(\sprintf('The environment "%s" contains invalid characters, it can only contain characters allowed in PHP class names.', $this->environment)); } return $class; @@ -586,10 +586,10 @@ protected function buildContainer(): ContainerBuilder foreach (['cache' => $this->getCacheDir(), 'build' => $this->warmupDir ?: $this->getBuildDir(), 'logs' => $this->getLogDir()] as $name => $dir) { if (!is_dir($dir)) { if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new \RuntimeException(sprintf('Unable to create the "%s" directory (%s).', $name, $dir)); + throw new \RuntimeException(\sprintf('Unable to create the "%s" directory (%s).', $name, $dir)); } } elseif (!is_writable($dir)) { - throw new \RuntimeException(sprintf('Unable to write in the "%s" directory (%s).', $name, $dir)); + throw new \RuntimeException(\sprintf('Unable to write in the "%s" directory (%s).', $name, $dir)); } } diff --git a/Log/Logger.php b/Log/Logger.php index 6b7a90d429..1547ebac2b 100644 --- a/Log/Logger.php +++ b/Log/Logger.php @@ -74,13 +74,13 @@ public function __construct(?string $minLevel = null, $output = null, ?callable } if (!isset(self::LEVELS[$minLevel])) { - throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $minLevel)); + throw new InvalidArgumentException(\sprintf('The log level "%s" does not exist.', $minLevel)); } $this->minLevelIndex = self::LEVELS[$minLevel]; $this->formatter = null !== $formatter ? $formatter(...) : $this->format(...); if ($output && false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) { - throw new InvalidArgumentException(sprintf('Unable to open "%s".', $output)); + throw new InvalidArgumentException(\sprintf('Unable to open "%s".', $output)); } $this->debug = $debug; } @@ -93,7 +93,7 @@ public function enableDebug(): void public function log($level, $message, array $context = []): void { if (!isset(self::LEVELS[$level])) { - throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level)); + throw new InvalidArgumentException(\sprintf('The log level "%s" does not exist.', $level)); } if (self::LEVELS[$level] < $this->minLevelIndex) { @@ -155,7 +155,7 @@ private function format(string $level, string $message, array $context, bool $pr $message = strtr($message, $replacements); } - $log = sprintf('[%s] %s', $level, $message); + $log = \sprintf('[%s] %s', $level, $message); if ($prefixDate) { $log = date(\DateTimeInterface::RFC3339).' '.$log; } diff --git a/Profiler/FileProfilerStorage.php b/Profiler/FileProfilerStorage.php index 2d31bc2304..2851600096 100644 --- a/Profiler/FileProfilerStorage.php +++ b/Profiler/FileProfilerStorage.php @@ -33,12 +33,12 @@ class FileProfilerStorage implements ProfilerStorageInterface public function __construct(string $dsn) { if (!str_starts_with($dsn, 'file:')) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use FileStorage with an invalid dsn "%s". The expected format is "file:/path/to/the/storage/folder".', $dsn)); + throw new \RuntimeException(\sprintf('Please check your configuration. You are trying to use FileStorage with an invalid dsn "%s". The expected format is "file:/path/to/the/storage/folder".', $dsn)); } $this->folder = substr($dsn, 5); if (!is_dir($this->folder) && false === @mkdir($this->folder, 0777, true) && !is_dir($this->folder)) { - throw new \RuntimeException(sprintf('Unable to create the storage directory (%s).', $this->folder)); + throw new \RuntimeException(\sprintf('Unable to create the storage directory (%s).', $this->folder)); } } @@ -137,7 +137,7 @@ public function write(Profile $profile): bool // Create directory $dir = \dirname($file); if (!is_dir($dir) && false === @mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new \RuntimeException(sprintf('Unable to create the storage directory (%s).', $dir)); + throw new \RuntimeException(\sprintf('Unable to create the storage directory (%s).', $dir)); } } diff --git a/Profiler/Profile.php b/Profiler/Profile.php index a18e2e5cf5..ff2bbdbc42 100644 --- a/Profiler/Profile.php +++ b/Profiler/Profile.php @@ -207,7 +207,7 @@ public function getChildByToken(string $token): ?self public function getCollector(string $name): DataCollectorInterface { if (!isset($this->collectors[$name])) { - throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name)); + throw new \InvalidArgumentException(\sprintf('Collector "%s" does not exist.', $name)); } return $this->collectors[$name]; diff --git a/Profiler/Profiler.php b/Profiler/Profiler.php index 004173b65f..2995447955 100644 --- a/Profiler/Profiler.php +++ b/Profiler/Profiler.php @@ -221,7 +221,7 @@ public function has(string $name): bool public function get(string $name): DataCollectorInterface { if (!isset($this->collectors[$name])) { - throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name)); + throw new \InvalidArgumentException(\sprintf('Collector "%s" does not exist.', $name)); } return $this->collectors[$name]; diff --git a/Tests/Controller/ArgumentResolver/QueryParameterValueResolverTest.php b/Tests/Controller/ArgumentResolver/QueryParameterValueResolverTest.php index cc7e141169..43161d1a10 100644 --- a/Tests/Controller/ArgumentResolver/QueryParameterValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/QueryParameterValueResolverTest.php @@ -66,7 +66,7 @@ public function testResolvingWithInvalidOrMissingArgument(Request $request, Argu try { $this->resolver->resolve($request, $metadata); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $exception) { $this->assertSame($expectedException->getMessage(), $exception->getMessage()); $this->assertSame($expectedException->getStatusCode(), $exception->getStatusCode()); diff --git a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php index b277650b44..7b830b041b 100644 --- a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php @@ -173,7 +173,7 @@ public function testNullPayloadAndNotDefaultOrNullableArgument() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $this->assertSame(422, $e->getStatusCode()); } @@ -198,7 +198,7 @@ public function testQueryNullPayloadAndNotDefaultOrNullableArgument() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $this->assertSame(404, $e->getStatusCode()); } @@ -222,7 +222,7 @@ public function testWithoutValidatorAndCouldNotDenormalize() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $this->assertInstanceOf(PartialDenormalizationException::class, $e->getPrevious()); } @@ -250,7 +250,7 @@ public function testValidationNotPassed() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertSame(422, $e->getStatusCode()); @@ -281,7 +281,7 @@ public function testValidationNotPerformedWhenPartialDenormalizationReturnsViola try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); @@ -306,7 +306,7 @@ public function testUnsupportedMedia() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $this->assertSame(415, $e->getStatusCode()); } @@ -592,7 +592,7 @@ public function testAcceptFormatNotPassed(mixed $acceptFormat, string $contentTy try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $this->assertSame(415, $e->getStatusCode()); $this->assertSame($expectedExceptionMessage, $e->getMessage()); @@ -688,7 +688,7 @@ public function testValidationGroupsNotPassed(string $method, ValueResolver $att try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); @@ -753,7 +753,7 @@ public function testQueryValidationErrorCustomStatusCode() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertSame(400, $e->getStatusCode()); @@ -784,7 +784,7 @@ public function testRequestPayloadValidationErrorCustomStatusCode() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertSame(400, $e->getStatusCode()); diff --git a/Tests/DataCollector/ConfigDataCollectorTest.php b/Tests/DataCollector/ConfigDataCollectorTest.php index efee6742ea..00da7a7801 100644 --- a/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/Tests/DataCollector/ConfigDataCollectorTest.php @@ -41,7 +41,7 @@ public function testCollect() $this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug()); $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL), $c->hasZendOpcache()); $this->assertSame(\extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL), $c->hasApcu()); - $this->assertSame(sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); + $this->assertSame(\sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); $this->assertContains($c->getSymfonyState(), ['eol', 'eom', 'dev', 'stable']); $eom = \DateTimeImmutable::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE)->format('F Y'); @@ -69,7 +69,7 @@ public function testCollectWithoutKernel() $this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug()); $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL), $c->hasZendOpcache()); $this->assertSame(\extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL), $c->hasApcu()); - $this->assertSame(sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); + $this->assertSame(\sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); $this->assertContains($c->getSymfonyState(), ['eol', 'eom', 'dev', 'stable']); $eom = \DateTimeImmutable::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE)->format('F Y'); diff --git a/Tests/DataCollector/RequestDataCollectorTest.php b/Tests/DataCollector/RequestDataCollectorTest.php index 04649f9ef3..65608851de 100644 --- a/Tests/DataCollector/RequestDataCollectorTest.php +++ b/Tests/DataCollector/RequestDataCollectorTest.php @@ -89,7 +89,7 @@ public function testControllerInspection($name, $callable, $expected) $c->collect($request, $response); $c->lateCollect(); - $this->assertSame($expected, $c->getController()->getValue(true), sprintf('Testing: %s', $name)); + $this->assertSame($expected, $c->getController()->getValue(true), \sprintf('Testing: %s', $name)); } public static function provideControllerCallables(): array @@ -118,7 +118,7 @@ public static function provideControllerCallables(): array 'Closure', fn () => 'foo', [ - 'class' => \PHP_VERSION_ID >= 80400 ? sprintf('{closure:%s():%d}', __METHOD__, __LINE__ - 2) : __NAMESPACE__.'\{closure}', + 'class' => \PHP_VERSION_ID >= 80400 ? \sprintf('{closure:%s():%d}', __METHOD__, __LINE__ - 2) : __NAMESPACE__.'\{closure}', 'method' => null, 'file' => __FILE__, 'line' => __LINE__ - 5, @@ -301,7 +301,7 @@ public function testItCollectsTheSessionTraceProperly() $this->assertSame('getMetadataBag', $trace[0]['function']); $this->assertSame(self::class, $class = $trace[1]['class']); - $this->assertSame(sprintf('%s:%s', $class, $line), $usages[0]['name']); + $this->assertSame(\sprintf('%s:%s', $class, $line), $usages[0]['name']); } public function testStatelessCheck() @@ -412,7 +412,7 @@ private function getCookieByName(Response $response, $name) } } - throw new \InvalidArgumentException(sprintf('Cookie named "%s" is not in response', $name)); + throw new \InvalidArgumentException(\sprintf('Cookie named "%s" is not in response', $name)); } /** diff --git a/Tests/EventListener/CacheAttributeListenerTest.php b/Tests/EventListener/CacheAttributeListenerTest.php index 0afae63a0a..1542b35e74 100644 --- a/Tests/EventListener/CacheAttributeListenerTest.php +++ b/Tests/EventListener/CacheAttributeListenerTest.php @@ -227,7 +227,7 @@ public function testEtagNotModifiedResponse(string $expression) $request = $this->createRequest(new Cache(etag: $expression)); $request->attributes->set('id', '12345'); - $request->headers->add(['If-None-Match' => sprintf('"%s"', hash('sha256', $entity->getId()))]); + $request->headers->add(['If-None-Match' => \sprintf('"%s"', hash('sha256', $entity->getId()))]); $listener = new CacheAttributeListener(); $controllerArgumentsEvent = new ControllerArgumentsEvent($this->getKernel(), fn (TestEntity $test) => new Response(), [$entity], $request, null); diff --git a/Tests/HttpCache/ResponseCacheStrategyTest.php b/Tests/HttpCache/ResponseCacheStrategyTest.php index 377253a086..9869f5eefb 100644 --- a/Tests/HttpCache/ResponseCacheStrategyTest.php +++ b/Tests/HttpCache/ResponseCacheStrategyTest.php @@ -316,14 +316,14 @@ public function testCacheControlMerging(array $expects, array $master, array $su } elseif ('age' === $key) { $this->assertSame($value, $response->getAge()); } elseif (true === $value) { - $this->assertTrue($response->headers->hasCacheControlDirective($key), sprintf('Cache-Control header must have "%s" flag', $key)); + $this->assertTrue($response->headers->hasCacheControlDirective($key), \sprintf('Cache-Control header must have "%s" flag', $key)); } elseif (false === $value) { $this->assertFalse( $response->headers->hasCacheControlDirective($key), - sprintf('Cache-Control header must NOT have "%s" flag', $key) + \sprintf('Cache-Control header must NOT have "%s" flag', $key) ); } else { - $this->assertSame($value, $response->headers->getCacheControlDirective($key), sprintf('Cache-Control flag "%s" should be "%s"', $key, $value)); + $this->assertSame($value, $response->headers->getCacheControlDirective($key), \sprintf('Cache-Control flag "%s" should be "%s"', $key, $value)); } } } diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index ff05190eb6..a1eff2e3ad 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -59,7 +59,7 @@ public function testConstructor() public function testEmptyEnv() { $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage(sprintf('Invalid environment provided to "%s": the environment cannot be empty.', KernelForTest::class)); + $this->expectExceptionMessage(\sprintf('Invalid environment provided to "%s": the environment cannot be empty.', KernelForTest::class)); new KernelForTest('', false); } From b1398ce75094f84d41a8678d556de283185fb7f5 Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Sun, 16 Jun 2024 17:17:26 +0200 Subject: [PATCH 102/210] chore: CS fixes --- HttpCache/HttpCache.php | 1 - Profiler/Profile.php | 1 - 2 files changed, 2 deletions(-) diff --git a/HttpCache/HttpCache.php b/HttpCache/HttpCache.php index c1f88747b2..c1b38fa543 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -87,7 +87,6 @@ public function __construct( private ?SurrogateInterface $surrogate = null, array $options = [], ) { - // needed in case there is a fatal error because the backend is too slow to respond register_shutdown_function($this->store->cleanup(...)); diff --git a/Profiler/Profile.php b/Profiler/Profile.php index ff2bbdbc42..84d9ab93ac 100644 --- a/Profiler/Profile.php +++ b/Profiler/Profile.php @@ -20,7 +20,6 @@ */ class Profile { - /** * @var DataCollectorInterface[] */ From 68f844c8a8d49959da6e98e42e75bb648713290d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Jun 2024 15:05:45 +0200 Subject: [PATCH 103/210] Update VERSION for 7.0.9 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index c20a70e84f..34e48d17ce 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.0.9-DEV'; + public const VERSION = '7.0.9'; public const VERSION_ID = 70009; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 0; public const RELEASE_VERSION = 9; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '07/2024'; public const END_OF_LIFE = '07/2024'; From 5b1c8beda5b4b64c5f980571f9e7777bac2e1f42 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Jun 2024 15:13:04 +0200 Subject: [PATCH 104/210] Bump Symfony version to 7.0.10 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 34e48d17ce..e11e235d52 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.0.9'; - public const VERSION_ID = 70009; + public const VERSION = '7.0.10-DEV'; + public const VERSION_ID = 70010; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 0; - public const RELEASE_VERSION = 9; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 10; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '07/2024'; public const END_OF_LIFE = '07/2024'; From ae3fa717db4d41a55d14c2bd92399e37cf5bc0f6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Jun 2024 15:13:31 +0200 Subject: [PATCH 105/210] Update VERSION for 7.1.2 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index e3cec13085..a7a0232ffa 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.2-DEV'; + public const VERSION = '7.1.2'; public const VERSION_ID = 70102; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; public const RELEASE_VERSION = 2; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From 3f56b920aaab58a769963e3b5964ebd2d7f266ca Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Jun 2024 15:21:16 +0200 Subject: [PATCH 106/210] Bump Symfony version to 7.1.3 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index a7a0232ffa..bdf6189789 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.2'; - public const VERSION_ID = 70102; + public const VERSION = '7.1.3-DEV'; + public const VERSION_ID = 70103; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; - public const RELEASE_VERSION = 2; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 3; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From 992badf06ca48cb8ffea83b74d4f8a7b3921c6ca Mon Sep 17 00:00:00 2001 From: Piotr Zajac Date: Tue, 28 May 2024 13:26:56 +0200 Subject: [PATCH 107/210] validate empty request MapQueryString/MapRequestPayload skips validation when empty request is sent resolves #54617 --- .../RequestPayloadValueResolver.php | 4 ++-- .../RequestPayloadValueResolverTest.php | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Controller/ArgumentResolver/RequestPayloadValueResolver.php b/Controller/ArgumentResolver/RequestPayloadValueResolver.php index 7ccff6f758..94d04bfe4e 100644 --- a/Controller/ArgumentResolver/RequestPayloadValueResolver.php +++ b/Controller/ArgumentResolver/RequestPayloadValueResolver.php @@ -185,7 +185,7 @@ public static function getSubscribedEvents(): array private function mapQueryString(Request $request, ArgumentMetadata $argument, MapQueryString $attribute): ?object { - if (!$data = $request->query->all()) { + if (!($data = $request->query->all()) && ($argument->isNullable() || $argument->hasDefaultValue())) { return null; } @@ -212,7 +212,7 @@ private function mapRequestPayload(Request $request, ArgumentMetadata $argument, return $this->serializer->denormalize($data, $type, null, $attribute->serializationContext + self::CONTEXT_DENORMALIZE + ('form' === $format ? ['filter_bool' => true] : [])); } - if ('' === $data = $request->getContent()) { + if ('' === ($data = $request->getContent()) && ($argument->isNullable() || $argument->hasDefaultValue())) { return null; } diff --git a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php index 7b830b041b..8b26767f9e 100644 --- a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php @@ -116,7 +116,7 @@ public function testNullableValueArgument() $validator->expects($this->never()) ->method('validate'); - $resolver = new RequestPayloadValueResolver(new Serializer(), $validator); + $resolver = new RequestPayloadValueResolver(new Serializer([new ObjectNormalizer()], ['json' => new JsonEncoder()]), $validator); $argument = new ArgumentMetadata('valid', RequestPayload::class, false, false, null, true, [ MapRequestPayload::class => new MapRequestPayload(), @@ -138,9 +138,9 @@ public function testQueryNullableValueArgument() $validator->expects($this->never()) ->method('validate'); - $resolver = new RequestPayloadValueResolver(new Serializer(), $validator); + $resolver = new RequestPayloadValueResolver(new Serializer([new ObjectNormalizer()], ['json' => new JsonEncoder()]), $validator); - $argument = new ArgumentMetadata('valid', RequestPayload::class, false, false, null, true, [ + $argument = new ArgumentMetadata('valid', QueryPayload::class, false, false, null, true, [ MapQueryString::class => new MapQueryString(), ]); $request = Request::create('/', 'GET'); @@ -160,7 +160,7 @@ public function testNullPayloadAndNotDefaultOrNullableArgument() $validator->expects($this->never()) ->method('validate'); - $resolver = new RequestPayloadValueResolver(new Serializer(), $validator); + $resolver = new RequestPayloadValueResolver(new Serializer([new ObjectNormalizer()], ['json' => new JsonEncoder()]), $validator); $argument = new ArgumentMetadata('valid', RequestPayload::class, false, false, null, false, [ MapRequestPayload::class => new MapRequestPayload(), @@ -175,7 +175,7 @@ public function testNullPayloadAndNotDefaultOrNullableArgument() $resolver->onKernelControllerArguments($event); $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { - $this->assertSame(422, $e->getStatusCode()); + $this->assertSame(400, $e->getStatusCode()); } } @@ -185,9 +185,9 @@ public function testQueryNullPayloadAndNotDefaultOrNullableArgument() $validator->expects($this->never()) ->method('validate'); - $resolver = new RequestPayloadValueResolver(new Serializer(), $validator); + $resolver = new RequestPayloadValueResolver(new Serializer([new ObjectNormalizer()]), $validator); - $argument = new ArgumentMetadata('valid', RequestPayload::class, false, false, null, false, [ + $argument = new ArgumentMetadata('valid', QueryPayload::class, false, false, null, false, [ MapQueryString::class => new MapQueryString(), ]); $request = Request::create('/', 'GET'); @@ -230,7 +230,7 @@ public function testWithoutValidatorAndCouldNotDenormalize() public function testValidationNotPassed() { - $content = '{"price": 50, "title": ["not a string"]}'; + $content = '{"price": 50.0, "title": ["not a string"]}'; $serializer = new Serializer([new ObjectNormalizer()], ['json' => new JsonEncoder()]); $validator = $this->createMock(ValidatorInterface::class); From ee12dbed616ae23f72aad80a4a4ecd347975dbc0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 6 Jul 2024 09:57:16 +0200 Subject: [PATCH 108/210] Update .gitattributes --- .gitattributes | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index 84c7add058..14c3c35940 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,3 @@ /Tests export-ignore /phpunit.xml.dist export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore +/.git* export-ignore From ceb929246d4c73373555606d0e87c2bee88f7529 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 15 Jul 2024 14:43:16 +0200 Subject: [PATCH 109/210] Use `createMock` --- Tests/EventListener/CacheAttributeListenerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/EventListener/CacheAttributeListenerTest.php b/Tests/EventListener/CacheAttributeListenerTest.php index 1542b35e74..b888579b80 100644 --- a/Tests/EventListener/CacheAttributeListenerTest.php +++ b/Tests/EventListener/CacheAttributeListenerTest.php @@ -330,7 +330,7 @@ private function createEventMock(Request $request, Response $response): Response private function getKernel(): MockObject&HttpKernelInterface { - return $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + return $this->createMock(HttpKernelInterface::class); } } From 25a589485987734d43ee95e48ca85ebcf7f64856 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 17 Jul 2024 10:14:50 +0200 Subject: [PATCH 110/210] do not use uniqid() for generating dev tool tokens --- Debug/TraceableEventDispatcher.php | 2 +- Profiler/Profiler.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Debug/TraceableEventDispatcher.php b/Debug/TraceableEventDispatcher.php index 2b2e2e2812..9c4f4981a5 100644 --- a/Debug/TraceableEventDispatcher.php +++ b/Debug/TraceableEventDispatcher.php @@ -27,7 +27,7 @@ protected function beforeDispatch(string $eventName, object $event): void { switch ($eventName) { case KernelEvents::REQUEST: - $event->getRequest()->attributes->set('_stopwatch_token', substr(hash('xxh128', uniqid(mt_rand(), true)), 0, 6)); + $event->getRequest()->attributes->set('_stopwatch_token', bin2hex(random_bytes(3))); $this->stopwatch->openSection(); break; case KernelEvents::VIEW: diff --git a/Profiler/Profiler.php b/Profiler/Profiler.php index 2995447955..b2089f10c7 100644 --- a/Profiler/Profiler.php +++ b/Profiler/Profiler.php @@ -133,7 +133,7 @@ public function collect(Request $request, Response $response, ?\Throwable $excep return null; } - $profile = new Profile(substr(hash('xxh128', uniqid(mt_rand(), true)), 0, 6)); + $profile = new Profile(bin2hex(random_bytes(3))); $profile->setTime(time()); $profile->setUrl($request->getUri()); $profile->setMethod($request->getMethod()); From 143526587ecc9f4ec36aaca8786085d052d0d4c3 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Fri, 19 Jul 2024 10:48:20 +0200 Subject: [PATCH 111/210] [HttpFoundation][HttpKernel] Remove dead code and useless casts --- Attribute/AsController.php | 3 --- CacheWarmer/CacheWarmerAggregate.php | 2 +- DataCollector/DataCollector.php | 4 +--- .../RegisterControllerArgumentLocatorsPass.php | 2 +- Kernel.php | 4 ++-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Attribute/AsController.php b/Attribute/AsController.php index 0f2c91d45b..f0d10a8b33 100644 --- a/Attribute/AsController.php +++ b/Attribute/AsController.php @@ -21,7 +21,4 @@ #[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_FUNCTION)] class AsController { - public function __construct() - { - } } diff --git a/CacheWarmer/CacheWarmerAggregate.php b/CacheWarmer/CacheWarmerAggregate.php index 60355e10b1..421533df61 100644 --- a/CacheWarmer/CacheWarmerAggregate.php +++ b/CacheWarmer/CacheWarmerAggregate.php @@ -93,7 +93,7 @@ public function warmUp(string $cacheDir, ?string $buildDir = null, ?SymfonyStyle } $start = microtime(true); - foreach ((array) $warmer->warmUp($cacheDir, $buildDir) as $item) { + foreach ($warmer->warmUp($cacheDir, $buildDir) as $item) { if (is_dir($item) || (str_starts_with($item, \dirname($cacheDir)) && !is_file($item)) || ($buildDir && str_starts_with($item, \dirname($buildDir)) && !is_file($item))) { throw new \LogicException(\sprintf('"%s::warmUp()" should return a list of files or classes but "%s" is none of them.', $warmer::class, $item)); } diff --git a/DataCollector/DataCollector.php b/DataCollector/DataCollector.php index 607bb81538..3238e2bb8d 100644 --- a/DataCollector/DataCollector.php +++ b/DataCollector/DataCollector.php @@ -57,7 +57,7 @@ protected function cloneVar(mixed $var): Data */ protected function getCasters(): array { - $casters = [ + return [ '*' => function ($v, array $a, Stub $s, $isNested) { if (!$v instanceof Stub) { $b = $a; @@ -82,8 +82,6 @@ protected function getCasters(): array return $a; }, ] + ReflectionCaster::UNSET_CLOSURE_FILE_INFO; - - return $casters; } public function __sleep(): array diff --git a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index 2c16ec6f5f..d473a2e6b0 100644 --- a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -137,7 +137,7 @@ public function process(ContainerBuilder $container): void $target = $arguments[$r->name][$p->name]; if ('?' !== $target[0]) { $invalidBehavior = ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE; - } elseif ('' === $target = (string) substr($target, 1)) { + } 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; diff --git a/Kernel.php b/Kernel.php index fe55a27f46..5bfbdcbaaf 100644 --- a/Kernel.php +++ b/Kernel.php @@ -530,7 +530,7 @@ protected function initializeContainer(): void $buildDir = $this->container->getParameter('kernel.build_dir'); $cacheDir = $this->container->getParameter('kernel.cache_dir'); - $preload = $this instanceof WarmableInterface ? (array) $this->warmUp($cacheDir, $buildDir) : []; + $preload = $this instanceof WarmableInterface ? $this->warmUp($cacheDir, $buildDir) : []; if ($this->container->has('cache_warmer')) { $cacheWarmer = $this->container->get('cache_warmer'); @@ -539,7 +539,7 @@ protected function initializeContainer(): void $cacheWarmer->enableOptionalWarmers(); } - $preload = array_merge($preload, (array) $cacheWarmer->warmUp($cacheDir, $buildDir)); + $preload = array_merge($preload, $cacheWarmer->warmUp($cacheDir, $buildDir)); } if ($preload && file_exists($preloadFile = $buildDir.'/'.$class.'.preload.php')) { From 042a69bc4b31db698037076e753453bf0108563e Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Mon, 22 Jul 2024 10:27:43 +0200 Subject: [PATCH 112/210] Use CPP where possible --- Controller/ArgumentResolver.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Controller/ArgumentResolver.php b/Controller/ArgumentResolver.php index 79be8266c7..b09a92f02d 100644 --- a/Controller/ArgumentResolver.php +++ b/Controller/ArgumentResolver.php @@ -34,16 +34,17 @@ final class ArgumentResolver implements ArgumentResolverInterface { private ArgumentMetadataFactoryInterface $argumentMetadataFactory; private iterable $argumentValueResolvers; - private ?ContainerInterface $namedResolvers; /** * @param iterable $argumentValueResolvers */ - public function __construct(?ArgumentMetadataFactoryInterface $argumentMetadataFactory = null, iterable $argumentValueResolvers = [], ?ContainerInterface $namedResolvers = null) - { + public function __construct( + ?ArgumentMetadataFactoryInterface $argumentMetadataFactory = null, + iterable $argumentValueResolvers = [], + private ?ContainerInterface $namedResolvers = null, + ) { $this->argumentMetadataFactory = $argumentMetadataFactory ?? new ArgumentMetadataFactory(); $this->argumentValueResolvers = $argumentValueResolvers ?: self::getDefaultArgumentValueResolvers(); - $this->namedResolvers = $namedResolvers; } public function getArguments(Request $request, callable $controller, ?\ReflectionFunctionAbstract $reflector = null): array From 8d9e9def0ca3a5974f968c5a0e5d4e72b5f970d1 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 23 Jul 2024 14:57:51 +0200 Subject: [PATCH 113/210] make use of the @template annotation to improve type information --- HttpKernelBrowser.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/HttpKernelBrowser.php b/HttpKernelBrowser.php index 7f89e35b97..db6d0e08a9 100644 --- a/HttpKernelBrowser.php +++ b/HttpKernelBrowser.php @@ -25,8 +25,7 @@ * * @author Fabien Potencier * - * @method Request getRequest() - * @method Response getResponse() + * @template-extends AbstractBrowser */ class HttpKernelBrowser extends AbstractBrowser { From db9702f3a04cc471ec8c70e881825db26ac5f186 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 26 Jul 2024 16:58:15 +0200 Subject: [PATCH 114/210] Update VERSION for 7.1.3 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index cbd5987b3d..5af6a29550 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.3-DEV'; + public const VERSION = '7.1.3'; public const VERSION_ID = 70103; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; public const RELEASE_VERSION = 3; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From ae9c137367dd4a833f198f01d5a1c02a3a5840f2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 26 Jul 2024 17:03:22 +0200 Subject: [PATCH 115/210] Bump Symfony version to 7.1.4 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 5af6a29550..321bac70bb 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.3'; - public const VERSION_ID = 70103; + public const VERSION = '7.1.4-DEV'; + public const VERSION_ID = 70104; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; - public const RELEASE_VERSION = 3; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 4; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From 2594f1957bf456970cf6a7ed54420d37093d9dd9 Mon Sep 17 00:00:00 2001 From: Roy de Vos Burchart Date: Thu, 1 Aug 2024 17:21:17 +0200 Subject: [PATCH 116/210] Code style change in `@PER-CS2.0` affecting `@Symfony` (parentheses for anonymous classes) --- Tests/Controller/ArgumentResolverTest.php | 8 ++++---- Tests/Controller/TraceableArgumentResolverTest.php | 2 +- Tests/Controller/TraceableControllerResolverTest.php | 2 +- Tests/EventListener/SessionListenerTest.php | 2 +- Tests/KernelTest.php | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Tests/Controller/ArgumentResolverTest.php b/Tests/Controller/ArgumentResolverTest.php index 8b7f70056d..ed06130b92 100644 --- a/Tests/Controller/ArgumentResolverTest.php +++ b/Tests/Controller/ArgumentResolverTest.php @@ -350,7 +350,7 @@ public function testUnknownTargetedResolver() public function testResolversChainCompletionWhenResolverThrowsSpecialException() { - $failingValueResolver = new class() implements ValueResolverInterface { + $failingValueResolver = new class implements ValueResolverInterface { public function resolve(Request $request, ArgumentMetadata $argument): iterable { throw new NearMissValueResolverException('This resolver throws an exception'); @@ -370,7 +370,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable public function testExceptionListSingle() { - $failingValueResolverOne = new class() implements ValueResolverInterface { + $failingValueResolverOne = new class implements ValueResolverInterface { public function resolve(Request $request, ArgumentMetadata $argument): iterable { throw new NearMissValueResolverException('Some reason why value could not be resolved.'); @@ -388,13 +388,13 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable public function testExceptionListMultiple() { - $failingValueResolverOne = new class() implements ValueResolverInterface { + $failingValueResolverOne = new class implements ValueResolverInterface { public function resolve(Request $request, ArgumentMetadata $argument): iterable { throw new NearMissValueResolverException('Some reason why value could not be resolved.'); } }; - $failingValueResolverTwo = new class() implements ValueResolverInterface { + $failingValueResolverTwo = new class implements ValueResolverInterface { public function resolve(Request $request, ArgumentMetadata $argument): iterable { throw new NearMissValueResolverException('Another reason why value could not be resolved.'); diff --git a/Tests/Controller/TraceableArgumentResolverTest.php b/Tests/Controller/TraceableArgumentResolverTest.php index 71c9b799c0..74900f822e 100644 --- a/Tests/Controller/TraceableArgumentResolverTest.php +++ b/Tests/Controller/TraceableArgumentResolverTest.php @@ -28,7 +28,7 @@ public function testStopwatchEventIsStoppedWhenResolverThrows() $stopwatch = $this->createStub(Stopwatch::class); $stopwatch->method('start')->willReturn($stopwatchEvent); - $resolver = new class() implements ArgumentResolverInterface { + $resolver = new class implements ArgumentResolverInterface { public function getArguments(Request $request, callable $controller, ?\ReflectionFunctionAbstract $reflector = null): array { throw new \Exception(); diff --git a/Tests/Controller/TraceableControllerResolverTest.php b/Tests/Controller/TraceableControllerResolverTest.php index ecd4a23736..fcdb6bea97 100644 --- a/Tests/Controller/TraceableControllerResolverTest.php +++ b/Tests/Controller/TraceableControllerResolverTest.php @@ -28,7 +28,7 @@ public function testStopwatchEventIsStoppedWhenResolverThrows() $stopwatch = $this->createStub(Stopwatch::class); $stopwatch->method('start')->willReturn($stopwatchEvent); - $resolver = new class() implements ControllerResolverInterface { + $resolver = new class implements ControllerResolverInterface { public function getController(Request $request): callable|false { throw new \Exception(); diff --git a/Tests/EventListener/SessionListenerTest.php b/Tests/EventListener/SessionListenerTest.php index aed02928f8..2aa5d622e2 100644 --- a/Tests/EventListener/SessionListenerTest.php +++ b/Tests/EventListener/SessionListenerTest.php @@ -336,7 +336,7 @@ public function testSessionCookieSetWhenOtherNativeVariablesSet() public function testOnlyTriggeredOnMainRequest() { - $listener = new class() extends AbstractSessionListener { + $listener = new class extends AbstractSessionListener { protected function getSession(): ?SessionInterface { return null; diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 845f6bdfb7..e379e41bf5 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -412,7 +412,7 @@ public function testKernelReset() public function testKernelExtension() { - $kernel = new class() extends CustomProjectDirKernel implements ExtensionInterface { + $kernel = new class extends CustomProjectDirKernel implements ExtensionInterface { public function load(array $configs, ContainerBuilder $container): void { $container->setParameter('test.extension-registered', true); From c2c3d0365eb5f00d8e876d4db469f0a83f5dbb76 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 27 Aug 2024 08:46:51 +0200 Subject: [PATCH 117/210] [HttpKernel] Fix method naming collision MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … of dummy logger implementations --- Tests/EventListener/ErrorListenerTest.php | 23 ++++++----- Tests/Logger.php | 48 ++--------------------- 2 files changed, 18 insertions(+), 53 deletions(-) diff --git a/Tests/EventListener/ErrorListenerTest.php b/Tests/EventListener/ErrorListenerTest.php index 4cc868a775..2e1f7d58b7 100644 --- a/Tests/EventListener/ErrorListenerTest.php +++ b/Tests/EventListener/ErrorListenerTest.php @@ -100,7 +100,7 @@ public function testHandleWithLogger($event, $event2) } $this->assertEquals(3, $logger->countErrors()); - $logs = $logger->getLogs('critical'); + $logs = $logger->getLogsForLevel('critical'); $this->assertCount(3, $logs); $this->assertStringStartsWith('Uncaught PHP Exception Exception: "foo" at ErrorListenerTest.php line', $logs[0]); $this->assertStringStartsWith('Uncaught PHP Exception Exception: "foo" at ErrorListenerTest.php line', $logs[1]); @@ -124,8 +124,8 @@ public function testHandleWithLoggerAndCustomConfiguration() $this->assertEquals(new Response('foo', 401), $event->getResponse()); $this->assertEquals(0, $logger->countErrors()); - $this->assertCount(0, $logger->getLogs('critical')); - $this->assertCount(1, $logger->getLogs('warning')); + $this->assertCount(0, $logger->getLogsForLevel('critical')); + $this->assertCount(1, $logger->getLogsForLevel('warning')); } public function testHandleWithLogLevelAttribute() @@ -139,8 +139,8 @@ public function testHandleWithLogLevelAttribute() $l->onKernelException($event); $this->assertEquals(0, $logger->countErrors()); - $this->assertCount(0, $logger->getLogs('critical')); - $this->assertCount(1, $logger->getLogs('warning')); + $this->assertCount(0, $logger->getLogsForLevel('critical')); + $this->assertCount(1, $logger->getLogsForLevel('warning')); } public function testHandleClassImplementingInterfaceWithLogLevelAttribute() @@ -154,8 +154,8 @@ public function testHandleClassImplementingInterfaceWithLogLevelAttribute() $l->onKernelException($event); $this->assertEquals(0, $logger->countErrors()); - $this->assertCount(0, $logger->getLogs('critical')); - $this->assertCount(1, $logger->getLogs('warning')); + $this->assertCount(0, $logger->getLogsForLevel('critical')); + $this->assertCount(1, $logger->getLogsForLevel('warning')); } public function testHandleWithLogLevelAttributeAndCustomConfiguration() @@ -173,8 +173,8 @@ public function testHandleWithLogLevelAttributeAndCustomConfiguration() $l->onKernelException($event); $this->assertEquals(0, $logger->countErrors()); - $this->assertCount(0, $logger->getLogs('warning')); - $this->assertCount(1, $logger->getLogs('info')); + $this->assertCount(0, $logger->getLogsForLevel('warning')); + $this->assertCount(1, $logger->getLogsForLevel('info')); } /** @@ -327,6 +327,11 @@ public function countErrors(?Request $request = null): int { return \count($this->logs['critical']); } + + public function getLogs(?Request $request = null): array + { + return []; + } } class TestKernel implements HttpKernelInterface diff --git a/Tests/Logger.php b/Tests/Logger.php index 22ef90d423..3620510e40 100644 --- a/Tests/Logger.php +++ b/Tests/Logger.php @@ -11,9 +11,9 @@ namespace Symfony\Component\HttpKernel\Tests; -use Psr\Log\LoggerInterface; +use Psr\Log\AbstractLogger; -class Logger implements LoggerInterface +class Logger extends AbstractLogger { protected array $logs; @@ -22,9 +22,9 @@ public function __construct() $this->clear(); } - public function getLogs($level = false): array + public function getLogsForLevel(string $level): array { - return false === $level ? $this->logs : $this->logs[$level]; + return $this->logs[$level]; } public function clear(): void @@ -45,44 +45,4 @@ public function log($level, $message, array $context = []): void { $this->logs[$level][] = $message; } - - public function emergency($message, array $context = []): void - { - $this->log('emergency', $message, $context); - } - - public function alert($message, array $context = []): void - { - $this->log('alert', $message, $context); - } - - public function critical($message, array $context = []): void - { - $this->log('critical', $message, $context); - } - - public function error($message, array $context = []): void - { - $this->log('error', $message, $context); - } - - public function warning($message, array $context = []): void - { - $this->log('warning', $message, $context); - } - - public function notice($message, array $context = []): void - { - $this->log('notice', $message, $context); - } - - public function info($message, array $context = []): void - { - $this->log('info', $message, $context); - } - - public function debug($message, array $context = []): void - { - $this->log('debug', $message, $context); - } } From 9b87a991e2b5903af5871f8bcc2a0b4d3c5acb7d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 27 Aug 2024 13:49:50 +0200 Subject: [PATCH 118/210] [HttpKernel][Security] Minor cleanups --- EventListener/AbstractSessionListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventListener/AbstractSessionListener.php b/EventListener/AbstractSessionListener.php index 5c9517be65..74534aa8ac 100644 --- a/EventListener/AbstractSessionListener.php +++ b/EventListener/AbstractSessionListener.php @@ -93,7 +93,7 @@ public function onKernelRequest(RequestEvent $event): void */ public function onKernelResponse(ResponseEvent $event): void { - if (!$event->isMainRequest() || (!$this->container->has('initialized_session') && !$event->getRequest()->hasSession())) { + if (!$event->isMainRequest()) { return; } From b0153221d92ce09433161b32d084b9872c2aff55 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 29 Aug 2024 10:25:47 +0200 Subject: [PATCH 119/210] bump requirement for Twig to 3.12+ --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 8e54c82c9a..89421417f5 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "symfony/var-dumper": "^6.4|^7.0", "symfony/var-exporter": "^6.4|^7.0", "psr/cache": "^1.0|^2.0|^3.0", - "twig/twig": "^3.0.4" + "twig/twig": "^3.12" }, "provide": { "psr/log-implementation": "1.0|2.0|3.0" @@ -69,7 +69,7 @@ "symfony/twig-bridge": "<6.4", "symfony/validator": "<6.4", "symfony/var-dumper": "<6.4", - "twig/twig": "<3.0.4" + "twig/twig": "<3.12" }, "autoload": { "psr-4": { "Symfony\\Component\\HttpKernel\\": "" }, From 4c06f9494e22e90428c7c27bad88ced379d50e54 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 8 Aug 2024 17:42:54 +0200 Subject: [PATCH 120/210] [Config] Generate a meta file in JSON format for resource tracking --- CHANGELOG.md | 1 + Kernel.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed608d8f91..1f1dfcd812 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG --- * Remove `@internal` flag and add `@final` to `ServicesResetter` + * Add support for `SYMFONY_DISABLE_RESOURCE_TRACKING` env var 7.1 --- diff --git a/Kernel.php b/Kernel.php index 5bfbdcbaaf..38a8c330c9 100644 --- a/Kernel.php +++ b/Kernel.php @@ -392,7 +392,10 @@ protected function initializeContainer(): void { $class = $this->getContainerClass(); $buildDir = $this->warmupDir ?: $this->getBuildDir(); - $cache = new ConfigCache($buildDir.'/'.$class.'.php', $this->debug); + $skip = $_SERVER['SYMFONY_DISABLE_RESOURCE_TRACKING'] ?? ''; + $skip = filter_var($skip, \FILTER_VALIDATE_BOOLEAN, \FILTER_NULL_ON_FAILURE) ?? explode(',', $skip); + $cache = new ConfigCache($buildDir.'/'.$class.'.php', $this->debug, null, \is_array($skip) && ['*'] !== $skip ? $skip : ($skip ? [] : null)); + $cachePath = $cache->getPath(); // Silence E_WARNING to ignore "include" failures - don't use "@" to prevent silencing fatal errors From 6efcbd1b3f444f631c386504fc83eeca25963747 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 30 Aug 2024 19:02:28 +0200 Subject: [PATCH 121/210] Update VERSION for 7.1.4 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 321bac70bb..3999386fb8 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.4-DEV'; + public const VERSION = '7.1.4'; public const VERSION_ID = 70104; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; public const RELEASE_VERSION = 4; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From a3d1d7e11ba3cba19266a7231e46d2514e93954f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 30 Aug 2024 19:06:31 +0200 Subject: [PATCH 122/210] Bump Symfony version to 7.1.5 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 3999386fb8..8b76fe637a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.4'; - public const VERSION_ID = 70104; + public const VERSION = '7.1.5-DEV'; + public const VERSION_ID = 70105; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; - public const RELEASE_VERSION = 4; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 5; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From 685c1a322f3c0f34ac91cae4ba8b2698551425c1 Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Sat, 31 Aug 2024 00:31:12 +0200 Subject: [PATCH 123/210] CS: re-apply `trailing_comma_in_multiline` --- Tests/HttpCache/HttpCacheTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index 109c1685dd..e24a2a3b6b 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -1292,7 +1292,7 @@ public function testEsiCacheIncludesEmbeddedResponseContentWhenMainResponseFails 'headers' => [ 'Cache-Control' => 's-maxage=10', // stays fresh 'Last-Modified' => 'Mon, 12 Aug 2024 10:05:00 +0000', - ] + ], ], ]); @@ -1349,7 +1349,7 @@ public function testEsiCacheIncludesEmbeddedResponseContentWhenMainResponseFails 'headers' => [ 'Cache-Control' => 's-maxage=0', // goes stale immediately 'Last-Modified' => 'Mon, 12 Aug 2024 10:05:00 +0000', - ] + ], ], ]); @@ -1414,7 +1414,7 @@ public function testEsiCacheIncludesEmbeddedResponseContentWhenMainAndEmbeddedRe 'headers' => [ 'Cache-Control' => 's-maxage=10', 'Last-Modified' => 'Mon, 12 Aug 2024 10:00:00 +0000', - ] + ], ], ]); From 1732b1e9f52a99b4c6e84fb28be2dc7dbb8a1343 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 30 Aug 2024 09:35:32 +0200 Subject: [PATCH 124/210] allow Twig 4 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 89421417f5..635f5ddb8d 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "symfony/var-dumper": "^6.4|^7.0", "symfony/var-exporter": "^6.4|^7.0", "psr/cache": "^1.0|^2.0|^3.0", - "twig/twig": "^3.12" + "twig/twig": "^3.12|^4.0" }, "provide": { "psr/log-implementation": "1.0|2.0|3.0" From 57460735a9469c9edc67d3fff94922782ff5bb37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Geffroy?= <81738559+raphael-geffroy@users.noreply.github.com> Date: Thu, 5 Sep 2024 16:43:15 +0200 Subject: [PATCH 125/210] fix: pass validator.translation_domain to RequestPayloadValueResolver --- Controller/ArgumentResolver/RequestPayloadValueResolver.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Controller/ArgumentResolver/RequestPayloadValueResolver.php b/Controller/ArgumentResolver/RequestPayloadValueResolver.php index 94d04bfe4e..1f0ff7cc0f 100644 --- a/Controller/ArgumentResolver/RequestPayloadValueResolver.php +++ b/Controller/ArgumentResolver/RequestPayloadValueResolver.php @@ -65,6 +65,7 @@ public function __construct( private readonly SerializerInterface&DenormalizerInterface $serializer, private readonly ?ValidatorInterface $validator = null, private readonly ?TranslatorInterface $translator = null, + private string $translationDomain = 'validators', ) { } @@ -137,7 +138,7 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event): vo if ($error->canUseMessageForUser()) { $parameters['hint'] = $error->getMessage(); } - $message = $trans($template, $parameters, 'validators'); + $message = $trans($template, $parameters, $this->translationDomain); $violations->add(new ConstraintViolation($message, $template, $parameters, null, $error->getPath(), null)); } $payload = $e->getData(); From 571e0a7bc5b1388a43ca7dfbc2aa4923a69bcb74 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Wed, 18 Sep 2024 13:33:46 +0200 Subject: [PATCH 126/210] Miscellaneous tests improvements --- Tests/DataCollector/LoggerDataCollectorTest.php | 10 +++++----- Tests/Event/ControllerArgumentsEventTest.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Tests/DataCollector/LoggerDataCollectorTest.php b/Tests/DataCollector/LoggerDataCollectorTest.php index 3e1654247b..67dd853b40 100644 --- a/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/Tests/DataCollector/LoggerDataCollectorTest.php @@ -79,11 +79,11 @@ public function testCollectFromDeprecationsLog() $this->assertCount(1, $processedLogs); - $this->assertEquals($processedLogs[0]['type'], 'deprecation'); - $this->assertEquals($processedLogs[0]['errorCount'], 1); - $this->assertEquals($processedLogs[0]['timestamp'], (new \DateTimeImmutable())->setTimestamp(filemtime($path))->format(\DateTimeInterface::RFC3339_EXTENDED)); - $this->assertEquals($processedLogs[0]['priority'], 100); - $this->assertEquals($processedLogs[0]['priorityName'], 'DEBUG'); + $this->assertSame('deprecation', $processedLogs[0]['type']); + $this->assertSame(1, $processedLogs[0]['errorCount']); + $this->assertSame($processedLogs[0]['timestamp'], (new \DateTimeImmutable())->setTimestamp(filemtime($path))->format(\DateTimeInterface::RFC3339_EXTENDED)); + $this->assertSame(100, $processedLogs[0]['priority']); + $this->assertSame('DEBUG', $processedLogs[0]['priorityName']); $this->assertNull($processedLogs[0]['channel']); $this->assertInstanceOf(Data::class, $processedLogs[0]['message']); diff --git a/Tests/Event/ControllerArgumentsEventTest.php b/Tests/Event/ControllerArgumentsEventTest.php index ef3ef7ad9e..0fc2013189 100644 --- a/Tests/Event/ControllerArgumentsEventTest.php +++ b/Tests/Event/ControllerArgumentsEventTest.php @@ -26,7 +26,7 @@ class ControllerArgumentsEventTest extends TestCase public function testControllerArgumentsEvent() { $event = new ControllerArgumentsEvent(new TestHttpKernel(), function () {}, ['test'], new Request(), HttpKernelInterface::MAIN_REQUEST); - $this->assertEquals($event->getArguments(), ['test']); + $this->assertSame(['test'], $event->getArguments()); } public function testSetAttributes() From 44204d96150a9df1fc57601ec933d23fefc2d65b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 21 Sep 2024 08:09:21 +0200 Subject: [PATCH 127/210] Update VERSION for 7.1.5 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 8b76fe637a..702f19ce93 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.5-DEV'; + public const VERSION = '7.1.5'; public const VERSION_ID = 70105; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; public const RELEASE_VERSION = 5; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From f213db02219cf919c0034b919cdcf3cb9bcd86b5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 21 Sep 2024 08:14:25 +0200 Subject: [PATCH 128/210] Bump Symfony version to 7.1.6 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 702f19ce93..21ee4c3412 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.5'; - public const VERSION_ID = 70105; + public const VERSION = '7.1.6-DEV'; + public const VERSION_ID = 70106; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; - public const RELEASE_VERSION = 5; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 6; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From 346766b9c1d0f26b682aaf80c4cd7f1925090422 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 23 Sep 2024 12:51:56 +0200 Subject: [PATCH 129/210] do not use the Test suffix for non test classes --- Tests/Fixtures/KernelForTest.php | 57 ------------------- .../KernelForTestWithLoadClassCache.php | 19 ------- Tests/KernelTest.php | 52 ++++++++++++++++- 3 files changed, 49 insertions(+), 79 deletions(-) delete mode 100644 Tests/Fixtures/KernelForTest.php delete mode 100644 Tests/Fixtures/KernelForTestWithLoadClassCache.php diff --git a/Tests/Fixtures/KernelForTest.php b/Tests/Fixtures/KernelForTest.php deleted file mode 100644 index 9146e46910..0000000000 --- a/Tests/Fixtures/KernelForTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\Kernel; - -class KernelForTest extends Kernel -{ - public function __construct(string $environment, bool $debug, private readonly bool $fakeContainer = true) - { - parent::__construct($environment, $debug); - } - - public function getBundleMap(): array - { - return []; - } - - public function registerBundles(): iterable - { - return []; - } - - public function registerContainerConfiguration(LoaderInterface $loader): void - { - } - - public function isBooted(): bool - { - return $this->booted; - } - - public function getProjectDir(): string - { - return __DIR__; - } - - protected function initializeContainer(): void - { - if ($this->fakeContainer) { - $this->container = new ContainerBuilder(); - } else { - parent::initializeContainer(); - } - } -} diff --git a/Tests/Fixtures/KernelForTestWithLoadClassCache.php b/Tests/Fixtures/KernelForTestWithLoadClassCache.php deleted file mode 100644 index 080953fe02..0000000000 --- a/Tests/Fixtures/KernelForTestWithLoadClassCache.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -class KernelForTestWithLoadClassCache extends KernelForTest -{ - public function doLoadClassCache(): void - { - } -} diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index e379e41bf5..c12c2ef72a 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -29,8 +29,6 @@ use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest; -use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTestWithLoadClassCache; use Symfony\Component\HttpKernel\Tests\Fixtures\KernelWithoutBundles; use Symfony\Component\HttpKernel\Tests\Fixtures\ResettableService; @@ -247,7 +245,7 @@ public function testSerialize() $env = 'test_env'; $debug = true; $kernel = new KernelForTest($env, $debug); - $expected = "O:57:\"Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest\":2:{s:14:\"\0*\0environment\";s:8:\"test_env\";s:8:\"\0*\0debug\";b:1;}"; + $expected = \sprintf("O:48:\"%s\":2:{s:14:\"\0*\0environment\";s:8:\"test_env\";s:8:\"\0*\0debug\";b:1;}", KernelForTest::class); $this->assertEquals($expected, serialize($kernel)); } @@ -661,3 +659,51 @@ public function process(ContainerBuilder $container): void $container->setParameter('test.processed', true); } } + +class KernelForTest extends Kernel +{ + public function __construct(string $environment, bool $debug, private readonly bool $fakeContainer = true) + { + parent::__construct($environment, $debug); + } + + public function getBundleMap(): array + { + return []; + } + + public function registerBundles(): iterable + { + return []; + } + + public function registerContainerConfiguration(LoaderInterface $loader): void + { + } + + public function isBooted(): bool + { + return $this->booted; + } + + public function getProjectDir(): string + { + return __DIR__; + } + + protected function initializeContainer(): void + { + if ($this->fakeContainer) { + $this->container = new ContainerBuilder(); + } else { + parent::initializeContainer(); + } + } +} + +class KernelForTestWithLoadClassCache extends KernelForTest +{ + public function doLoadClassCache(): void + { + } +} From cc28bac3ae5afd0281f5af6c8808490a06c26184 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 3 Sep 2024 14:33:41 +0200 Subject: [PATCH 130/210] [FrameworkBundle][HttpKernel] Add support for `SYMFONY_TRUSTED_PROXIES`, `SYMFONY_TRUSTED_HEADERS`, `SYMFONY_TRUST_X_SENDFILE_TYPE_HEADER` and `SYMFONY_TRUSTED_HOSTS` env vars --- CHANGELOG.md | 1 + Kernel.php | 25 ++++++++++++++++++++++--- Tests/KernelTest.php | 19 +++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f1dfcd812..1fc103b48d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ CHANGELOG * Remove `@internal` flag and add `@final` to `ServicesResetter` * Add support for `SYMFONY_DISABLE_RESOURCE_TRACKING` env var + * Add support for configuring trusted proxies/headers/hosts via env vars 7.1 --- diff --git a/Kernel.php b/Kernel.php index 38a8c330c9..7e8b002079 100644 --- a/Kernel.php +++ b/Kernel.php @@ -393,7 +393,7 @@ protected function initializeContainer(): void $class = $this->getContainerClass(); $buildDir = $this->warmupDir ?: $this->getBuildDir(); $skip = $_SERVER['SYMFONY_DISABLE_RESOURCE_TRACKING'] ?? ''; - $skip = filter_var($skip, \FILTER_VALIDATE_BOOLEAN, \FILTER_NULL_ON_FAILURE) ?? explode(',', $skip); + $skip = filter_var($skip, \FILTER_VALIDATE_BOOLEAN, \FILTER_NULL_ON_FAILURE) ?? explode(',', $skip); $cache = new ConfigCache($buildDir.'/'.$class.'.php', $this->debug, null, \is_array($skip) && ['*'] !== $skip ? $skip : ($skip ? [] : null)); $cachePath = $cache->getPath(); @@ -745,11 +745,30 @@ private function preBoot(): ContainerInterface $container = $this->container; if ($container->hasParameter('kernel.trusted_hosts') && $trustedHosts = $container->getParameter('kernel.trusted_hosts')) { - Request::setTrustedHosts($trustedHosts); + Request::setTrustedHosts(\is_array($trustedHosts) ? $trustedHosts : preg_split('/\s*+,\s*+(?![^{]*})/', $trustedHosts)); } if ($container->hasParameter('kernel.trusted_proxies') && $container->hasParameter('kernel.trusted_headers') && $trustedProxies = $container->getParameter('kernel.trusted_proxies')) { - Request::setTrustedProxies(\is_array($trustedProxies) ? $trustedProxies : array_map('trim', explode(',', $trustedProxies)), $container->getParameter('kernel.trusted_headers')); + $trustedHeaders = $container->getParameter('kernel.trusted_headers'); + + if (\is_string($trustedHeaders)) { + $trustedHeaders = array_map('trim', explode(',', $trustedHeaders)); + } + + if (\is_array($trustedHeaders)) { + $trustedHeaderSet = 0; + + foreach ($trustedHeaders as $header) { + if (!\defined($const = Request::class.'::HEADER_'.strtr(strtoupper($header), '-', '_'))) { + throw new \InvalidArgumentException(\sprintf('The trusted header "%s" is not supported.', $header)); + } + $trustedHeaderSet |= \constant($const); + } + } else { + $trustedHeaderSet = $trustedHeaders ?? (Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO); + } + + Request::setTrustedProxies(\is_array($trustedProxies) ? $trustedProxies : array_map('trim', explode(',', $trustedProxies)), $trustedHeaderSet); } return $container; diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index e379e41bf5..df4608a8e0 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -523,6 +523,25 @@ public function getContainerClass(): string $this->assertMatchesRegularExpression('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*TestDebugContainer$/', $kernel->getContainerClass()); } + public function testTrustedParameters() + { + $kernel = new CustomProjectDirKernel(function (ContainerBuilder $container) { + $container->setParameter('kernel.trusted_hosts', '^a{2,3}.com$, ^b{2,}.com$'); + $container->setParameter('kernel.trusted_proxies', 'a,b'); + $container->setParameter('kernel.trusted_headers', 'x-forwarded-for'); + }); + $kernel->boot(); + + try { + $this->assertSame(['{^a{2,3}.com$}i', '{^b{2,}.com$}i'], Request::getTrustedHosts()); + $this->assertSame(['a', 'b'], Request::getTrustedProxies()); + $this->assertSame(Request::HEADER_X_FORWARDED_FOR, Request::getTrustedHeaderSet()); + } finally { + Request::setTrustedHosts([]); + Request::setTrustedProxies([], 0); + } + } + /** * Returns a mock for the BundleInterface. */ From 2d4a4cc2cfc292a6eb4d8f3acff19b9cca5b7b62 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Thu, 26 Sep 2024 10:09:09 +0200 Subject: [PATCH 131/210] Remove unused imports --- Tests/DataCollector/RequestDataCollectorTest.php | 1 - Tests/HttpCache/StoreTest.php | 1 - 2 files changed, 2 deletions(-) diff --git a/Tests/DataCollector/RequestDataCollectorTest.php b/Tests/DataCollector/RequestDataCollectorTest.php index 65608851de..93ba4c1fc3 100644 --- a/Tests/DataCollector/RequestDataCollectorTest.php +++ b/Tests/DataCollector/RequestDataCollectorTest.php @@ -20,7 +20,6 @@ use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; diff --git a/Tests/HttpCache/StoreTest.php b/Tests/HttpCache/StoreTest.php index 1942e8d337..8c41ac5986 100644 --- a/Tests/HttpCache/StoreTest.php +++ b/Tests/HttpCache/StoreTest.php @@ -15,7 +15,6 @@ use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpCache\HttpCache; use Symfony\Component\HttpKernel\HttpCache\Store; class StoreTest extends TestCase From e91bf7b82a3fa94e88ebfac284e05375c999569c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 23 Sep 2024 16:14:41 +0200 Subject: [PATCH 132/210] [HttpKernel] Improve accessibility --- Resources/welcome.html.php | 140 ++++++++++++++++++++----------------- 1 file changed, 76 insertions(+), 64 deletions(-) diff --git a/Resources/welcome.html.php b/Resources/welcome.html.php index 4fd262ee16..810c71f988 100644 --- a/Resources/welcome.html.php +++ b/Resources/welcome.html.php @@ -1,6 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + $renderSymfonyLogoSvg = << + SVG; // SVG icons from the Tabler Icons project @@ -8,7 +18,7 @@ // https://github.com/tabler/tabler-icons/blob/master/LICENSE $renderBoxIconSvg = << +

+

Next Step @@ -262,7 +272,7 @@ -

+ @@ -270,59 +280,61 @@
-
-

- - Learn -

- -
+
From 4daa4fdb3ee3b0772ea3139f154b7a01ede40c77 Mon Sep 17 00:00:00 2001 From: JoppeDC Date: Thu, 25 Jul 2024 12:32:12 +0200 Subject: [PATCH 133/210] [FrameworkBundle] Finetune `AboutCommand` --- DataCollector/ConfigDataCollector.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index 2b2098ff0e..747a495036 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -40,6 +40,8 @@ public function collect(Request $request, Response $response, ?\Throwable $excep $eom = \DateTimeImmutable::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE); $eol = \DateTimeImmutable::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE); + $xdebugMode = getenv('XDEBUG_MODE') ?: \ini_get('xdebug.mode'); + $this->data = [ 'token' => $response->headers->get('X-Debug-Token'), 'symfony_version' => Kernel::VERSION, @@ -55,8 +57,11 @@ public function collect(Request $request, Response $response, ?\Throwable $excep 'php_intl_locale' => class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', 'php_timezone' => date_default_timezone_get(), 'xdebug_enabled' => \extension_loaded('xdebug'), + 'xdebug_status' => \extension_loaded('xdebug') ? ($xdebugMode && $xdebugMode !== 'off' ? 'Enabled (' . $xdebugMode . ')' : 'Not enabled') : 'Not installed', 'apcu_enabled' => \extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL), + 'apcu_status' => \extension_loaded('apcu') ? (filter_var(\ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'Enabled' : 'Not enabled') : 'Not installed', 'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL), + 'zend_opcache_status' => \extension_loaded('Zend OPcache') ? (filter_var(\ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) ? 'Enabled' : 'Not enabled') : 'Not installed', 'bundles' => [], 'sapi_name' => \PHP_SAPI, ]; @@ -192,6 +197,11 @@ public function hasXdebug(): bool return $this->data['xdebug_enabled']; } + public function getXdebugStatus(): string + { + return $this->data['xdebug_status']; + } + /** * Returns true if the function xdebug_info is available. */ @@ -208,6 +218,11 @@ public function hasApcu(): bool return $this->data['apcu_enabled']; } + public function getApcuStatus(): string + { + return $this->data['apcu_status']; + } + /** * Returns true if Zend OPcache is enabled. */ @@ -216,6 +231,11 @@ public function hasZendOpcache(): bool return $this->data['zend_opcache_enabled']; } + public function getZendOpcacheStatus(): string + { + return $this->data['zend_opcache_status']; + } + public function getBundles(): array|Data { return $this->data['bundles']; From 943fe90fbfe0bd14e21927d7036022353ea0c0e4 Mon Sep 17 00:00:00 2001 From: Shyim Date: Thu, 12 Sep 2024 11:06:05 +0200 Subject: [PATCH 134/210] [HttpKernel] allow narrow type of not nullable getResponse when hasResponse has been called --- Event/RequestEvent.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Event/RequestEvent.php b/Event/RequestEvent.php index 8b5c084b00..2ca242b734 100644 --- a/Event/RequestEvent.php +++ b/Event/RequestEvent.php @@ -46,6 +46,8 @@ public function setResponse(Response $response): void /** * Returns whether a response was set. + * + * @psalm-assert-if-true !null $this->getResponse() */ public function hasResponse(): bool { From 92d01724686241218c20a696ae362d8a02d4a5f9 Mon Sep 17 00:00:00 2001 From: Shyim Date: Mon, 14 Oct 2024 15:41:45 +0200 Subject: [PATCH 135/210] [HttpKernel] Let Monolog create the log folder --- Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel.php b/Kernel.php index 5f32158f68..223baa3afd 100644 --- a/Kernel.php +++ b/Kernel.php @@ -632,7 +632,7 @@ protected function getKernelParameters() */ protected function buildContainer() { - foreach (['cache' => $this->getCacheDir(), 'build' => $this->warmupDir ?: $this->getBuildDir(), 'logs' => $this->getLogDir()] as $name => $dir) { + foreach (['cache' => $this->getCacheDir(), 'build' => $this->warmupDir ?: $this->getBuildDir()] as $name => $dir) { if (!is_dir($dir)) { if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { throw new \RuntimeException(sprintf('Unable to create the "%s" directory (%s).', $name, $dir)); From 21f327f13aad1c6731303ee32c32e9768875c95a Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Mon, 14 Oct 2024 20:03:05 +0200 Subject: [PATCH 136/210] Reduce common control flows --- DataCollector/DumpDataCollector.php | 8 ++++---- Tests/Log/LoggerTest.php | 6 +----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 1e2190a993..f1d13d326f 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -121,12 +121,12 @@ public function collect(Request $request, Response $response, ?\Throwable $excep ) { if ($response->headers->has('Content-Type') && str_contains($response->headers->get('Content-Type') ?? '', 'html')) { $dumper = new HtmlDumper('php://output', $this->charset); - $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { $dumper = new CliDumper('php://output', $this->charset); - $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } + $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); + foreach ($this->data as $dump) { $this->doDump($dumper, $dump['data'], $dump['name'], $dump['file'], $dump['line'], $dump['label'] ?? ''); } @@ -235,12 +235,12 @@ public function __destruct() if ($this->webMode) { $dumper = new HtmlDumper('php://output', $this->charset); - $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { $dumper = new CliDumper('php://output', $this->charset); - $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } + $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); + foreach ($this->data as $i => $dump) { $this->data[$i] = null; $this->doDump($dumper, $dump['data'], $dump['name'], $dump['file'], $dump['line'], $dump['label'] ?? ''); diff --git a/Tests/Log/LoggerTest.php b/Tests/Log/LoggerTest.php index f6c943e88b..b70733d3bf 100644 --- a/Tests/Log/LoggerTest.php +++ b/Tests/Log/LoggerTest.php @@ -129,11 +129,7 @@ public function testContextReplacement() public function testObjectCastToString() { - if (method_exists($this, 'createPartialMock')) { - $dummy = $this->createPartialMock(DummyTest::class, ['__toString']); - } else { - $dummy = $this->createPartialMock(DummyTest::class, ['__toString']); - } + $dummy = $this->createPartialMock(DummyTest::class, ['__toString']); $dummy->expects($this->atLeastOnce()) ->method('__toString') ->willReturn('DUMMY'); From c4b0d7ffdf2ac83a29b305b027dc0c6ba9d5328b Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Fri, 18 Oct 2024 16:04:52 +0200 Subject: [PATCH 137/210] Remove always true/false occurrences --- DataCollector/LoggerDataCollector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataCollector/LoggerDataCollector.php b/DataCollector/LoggerDataCollector.php index ecf638fde8..428d676240 100644 --- a/DataCollector/LoggerDataCollector.php +++ b/DataCollector/LoggerDataCollector.php @@ -191,7 +191,7 @@ private function getContainerDeprecationLogs(): array $log['priorityName'] = 'DEBUG'; $log['channel'] = null; $log['scream'] = false; - unset($log['type'], $log['file'], $log['line'], $log['trace'], $log['trace'], $log['count']); + unset($log['type'], $log['file'], $log['line'], $log['trace'], $log['count']); $logs[] = $log; } From 63eb9d340f64b9cd9b7b59806ee649b933cbeb0f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 23 Oct 2024 10:11:04 +0200 Subject: [PATCH 138/210] revert allowing Twig 4 As Twig 4 will not be released before Symfony 7.2 we should not claim compatibility before a stable Twig 4 release. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 635f5ddb8d..89421417f5 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "symfony/var-dumper": "^6.4|^7.0", "symfony/var-exporter": "^6.4|^7.0", "psr/cache": "^1.0|^2.0|^3.0", - "twig/twig": "^3.12|^4.0" + "twig/twig": "^3.12" }, "provide": { "psr/log-implementation": "1.0|2.0|3.0" From 5d8315899cd76b2e7e29179bf5fea103e41bdf03 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 27 Oct 2024 14:54:21 +0100 Subject: [PATCH 139/210] Update VERSION for 7.1.6 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 21ee4c3412..33618bca92 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.6-DEV'; + public const VERSION = '7.1.6'; public const VERSION_ID = 70106; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; public const RELEASE_VERSION = 6; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From 96151247385bd724acd8bfc91a2558890d15b8da Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 27 Oct 2024 16:18:42 +0100 Subject: [PATCH 140/210] Bump Symfony version to 7.1.7 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 33618bca92..1dc609fcd4 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.6'; - public const VERSION_ID = 70106; + public const VERSION = '7.1.7-DEV'; + public const VERSION_ID = 70107; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; - public const RELEASE_VERSION = 6; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 7; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From 7f137cda31fd41e422edcdc01915f2c095b84399 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 6 Nov 2024 10:54:34 +0100 Subject: [PATCH 141/210] Update VERSION for 7.1.7 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1dc609fcd4..72f6d0ddca 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.7-DEV'; + public const VERSION = '7.1.7'; public const VERSION_ID = 70107; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; public const RELEASE_VERSION = 7; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From c2722fded7ff22147e01cd3975498af424674820 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 6 Nov 2024 10:59:44 +0100 Subject: [PATCH 142/210] Bump Symfony version to 7.1.8 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 72f6d0ddca..5bce80509b 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.7'; - public const VERSION_ID = 70107; + public const VERSION = '7.1.8-DEV'; + public const VERSION_ID = 70108; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; - public const RELEASE_VERSION = 7; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 8; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From 70a5fd8f9614f8ed1f0a1640f00d59047e7619bb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 6 Nov 2024 11:00:45 +0100 Subject: [PATCH 143/210] Update VERSION for 7.2.0-BETA2 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 7e8b002079..603df6a83a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.0-DEV'; + public const VERSION = '7.2.0-BETA2'; public const VERSION_ID = 70200; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = 'BETA2'; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From cd23537252813e8db3b22d0149e908a0ef473fcb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 6 Nov 2024 11:04:42 +0100 Subject: [PATCH 144/210] Bump Symfony version to 7.2.0 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 603df6a83a..7e8b002079 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.0-BETA2'; + public const VERSION = '7.2.0-DEV'; public const VERSION_ID = 70200; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = 'BETA2'; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From 33fef24e3dc79d6d30bf4936531f2f4bd2ca189e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 13 Nov 2024 15:25:32 +0100 Subject: [PATCH 145/210] Update VERSION for 7.1.8 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 5bce80509b..41f16f410a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.8-DEV'; + public const VERSION = '7.1.8'; public const VERSION_ID = 70108; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; public const RELEASE_VERSION = 8; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From acda5338545e40e2db25a1e7447bb1175adabf7f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 13 Nov 2024 15:51:58 +0100 Subject: [PATCH 146/210] Bump Symfony version to 7.1.9 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 41f16f410a..2c464c3936 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.8'; - public const VERSION_ID = 70108; + public const VERSION = '7.1.9-DEV'; + public const VERSION_ID = 70109; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; - public const RELEASE_VERSION = 8; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 9; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From 4b68f96409285fc1fc370ed09d25dad449d78f03 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 20 Nov 2024 09:03:09 +0100 Subject: [PATCH 147/210] Bump version to 7.3 --- Kernel.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Kernel.php b/Kernel.php index 7e8b002079..ec5e3b0df3 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,15 +73,15 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.0-DEV'; - public const VERSION_ID = 70200; + public const VERSION = '7.3.0-DEV'; + public const VERSION_ID = 70300; public const MAJOR_VERSION = 7; - public const MINOR_VERSION = 2; + public const MINOR_VERSION = 3; public const RELEASE_VERSION = 0; public const EXTRA_VERSION = 'DEV'; - public const END_OF_MAINTENANCE = '07/2025'; - public const END_OF_LIFE = '07/2025'; + public const END_OF_MAINTENANCE = '05/2025'; + public const END_OF_LIFE = '01/2026'; public function __construct( protected string $environment, From 649d0e23c571344ef1153d4ffb2564f534b85a45 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 27 Nov 2024 13:55:11 +0100 Subject: [PATCH 148/210] Update VERSION for 7.1.9 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 2c464c3936..dc038b0602 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.9-DEV'; + public const VERSION = '7.1.9'; public const VERSION_ID = 70109; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; public const RELEASE_VERSION = 9; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From 451a858327c5e0490c1ded9d773876bf26255e5d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 27 Nov 2024 14:02:29 +0100 Subject: [PATCH 149/210] Bump Symfony version to 7.1.10 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index dc038b0602..1c1d8de9fe 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.9'; - public const VERSION_ID = 70109; + public const VERSION = '7.1.10-DEV'; + public const VERSION_ID = 70110; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; - public const RELEASE_VERSION = 9; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 10; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From 6b4722a25e0aed1ccb4914b9bcbd493cc4676b4d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 29 Nov 2024 09:42:40 +0100 Subject: [PATCH 150/210] Update VERSION for 7.2.0 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 7e8b002079..f37b506b22 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.0-DEV'; + public const VERSION = '7.2.0'; public const VERSION_ID = 70200; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From 133609ac5d26ed67e70fabace67054b17d702311 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 29 Nov 2024 09:45:53 +0100 Subject: [PATCH 151/210] Bump Symfony version to 7.2.1 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index f37b506b22..65162adf19 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.0'; - public const VERSION_ID = 70200; + public const VERSION = '7.2.1-DEV'; + public const VERSION_ID = 70201; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; - public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 1; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From b3aaffb5e55d24cfc6a5789d63b8d9b1050d1dee Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Thu, 5 Dec 2024 00:17:16 +0100 Subject: [PATCH 152/210] chore: fix CS --- DataCollector/ConfigDataCollector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index 747a495036..8713dcf1e5 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -57,7 +57,7 @@ public function collect(Request $request, Response $response, ?\Throwable $excep 'php_intl_locale' => class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', 'php_timezone' => date_default_timezone_get(), 'xdebug_enabled' => \extension_loaded('xdebug'), - 'xdebug_status' => \extension_loaded('xdebug') ? ($xdebugMode && $xdebugMode !== 'off' ? 'Enabled (' . $xdebugMode . ')' : 'Not enabled') : 'Not installed', + 'xdebug_status' => \extension_loaded('xdebug') ? ($xdebugMode && 'off' !== $xdebugMode ? 'Enabled (' . $xdebugMode . ')' : 'Not enabled') : 'Not installed', 'apcu_enabled' => \extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL), 'apcu_status' => \extension_loaded('apcu') ? (filter_var(\ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'Enabled' : 'Not enabled') : 'Not installed', 'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL), From a1ecd5c472717cd4fb638b6c5f0ebbceb23096ce Mon Sep 17 00:00:00 2001 From: Felix Eymonot Date: Tue, 10 Dec 2024 12:40:59 +0100 Subject: [PATCH 153/210] [HttpKernel] [MapQueryString] added key argument to MapQueryString attribute --- Attribute/MapQueryString.php | 1 + CHANGELOG.md | 5 +++++ .../RequestPayloadValueResolver.php | 2 +- .../RequestPayloadValueResolverTest.php | 21 +++++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Attribute/MapQueryString.php b/Attribute/MapQueryString.php index dfff4ddcc9..07418df85c 100644 --- a/Attribute/MapQueryString.php +++ b/Attribute/MapQueryString.php @@ -37,6 +37,7 @@ public function __construct( public readonly string|GroupSequence|array|null $validationGroups = null, string $resolver = RequestPayloadValueResolver::class, public readonly int $validationFailedStatusCode = Response::HTTP_NOT_FOUND, + public readonly ?string $key = null, ) { parent::__construct($resolver); } diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fc103b48d..501ddbe6b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +7.3 +--- + + * Add `$key` argument to `#[MapQueryString]` that allows using a specific key for argument resolving + 7.2 --- diff --git a/Controller/ArgumentResolver/RequestPayloadValueResolver.php b/Controller/ArgumentResolver/RequestPayloadValueResolver.php index 1f0ff7cc0f..2da4b43905 100644 --- a/Controller/ArgumentResolver/RequestPayloadValueResolver.php +++ b/Controller/ArgumentResolver/RequestPayloadValueResolver.php @@ -186,7 +186,7 @@ public static function getSubscribedEvents(): array private function mapQueryString(Request $request, ArgumentMetadata $argument, MapQueryString $attribute): ?object { - if (!($data = $request->query->all()) && ($argument->isNullable() || $argument->hasDefaultValue())) { + if (!($data = $request->query->all($attribute->key)) && ($argument->isNullable() || $argument->hasDefaultValue())) { return null; } diff --git a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php index 8b26767f9e..2ed2e77042 100644 --- a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php @@ -874,6 +874,27 @@ public function testBoolArgumentInJsonBody() $this->assertTrue($event->getArguments()[0]->value); } + + public function testConfigKeyForQueryString() + { + $serializer = new Serializer([new ObjectNormalizer()]); + $validator = $this->createMock(ValidatorInterface::class); + $resolver = new RequestPayloadValueResolver($serializer, $validator); + + $argument = new ArgumentMetadata('filtered', QueryPayload::class, false, false, null, false, [ + MapQueryString::class => new MapQueryString(key: 'value'), + ]); + $request = Request::create('/', Request::METHOD_GET, ['value' => ['page' => 1.0]]); + + $kernel = $this->createMock(HttpKernelInterface::class); + $arguments = $resolver->resolve($request, $argument); + $event = new ControllerArgumentsEvent($kernel, function () {}, $arguments, $request, HttpKernelInterface::MAIN_REQUEST); + + $resolver->onKernelControllerArguments($event); + + $this->assertInstanceOf(QueryPayload::class, $event->getArguments()[0]); + $this->assertSame(1.0, $event->getArguments()[0]->page); + } } class RequestPayload From d8ae58eecae44c8e66833e76cc50a4ad3c002d97 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 11 Dec 2024 13:09:10 +0100 Subject: [PATCH 154/210] Update VERSION for 7.2.1 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 65162adf19..82e6dbfbd0 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.1-DEV'; + public const VERSION = '7.2.1'; public const VERSION_ID = 70201; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; public const RELEASE_VERSION = 1; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From b2bb44a00628562710bb5922f097199f846cfe6a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 11 Dec 2024 13:15:11 +0100 Subject: [PATCH 155/210] Bump Symfony version to 7.2.2 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 82e6dbfbd0..66644f2cbc 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.1'; - public const VERSION_ID = 70201; + public const VERSION = '7.2.2-DEV'; + public const VERSION_ID = 70202; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; - public const RELEASE_VERSION = 1; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 2; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From 406c453966dc1420d8b19ff45007bac8a51d401c Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Wed, 11 Dec 2024 14:08:35 +0100 Subject: [PATCH 156/210] chore: PHP CS Fixer fixes --- DataCollector/ConfigDataCollector.php | 6 +++--- HttpCache/ResponseCacheStrategy.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index 8713dcf1e5..cc8ff3ada9 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -57,11 +57,11 @@ public function collect(Request $request, Response $response, ?\Throwable $excep 'php_intl_locale' => class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', 'php_timezone' => date_default_timezone_get(), 'xdebug_enabled' => \extension_loaded('xdebug'), - 'xdebug_status' => \extension_loaded('xdebug') ? ($xdebugMode && 'off' !== $xdebugMode ? 'Enabled (' . $xdebugMode . ')' : 'Not enabled') : 'Not installed', + 'xdebug_status' => \extension_loaded('xdebug') ? ($xdebugMode && 'off' !== $xdebugMode ? 'Enabled ('.$xdebugMode.')' : 'Not enabled') : 'Not installed', 'apcu_enabled' => \extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL), - 'apcu_status' => \extension_loaded('apcu') ? (filter_var(\ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'Enabled' : 'Not enabled') : 'Not installed', + 'apcu_status' => \extension_loaded('apcu') ? (filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) ? 'Enabled' : 'Not enabled') : 'Not installed', 'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL), - 'zend_opcache_status' => \extension_loaded('Zend OPcache') ? (filter_var(\ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) ? 'Enabled' : 'Not enabled') : 'Not installed', + 'zend_opcache_status' => \extension_loaded('Zend OPcache') ? (filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) ? 'Enabled' : 'Not enabled') : 'Not installed', 'bundles' => [], 'sapi_name' => \PHP_SAPI, ]; diff --git a/HttpCache/ResponseCacheStrategy.php b/HttpCache/ResponseCacheStrategy.php index 9176ba5881..4aba46728d 100644 --- a/HttpCache/ResponseCacheStrategy.php +++ b/HttpCache/ResponseCacheStrategy.php @@ -222,7 +222,7 @@ private function storeRelativeAgeDirective(string $directive, ?int $value, ?int } if (false !== $this->ageDirectives[$directive]) { - $value = min($value ?? PHP_INT_MAX, $expires ?? PHP_INT_MAX); + $value = min($value ?? \PHP_INT_MAX, $expires ?? \PHP_INT_MAX); $value -= $age; $this->ageDirectives[$directive] = null !== $this->ageDirectives[$directive] ? min($this->ageDirectives[$directive], $value) : $value; } From 49bce5da5a3135fca24b33fda1f8276bdcd64f1b Mon Sep 17 00:00:00 2001 From: valtzu Date: Wed, 27 Nov 2024 22:28:12 +0200 Subject: [PATCH 157/210] Generate url-safe signatures --- Tests/Fragment/EsiFragmentRendererTest.php | 4 ++-- Tests/Fragment/HIncludeFragmentRendererTest.php | 2 +- Tests/Fragment/SsiFragmentRendererTest.php | 4 ++-- composer.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Tests/Fragment/EsiFragmentRendererTest.php b/Tests/Fragment/EsiFragmentRendererTest.php index fa9885d275..6a08d7eae6 100644 --- a/Tests/Fragment/EsiFragmentRendererTest.php +++ b/Tests/Fragment/EsiFragmentRendererTest.php @@ -61,7 +61,7 @@ public function testRenderControllerReference() $altReference = new ControllerReference('alt_controller', [], []); $this->assertEquals( - '', + '', $strategy->render($reference, $request, ['alt' => $altReference])->getContent() ); } @@ -79,7 +79,7 @@ public function testRenderControllerReferenceWithAbsoluteUri() $altReference = new ControllerReference('alt_controller', [], []); $this->assertSame( - '', + '', $strategy->render($reference, $request, ['alt' => $altReference, 'absolute_uri' => true])->getContent() ); } diff --git a/Tests/Fragment/HIncludeFragmentRendererTest.php b/Tests/Fragment/HIncludeFragmentRendererTest.php index f74887ade3..82b80a86ff 100644 --- a/Tests/Fragment/HIncludeFragmentRendererTest.php +++ b/Tests/Fragment/HIncludeFragmentRendererTest.php @@ -32,7 +32,7 @@ public function testRenderWithControllerAndSigner() { $strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo')); - $this->assertEquals('', $strategy->render(new ControllerReference('main_controller', [], []), Request::create('/'))->getContent()); + $this->assertEquals('', $strategy->render(new ControllerReference('main_controller', [], []), Request::create('/'))->getContent()); } public function testRenderWithUri() diff --git a/Tests/Fragment/SsiFragmentRendererTest.php b/Tests/Fragment/SsiFragmentRendererTest.php index 4af00f9f75..0d3f1dc2d4 100644 --- a/Tests/Fragment/SsiFragmentRendererTest.php +++ b/Tests/Fragment/SsiFragmentRendererTest.php @@ -52,7 +52,7 @@ public function testRenderControllerReference() $altReference = new ControllerReference('alt_controller', [], []); $this->assertEquals( - '', + '', $strategy->render($reference, $request, ['alt' => $altReference])->getContent() ); } @@ -70,7 +70,7 @@ public function testRenderControllerReferenceWithAbsoluteUri() $altReference = new ControllerReference('alt_controller', [], []); $this->assertSame( - '', + '', $strategy->render($reference, $request, ['alt' => $altReference, 'absolute_uri' => true])->getContent() ); } diff --git a/composer.json b/composer.json index 89421417f5..e9cb077587 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "symfony/deprecation-contracts": "^2.5|^3", "symfony/error-handler": "^6.4|^7.0", "symfony/event-dispatcher": "^6.4|^7.0", - "symfony/http-foundation": "^6.4|^7.0", + "symfony/http-foundation": "^7.3", "symfony/polyfill-ctype": "^1.8", "psr/log": "^1|^2|^3" }, From f4cab1e059b6a0c67b008a81fa1822aa4ed37379 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 31 Dec 2024 15:55:36 +0100 Subject: [PATCH 158/210] Update VERSION for 7.1.10 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1c1d8de9fe..cb0acb3448 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.10-DEV'; + public const VERSION = '7.1.10'; public const VERSION_ID = 70110; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; public const RELEASE_VERSION = 10; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From a26584ff3f93f9e0d0b188852c9235e8d8fd8b94 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 31 Dec 2024 15:59:19 +0100 Subject: [PATCH 159/210] Bump Symfony version to 7.1.11 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index cb0acb3448..901d12bf3e 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.1.10'; - public const VERSION_ID = 70110; + public const VERSION = '7.1.11-DEV'; + public const VERSION_ID = 70111; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 1; - public const RELEASE_VERSION = 10; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 11; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2025'; public const END_OF_LIFE = '01/2025'; From 3c432966bd8c7ec7429663105f5a02d7e75b4306 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 31 Dec 2024 15:59:40 +0100 Subject: [PATCH 160/210] Update VERSION for 7.2.2 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 66644f2cbc..387b51c8a4 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.2-DEV'; + public const VERSION = '7.2.2'; public const VERSION_ID = 70202; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; public const RELEASE_VERSION = 2; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From 4bdb6028eb4aaab96f108346be66a651949c17b1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 31 Dec 2024 16:04:08 +0100 Subject: [PATCH 161/210] Bump Symfony version to 7.2.3 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 387b51c8a4..1471776ddc 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.2'; - public const VERSION_ID = 70202; + public const VERSION = '7.2.3-DEV'; + public const VERSION_ID = 70203; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; - public const RELEASE_VERSION = 2; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 3; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From f4a8c06e9a8b6e8a994ce4ecec9f7e334be933cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Thu, 26 Dec 2024 01:19:19 +0100 Subject: [PATCH 162/210] [Cache][HttpKernel] Add a `noStore` argument to the `#` attribute --- Attribute/Cache.php | 12 +++++ EventListener/CacheAttributeListener.php | 9 ++++ .../CacheAttributeListenerTest.php | 47 +++++++++++++++++++ 3 files changed, 68 insertions(+) diff --git a/Attribute/Cache.php b/Attribute/Cache.php index 19d13e9228..fa2401a78c 100644 --- a/Attribute/Cache.php +++ b/Attribute/Cache.php @@ -102,6 +102,18 @@ public function __construct( * It can be expressed in seconds or with a relative time format (1 day, 2 weeks, ...). */ public int|string|null $staleIfError = null, + + /** + * Add the "no-store" Cache-Control directive when set to true. + * + * This directive indicates that no part of the response can be cached + * in any cache (not in a shared cache, nor in a private cache). + * + * Supersedes the "$public" and "$smaxage" values. + * + * @see https://datatracker.ietf.org/doc/html/rfc7234#section-5.2.2.3 + */ + public ?bool $noStore = null, ) { } } diff --git a/EventListener/CacheAttributeListener.php b/EventListener/CacheAttributeListener.php index f428ea9462..e913edf9e5 100644 --- a/EventListener/CacheAttributeListener.php +++ b/EventListener/CacheAttributeListener.php @@ -163,6 +163,15 @@ public function onKernelResponse(ResponseEvent $event): void if (false === $cache->public) { $response->setPrivate(); } + + if (true === $cache->noStore) { + $response->setPrivate(); + $response->headers->addCacheControlDirective('no-store'); + } + + if (false === $cache->noStore) { + $response->headers->removeCacheControlDirective('no-store'); + } } } diff --git a/Tests/EventListener/CacheAttributeListenerTest.php b/Tests/EventListener/CacheAttributeListenerTest.php index b888579b80..b185ea8994 100644 --- a/Tests/EventListener/CacheAttributeListenerTest.php +++ b/Tests/EventListener/CacheAttributeListenerTest.php @@ -91,6 +91,50 @@ public function testResponseIsPrivateIfConfigurationIsPublicFalse() $this->assertTrue($this->response->headers->hasCacheControlDirective('private')); } + public function testResponseIsPublicIfConfigurationIsPublicTrueNoStoreFalse() + { + $request = $this->createRequest(new Cache(public: true, noStore: false)); + + $this->listener->onKernelResponse($this->createEventMock($request, $this->response)); + + $this->assertTrue($this->response->headers->hasCacheControlDirective('public')); + $this->assertFalse($this->response->headers->hasCacheControlDirective('private')); + $this->assertFalse($this->response->headers->hasCacheControlDirective('no-store')); + } + + public function testResponseIsPrivateIfConfigurationIsPublicTrueNoStoreTrue() + { + $request = $this->createRequest(new Cache(public: true, noStore: true)); + + $this->listener->onKernelResponse($this->createEventMock($request, $this->response)); + + $this->assertFalse($this->response->headers->hasCacheControlDirective('public')); + $this->assertTrue($this->response->headers->hasCacheControlDirective('private')); + $this->assertTrue($this->response->headers->hasCacheControlDirective('no-store')); + } + + public function testResponseIsPrivateNoStoreIfConfigurationIsNoStoreTrue() + { + $request = $this->createRequest(new Cache(noStore: true)); + + $this->listener->onKernelResponse($this->createEventMock($request, $this->response)); + + $this->assertFalse($this->response->headers->hasCacheControlDirective('public')); + $this->assertTrue($this->response->headers->hasCacheControlDirective('private')); + $this->assertTrue($this->response->headers->hasCacheControlDirective('no-store')); + } + + public function testResponseIsPrivateIfSharedMaxAgeSetAndNoStoreIsTrue() + { + $request = $this->createRequest(new Cache(smaxage: 1, noStore: true)); + + $this->listener->onKernelResponse($this->createEventMock($request, $this->response)); + + $this->assertFalse($this->response->headers->hasCacheControlDirective('public')); + $this->assertTrue($this->response->headers->hasCacheControlDirective('private')); + $this->assertTrue($this->response->headers->hasCacheControlDirective('no-store')); + } + public function testResponseVary() { $vary = ['foobar']; @@ -132,6 +176,7 @@ public function testAttributeConfigurationsAreSetOnResponse() $this->assertFalse($this->response->headers->hasCacheControlDirective('max-stale')); $this->assertFalse($this->response->headers->hasCacheControlDirective('stale-while-revalidate')); $this->assertFalse($this->response->headers->hasCacheControlDirective('stale-if-error')); + $this->assertFalse($this->response->headers->hasCacheControlDirective('no-store')); $this->request->attributes->set('_cache', [new Cache( expires: 'tomorrow', @@ -140,6 +185,7 @@ public function testAttributeConfigurationsAreSetOnResponse() maxStale: '5', staleWhileRevalidate: '6', staleIfError: '7', + noStore: true, )]); $this->listener->onKernelResponse($this->event); @@ -149,6 +195,7 @@ public function testAttributeConfigurationsAreSetOnResponse() $this->assertSame('5', $this->response->headers->getCacheControlDirective('max-stale')); $this->assertSame('6', $this->response->headers->getCacheControlDirective('stale-while-revalidate')); $this->assertSame('7', $this->response->headers->getCacheControlDirective('stale-if-error')); + $this->assertTrue($this->response->headers->hasCacheControlDirective('no-store')); $this->assertInstanceOf(\DateTimeInterface::class, $this->response->getExpires()); } From 9c1165cecf40349035aa5b8492caa4ccf5233973 Mon Sep 17 00:00:00 2001 From: Jan Rosier Date: Mon, 6 Jan 2025 15:35:18 +0100 Subject: [PATCH 163/210] Use spl_object_id() instead of spl_object_hash() --- DataCollector/LoggerDataCollector.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DataCollector/LoggerDataCollector.php b/DataCollector/LoggerDataCollector.php index 428d676240..29024f6e74 100644 --- a/DataCollector/LoggerDataCollector.php +++ b/DataCollector/LoggerDataCollector.php @@ -233,10 +233,10 @@ private function sanitizeLogs(array $logs): array $exception = $log['context']['exception']; if ($exception instanceof SilencedErrorContext) { - if (isset($silencedLogs[$h = spl_object_hash($exception)])) { + if (isset($silencedLogs[$id = spl_object_id($exception)])) { continue; } - $silencedLogs[$h] = true; + $silencedLogs[$id] = true; if (!isset($sanitizedLogs[$message])) { $sanitizedLogs[$message] = $log + [ @@ -312,10 +312,10 @@ private function computeErrorsCount(array $containerDeprecationLogs): array if ($this->isSilencedOrDeprecationErrorLog($log)) { $exception = $log['context']['exception']; if ($exception instanceof SilencedErrorContext) { - if (isset($silencedLogs[$h = spl_object_hash($exception)])) { + if (isset($silencedLogs[$id = spl_object_id($exception)])) { continue; } - $silencedLogs[$h] = true; + $silencedLogs[$id] = true; $count['scream_count'] += $exception->count; } else { ++$count['deprecation_count']; From eb0e7ae3cffc41d41fc9705c35366e8aac763d95 Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Fri, 10 Jan 2025 15:17:09 +0100 Subject: [PATCH 164/210] chore: PHP CS Fixer fixes --- .../ArgumentResolver/RequestPayloadValueResolverTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php index 649a7dc87e..77cf7d9c58 100644 --- a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php @@ -420,7 +420,7 @@ public function testQueryStringParameterTypeMismatch() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); @@ -514,7 +514,7 @@ public function testRequestInputTypeMismatch() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); From caae9807f8e25a9b43ce8cc6fafab6cf91f0cc9b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 29 Jan 2025 08:40:13 +0100 Subject: [PATCH 165/210] Update VERSION for 7.2.3 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1471776ddc..4b6ecb68d8 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.3-DEV'; + public const VERSION = '7.2.3'; public const VERSION_ID = 70203; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; public const RELEASE_VERSION = 3; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From 7b2f5402eba26ed96ad1f1ae07afd118c7fa115c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 29 Jan 2025 08:46:06 +0100 Subject: [PATCH 166/210] Bump Symfony version to 7.2.4 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 4b6ecb68d8..d6cd83a211 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.3'; - public const VERSION_ID = 70203; + public const VERSION = '7.2.4-DEV'; + public const VERSION_ID = 70204; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; - public const RELEASE_VERSION = 3; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 4; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From dc54eb349f6b261db71cb6d5bddf6ca4241deef9 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 15 Jan 2025 18:41:27 +0100 Subject: [PATCH 167/210] [HttpKernel] Improve MapQueryParameter handling of options --- Attribute/MapQueryParameter.php | 6 ++--- .../QueryParameterValueResolver.php | 2 +- .../QueryParameterValueResolverTest.php | 22 +++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Attribute/MapQueryParameter.php b/Attribute/MapQueryParameter.php index ec9bf57726..486813a820 100644 --- a/Attribute/MapQueryParameter.php +++ b/Attribute/MapQueryParameter.php @@ -28,9 +28,9 @@ final class MapQueryParameter extends ValueResolver * @see https://php.net/manual/filter.constants for filter, flags and options * * @param string|null $name The name of the query parameter; if null, the name of the argument in the controller will be used - * @param (FILTER_VALIDATE_*)|(FILTER_SANITIZE_*)|null $filter The filter to pass to "filter_var()" - * @param int-mask-of<(FILTER_FLAG_*)|FILTER_NULL_ON_FAILURE> $flags The flags to pass to "filter_var()" - * @param array $options The options to pass to "filter_var()" + * @param (FILTER_VALIDATE_*)|(FILTER_SANITIZE_*)|null $filter The filter to pass to "filter_var()", deduced from the type-hint if null + * @param int-mask-of<(FILTER_FLAG_*)|FILTER_NULL_ON_FAILURE> $flags + * @param array{min_range?: int|float, max_range?: int|float, regexp?: string, ...} $options * @param class-string|string $resolver The name of the resolver to use */ public function __construct( diff --git a/Controller/ArgumentResolver/QueryParameterValueResolver.php b/Controller/ArgumentResolver/QueryParameterValueResolver.php index 8ceaba6da4..1566119dfd 100644 --- a/Controller/ArgumentResolver/QueryParameterValueResolver.php +++ b/Controller/ArgumentResolver/QueryParameterValueResolver.php @@ -76,7 +76,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array $enumType = null; $filter = match ($type) { 'array' => \FILTER_DEFAULT, - 'string' => \FILTER_DEFAULT, + 'string' => isset($attribute->options['regexp']) ? \FILTER_VALIDATE_REGEXP : \FILTER_DEFAULT, 'int' => \FILTER_VALIDATE_INT, 'float' => \FILTER_VALIDATE_FLOAT, 'bool' => \FILTER_VALIDATE_BOOL, diff --git a/Tests/Controller/ArgumentResolver/QueryParameterValueResolverTest.php b/Tests/Controller/ArgumentResolver/QueryParameterValueResolverTest.php index 43161d1a10..194cfd2e52 100644 --- a/Tests/Controller/ArgumentResolver/QueryParameterValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/QueryParameterValueResolverTest.php @@ -108,50 +108,50 @@ public static function validDataProvider(): iterable yield 'parameter found and string with regexp filter that matches' => [ Request::create('/', 'GET', ['firstName' => 'John']), - new ArgumentMetadata('firstName', 'string', false, false, false, attributes: [new MapQueryParameter(filter: \FILTER_VALIDATE_REGEXP, flags: \FILTER_NULL_ON_FAILURE, options: ['regexp' => '/John/'])]), + new ArgumentMetadata('firstName', 'string', false, false, false, attributes: [new MapQueryParameter(options: ['regexp' => '/John/'])]), ['John'], ]; yield 'parameter found and string with regexp filter that falls back to null on failure' => [ Request::create('/', 'GET', ['firstName' => 'Fabien']), - new ArgumentMetadata('firstName', 'string', false, false, false, attributes: [new MapQueryParameter(filter: \FILTER_VALIDATE_REGEXP, flags: \FILTER_NULL_ON_FAILURE, options: ['regexp' => '/John/'])]), + new ArgumentMetadata('firstName', 'string', false, false, false, attributes: [new MapQueryParameter(flags: \FILTER_NULL_ON_FAILURE, options: ['regexp' => '/John/'])]), [null], ]; yield 'parameter found and string variadic with regexp filter that matches' => [ Request::create('/', 'GET', ['firstName' => ['John', 'John']]), - new ArgumentMetadata('firstName', 'string', true, false, false, attributes: [new MapQueryParameter(filter: \FILTER_VALIDATE_REGEXP, flags: \FILTER_NULL_ON_FAILURE, options: ['regexp' => '/John/'])]), + new ArgumentMetadata('firstName', 'string', true, false, false, attributes: [new MapQueryParameter(options: ['regexp' => '/John/'])]), ['John', 'John'], ]; yield 'parameter found and string variadic with regexp filter that falls back to null on failure' => [ Request::create('/', 'GET', ['firstName' => ['John', 'Fabien']]), - new ArgumentMetadata('firstName', 'string', true, false, false, attributes: [new MapQueryParameter(filter: \FILTER_VALIDATE_REGEXP, flags: \FILTER_NULL_ON_FAILURE, options: ['regexp' => '/John/'])]), + new ArgumentMetadata('firstName', 'string', true, false, false, attributes: [new MapQueryParameter(flags: \FILTER_NULL_ON_FAILURE, options: ['regexp' => '/John/'])]), ['John'], ]; yield 'parameter found and integer' => [ - Request::create('/', 'GET', ['age' => 123]), + Request::create('/', 'GET', ['age' => '123']), new ArgumentMetadata('age', 'int', false, false, false, attributes: [new MapQueryParameter()]), [123], ]; yield 'parameter found and integer variadic' => [ - Request::create('/', 'GET', ['age' => [123, 222]]), + Request::create('/', 'GET', ['age' => ['123', '222']]), new ArgumentMetadata('age', 'int', true, false, false, attributes: [new MapQueryParameter()]), [123, 222], ]; yield 'parameter found and float' => [ - Request::create('/', 'GET', ['price' => 10.99]), + Request::create('/', 'GET', ['price' => '10.99']), new ArgumentMetadata('price', 'float', false, false, false, attributes: [new MapQueryParameter()]), [10.99], ]; yield 'parameter found and float variadic' => [ - Request::create('/', 'GET', ['price' => [10.99, 5.99]]), + Request::create('/', 'GET', ['price' => ['10.99e2', '5.99']]), new ArgumentMetadata('price', 'float', true, false, false, attributes: [new MapQueryParameter()]), - [10.99, 5.99], + [1099.0, 5.99], ]; yield 'parameter found and boolean yes' => [ @@ -209,7 +209,7 @@ public static function validDataProvider(): iterable ]; yield 'parameter found and backing type variadic and at least one backing value not int nor string that fallbacks to null on failure' => [ - Request::create('/', 'GET', ['suits' => [1, 'D']]), + Request::create('/', 'GET', ['suits' => ['1', 'D']]), new ArgumentMetadata('suits', Suit::class, false, false, false, attributes: [new MapQueryParameter(flags: \FILTER_NULL_ON_FAILURE)]), [null], ]; @@ -265,7 +265,7 @@ public static function invalidArgumentTypeProvider(): iterable public static function invalidOrMissingArgumentProvider(): iterable { yield 'parameter found and array variadic with parameter not array failure' => [ - Request::create('/', 'GET', ['ids' => [['1', '2'], 1]]), + Request::create('/', 'GET', ['ids' => [['1', '2'], '1']]), new ArgumentMetadata('ids', 'array', true, false, false, attributes: [new MapQueryParameter()]), new NotFoundHttpException('Invalid query parameter "ids".'), ]; From cb1eeade523fd4daae0b053678bca1361b4465e3 Mon Sep 17 00:00:00 2001 From: seb-jean Date: Wed, 30 Oct 2024 14:27:35 +0100 Subject: [PATCH 168/210] [HttpKernel] Support `Uid` in `#[MapQueryParameter]` --- CHANGELOG.md | 1 + .../QueryParameterValueResolver.php | 14 +++++++++++++- .../QueryParameterValueResolverTest.php | 13 ++++++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 501ddbe6b7..cc9da8a2a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG --- * Add `$key` argument to `#[MapQueryString]` that allows using a specific key for argument resolving + * Support `Uid` in `#[MapQueryParameter]` 7.2 --- diff --git a/Controller/ArgumentResolver/QueryParameterValueResolver.php b/Controller/ArgumentResolver/QueryParameterValueResolver.php index 1566119dfd..5fe3d75313 100644 --- a/Controller/ArgumentResolver/QueryParameterValueResolver.php +++ b/Controller/ArgumentResolver/QueryParameterValueResolver.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; use Symfony\Component\HttpKernel\Exception\HttpException; +use Symfony\Component\Uid\AbstractUid; /** * Resolve arguments of type: array, string, int, float, bool, \BackedEnum from query parameters. @@ -73,6 +74,12 @@ public function resolve(Request $request, ArgumentMetadata $argument): array $options['flags'] |= \FILTER_REQUIRE_SCALAR; } + $uidType = null; + if (is_subclass_of($type, AbstractUid::class)) { + $uidType = $type; + $type = 'uid'; + } + $enumType = null; $filter = match ($type) { 'array' => \FILTER_DEFAULT, @@ -80,10 +87,11 @@ public function resolve(Request $request, ArgumentMetadata $argument): array 'int' => \FILTER_VALIDATE_INT, 'float' => \FILTER_VALIDATE_FLOAT, 'bool' => \FILTER_VALIDATE_BOOL, + 'uid' => \FILTER_DEFAULT, default => match ($enumType = is_subclass_of($type, \BackedEnum::class) ? (new \ReflectionEnum($type))->getBackingType()->getName() : null) { 'int' => \FILTER_VALIDATE_INT, 'string' => \FILTER_DEFAULT, - default => throw new \LogicException(\sprintf('#[MapQueryParameter] cannot be used on controller argument "%s$%s" of type "%s"; one of array, string, int, float, bool or \BackedEnum should be used.', $argument->isVariadic() ? '...' : '', $argument->getName(), $type ?? 'mixed')), + default => throw new \LogicException(\sprintf('#[MapQueryParameter] cannot be used on controller argument "%s$%s" of type "%s"; one of array, string, int, float, bool, uid or \BackedEnum should be used.', $argument->isVariadic() ? '...' : '', $argument->getName(), $type ?? 'mixed')), }, }; @@ -105,6 +113,10 @@ public function resolve(Request $request, ArgumentMetadata $argument): array $value = \is_array($value) ? array_map($enumFrom, $value) : $enumFrom($value); } + if (null !== $uidType) { + $value = \is_array($value) ? array_map([$uidType, 'fromString'], $value) : $uidType::fromString($value); + } + if (null === $value && !($attribute->flags & \FILTER_NULL_ON_FAILURE)) { throw HttpException::fromStatusCode($validationFailedCode, \sprintf('Invalid query parameter "%s".', $name)); } diff --git a/Tests/Controller/ArgumentResolver/QueryParameterValueResolverTest.php b/Tests/Controller/ArgumentResolver/QueryParameterValueResolverTest.php index 194cfd2e52..2b887db821 100644 --- a/Tests/Controller/ArgumentResolver/QueryParameterValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/QueryParameterValueResolverTest.php @@ -22,6 +22,7 @@ use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Tests\Fixtures\Suit; +use Symfony\Component\Uid\Ulid; class QueryParameterValueResolverTest extends TestCase { @@ -44,7 +45,7 @@ public function testSkipWhenNoAttribute() */ public function testResolvingSuccessfully(Request $request, ArgumentMetadata $metadata, array $expected) { - $this->assertSame($expected, $this->resolver->resolve($request, $metadata)); + $this->assertEquals($expected, $this->resolver->resolve($request, $metadata)); } /** @@ -231,6 +232,12 @@ public static function validDataProvider(): iterable new ArgumentMetadata('firstName', 'string', false, true, false, attributes: [new MapQueryParameter()]), [], ]; + + yield 'parameter found and ULID' => [ + Request::create('/', 'GET', ['groupId' => '01E439TP9XJZ9RPFH3T1PYBCR8']), + new ArgumentMetadata('groupId', Ulid::class, false, true, false, attributes: [new MapQueryParameter()]), + [Ulid::fromString('01E439TP9XJZ9RPFH3T1PYBCR8')], + ]; } /** @@ -245,13 +252,13 @@ public static function invalidArgumentTypeProvider(): iterable yield 'unsupported type' => [ Request::create('/', 'GET', ['standardClass' => 'test']), new ArgumentMetadata('standardClass', \stdClass::class, false, false, false, attributes: [new MapQueryParameter()]), - '#[MapQueryParameter] cannot be used on controller argument "$standardClass" of type "stdClass"; one of array, string, int, float, bool or \BackedEnum should be used.', + '#[MapQueryParameter] cannot be used on controller argument "$standardClass" of type "stdClass"; one of array, string, int, float, bool, uid or \BackedEnum should be used.', ]; yield 'unsupported type variadic' => [ Request::create('/', 'GET', ['standardClass' => 'test']), new ArgumentMetadata('standardClass', \stdClass::class, true, false, false, attributes: [new MapQueryParameter()]), - '#[MapQueryParameter] cannot be used on controller argument "...$standardClass" of type "stdClass"; one of array, string, int, float, bool or \BackedEnum should be used.', + '#[MapQueryParameter] cannot be used on controller argument "...$standardClass" of type "stdClass"; one of array, string, int, float, bool, uid or \BackedEnum should be used.', ]; } From 9f1103734c5789798fefb90e91de4586039003ed Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 26 Feb 2025 12:01:22 +0100 Subject: [PATCH 169/210] Update VERSION for 7.2.4 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index d6cd83a211..ead55c9272 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.4-DEV'; + public const VERSION = '7.2.4'; public const VERSION_ID = 70204; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; public const RELEASE_VERSION = 4; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From d329d462e983ea097a6210fb327c1c5169a5db66 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 26 Feb 2025 12:06:00 +0100 Subject: [PATCH 170/210] Bump Symfony version to 7.2.5 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index ead55c9272..b1ce3cddc8 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.4'; - public const VERSION_ID = 70204; + public const VERSION = '7.2.5-DEV'; + public const VERSION_ID = 70205; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; - public const RELEASE_VERSION = 4; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 5; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From 6feb9cf0d7ef1b7e01dadfd6c9ee5925eff57b7d Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 2 Mar 2025 16:03:52 +0100 Subject: [PATCH 171/210] replace assertEmpty() with stricter assertions --- .../TraceableValueResolverTest.php | 2 +- .../UploadedFileValueResolverTest.php | 2 +- Tests/DataCollector/DumpDataCollectorTest.php | 6 ++--- .../AddAnnotatedClassesToCachePassTest.php | 22 +++++++++---------- ...sterControllerArgumentLocatorsPassTest.php | 6 ++--- Tests/EventListener/SessionListenerTest.php | 8 +++---- Tests/Fragment/InlineFragmentRendererTest.php | 2 +- Tests/HttpCache/HttpCacheTest.php | 12 +++++----- Tests/HttpCache/StoreTest.php | 10 ++++----- Tests/Profiler/FileProfilerStorageTest.php | 2 +- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Tests/Controller/ArgumentResolver/TraceableValueResolverTest.php b/Tests/Controller/ArgumentResolver/TraceableValueResolverTest.php index 5ede33ccb3..cf4e837f73 100644 --- a/Tests/Controller/ArgumentResolver/TraceableValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/TraceableValueResolverTest.php @@ -32,7 +32,7 @@ public function testTimingsInResolve() foreach ($iterable as $index => $resolved) { $event = $stopwatch->getEvent(ResolverStub::class.'::resolve'); $this->assertTrue($event->isStarted()); - $this->assertEmpty($event->getPeriods()); + $this->assertSame([], $event->getPeriods()); switch ($index) { case 0: $this->assertEquals('first', $resolved); diff --git a/Tests/Controller/ArgumentResolver/UploadedFileValueResolverTest.php b/Tests/Controller/ArgumentResolver/UploadedFileValueResolverTest.php index 5eb0d32483..11ab6f36a1 100644 --- a/Tests/Controller/ArgumentResolver/UploadedFileValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/UploadedFileValueResolverTest.php @@ -85,7 +85,7 @@ static function () {}, $resolver->onKernelControllerArguments($event); $data = $event->getArguments()[0]; - $this->assertEmpty($data); + $this->assertSame([], $data); } /** diff --git a/Tests/DataCollector/DumpDataCollectorTest.php b/Tests/DataCollector/DumpDataCollectorTest.php index e55af09fe5..11e1bc2e6c 100644 --- a/Tests/DataCollector/DumpDataCollectorTest.php +++ b/Tests/DataCollector/DumpDataCollectorTest.php @@ -79,7 +79,7 @@ public function testDumpWithServerConnection() // Collect doesn't re-trigger dump ob_start(); $collector->collect(new Request(), new Response()); - $this->assertEmpty(ob_get_clean()); + $this->assertSame('', ob_get_clean()); $this->assertStringMatchesFormat('%a;a:%d:{i:0;a:6:{s:4:"data";%c:39:"Symfony\Component\VarDumper\Cloner\Data":%a', serialize($collector)); } @@ -157,7 +157,7 @@ public function testFlushNothingWhenDataDumperIsProvided() ob_start(); $collector->__destruct(); - $this->assertEmpty(ob_get_clean()); + $this->assertSame('', ob_get_clean()); } public function testNullContentTypeWithNoDebugEnv() @@ -175,6 +175,6 @@ public function testNullContentTypeWithNoDebugEnv() ob_start(); $collector->__destruct(); - $this->assertEmpty(ob_get_clean()); + $this->assertSame('', ob_get_clean()); } } diff --git a/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php b/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php index 387a5108ec..e57c349609 100644 --- a/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php +++ b/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php @@ -36,33 +36,33 @@ public function testExpandClasses() $this->assertSame('Foo\\Bar', $expand(['Foo\\'], ['\\Foo\\Bar'])[0]); $this->assertSame('Foo\\Bar\\Acme', $expand(['Foo\\'], ['\\Foo\\Bar\\Acme'])[0]); - $this->assertEmpty($expand(['Foo\\'], ['\\Foo'])); + $this->assertSame([], $expand(['Foo\\'], ['\\Foo'])); $this->assertSame('Acme\\Foo\\Bar', $expand(['**\\Foo\\'], ['\\Acme\\Foo\\Bar'])[0]); - $this->assertEmpty($expand(['**\\Foo\\'], ['\\Foo\\Bar'])); - $this->assertEmpty($expand(['**\\Foo\\'], ['\\Acme\\Foo'])); - $this->assertEmpty($expand(['**\\Foo\\'], ['\\Foo'])); + $this->assertSame([], $expand(['**\\Foo\\'], ['\\Foo\\Bar'])); + $this->assertSame([], $expand(['**\\Foo\\'], ['\\Acme\\Foo'])); + $this->assertSame([], $expand(['**\\Foo\\'], ['\\Foo'])); $this->assertSame('Acme\\Foo', $expand(['**\\Foo'], ['\\Acme\\Foo'])[0]); - $this->assertEmpty($expand(['**\\Foo'], ['\\Acme\\Foo\\AcmeBundle'])); - $this->assertEmpty($expand(['**\\Foo'], ['\\Acme\\FooBar\\AcmeBundle'])); + $this->assertSame([], $expand(['**\\Foo'], ['\\Acme\\Foo\\AcmeBundle'])); + $this->assertSame([], $expand(['**\\Foo'], ['\\Acme\\FooBar\\AcmeBundle'])); $this->assertSame('Foo\\Acme\\Bar', $expand(['Foo\\*\\Bar'], ['\\Foo\\Acme\\Bar'])[0]); - $this->assertEmpty($expand(['Foo\\*\\Bar'], ['\\Foo\\Acme\\Bundle\\Bar'])); + $this->assertSame([], $expand(['Foo\\*\\Bar'], ['\\Foo\\Acme\\Bundle\\Bar'])); $this->assertSame('Foo\\Acme\\Bar', $expand(['Foo\\**\\Bar'], ['\\Foo\\Acme\\Bar'])[0]); $this->assertSame('Foo\\Acme\\Bundle\\Bar', $expand(['Foo\\**\\Bar'], ['\\Foo\\Acme\\Bundle\\Bar'])[0]); $this->assertSame('Acme\\Bar', $expand(['*\\Bar'], ['\\Acme\\Bar'])[0]); - $this->assertEmpty($expand(['*\\Bar'], ['\\Bar'])); - $this->assertEmpty($expand(['*\\Bar'], ['\\Foo\\Acme\\Bar'])); + $this->assertSame([], $expand(['*\\Bar'], ['\\Bar'])); + $this->assertSame([], $expand(['*\\Bar'], ['\\Foo\\Acme\\Bar'])); $this->assertSame('Foo\\Acme\\Bar', $expand(['**\\Bar'], ['\\Foo\\Acme\\Bar'])[0]); $this->assertSame('Foo\\Acme\\Bundle\\Bar', $expand(['**\\Bar'], ['\\Foo\\Acme\\Bundle\\Bar'])[0]); - $this->assertEmpty($expand(['**\\Bar'], ['\\Bar'])); + $this->assertSame([], $expand(['**\\Bar'], ['\\Bar'])); $this->assertSame('Foo\\Bar', $expand(['Foo\\*'], ['\\Foo\\Bar'])[0]); - $this->assertEmpty($expand(['Foo\\*'], ['\\Foo\\Acme\\Bar'])); + $this->assertSame([], $expand(['Foo\\*'], ['\\Foo\\Acme\\Bar'])); $this->assertSame('Foo\\Bar', $expand(['Foo\\**'], ['\\Foo\\Bar'])[0]); $this->assertSame('Foo\\Acme\\Bar', $expand(['Foo\\**'], ['\\Foo\\Acme\\Bar'])[0]); diff --git a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index 02b5df6512..03aef073d0 100644 --- a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -277,7 +277,7 @@ public function testArgumentWithNoTypeHintIsOk() $pass->process($container); $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - $this->assertEmpty(array_keys($locator)); + $this->assertSame([], array_keys($locator)); } public function testControllersAreMadePublic() @@ -440,7 +440,7 @@ public function testEnumArgumentIsIgnored() $pass->process($container); $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - $this->assertEmpty(array_keys($locator), 'enum typed argument is ignored'); + $this->assertSame([], array_keys($locator), 'enum typed argument is ignored'); } public function testBindWithTarget() @@ -480,7 +480,7 @@ public function testResponseArgumentIsIgnored() (new RegisterControllerArgumentLocatorsPass())->process($container); $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - $this->assertEmpty(array_keys($locator), 'Response typed argument is ignored'); + $this->assertSame([], array_keys($locator), 'Response typed argument is ignored'); } public function testAutowireAttribute() diff --git a/Tests/EventListener/SessionListenerTest.php b/Tests/EventListener/SessionListenerTest.php index 2aa5d622e2..deba6661f0 100644 --- a/Tests/EventListener/SessionListenerTest.php +++ b/Tests/EventListener/SessionListenerTest.php @@ -896,8 +896,8 @@ public function testReset() (new SessionListener($container, true))->reset(); - $this->assertEmpty($_SESSION); - $this->assertEmpty(session_id()); + $this->assertSame([], $_SESSION); + $this->assertSame('', session_id()); $this->assertSame(\PHP_SESSION_NONE, session_status()); } @@ -917,8 +917,8 @@ public function testResetUnclosedSession() (new SessionListener($container, true))->reset(); - $this->assertEmpty($_SESSION); - $this->assertEmpty(session_id()); + $this->assertSame([], $_SESSION); + $this->assertSame('', session_id()); $this->assertSame(\PHP_SESSION_NONE, session_status()); } diff --git a/Tests/Fragment/InlineFragmentRendererTest.php b/Tests/Fragment/InlineFragmentRendererTest.php index 2d492c5359..8266458fd6 100644 --- a/Tests/Fragment/InlineFragmentRendererTest.php +++ b/Tests/Fragment/InlineFragmentRendererTest.php @@ -97,7 +97,7 @@ public function testRenderExceptionIgnoreErrors() $strategy = new InlineFragmentRenderer($kernel, $dispatcher); - $this->assertEmpty($strategy->render('/', $request, ['ignore_errors' => true])->getContent()); + $this->assertSame('', $strategy->render('/', $request, ['ignore_errors' => true])->getContent()); } public function testRenderExceptionIgnoreErrorsWithAlt() diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index 0a9e548990..e82e8fd81b 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -195,7 +195,7 @@ public function testRespondsWith304WhenIfModifiedSinceMatchesLastModified() $this->assertHttpKernelIsCalled(); $this->assertEquals(304, $this->response->getStatusCode()); $this->assertEquals('', $this->response->headers->get('Content-Type')); - $this->assertEmpty($this->response->getContent()); + $this->assertSame('', $this->response->getContent()); $this->assertTraceContains('miss'); $this->assertTraceContains('store'); } @@ -209,7 +209,7 @@ public function testRespondsWith304WhenIfNoneMatchMatchesETag() $this->assertEquals(304, $this->response->getStatusCode()); $this->assertEquals('', $this->response->headers->get('Content-Type')); $this->assertTrue($this->response->headers->has('ETag')); - $this->assertEmpty($this->response->getContent()); + $this->assertSame('', $this->response->getContent()); $this->assertTraceContains('miss'); $this->assertTraceContains('store'); } @@ -1281,7 +1281,7 @@ public function testEsiCacheSendsTheLowestTtlForHeadRequests() $this->request('HEAD', '/', [], [], true); - $this->assertEmpty($this->response->getContent()); + $this->assertSame('', $this->response->getContent()); $this->assertEquals(100, $this->response->getTtl()); } @@ -1510,7 +1510,7 @@ public function testEsiCacheForceValidationForHeadRequests() // The response has been assembled from expiration and validation based resources // This can neither be cached nor revalidated, so it should be private/no cache - $this->assertEmpty($this->response->getContent()); + $this->assertSame('', $this->response->getContent()); $this->assertNull($this->response->getTtl()); $this->assertTrue($this->response->headers->hasCacheControlDirective('private')); $this->assertTrue($this->response->headers->hasCacheControlDirective('no-cache')); @@ -1568,7 +1568,7 @@ public function testEsiRecalculateContentLengthHeaderForHeadRequest() // in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD // method, the size of the entity-body that would have been sent had the request // been a GET." - $this->assertEmpty($this->response->getContent()); + $this->assertSame('', $this->response->getContent()); $this->assertEquals(12, $this->response->headers->get('Content-Length')); } @@ -1692,7 +1692,7 @@ public function testEsiCacheRemoveValidationHeadersIfEmbeddedResponsesAndHeadReq $this->setNextResponses($responses); $this->request('HEAD', '/', [], [], true); - $this->assertEmpty($this->response->getContent()); + $this->assertSame('', $this->response->getContent()); $this->assertNull($this->response->getETag()); $this->assertNull($this->response->getLastModified()); } diff --git a/Tests/HttpCache/StoreTest.php b/Tests/HttpCache/StoreTest.php index 8c41ac5986..a24aa95c87 100644 --- a/Tests/HttpCache/StoreTest.php +++ b/Tests/HttpCache/StoreTest.php @@ -40,7 +40,7 @@ protected function tearDown(): void public function testReadsAnEmptyArrayWithReadWhenNothingCachedAtKey() { - $this->assertEmpty($this->getStoreMetadata('/nothing')); + $this->assertSame([], $this->getStoreMetadata('/nothing')); } public function testUnlockFileThatDoesExist() @@ -65,7 +65,7 @@ public function testRemovesEntriesForKeyWithPurge() $this->assertNotEmpty($metadata); $this->assertTrue($this->store->purge('/foo')); - $this->assertEmpty($this->getStoreMetadata($request)); + $this->assertSame([], $this->getStoreMetadata($request)); // cached content should be kept after purging $path = $this->store->getPath($metadata[0][1]['x-content-digest'][0]); @@ -291,7 +291,7 @@ public function testPurgeHttps() $this->assertNotEmpty($this->getStoreMetadata($request)); $this->assertTrue($this->store->purge('https://example.com/foo')); - $this->assertEmpty($this->getStoreMetadata($request)); + $this->assertSame([], $this->getStoreMetadata($request)); } public function testPurgeHttpAndHttps() @@ -306,8 +306,8 @@ public function testPurgeHttpAndHttps() $this->assertNotEmpty($this->getStoreMetadata($requestHttps)); $this->assertTrue($this->store->purge('http://example.com/foo')); - $this->assertEmpty($this->getStoreMetadata($requestHttp)); - $this->assertEmpty($this->getStoreMetadata($requestHttps)); + $this->assertSame([], $this->getStoreMetadata($requestHttp)); + $this->assertSame([], $this->getStoreMetadata($requestHttps)); } public function testDoesNotStorePrivateHeaders() diff --git a/Tests/Profiler/FileProfilerStorageTest.php b/Tests/Profiler/FileProfilerStorageTest.php index d191ff074e..eb8f99c806 100644 --- a/Tests/Profiler/FileProfilerStorageTest.php +++ b/Tests/Profiler/FileProfilerStorageTest.php @@ -292,7 +292,7 @@ public function testPurge() $this->storage->purge(); - $this->assertEmpty($this->storage->read('token'), '->purge() removes all data stored by profiler'); + $this->assertNull($this->storage->read('token'), '->purge() removes all data stored by profiler'); $this->assertCount(0, $this->storage->find('127.0.0.1', '', 10, 'GET'), '->purge() removes all items from index'); } From 1b5ec906db2d2feebc3c7846a2ce549854314a60 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 15 Mar 2025 14:10:48 +0100 Subject: [PATCH 172/210] Various cleanups --- DependencyInjection/ServicesResetter.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/DependencyInjection/ServicesResetter.php b/DependencyInjection/ServicesResetter.php index 7636e52a18..c2a19d992f 100644 --- a/DependencyInjection/ServicesResetter.php +++ b/DependencyInjection/ServicesResetter.php @@ -46,6 +46,10 @@ public function reset(): void 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; From 2ec3b84cd88992214f379059b03625ac1efbc90c Mon Sep 17 00:00:00 2001 From: Pierre Ambroise Date: Wed, 19 Mar 2025 09:22:52 +0100 Subject: [PATCH 173/210] Open doc in new page in default page --- Resources/welcome.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/welcome.html.php b/Resources/welcome.html.php index 810c71f988..549c4ff192 100644 --- a/Resources/welcome.html.php +++ b/Resources/welcome.html.php @@ -265,7 +265,7 @@ Next Step - Create your first page + Create your first page to replace this placeholder page.

From 84b25e32c3872d70c92fcb848b35800df2c8052d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Fri, 21 Mar 2025 13:14:10 +0100 Subject: [PATCH 174/210] [FrameworkBundle] Add alias `ServicesResetter` for `services_resetter` service --- CHANGELOG.md | 1 + DependencyInjection/ServicesResetter.php | 3 +-- .../ServicesResetterInterface.php | 21 +++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 DependencyInjection/ServicesResetterInterface.php diff --git a/CHANGELOG.md b/CHANGELOG.md index cc9da8a2a9..1d533c29f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ CHANGELOG * Add `$key` argument to `#[MapQueryString]` that allows using a specific key for argument resolving * Support `Uid` in `#[MapQueryParameter]` + * Add `ServicesResetterInterface`, implemented by `ServicesResetter` 7.2 --- diff --git a/DependencyInjection/ServicesResetter.php b/DependencyInjection/ServicesResetter.php index c2a19d992f..57e394fcc5 100644 --- a/DependencyInjection/ServicesResetter.php +++ b/DependencyInjection/ServicesResetter.php @@ -13,7 +13,6 @@ use ProxyManager\Proxy\LazyLoadingInterface; use Symfony\Component\VarExporter\LazyObjectInterface; -use Symfony\Contracts\Service\ResetInterface; /** * Resets provided services. @@ -23,7 +22,7 @@ * * @final since Symfony 7.2 */ -class ServicesResetter implements ResetInterface +class ServicesResetter implements ServicesResetterInterface { /** * @param \Traversable $resettableServices diff --git a/DependencyInjection/ServicesResetterInterface.php b/DependencyInjection/ServicesResetterInterface.php new file mode 100644 index 0000000000..88fba821db --- /dev/null +++ b/DependencyInjection/ServicesResetterInterface.php @@ -0,0 +1,21 @@ + + * + * 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 +{ +} From d71f6c83a7d35a72397ab7fbdfdc5aad22635de7 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 28 Feb 2025 22:27:11 +0100 Subject: [PATCH 175/210] [VarExporter] Leverage native lazy objects --- Tests/Fixtures/LazyResettableService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Fixtures/LazyResettableService.php b/Tests/Fixtures/LazyResettableService.php index 543cf0d953..1b66415c4b 100644 --- a/Tests/Fixtures/LazyResettableService.php +++ b/Tests/Fixtures/LazyResettableService.php @@ -11,7 +11,7 @@ namespace Symfony\Component\HttpKernel\Tests\Fixtures; -class LazyResettableService +class LazyResettableService extends \stdClass { public static $counter = 0; From aa58e4994cea483bd1c2166817ae9b11c77236a1 Mon Sep 17 00:00:00 2001 From: eltharin Date: Mon, 3 Mar 2025 21:12:56 +0100 Subject: [PATCH 176/210] [Routing] Add alias in `{foo:bar}` syntax in route parameter --- EventListener/RouterListener.php | 9 ++++- Tests/EventListener/RouterListenerTest.php | 44 ++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/EventListener/RouterListener.php b/EventListener/RouterListener.php index fb4bd60bc3..dd6f5bb214 100644 --- a/EventListener/RouterListener.php +++ b/EventListener/RouterListener.php @@ -117,7 +117,14 @@ public function onKernelRequest(RequestEvent $event): void $attributes = []; foreach ($parameters as $parameter => $value) { - $attribute = $mapping[$parameter] ?? $parameter; + if (!isset($mapping[$parameter])) { + $attribute = $parameter; + } elseif (\is_array($mapping[$parameter])) { + [$attribute, $parameter] = $mapping[$parameter]; + $mappedAttributes[$attribute] = ''; + } else { + $attribute = $mapping[$parameter]; + } if (!isset($mappedAttributes[$attribute])) { $attributes[$attribute] = $value; diff --git a/Tests/EventListener/RouterListenerTest.php b/Tests/EventListener/RouterListenerTest.php index d13093db0c..ca7bb1b1f6 100644 --- a/Tests/EventListener/RouterListenerTest.php +++ b/Tests/EventListener/RouterListenerTest.php @@ -323,5 +323,49 @@ public static function provideRouteMapping(): iterable ], ], ]; + + yield [ + [ + 'conference' => ['slug' => 'vienna-2024'], + ], + [ + 'slug' => 'vienna-2024', + '_route_mapping' => [ + 'slug' => [ + 'conference', + 'slug', + ], + ], + ], + ]; + + yield [ + [ + 'article' => [ + 'id' => 'abc123', + 'date' => '2024-04-24', + 'slug' => 'symfony-rocks', + ], + ], + [ + 'id' => 'abc123', + 'date' => '2024-04-24', + 'slug' => 'symfony-rocks', + '_route_mapping' => [ + 'id' => [ + 'article', + 'id' + ], + 'date' => [ + 'article', + 'date', + ], + 'slug' => [ + 'article', + 'slug', + ], + ], + ], + ]; } } From 5e575fbdc09d69e68bb8fd8dd4bde2eab5737c86 Mon Sep 17 00:00:00 2001 From: Arkalo2 <24898676+Arkalo2@users.noreply.github.com> Date: Sat, 22 Mar 2025 19:57:41 +0100 Subject: [PATCH 177/210] [FrameworkBundle][HttpKernel] Allow configuring the logging channel per type of exceptions --- CHANGELOG.md | 3 +- EventListener/ErrorListener.php | 38 +++++++++++---- Tests/EventListener/ErrorListenerTest.php | 57 +++++++++++++++++++++++ 3 files changed, 89 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d533c29f5..6bf1a60ebc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ CHANGELOG * Add `$key` argument to `#[MapQueryString]` that allows using a specific key for argument resolving * Support `Uid` in `#[MapQueryParameter]` * Add `ServicesResetterInterface`, implemented by `ServicesResetter` - + * Allow configuring the logging channel per type of exceptions in ErrorListener + 7.2 --- diff --git a/EventListener/ErrorListener.php b/EventListener/ErrorListener.php index c677958cde..18e8bff441 100644 --- a/EventListener/ErrorListener.php +++ b/EventListener/ErrorListener.php @@ -34,13 +34,14 @@ class ErrorListener implements EventSubscriberInterface { /** - * @param array|null}> $exceptionsMapping + * @param array|null, log_channel: string|null}> $exceptionsMapping */ public function __construct( protected string|object|array|null $controller, protected ?LoggerInterface $logger = null, protected bool $debug = false, protected array $exceptionsMapping = [], + protected array $loggers = [], ) { } @@ -48,6 +49,7 @@ public function logKernelException(ExceptionEvent $event): void { $throwable = $event->getThrowable(); $logLevel = $this->resolveLogLevel($throwable); + $logChannel = $this->resolveLogChannel($throwable); foreach ($this->exceptionsMapping as $class => $config) { if (!$throwable instanceof $class || !$config['status_code']) { @@ -69,7 +71,7 @@ public function logKernelException(ExceptionEvent $event): void $e = FlattenException::createFromThrowable($throwable); - $this->logException($throwable, \sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), basename($e->getFile()), $e->getLine()), $logLevel); + $this->logException($throwable, \sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), basename($e->getFile()), $e->getLine()), $logLevel, $logChannel); } public function onKernelException(ExceptionEvent $event): void @@ -159,16 +161,20 @@ public static function getSubscribedEvents(): array /** * Logs an exception. + * + * @param ?string $logChannel */ - protected function logException(\Throwable $exception, string $message, ?string $logLevel = null): void + protected function logException(\Throwable $exception, string $message, ?string $logLevel = null, /* ?string $logChannel = null */): void { - if (null === $this->logger) { + $logChannel = (3 < \func_num_args() ? \func_get_arg(3) : null) ?? $this->resolveLogChannel($exception); + + $logLevel ??= $this->resolveLogLevel($exception); + + if(!$logger = $this->getLogger($logChannel)) { return; } - $logLevel ??= $this->resolveLogLevel($exception); - - $this->logger->log($logLevel, $message, ['exception' => $exception]); + $logger->log($logLevel, $message, ['exception' => $exception]); } /** @@ -193,6 +199,17 @@ private function resolveLogLevel(\Throwable $throwable): string return LogLevel::ERROR; } + private function resolveLogChannel(\Throwable $throwable): ?string + { + foreach ($this->exceptionsMapping as $class => $config) { + if ($throwable instanceof $class && isset($config['log_channel'])) { + return $config['log_channel']; + } + } + + return null; + } + /** * Clones the request for the exception. */ @@ -201,7 +218,7 @@ protected function duplicateRequest(\Throwable $exception, Request $request): Re $attributes = [ '_controller' => $this->controller, 'exception' => $exception, - 'logger' => DebugLoggerConfigurator::getDebugLogger($this->logger), + 'logger' => DebugLoggerConfigurator::getDebugLogger($this->getLogger($exception)), ]; $request = $request->duplicate(null, null, $attributes); $request->setMethod('GET'); @@ -249,4 +266,9 @@ private function getInheritedAttribute(string $class, string $attribute): ?objec return $attributeReflector?->newInstance(); } + + private function getLogger(?string $logChannel): ?LoggerInterface + { + return $logChannel ? $this->loggers[$logChannel] ?? $this->logger : $this->logger; + } } diff --git a/Tests/EventListener/ErrorListenerTest.php b/Tests/EventListener/ErrorListenerTest.php index 2e1f7d58b7..7fdda59635 100644 --- a/Tests/EventListener/ErrorListenerTest.php +++ b/Tests/EventListener/ErrorListenerTest.php @@ -143,6 +143,63 @@ public function testHandleWithLogLevelAttribute() $this->assertCount(1, $logger->getLogsForLevel('warning')); } + public function testHandleWithLogChannel() + { + $request = new Request(); + $event = new ExceptionEvent(new TestKernel(), $request, HttpKernelInterface::MAIN_REQUEST, new \RuntimeException('bar')); + + $defaultLogger = new TestLogger(); + $channelLoger = new TestLogger(); + + $l = new ErrorListener('not used', $defaultLogger, false, [ + \RuntimeException::class => [ + 'log_level' => 'warning', + 'status_code' => 401, + 'log_channel' => 'channel', + ], + \Exception::class => [ + 'log_level' => 'error', + 'status_code' => 402, + ], + ], ['channel' => $channelLoger]); + + $l->logKernelException($event); + $l->onKernelException($event); + + $this->assertCount(0, $defaultLogger->getLogsForLevel('error')); + $this->assertCount(0, $defaultLogger->getLogsForLevel('warning')); + $this->assertCount(0, $channelLoger->getLogsForLevel('error')); + $this->assertCount(1, $channelLoger->getLogsForLevel('warning')); + } + + public function testHandleWithLoggerChannelNotUsed() + { + $request = new Request(); + $event = new ExceptionEvent(new TestKernel(), $request, HttpKernelInterface::MAIN_REQUEST, new \RuntimeException('bar')); + $defaultLogger = new TestLogger(); + $channelLoger = new TestLogger(); + $l = new ErrorListener('not used', $defaultLogger, false, [ + \RuntimeException::class => [ + 'log_level' => 'warning', + 'status_code' => 401, + ], + \ErrorException::class => [ + 'log_level' => 'error', + 'status_code' => 402, + 'log_channel' => 'channel', + ], + ], ['channel' => $channelLoger]); + $l->logKernelException($event); + $l->onKernelException($event); + + $this->assertSame(0, $defaultLogger->countErrors()); + $this->assertCount(0, $defaultLogger->getLogsForLevel('critical')); + $this->assertCount(1, $defaultLogger->getLogsForLevel('warning')); + $this->assertCount(0, $channelLoger->getLogsForLevel('warning')); + $this->assertCount(0, $channelLoger->getLogsForLevel('error')); + $this->assertCount(0, $channelLoger->getLogsForLevel('critical')); + } + public function testHandleClassImplementingInterfaceWithLogLevelAttribute() { $request = new Request(); From b1fe91bc1fa454a806d3f98db4ba826eb9941a54 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Mar 2025 14:32:50 +0100 Subject: [PATCH 178/210] Update VERSION for 7.2.5 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 6583072274..d2e1eda84c 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.5-DEV'; + public const VERSION = '7.2.5'; public const VERSION_ID = 70205; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; public const RELEASE_VERSION = 5; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From edea8d1f4404e9b54d1adcafe13c25053f1868b7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Mar 2025 14:38:46 +0100 Subject: [PATCH 179/210] Bump Symfony version to 7.2.6 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index d2e1eda84c..79b84228d2 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.5'; - public const VERSION_ID = 70205; + public const VERSION = '7.2.6-DEV'; + public const VERSION_ID = 70206; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; - public const RELEASE_VERSION = 5; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 6; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From 5617b2e23c0196df04476290921ab4b70c106bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Fri, 28 Mar 2025 18:29:28 +0100 Subject: [PATCH 180/210] Remove always-true condition Introduced in symfony/symfony#45657 symfony/dependency-injection 6.4+ is required, so the class always exists --- .../RegisterControllerArgumentLocatorsPass.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index d473a2e6b0..a5fa06f17b 100644 --- a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -51,8 +51,6 @@ public function process(ContainerBuilder $container): void } } - $emptyAutowireAttributes = class_exists(Autowire::class) ? null : []; - foreach ($container->findTaggedServiceIds('controller.service_arguments', true) as $id => $tags) { $def = $container->getDefinition($id); $def->setPublic(true); @@ -129,7 +127,7 @@ public function process(ContainerBuilder $container): void /** @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; @@ -155,7 +153,7 @@ public function process(ContainerBuilder $container): void $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)) { // do not attempt to register enum typed arguments if not already present in bindings From 610f13eca95059fb0af6eb164b4cf7ca6e980778 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 18 Apr 2025 14:51:48 +0200 Subject: [PATCH 181/210] Don't enable tracing unless the profiler is enabled --- Debug/TraceableEventDispatcher.php | 6 ++++++ Profiler/ProfilerStateChecker.php | 33 ++++++++++++++++++++++++++++++ composer.json | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Profiler/ProfilerStateChecker.php diff --git a/Debug/TraceableEventDispatcher.php b/Debug/TraceableEventDispatcher.php index beca6bfb14..915862eddb 100644 --- a/Debug/TraceableEventDispatcher.php +++ b/Debug/TraceableEventDispatcher.php @@ -25,6 +25,9 @@ class TraceableEventDispatcher extends BaseTraceableEventDispatcher { protected function beforeDispatch(string $eventName, object $event): void { + if ($this->disabled?->__invoke()) { + return; + } switch ($eventName) { case KernelEvents::REQUEST: $event->getRequest()->attributes->set('_stopwatch_token', bin2hex(random_bytes(3))); @@ -57,6 +60,9 @@ protected function beforeDispatch(string $eventName, object $event): void protected function afterDispatch(string $eventName, object $event): void { + if ($this->disabled?->__invoke()) { + return; + } switch ($eventName) { case KernelEvents::CONTROLLER_ARGUMENTS: $this->stopwatch->start('controller', 'section'); diff --git a/Profiler/ProfilerStateChecker.php b/Profiler/ProfilerStateChecker.php new file mode 100644 index 0000000000..56cb4e3cc5 --- /dev/null +++ b/Profiler/ProfilerStateChecker.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Profiler; + +use Psr\Container\ContainerInterface; + +class ProfilerStateChecker +{ + public function __construct( + private ContainerInterface $container, + private bool $defaultEnabled, + ) { + } + + public function isProfilerEnabled(): bool + { + return $this->container->get('profiler')?->isEnabled() ?? $this->defaultEnabled; + } + + public function isProfilerDisabled(): bool + { + return !$this->isProfilerEnabled(); + } +} diff --git a/composer.json b/composer.json index e9cb077587..bb9f4ba617 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": ">=8.2", "symfony/deprecation-contracts": "^2.5|^3", "symfony/error-handler": "^6.4|^7.0", - "symfony/event-dispatcher": "^6.4|^7.0", + "symfony/event-dispatcher": "^7.3", "symfony/http-foundation": "^7.3", "symfony/polyfill-ctype": "^1.8", "psr/log": "^1|^2|^3" From f9dec01e6094a063e738f8945ef69c0cfcf792ec Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 2 May 2025 11:04:03 +0200 Subject: [PATCH 182/210] Update VERSION for 7.2.6 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 79b84228d2..12f65d3a89 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.6-DEV'; + public const VERSION = '7.2.6'; public const VERSION_ID = 70206; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; public const RELEASE_VERSION = 6; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From e1052a3522099db45b528870d95fcff054e8d2f7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 2 May 2025 11:13:32 +0200 Subject: [PATCH 183/210] Bump Symfony version to 7.2.7 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 12f65d3a89..39964de474 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.6'; - public const VERSION_ID = 70206; + public const VERSION = '7.2.7-DEV'; + public const VERSION_ID = 70207; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; - public const RELEASE_VERSION = 6; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 7; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From 8ff29094f0fe007ae73534950cf4f694955ad224 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 10 May 2025 14:09:33 +0200 Subject: [PATCH 184/210] Update VERSION for 7.3.0-BETA2 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index b5a41236d1..d09c86966d 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.3.0-DEV'; + public const VERSION = '7.3.0-BETA2'; public const VERSION_ID = 70300; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 3; public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = 'BETA2'; public const END_OF_MAINTENANCE = '05/2025'; public const END_OF_LIFE = '01/2026'; From 85ad11b3df4f1d292d074b81d50c9ac79e79ec7b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 10 May 2025 14:15:19 +0200 Subject: [PATCH 185/210] Bump Symfony version to 7.3.0 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index d09c86966d..b5a41236d1 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.3.0-BETA2'; + public const VERSION = '7.3.0-DEV'; public const VERSION_ID = 70300; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 3; public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = 'BETA2'; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '05/2025'; public const END_OF_LIFE = '01/2026'; From b4d1f001bddcb11662794f5d5247639f5a51ce33 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 25 May 2025 22:29:38 +0200 Subject: [PATCH 186/210] Update VERSION for 7.3.0-RC1 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index b5a41236d1..566e721bf3 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.3.0-DEV'; + public const VERSION = '7.3.0-RC1'; public const VERSION_ID = 70300; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 3; public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = 'RC1'; public const END_OF_MAINTENANCE = '05/2025'; public const END_OF_LIFE = '01/2026'; From 410a7f16a68b6cb19c18d21effc380292526d7a4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 25 May 2025 23:07:09 +0200 Subject: [PATCH 187/210] Bump Symfony version to 7.3.0 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 566e721bf3..b5a41236d1 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.3.0-RC1'; + public const VERSION = '7.3.0-DEV'; public const VERSION_ID = 70300; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 3; public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = 'RC1'; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '05/2025'; public const END_OF_LIFE = '01/2026'; From 242e4b5c4283c97a941dc4251c358f6041e8e7a3 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 29 May 2025 09:34:10 +0200 Subject: [PATCH 188/210] Bump Symfony version to 6.4.23 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index bd75891730..91c143f342 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.4.22'; - public const VERSION_ID = 60422; + public const VERSION = '6.4.23-DEV'; + public const VERSION_ID = 60423; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 22; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 23; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2026'; public const END_OF_LIFE = '11/2027'; From 4523deb9efb3c5033d84ea664a0da8341d3a4596 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 29 May 2025 09:35:19 +0200 Subject: [PATCH 189/210] Update VERSION for 7.2.7 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 39964de474..09b362c1ff 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.7-DEV'; + public const VERSION = '7.2.7'; public const VERSION_ID = 70207; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; public const RELEASE_VERSION = 7; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From 36cae1393be89e4d520541cb84325459d6c3b598 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 29 May 2025 09:38:07 +0200 Subject: [PATCH 190/210] Bump Symfony version to 7.2.8 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 09b362c1ff..8948fc7533 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.7'; - public const VERSION_ID = 70207; + public const VERSION = '7.2.8-DEV'; + public const VERSION_ID = 70208; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; - public const RELEASE_VERSION = 7; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 8; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From ac7b8e163e8c83dce3abcc055a502d4486051a9f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 29 May 2025 09:47:32 +0200 Subject: [PATCH 191/210] Update VERSION for 7.3.0 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index b5a41236d1..bfef40fac5 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.3.0-DEV'; + public const VERSION = '7.3.0'; public const VERSION_ID = 70300; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 3; public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '05/2025'; public const END_OF_LIFE = '01/2026'; From a73edfc38d6bdc779c8c60f57c5a3ed79706eb84 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 29 May 2025 09:51:04 +0200 Subject: [PATCH 192/210] Bump Symfony version to 7.3.1 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index bfef40fac5..dfee565d06 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.3.0'; - public const VERSION_ID = 70300; + public const VERSION = '7.3.1-DEV'; + public const VERSION_ID = 70301; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 3; - public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 1; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '05/2025'; public const END_OF_LIFE = '01/2026'; From 003a7facfa510e8e68fc62e55615d3f3fc35ee1d Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Wed, 28 May 2025 09:33:08 +0200 Subject: [PATCH 193/210] [HttpKernel] Do not superseed private cache-control when no-store is set --- EventListener/CacheAttributeListener.php | 1 - Tests/EventListener/CacheAttributeListenerTest.php | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/EventListener/CacheAttributeListener.php b/EventListener/CacheAttributeListener.php index e913edf9e5..436e031bbb 100644 --- a/EventListener/CacheAttributeListener.php +++ b/EventListener/CacheAttributeListener.php @@ -165,7 +165,6 @@ public function onKernelResponse(ResponseEvent $event): void } if (true === $cache->noStore) { - $response->setPrivate(); $response->headers->addCacheControlDirective('no-store'); } diff --git a/Tests/EventListener/CacheAttributeListenerTest.php b/Tests/EventListener/CacheAttributeListenerTest.php index b185ea8994..d2c8ed0db6 100644 --- a/Tests/EventListener/CacheAttributeListenerTest.php +++ b/Tests/EventListener/CacheAttributeListenerTest.php @@ -102,18 +102,18 @@ public function testResponseIsPublicIfConfigurationIsPublicTrueNoStoreFalse() $this->assertFalse($this->response->headers->hasCacheControlDirective('no-store')); } - public function testResponseIsPrivateIfConfigurationIsPublicTrueNoStoreTrue() + public function testResponseKeepPublicIfConfigurationIsPublicTrueNoStoreTrue() { $request = $this->createRequest(new Cache(public: true, noStore: true)); $this->listener->onKernelResponse($this->createEventMock($request, $this->response)); - $this->assertFalse($this->response->headers->hasCacheControlDirective('public')); - $this->assertTrue($this->response->headers->hasCacheControlDirective('private')); + $this->assertTrue($this->response->headers->hasCacheControlDirective('public')); + $this->assertFalse($this->response->headers->hasCacheControlDirective('private')); $this->assertTrue($this->response->headers->hasCacheControlDirective('no-store')); } - public function testResponseIsPrivateNoStoreIfConfigurationIsNoStoreTrue() + public function testResponseKeepPrivateNoStoreIfConfigurationIsNoStoreTrue() { $request = $this->createRequest(new Cache(noStore: true)); @@ -124,14 +124,14 @@ public function testResponseIsPrivateNoStoreIfConfigurationIsNoStoreTrue() $this->assertTrue($this->response->headers->hasCacheControlDirective('no-store')); } - public function testResponseIsPrivateIfSharedMaxAgeSetAndNoStoreIsTrue() + public function testResponseIsPublicIfSharedMaxAgeSetAndNoStoreIsTrue() { $request = $this->createRequest(new Cache(smaxage: 1, noStore: true)); $this->listener->onKernelResponse($this->createEventMock($request, $this->response)); - $this->assertFalse($this->response->headers->hasCacheControlDirective('public')); - $this->assertTrue($this->response->headers->hasCacheControlDirective('private')); + $this->assertTrue($this->response->headers->hasCacheControlDirective('public')); + $this->assertFalse($this->response->headers->hasCacheControlDirective('private')); $this->assertTrue($this->response->headers->hasCacheControlDirective('no-store')); } From 059b29f20366d8ed04acd22271c9949052fd2dd1 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 31 May 2025 13:46:05 +0200 Subject: [PATCH 194/210] [HttpKernel] Fix Symfony 7.3 end of maintenance date --- Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel.php b/Kernel.php index dfee565d06..10e2512cc0 100644 --- a/Kernel.php +++ b/Kernel.php @@ -80,7 +80,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl public const RELEASE_VERSION = 1; public const EXTRA_VERSION = 'DEV'; - public const END_OF_MAINTENANCE = '05/2025'; + public const END_OF_MAINTENANCE = '01/2026'; public const END_OF_LIFE = '01/2026'; public function __construct( From 0b4ef6a6145d510d9a428e0a61021e4548feaf82 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 1 Jun 2025 22:50:36 +0200 Subject: [PATCH 195/210] pass log level instead of exception to resolve the logger --- EventListener/ErrorListener.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/EventListener/ErrorListener.php b/EventListener/ErrorListener.php index 18e8bff441..2599b27de0 100644 --- a/EventListener/ErrorListener.php +++ b/EventListener/ErrorListener.php @@ -161,15 +161,15 @@ public static function getSubscribedEvents(): array /** * Logs an exception. - * + * * @param ?string $logChannel */ protected function logException(\Throwable $exception, string $message, ?string $logLevel = null, /* ?string $logChannel = null */): void { $logChannel = (3 < \func_num_args() ? \func_get_arg(3) : null) ?? $this->resolveLogChannel($exception); - + $logLevel ??= $this->resolveLogLevel($exception); - + if(!$logger = $this->getLogger($logChannel)) { return; } @@ -218,7 +218,7 @@ protected function duplicateRequest(\Throwable $exception, Request $request): Re $attributes = [ '_controller' => $this->controller, 'exception' => $exception, - 'logger' => DebugLoggerConfigurator::getDebugLogger($this->getLogger($exception)), + 'logger' => DebugLoggerConfigurator::getDebugLogger($this->getLogger($this->resolveLogChannel($exception))), ]; $request = $request->duplicate(null, null, $attributes); $request->setMethod('GET'); From 58a0b41ed17607521e009817db1ab593b2836b66 Mon Sep 17 00:00:00 2001 From: Santiago San Martin Date: Mon, 19 May 2025 20:36:58 -0300 Subject: [PATCH 196/210] [HttpKernel] Fix `#[MapUploadedFile]` handling for optional file uploads --- .../RequestPayloadValueResolver.php | 6 +- .../UploadedFileValueResolverTest.php | 60 +++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/Controller/ArgumentResolver/RequestPayloadValueResolver.php b/Controller/ArgumentResolver/RequestPayloadValueResolver.php index a196250e8b..3a10c9d9c7 100644 --- a/Controller/ArgumentResolver/RequestPayloadValueResolver.php +++ b/Controller/ArgumentResolver/RequestPayloadValueResolver.php @@ -232,6 +232,10 @@ private function mapRequestPayload(Request $request, ArgumentMetadata $argument, private function mapUploadedFile(Request $request, ArgumentMetadata $argument, MapUploadedFile $attribute): UploadedFile|array|null { - return $request->files->get($attribute->name ?? $argument->getName(), []); + if (!($files = $request->files->get($attribute->name ?? $argument->getName(), [])) && ($argument->isNullable() || $argument->hasDefaultValue())) { + return null; + } + + return $files; } } diff --git a/Tests/Controller/ArgumentResolver/UploadedFileValueResolverTest.php b/Tests/Controller/ArgumentResolver/UploadedFileValueResolverTest.php index 5eb0d32483..479fbf1808 100644 --- a/Tests/Controller/ArgumentResolver/UploadedFileValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/UploadedFileValueResolverTest.php @@ -307,6 +307,66 @@ static function () {}, $resolver->onKernelControllerArguments($event); } + /** + * @dataProvider provideContext + */ + public function testShouldAllowEmptyWhenNullable(RequestPayloadValueResolver $resolver, Request $request) + { + $attribute = new MapUploadedFile(); + $argument = new ArgumentMetadata( + 'qux', + UploadedFile::class, + false, + false, + null, + true, + [$attribute::class => $attribute] + ); + /** @var HttpKernelInterface&MockObject $httpKernel */ + $httpKernel = $this->createMock(HttpKernelInterface::class); + $event = new ControllerArgumentsEvent( + $httpKernel, + static function () {}, + $resolver->resolve($request, $argument), + $request, + HttpKernelInterface::MAIN_REQUEST + ); + $resolver->onKernelControllerArguments($event); + $data = $event->getArguments()[0]; + + $this->assertNull($data); + } + + /** + * @dataProvider provideContext + */ + public function testShouldAllowEmptyWhenHasDefaultValue(RequestPayloadValueResolver $resolver, Request $request) + { + $attribute = new MapUploadedFile(); + $argument = new ArgumentMetadata( + 'qux', + UploadedFile::class, + false, + true, + 'default-value', + false, + [$attribute::class => $attribute] + ); + /** @var HttpKernelInterface&MockObject $httpKernel */ + $httpKernel = $this->createMock(HttpKernelInterface::class); + $event = new ControllerArgumentsEvent( + $httpKernel, + static function () {}, + $resolver->resolve($request, $argument), + $request, + HttpKernelInterface::MAIN_REQUEST + ); + $resolver->onKernelControllerArguments($event); + $data = $event->getArguments()[0]; + + $this->assertSame('default-value', $data); + } + public static function provideContext(): iterable { $resolver = new RequestPayloadValueResolver( From 9e9c725272b51aaddb863dcd59ca3ab4070a6df3 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 21 May 2025 14:18:44 +0200 Subject: [PATCH 197/210] [HttpCache] Hit the backend only once after waiting for the cache lock --- HttpCache/CacheWasLockedException.php | 19 +++++++++ HttpCache/HttpCache.php | 18 ++++---- Tests/HttpCache/HttpCacheTest.php | 60 +++++++++++++++++++++++++++ Tests/HttpCache/HttpCacheTestCase.php | 11 ++++- 4 files changed, 96 insertions(+), 12 deletions(-) create mode 100644 HttpCache/CacheWasLockedException.php diff --git a/HttpCache/CacheWasLockedException.php b/HttpCache/CacheWasLockedException.php new file mode 100644 index 0000000000..f13946ad71 --- /dev/null +++ b/HttpCache/CacheWasLockedException.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\HttpCache; + +/** + * @internal + */ +class CacheWasLockedException extends \Exception +{ +} diff --git a/HttpCache/HttpCache.php b/HttpCache/HttpCache.php index 3b484e5c3e..bce0e99b5e 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -219,7 +219,13 @@ public function handle(Request $request, int $type = HttpKernelInterface::MAIN_R $this->record($request, 'reload'); $response = $this->fetch($request, $catch); } else { - $response = $this->lookup($request, $catch); + $response = null; + do { + try { + $response = $this->lookup($request, $catch); + } catch (CacheWasLockedException) { + } + } while (null === $response); } $this->restoreResponseBody($request, $response); @@ -576,15 +582,7 @@ protected function lock(Request $request, Response $entry): bool // wait for the lock to be released if ($this->waitForLock($request)) { - // replace the current entry with the fresh one - $new = $this->lookup($request); - $entry->headers = $new->headers; - $entry->setContent($new->getContent()); - $entry->setStatusCode($new->getStatusCode()); - $entry->setProtocolVersion($new->getProtocolVersion()); - foreach ($new->headers->getCookies() as $cookie) { - $entry->headers->setCookie($cookie); - } + throw new CacheWasLockedException(); // unwind back to handle(), try again } else { // backend is slow as hell, send a 503 response (to avoid the dog pile effect) $entry->setStatusCode(503); diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index a72c08b872..39f00a0139 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -18,6 +18,7 @@ use Symfony\Component\HttpKernel\Event\TerminateEvent; use Symfony\Component\HttpKernel\HttpCache\Esi; use Symfony\Component\HttpKernel\HttpCache\HttpCache; +use Symfony\Component\HttpKernel\HttpCache\Store; use Symfony\Component\HttpKernel\HttpCache\StoreInterface; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Kernel; @@ -717,6 +718,7 @@ public function testDegradationWhenCacheLocked() */ sleep(10); + $this->store = $this->createStore(); // create another store instance that does not hold the current lock $this->request('GET', '/'); $this->assertHttpKernelIsNotCalled(); $this->assertEquals(200, $this->response->getStatusCode()); @@ -735,6 +737,64 @@ public function testDegradationWhenCacheLocked() $this->assertEquals('Old response', $this->response->getContent()); } + public function testHitBackendOnlyOnceWhenCacheWasLocked() + { + // Disable stale-while-revalidate, it circumvents waiting for the lock + $this->cacheConfig['stale_while_revalidate'] = 0; + + $this->setNextResponses([ + [ + 'status' => 200, + 'body' => 'initial response', + 'headers' => [ + 'Cache-Control' => 'public, no-cache', + 'Last-Modified' => 'some while ago', + ], + ], + [ + 'status' => 304, + 'body' => '', + 'headers' => [ + 'Cache-Control' => 'public, no-cache', + 'Last-Modified' => 'some while ago', + ], + ], + [ + 'status' => 500, + 'body' => 'The backend should not be called twice during revalidation', + 'headers' => [], + ], + ]); + + $this->request('GET', '/'); // warm the cache + + // Use a store that simulates a cache entry being locked upon first attempt + $this->store = new class(sys_get_temp_dir() . '/http_cache') extends Store { + private bool $hasLock = false; + + public function lock(Request $request): bool + { + $hasLock = $this->hasLock; + $this->hasLock = true; + + return $hasLock; + } + + public function isLocked(Request $request): bool + { + return false; + } + }; + + $this->request('GET', '/'); // hit the cache with simulated lock/concurrency block + + $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertEquals('initial response', $this->response->getContent()); + + $traces = $this->cache->getTraces(); + $this->assertSame(['stale', 'valid', 'store'], current($traces)); + } + public function testHitsCachedResponseWithSMaxAgeDirective() { $time = \DateTimeImmutable::createFromFormat('U', time() - 5); diff --git a/Tests/HttpCache/HttpCacheTestCase.php b/Tests/HttpCache/HttpCacheTestCase.php index 26a29f16b2..88f6bed56f 100644 --- a/Tests/HttpCache/HttpCacheTestCase.php +++ b/Tests/HttpCache/HttpCacheTestCase.php @@ -30,7 +30,7 @@ abstract class HttpCacheTestCase extends TestCase protected $responses; protected $catch; protected $esi; - protected Store $store; + protected ?Store $store = null; protected function setUp(): void { @@ -115,7 +115,9 @@ public function request($method, $uri = '/', $server = [], $cookies = [], $esi = $this->kernel->reset(); - $this->store = new Store(sys_get_temp_dir().'/http_cache'); + if (! $this->store) { + $this->store = $this->createStore(); + } if (!isset($this->cacheConfig['debug'])) { $this->cacheConfig['debug'] = true; @@ -183,4 +185,9 @@ public static function clearDirectory($directory) closedir($fp); } + + protected function createStore(): Store + { + return new Store(sys_get_temp_dir() . '/http_cache'); + } } From 2bb2cba685aabd859f22cf6946554e8e7f3c329a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 Jun 2025 10:14:51 +0200 Subject: [PATCH 198/210] Update VERSION for 6.4.23 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 91c143f342..04f788167c 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.4.23-DEV'; + public const VERSION = '6.4.23'; public const VERSION_ID = 60423; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 23; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2026'; public const END_OF_LIFE = '11/2027'; From 54e84316f07afdfdf6c43677da76bc3a445a0b86 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 Jun 2025 10:19:39 +0200 Subject: [PATCH 199/210] Bump Symfony version to 6.4.24 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 04f788167c..761461f616 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.4.23'; - public const VERSION_ID = 60423; + public const VERSION = '6.4.24-DEV'; + public const VERSION_ID = 60424; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 23; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 24; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2026'; public const END_OF_LIFE = '11/2027'; From 3f461ff845e4529e0fa14f9639a7b6898367aa34 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 Jun 2025 10:20:39 +0200 Subject: [PATCH 200/210] Update VERSION for 7.2.8 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 8948fc7533..12ec6da633 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.8-DEV'; + public const VERSION = '7.2.8'; public const VERSION_ID = 70208; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; public const RELEASE_VERSION = 8; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From 2a5fa0e3df2402e22ead00d4cdb0dd443d4f80f4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 Jun 2025 10:23:57 +0200 Subject: [PATCH 201/210] Bump Symfony version to 7.2.9 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 12ec6da633..5013a64f76 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.2.8'; - public const VERSION_ID = 70208; + public const VERSION = '7.2.9-DEV'; + public const VERSION_ID = 70209; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 2; - public const RELEASE_VERSION = 8; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 9; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '07/2025'; public const END_OF_LIFE = '07/2025'; From 1644879a66e4aa29c36fe33dfa6c54b450ce1831 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 Jun 2025 10:24:55 +0200 Subject: [PATCH 202/210] Update VERSION for 7.3.1 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 10e2512cc0..4829bfb7de 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.3.1-DEV'; + public const VERSION = '7.3.1'; public const VERSION_ID = 70301; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 3; public const RELEASE_VERSION = 1; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2026'; public const END_OF_LIFE = '01/2026'; From ab1f64e4bf0eeafb927e7ad6f9de4b0be3f3966e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 Jun 2025 10:29:55 +0200 Subject: [PATCH 203/210] Bump Symfony version to 7.3.2 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 4829bfb7de..7bc59a9e68 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.3.1'; - public const VERSION_ID = 70301; + public const VERSION = '7.3.2-DEV'; + public const VERSION_ID = 70302; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 3; - public const RELEASE_VERSION = 1; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 2; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2026'; public const END_OF_LIFE = '01/2026'; From 63f320d6a15f23be309c7ec4b72bb89794cfa727 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 10 Jul 2025 09:12:18 +0200 Subject: [PATCH 204/210] CS fixes --- Attribute/WithLogLevel.php | 2 +- Bundle/Bundle.php | 4 +-- CacheClearer/Psr6CacheClearer.php | 4 +-- CacheWarmer/CacheWarmer.php | 2 +- CacheWarmer/CacheWarmerAggregate.php | 4 +-- Controller/ArgumentResolver.php | 8 +++--- .../BackedEnumValueResolver.php | 4 +-- .../DateTimeValueResolver.php | 2 +- .../NotTaggedControllerValueResolver.php | 4 +-- .../QueryParameterValueResolver.php | 12 ++++---- .../RequestPayloadValueResolver.php | 12 ++++---- .../ArgumentResolver/ServiceValueResolver.php | 4 +-- .../ArgumentResolver/UidValueResolver.php | 2 +- .../VariadicValueResolver.php | 2 +- Controller/ContainerControllerResolver.php | 6 ++-- Controller/ControllerResolver.php | 28 +++++++++---------- ControllerMetadata/ArgumentMetadata.php | 2 +- DataCollector/ConfigDataCollector.php | 2 +- DataCollector/DumpDataCollector.php | 6 ++-- DataCollector/RequestDataCollector.php | 2 +- DependencyInjection/FragmentRendererPass.php | 4 +-- ...RegisterControllerArgumentLocatorsPass.php | 12 ++++---- ...oveEmptyControllerArgumentLocatorsPass.php | 4 +-- DependencyInjection/ResettableServicePass.php | 2 +- EventListener/ErrorListener.php | 4 +-- EventListener/RouterListener.php | 6 ++-- Exception/ResolverNotFoundException.php | 2 +- Fragment/FragmentHandler.php | 4 +-- Fragment/FragmentUriGenerator.php | 2 +- Fragment/HIncludeFragmentRenderer.php | 4 +-- HttpCache/AbstractSurrogate.php | 18 ++++++------ HttpCache/Esi.php | 6 ++-- HttpCache/HttpCache.php | 2 +- HttpCache/ResponseCacheStrategy.php | 4 +-- HttpCache/Ssi.php | 2 +- HttpCache/Store.php | 2 +- HttpCache/SubRequestHandler.php | 6 ++-- HttpClientKernel.php | 2 +- HttpKernel.php | 16 +++++------ Kernel.php | 22 +++++++-------- Log/Logger.php | 8 +++--- Profiler/FileProfilerStorage.php | 6 ++-- Profiler/Profile.php | 2 +- Profiler/Profiler.php | 2 +- .../RequestPayloadValueResolverTest.php | 28 +++++++++---------- Tests/Controller/ArgumentResolverTest.php | 4 +-- .../TraceableArgumentResolverTest.php | 2 +- .../TraceableControllerResolverTest.php | 2 +- .../DataCollector/ConfigDataCollectorTest.php | 4 +-- .../RequestDataCollectorTest.php | 8 +++--- ...sterControllerArgumentLocatorsPassTest.php | 2 +- .../CacheAttributeListenerTest.php | 2 +- Tests/EventListener/SessionListenerTest.php | 2 +- Tests/HttpCache/HttpCacheTest.php | 8 +++--- Tests/HttpCache/HttpCacheTestCase.php | 4 +-- Tests/HttpCache/ResponseCacheStrategyTest.php | 6 ++-- Tests/KernelTest.php | 6 ++-- 57 files changed, 166 insertions(+), 166 deletions(-) diff --git a/Attribute/WithLogLevel.php b/Attribute/WithLogLevel.php index 762b077043..10ed3b8eaa 100644 --- a/Attribute/WithLogLevel.php +++ b/Attribute/WithLogLevel.php @@ -25,7 +25,7 @@ final class WithLogLevel public function __construct(public readonly string $level) { if (!\defined('Psr\Log\LogLevel::'.strtoupper($this->level))) { - throw new \InvalidArgumentException(sprintf('Invalid log level "%s".', $this->level)); + throw new \InvalidArgumentException(\sprintf('Invalid log level "%s".', $this->level)); } } } diff --git a/Bundle/Bundle.php b/Bundle/Bundle.php index 09a19c480c..0efc21a5e0 100644 --- a/Bundle/Bundle.php +++ b/Bundle/Bundle.php @@ -70,7 +70,7 @@ public function getContainerExtension(): ?ExtensionInterface if (null !== $extension) { if (!$extension instanceof ExtensionInterface) { - throw new \LogicException(sprintf('Extension "%s" must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', get_debug_type($extension))); + throw new \LogicException(\sprintf('Extension "%s" must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', get_debug_type($extension))); } // check naming convention @@ -78,7 +78,7 @@ public function getContainerExtension(): ?ExtensionInterface $expectedAlias = Container::underscore($basename); if ($expectedAlias != $extension->getAlias()) { - throw new \LogicException(sprintf('Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.', $expectedAlias, $extension->getAlias())); + throw new \LogicException(\sprintf('Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.', $expectedAlias, $extension->getAlias())); } $this->extension = $extension; diff --git a/CacheClearer/Psr6CacheClearer.php b/CacheClearer/Psr6CacheClearer.php index 3c99b74af3..87614e9417 100644 --- a/CacheClearer/Psr6CacheClearer.php +++ b/CacheClearer/Psr6CacheClearer.php @@ -39,7 +39,7 @@ public function hasPool(string $name): bool public function getPool(string $name): CacheItemPoolInterface { if (!$this->hasPool($name)) { - throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name)); + throw new \InvalidArgumentException(\sprintf('Cache pool not found: "%s".', $name)); } return $this->pools[$name]; @@ -51,7 +51,7 @@ public function getPool(string $name): CacheItemPoolInterface public function clearPool(string $name): bool { if (!isset($this->pools[$name])) { - throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name)); + throw new \InvalidArgumentException(\sprintf('Cache pool not found: "%s".', $name)); } return $this->pools[$name]->clear(); diff --git a/CacheWarmer/CacheWarmer.php b/CacheWarmer/CacheWarmer.php index f940ba4a72..664110a222 100644 --- a/CacheWarmer/CacheWarmer.php +++ b/CacheWarmer/CacheWarmer.php @@ -30,6 +30,6 @@ protected function writeCacheFile(string $file, $content) return; } - throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file)); + throw new \RuntimeException(\sprintf('Failed to write cache file "%s".', $file)); } } diff --git a/CacheWarmer/CacheWarmerAggregate.php b/CacheWarmer/CacheWarmerAggregate.php index 47873fe183..9f1c53456c 100644 --- a/CacheWarmer/CacheWarmerAggregate.php +++ b/CacheWarmer/CacheWarmerAggregate.php @@ -107,13 +107,13 @@ public function warmUp(string $cacheDir, string|SymfonyStyle|null $buildDir = nu $start = microtime(true); foreach ((array) $warmer->warmUp($cacheDir, $buildDir) as $item) { if (is_dir($item) || (str_starts_with($item, \dirname($cacheDir)) && !is_file($item)) || ($buildDir && str_starts_with($item, \dirname($buildDir)) && !is_file($item))) { - throw new \LogicException(sprintf('"%s::warmUp()" should return a list of files or classes but "%s" is none of them.', $warmer::class, $item)); + throw new \LogicException(\sprintf('"%s::warmUp()" should return a list of files or classes but "%s" is none of them.', $warmer::class, $item)); } $preload[] = $item; } if ($io?->isDebug()) { - $io->info(sprintf('"%s" completed in %0.2fms.', $warmer::class, 1000 * (microtime(true) - $start))); + $io->info(\sprintf('"%s" completed in %0.2fms.', $warmer::class, 1000 * (microtime(true) - $start))); } } } finally { diff --git a/Controller/ArgumentResolver.php b/Controller/ArgumentResolver.php index 23c2d7faa2..991e99bdc6 100644 --- a/Controller/ArgumentResolver.php +++ b/Controller/ArgumentResolver.php @@ -60,7 +60,7 @@ public function getArguments(Request $request, callable $controller, ?\Reflectio if ($attribute->disabled) { $disabledResolvers[$attribute->resolver] = true; } elseif ($resolverName) { - throw new \LogicException(sprintf('You can only pin one resolver per argument, but argument "$%s" of "%s()" has more.', $metadata->getName(), $this->getPrettyName($controller))); + throw new \LogicException(\sprintf('You can only pin one resolver per argument, but argument "$%s" of "%s()" has more.', $metadata->getName(), $this->getPrettyName($controller))); } else { $resolverName = $attribute->resolver; } @@ -94,7 +94,7 @@ public function getArguments(Request $request, callable $controller, ?\Reflectio } if (1 < $count && !$metadata->isVariadic()) { - throw new \InvalidArgumentException(sprintf('"%s::resolve()" must yield at most one value for non-variadic arguments.', get_debug_type($resolver))); + throw new \InvalidArgumentException(\sprintf('"%s::resolve()" must yield at most one value for non-variadic arguments.', get_debug_type($resolver))); } if ($count) { @@ -103,11 +103,11 @@ public function getArguments(Request $request, callable $controller, ?\Reflectio } if (!$resolver instanceof ValueResolverInterface) { - throw new \InvalidArgumentException(sprintf('"%s::resolve()" must yield at least one value.', get_debug_type($resolver))); + throw new \InvalidArgumentException(\sprintf('"%s::resolve()" must yield at least one value.', get_debug_type($resolver))); } } - throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or there is a non-optional argument after this one.', $this->getPrettyName($controller), $metadata->getName())); + throw new \RuntimeException(\sprintf('Controller "%s" requires that you provide a value for the "$%s" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or there is a non-optional argument after this one.', $this->getPrettyName($controller), $metadata->getName())); } return $arguments; diff --git a/Controller/ArgumentResolver/BackedEnumValueResolver.php b/Controller/ArgumentResolver/BackedEnumValueResolver.php index 620e2de080..c29725dd22 100644 --- a/Controller/ArgumentResolver/BackedEnumValueResolver.php +++ b/Controller/ArgumentResolver/BackedEnumValueResolver.php @@ -78,7 +78,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable } if (!\is_int($value) && !\is_string($value)) { - throw new \LogicException(sprintf('Could not resolve the "%s $%s" controller argument: expecting an int or string, got "%s".', $argument->getType(), $argument->getName(), get_debug_type($value))); + throw new \LogicException(\sprintf('Could not resolve the "%s $%s" controller argument: expecting an int or string, got "%s".', $argument->getType(), $argument->getName(), get_debug_type($value))); } /** @var class-string<\BackedEnum> $enumType */ @@ -87,7 +87,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable try { return [$enumType::from($value)]; } catch (\ValueError|\TypeError $e) { - throw new NotFoundHttpException(sprintf('Could not resolve the "%s $%s" controller argument: ', $argument->getType(), $argument->getName()).$e->getMessage(), $e); + throw new NotFoundHttpException(\sprintf('Could not resolve the "%s $%s" controller argument: ', $argument->getType(), $argument->getName()).$e->getMessage(), $e); } } } diff --git a/Controller/ArgumentResolver/DateTimeValueResolver.php b/Controller/ArgumentResolver/DateTimeValueResolver.php index 0cfd42badc..388f02b317 100644 --- a/Controller/ArgumentResolver/DateTimeValueResolver.php +++ b/Controller/ArgumentResolver/DateTimeValueResolver.php @@ -90,7 +90,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array } if (!$date) { - throw new NotFoundHttpException(sprintf('Invalid date given for parameter "%s".', $argument->getName())); + throw new NotFoundHttpException(\sprintf('Invalid date given for parameter "%s".', $argument->getName())); } return [$date]; diff --git a/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php b/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php index 2640361288..594f1b8a6f 100644 --- a/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php +++ b/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php @@ -82,8 +82,8 @@ public function resolve(Request $request, ArgumentMetadata $argument): array return []; } - $what = sprintf('argument $%s of "%s()"', $argument->getName(), $controller); - $message = sprintf('Could not resolve %s, maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?', $what); + $what = \sprintf('argument $%s of "%s()"', $argument->getName(), $controller); + $message = \sprintf('Could not resolve %s, maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?', $what); throw new RuntimeException($message); } diff --git a/Controller/ArgumentResolver/QueryParameterValueResolver.php b/Controller/ArgumentResolver/QueryParameterValueResolver.php index b186a39c59..0b64a444b9 100644 --- a/Controller/ArgumentResolver/QueryParameterValueResolver.php +++ b/Controller/ArgumentResolver/QueryParameterValueResolver.php @@ -38,7 +38,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array return []; } - throw new NotFoundHttpException(sprintf('Missing query parameter "%s".', $name)); + throw new NotFoundHttpException(\sprintf('Missing query parameter "%s".', $name)); } $value = $request->query->all()[$name]; @@ -52,7 +52,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array $filtered = array_values(array_filter((array) $value, \is_array(...))); if ($filtered !== $value && !($attribute->flags & \FILTER_NULL_ON_FAILURE)) { - throw new NotFoundHttpException(sprintf('Invalid query parameter "%s".', $name)); + throw new NotFoundHttpException(\sprintf('Invalid query parameter "%s".', $name)); } return $filtered; @@ -80,8 +80,8 @@ public function resolve(Request $request, ArgumentMetadata $argument): array default => match ($enumType = is_subclass_of($type, \BackedEnum::class) ? (new \ReflectionEnum($type))->getBackingType()->getName() : null) { 'int' => \FILTER_VALIDATE_INT, 'string' => \FILTER_DEFAULT, - default => throw new \LogicException(sprintf('#[MapQueryParameter] cannot be used on controller argument "%s$%s" of type "%s"; one of array, string, int, float, bool or \BackedEnum should be used.', $argument->isVariadic() ? '...' : '', $argument->getName(), $type ?? 'mixed')), - } + default => throw new \LogicException(\sprintf('#[MapQueryParameter] cannot be used on controller argument "%s$%s" of type "%s"; one of array, string, int, float, bool or \BackedEnum should be used.', $argument->isVariadic() ? '...' : '', $argument->getName(), $type ?? 'mixed')), + }, }; $value = filter_var($value, $attribute->filter ?? $filter, $options); @@ -103,7 +103,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array } if (null === $value && !($attribute->flags & \FILTER_NULL_ON_FAILURE)) { - throw new NotFoundHttpException(sprintf('Invalid query parameter "%s".', $name)); + throw new NotFoundHttpException(\sprintf('Invalid query parameter "%s".', $name)); } if (!\is_array($value)) { @@ -117,7 +117,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array } if ($filtered !== $value && !($attribute->flags & \FILTER_NULL_ON_FAILURE)) { - throw new NotFoundHttpException(sprintf('Invalid query parameter "%s".', $name)); + throw new NotFoundHttpException(\sprintf('Invalid query parameter "%s".', $name)); } return $argument->isVariadic() ? $filtered : [$filtered]; diff --git a/Controller/ArgumentResolver/RequestPayloadValueResolver.php b/Controller/ArgumentResolver/RequestPayloadValueResolver.php index f0f735da42..996eacf06f 100644 --- a/Controller/ArgumentResolver/RequestPayloadValueResolver.php +++ b/Controller/ArgumentResolver/RequestPayloadValueResolver.php @@ -71,7 +71,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable } if ($argument->isVariadic()) { - throw new \LogicException(sprintf('Mapping variadic argument "$%s" is not supported.', $argument->getName())); + throw new \LogicException(\sprintf('Mapping variadic argument "$%s" is not supported.', $argument->getName())); } $attribute->metadata = $argument; @@ -96,7 +96,7 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event): vo $request = $event->getRequest(); if (!$type = $argument->metadata->getType()) { - throw new \LogicException(sprintf('Could not resolve the "$%s" controller argument: argument should be typed.', $argument->metadata->getName())); + throw new \LogicException(\sprintf('Could not resolve the "$%s" controller argument: argument should be typed.', $argument->metadata->getName())); } if ($this->validator) { @@ -140,7 +140,7 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event): vo $payload = match (true) { $argument->metadata->hasDefaultValue() => $argument->metadata->getDefaultValue(), $argument->metadata->isNullable() => null, - default => throw new HttpException($validationFailedCode) + default => throw new HttpException($validationFailedCode), }; } @@ -173,7 +173,7 @@ private function mapRequestPayload(Request $request, string $type, MapRequestPay } if ($attribute->acceptFormat && !\in_array($format, (array) $attribute->acceptFormat, true)) { - throw new HttpException(Response::HTTP_UNSUPPORTED_MEDIA_TYPE, sprintf('Unsupported format, expects "%s", but "%s" given.', implode('", "', (array) $attribute->acceptFormat), $format)); + throw new HttpException(Response::HTTP_UNSUPPORTED_MEDIA_TYPE, \sprintf('Unsupported format, expects "%s", but "%s" given.', implode('", "', (array) $attribute->acceptFormat), $format)); } if ($data = $request->request->all()) { @@ -191,9 +191,9 @@ private function mapRequestPayload(Request $request, string $type, MapRequestPay try { return $this->serializer->deserialize($data, $type, $format, self::CONTEXT_DESERIALIZE + $attribute->serializationContext); } catch (UnsupportedFormatException $e) { - throw new HttpException(Response::HTTP_UNSUPPORTED_MEDIA_TYPE, sprintf('Unsupported format: "%s".', $format), $e); + throw new HttpException(Response::HTTP_UNSUPPORTED_MEDIA_TYPE, \sprintf('Unsupported format: "%s".', $format), $e); } catch (NotEncodableValueException $e) { - throw new HttpException(Response::HTTP_BAD_REQUEST, sprintf('Request payload contains invalid "%s" data.', $format), $e); + throw new HttpException(Response::HTTP_BAD_REQUEST, \sprintf('Request payload contains invalid "%s" data.', $format), $e); } } } diff --git a/Controller/ArgumentResolver/ServiceValueResolver.php b/Controller/ArgumentResolver/ServiceValueResolver.php index 96e0337d6a..fecf59cafe 100644 --- a/Controller/ArgumentResolver/ServiceValueResolver.php +++ b/Controller/ArgumentResolver/ServiceValueResolver.php @@ -83,11 +83,11 @@ public function resolve(Request $request, ArgumentMetadata $argument): array try { return [$this->container->get($controller)->get($argument->getName())]; } catch (RuntimeException $e) { - $what = sprintf('argument $%s of "%s()"', $argument->getName(), $controller); + $what = \sprintf('argument $%s of "%s()"', $argument->getName(), $controller); $message = preg_replace('/service "\.service_locator\.[^"]++"/', $what, $e->getMessage()); if ($e->getMessage() === $message) { - $message = sprintf('Cannot resolve %s: %s', $what, $message); + $message = \sprintf('Cannot resolve %s: %s', $what, $message); } $r = new \ReflectionProperty($e, 'message'); diff --git a/Controller/ArgumentResolver/UidValueResolver.php b/Controller/ArgumentResolver/UidValueResolver.php index 7a12e21ead..afe702300e 100644 --- a/Controller/ArgumentResolver/UidValueResolver.php +++ b/Controller/ArgumentResolver/UidValueResolver.php @@ -46,7 +46,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array try { return [$uidClass::fromString($value)]; } catch (\InvalidArgumentException $e) { - throw new NotFoundHttpException(sprintf('The uid for the "%s" parameter is invalid.', $argument->getName()), $e); + throw new NotFoundHttpException(\sprintf('The uid for the "%s" parameter is invalid.', $argument->getName()), $e); } } } diff --git a/Controller/ArgumentResolver/VariadicValueResolver.php b/Controller/ArgumentResolver/VariadicValueResolver.php index 4f6cba729e..b4946698d1 100644 --- a/Controller/ArgumentResolver/VariadicValueResolver.php +++ b/Controller/ArgumentResolver/VariadicValueResolver.php @@ -42,7 +42,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array $values = $request->attributes->get($argument->getName()); if (!\is_array($values)) { - throw new \InvalidArgumentException(sprintf('The action argument "...$%1$s" is required to be an array, the request attribute "%1$s" contains a type of "%2$s" instead.', $argument->getName(), get_debug_type($values))); + throw new \InvalidArgumentException(\sprintf('The action argument "...$%1$s" is required to be an array, the request attribute "%1$s" contains a type of "%2$s" instead.', $argument->getName(), get_debug_type($values))); } return $values; diff --git a/Controller/ContainerControllerResolver.php b/Controller/ContainerControllerResolver.php index 12232d58b5..5cd9edb31c 100644 --- a/Controller/ContainerControllerResolver.php +++ b/Controller/ContainerControllerResolver.php @@ -48,16 +48,16 @@ protected function instantiateController(string $class): object $this->throwExceptionIfControllerWasRemoved($class, $e); if ($e instanceof \ArgumentCountError) { - throw new \InvalidArgumentException(sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?', $class), 0, $e); + throw new \InvalidArgumentException(\sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?', $class), 0, $e); } - throw new \InvalidArgumentException(sprintf('Controller "%s" does neither exist as service nor as class.', $class), 0, $e); + throw new \InvalidArgumentException(\sprintf('Controller "%s" does neither exist as service nor as class.', $class), 0, $e); } private function throwExceptionIfControllerWasRemoved(string $controller, \Throwable $previous): void { if ($this->container instanceof Container && isset($this->container->getRemovedIds()[$controller])) { - throw new \InvalidArgumentException(sprintf('Controller "%s" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?', $controller), 0, $previous); + throw new \InvalidArgumentException(\sprintf('Controller "%s" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?', $controller), 0, $previous); } } } diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 8424b02cc1..72ece351bf 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -74,7 +74,7 @@ public function getController(Request $request): callable|false } if (!\is_callable($controller)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($controller)); + throw new \InvalidArgumentException(\sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($controller)); } return $this->checkController($request, $controller); @@ -82,7 +82,7 @@ public function getController(Request $request): callable|false if (\is_object($controller)) { if (!\is_callable($controller)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($controller)); + throw new \InvalidArgumentException(\sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($controller)); } return $this->checkController($request, $controller); @@ -95,11 +95,11 @@ public function getController(Request $request): callable|false try { $callable = $this->createController($controller); } catch (\InvalidArgumentException $e) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$e->getMessage(), 0, $e); + throw new \InvalidArgumentException(\sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$e->getMessage(), 0, $e); } if (!\is_callable($callable)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($callable)); + throw new \InvalidArgumentException(\sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($callable)); } return $this->checkController($request, $callable); @@ -159,19 +159,19 @@ private function getControllerError(mixed $callable): string if (str_contains($callable, '::')) { $callable = explode('::', $callable, 2); } else { - return sprintf('Function "%s" does not exist.', $callable); + return \sprintf('Function "%s" does not exist.', $callable); } } if (\is_object($callable)) { $availableMethods = $this->getClassMethodsWithoutMagicMethods($callable); - $alternativeMsg = $availableMethods ? sprintf(' or use one of the available methods: "%s"', implode('", "', $availableMethods)) : ''; + $alternativeMsg = $availableMethods ? \sprintf(' or use one of the available methods: "%s"', implode('", "', $availableMethods)) : ''; - return sprintf('Controller class "%s" cannot be called without a method name. You need to implement "__invoke"%s.', get_debug_type($callable), $alternativeMsg); + return \sprintf('Controller class "%s" cannot be called without a method name. You need to implement "__invoke"%s.', get_debug_type($callable), $alternativeMsg); } if (!\is_array($callable)) { - return sprintf('Invalid type for controller given, expected string, array or object, got "%s".', get_debug_type($callable)); + return \sprintf('Invalid type for controller given, expected string, array or object, got "%s".', get_debug_type($callable)); } if (!isset($callable[0]) || !isset($callable[1]) || 2 !== \count($callable)) { @@ -181,13 +181,13 @@ private function getControllerError(mixed $callable): string [$controller, $method] = $callable; if (\is_string($controller) && !class_exists($controller)) { - return sprintf('Class "%s" does not exist.', $controller); + return \sprintf('Class "%s" does not exist.', $controller); } $className = \is_object($controller) ? get_debug_type($controller) : $controller; if (method_exists($controller, $method)) { - return sprintf('Method "%s" on class "%s" should be public and non-abstract.', $method, $className); + return \sprintf('Method "%s" on class "%s" should be public and non-abstract.', $method, $className); } $collection = $this->getClassMethodsWithoutMagicMethods($controller); @@ -204,12 +204,12 @@ private function getControllerError(mixed $callable): string asort($alternatives); - $message = sprintf('Expected method "%s" on class "%s"', $method, $className); + $message = \sprintf('Expected method "%s" on class "%s"', $method, $className); if (\count($alternatives) > 0) { - $message .= sprintf(', did you mean "%s"?', implode('", "', $alternatives)); + $message .= \sprintf(', did you mean "%s"?', implode('", "', $alternatives)); } else { - $message .= sprintf('. Available methods: "%s".', implode('", "', $collection)); + $message .= \sprintf('. Available methods: "%s".', implode('", "', $collection)); } return $message; @@ -274,6 +274,6 @@ private function checkController(Request $request, callable $controller): callab return $controller; } - throw new BadRequestException(sprintf('Callable "%s()" is not allowed as a controller. Did you miss tagging it with "#[AsController]" or registering its type with "%s::allowControllers()"?', $name, self::class)); + throw new BadRequestException(\sprintf('Callable "%s()" is not allowed as a controller. Did you miss tagging it with "#[AsController]" or registering its type with "%s::allowControllers()"?', $name, self::class)); } } diff --git a/ControllerMetadata/ArgumentMetadata.php b/ControllerMetadata/ArgumentMetadata.php index dd6c8be86f..d3ca53fa63 100644 --- a/ControllerMetadata/ArgumentMetadata.php +++ b/ControllerMetadata/ArgumentMetadata.php @@ -94,7 +94,7 @@ public function isNullable(): bool public function getDefaultValue(): mixed { if (!$this->hasDefaultValue) { - throw new \LogicException(sprintf('Argument $%s does not have a default value. Use "%s::hasDefaultValue()" to avoid this exception.', $this->name, __CLASS__)); + throw new \LogicException(\sprintf('Argument $%s does not have a default value. Use "%s::hasDefaultValue()" to avoid this exception.', $this->name, __CLASS__)); } return $this->defaultValue; diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index f9ca5da1d6..ba8fc0c317 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -47,7 +47,7 @@ public function collect(Request $request, Response $response, ?\Throwable $excep $this->data = [ 'token' => $response->headers->get('X-Debug-Token'), 'symfony_version' => Kernel::VERSION, - 'symfony_minor_version' => sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), + 'symfony_minor_version' => \sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), 'symfony_lts' => 4 === Kernel::MINOR_VERSION, 'symfony_state' => $this->determineSymfonyState(), 'symfony_eom' => $eom->format('F Y'), diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 0a46a8cd4e..2300acf914 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -196,7 +196,7 @@ public function getDumps(string $format, int $maxDepthLimit = -1, int $maxItemsP $dumper = new HtmlDumper($data, $this->charset); $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { - throw new \InvalidArgumentException(sprintf('Invalid dump format: "%s".', $format)); + throw new \InvalidArgumentException(\sprintf('Invalid dump format: "%s".', $format)); } $dumps = []; @@ -263,9 +263,9 @@ private function doDump(DataDumperInterface $dumper, Data $data, string $name, s $f = strip_tags($this->style('', $file)); $name = strip_tags($this->style('', $name)); if ($fmt && $link = \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line)) { - $name = sprintf(''.$s.'', strip_tags($this->style('', $link)), $f, $name); + $name = \sprintf(''.$s.'', strip_tags($this->style('', $link)), $f, $name); } else { - $name = sprintf(''.$s.'', $f, $name); + $name = \sprintf(''.$s.'', $f, $name); } } else { $name = $this->style('meta', $name); diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index 12951b495c..4792f160c0 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -452,7 +452,7 @@ public function collectSessionUsage(): void array_splice($trace, 0, $traceEndIndex); // Merge identical backtraces generated by internal call reports - $name = sprintf('%s:%s', $trace[1]['class'] ?? $trace[0]['file'], $trace[0]['line']); + $name = \sprintf('%s:%s', $trace[1]['class'] ?? $trace[0]['file'], $trace[0]['line']); if (!\array_key_exists($name, $this->sessionUsages)) { $this->sessionUsages[$name] = [ 'name' => $name, diff --git a/DependencyInjection/FragmentRendererPass.php b/DependencyInjection/FragmentRendererPass.php index f41d58b81b..9a32b8a4eb 100644 --- a/DependencyInjection/FragmentRendererPass.php +++ b/DependencyInjection/FragmentRendererPass.php @@ -41,10 +41,10 @@ public function process(ContainerBuilder $container) $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) { diff --git a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index 7d13c223a6..e2f50dcba1 100644 --- a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -73,7 +73,7 @@ public function process(ContainerBuilder $container) $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; @@ -98,11 +98,11 @@ public function process(ContainerBuilder $container) } 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; @@ -118,7 +118,7 @@ public function process(ContainerBuilder $container) } 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)); } } @@ -140,7 +140,7 @@ public function process(ContainerBuilder $container) 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)); + 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; } @@ -191,7 +191,7 @@ public function process(ContainerBuilder $container) } 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, '\\'))) { diff --git a/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php b/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php index 7a21fe0e59..ef859a611b 100644 --- a/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php @@ -34,7 +34,7 @@ public function process(ContainerBuilder $container) 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 +47,7 @@ public function process(ContainerBuilder $container) $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; } } diff --git a/DependencyInjection/ResettableServicePass.php b/DependencyInjection/ResettableServicePass.php index da9f8d6320..8479c8d630 100644 --- a/DependencyInjection/ResettableServicePass.php +++ b/DependencyInjection/ResettableServicePass.php @@ -39,7 +39,7 @@ public function process(ContainerBuilder $container) 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])) { diff --git a/EventListener/ErrorListener.php b/EventListener/ErrorListener.php index 7aa4875e5a..266d96cf8e 100644 --- a/EventListener/ErrorListener.php +++ b/EventListener/ErrorListener.php @@ -90,7 +90,7 @@ public function logKernelException(ExceptionEvent $event) $e = FlattenException::createFromThrowable($throwable); - $this->logException($throwable, sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), basename($e->getFile()), $e->getLine()), $logLevel); + $this->logException($throwable, \sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), basename($e->getFile()), $e->getLine()), $logLevel); } /** @@ -118,7 +118,7 @@ public function onKernelException(ExceptionEvent $event) } catch (\Exception $e) { $f = FlattenException::createFromThrowable($e); - $this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', $f->getClass(), $f->getMessage(), basename($e->getFile()), $e->getLine())); + $this->logException($e, \sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', $f->getClass(), $f->getMessage(), basename($e->getFile()), $e->getLine())); $prev = $e; do { diff --git a/EventListener/RouterListener.php b/EventListener/RouterListener.php index f4406ade49..fd8ac1a5c6 100644 --- a/EventListener/RouterListener.php +++ b/EventListener/RouterListener.php @@ -118,15 +118,15 @@ public function onKernelRequest(RequestEvent $event): void unset($parameters['_route'], $parameters['_controller']); $request->attributes->set('_route_params', $parameters); } catch (ResourceNotFoundException $e) { - $message = sprintf('No route found for "%s %s"', $request->getMethod(), $request->getUriForPath($request->getPathInfo())); + $message = \sprintf('No route found for "%s %s"', $request->getMethod(), $request->getUriForPath($request->getPathInfo())); if ($referer = $request->headers->get('referer')) { - $message .= sprintf(' (from "%s")', $referer); + $message .= \sprintf(' (from "%s")', $referer); } throw new NotFoundHttpException($message, $e); } catch (MethodNotAllowedException $e) { - $message = sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getUriForPath($request->getPathInfo()), implode(', ', $e->getAllowedMethods())); + $message = \sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getUriForPath($request->getPathInfo()), implode(', ', $e->getAllowedMethods())); throw new MethodNotAllowedHttpException($e->getAllowedMethods(), $message, $e); } diff --git a/Exception/ResolverNotFoundException.php b/Exception/ResolverNotFoundException.php index 6d9fb8a01f..aa859d5115 100644 --- a/Exception/ResolverNotFoundException.php +++ b/Exception/ResolverNotFoundException.php @@ -18,7 +18,7 @@ class ResolverNotFoundException extends \RuntimeException */ public function __construct(string $name, array $alternatives = []) { - $msg = sprintf('You have requested a non-existent resolver "%s".', $name); + $msg = \sprintf('You have requested a non-existent resolver "%s".', $name); if ($alternatives) { if (1 === \count($alternatives)) { $msg .= ' Did you mean this: "'; diff --git a/Fragment/FragmentHandler.php b/Fragment/FragmentHandler.php index 62b21e6d4e..7452424192 100644 --- a/Fragment/FragmentHandler.php +++ b/Fragment/FragmentHandler.php @@ -73,7 +73,7 @@ public function render(string|ControllerReference $uri, string $renderer = 'inli } if (!isset($this->renderers[$renderer])) { - throw new \InvalidArgumentException(sprintf('The "%s" renderer does not exist.', $renderer)); + throw new \InvalidArgumentException(\sprintf('The "%s" renderer does not exist.', $renderer)); } if (!$request = $this->requestStack->getCurrentRequest()) { @@ -97,7 +97,7 @@ protected function deliver(Response $response): ?string { if (!$response->isSuccessful()) { $responseStatusCode = $response->getStatusCode(); - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $this->requestStack->getCurrentRequest()->getUri(), $responseStatusCode), 0, new HttpException($responseStatusCode)); + throw new \RuntimeException(\sprintf('Error when rendering "%s" (Status code is %d).', $this->requestStack->getCurrentRequest()->getUri(), $responseStatusCode), 0, new HttpException($responseStatusCode)); } if (!$response instanceof StreamedResponse) { diff --git a/Fragment/FragmentUriGenerator.php b/Fragment/FragmentUriGenerator.php index 59423293e8..aeb1f71239 100644 --- a/Fragment/FragmentUriGenerator.php +++ b/Fragment/FragmentUriGenerator.php @@ -83,7 +83,7 @@ private function checkNonScalar(array $values): void if (\is_array($value)) { $this->checkNonScalar($value); } elseif (!\is_scalar($value) && null !== $value) { - throw new \LogicException(sprintf('Controller attributes cannot contain non-scalar/non-null values (value for key "%s" is not a scalar or null).', $key)); + throw new \LogicException(\sprintf('Controller attributes cannot contain non-scalar/non-null values (value for key "%s" is not a scalar or null).', $key)); } } } diff --git a/Fragment/HIncludeFragmentRenderer.php b/Fragment/HIncludeFragmentRenderer.php index edcf9938c4..9cb01f321e 100644 --- a/Fragment/HIncludeFragmentRenderer.php +++ b/Fragment/HIncludeFragmentRenderer.php @@ -79,7 +79,7 @@ public function render(string|ControllerReference $uri, Request $request, array if (\count($attributes) > 0) { $flags = \ENT_QUOTES | \ENT_SUBSTITUTE; foreach ($attributes as $attribute => $value) { - $renderedAttributes .= sprintf( + $renderedAttributes .= \sprintf( ' %s="%s"', htmlspecialchars($attribute, $flags, $this->charset, false), htmlspecialchars($value, $flags, $this->charset, false) @@ -87,7 +87,7 @@ public function render(string|ControllerReference $uri, Request $request, array } } - return new Response(sprintf('%s', $uri, $renderedAttributes, $content)); + return new Response(\sprintf('%s', $uri, $renderedAttributes, $content)); } public function getName(): string diff --git a/HttpCache/AbstractSurrogate.php b/HttpCache/AbstractSurrogate.php index 95518bed2b..152aedad08 100644 --- a/HttpCache/AbstractSurrogate.php +++ b/HttpCache/AbstractSurrogate.php @@ -56,7 +56,7 @@ public function hasSurrogateCapability(Request $request): bool return false; } - return str_contains($value, sprintf('%s/1.0', strtoupper($this->getName()))); + return str_contains($value, \sprintf('%s/1.0', strtoupper($this->getName()))); } /** @@ -65,7 +65,7 @@ public function hasSurrogateCapability(Request $request): bool public function addSurrogateCapability(Request $request) { $current = $request->headers->get('Surrogate-Capability'); - $new = sprintf('symfony="%s/1.0"', strtoupper($this->getName())); + $new = \sprintf('symfony="%s/1.0"', strtoupper($this->getName())); $request->headers->set('Surrogate-Capability', $current ? $current.', '.$new : $new); } @@ -76,7 +76,7 @@ public function needsParsing(Response $response): bool return false; } - $pattern = sprintf('#content="[^"]*%s/1.0[^"]*"#', strtoupper($this->getName())); + $pattern = \sprintf('#content="[^"]*%s/1.0[^"]*"#', strtoupper($this->getName())); return (bool) preg_match($pattern, $control); } @@ -89,7 +89,7 @@ public function handle(HttpCache $cache, string $uri, string $alt, bool $ignoreE $response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true); if (!$response->isSuccessful() && Response::HTTP_NOT_MODIFIED !== $response->getStatusCode()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $subRequest->getUri(), $response->getStatusCode())); + throw new \RuntimeException(\sprintf('Error when rendering "%s" (Status code is %d).', $subRequest->getUri(), $response->getStatusCode())); } return $response->getContent(); @@ -120,12 +120,12 @@ protected function removeFromControl(Response $response) $value = $response->headers->get('Surrogate-Control'); $upperName = strtoupper($this->getName()); - if (sprintf('content="%s/1.0"', $upperName) == $value) { + if (\sprintf('content="%s/1.0"', $upperName) == $value) { $response->headers->remove('Surrogate-Control'); - } elseif (preg_match(sprintf('#,\s*content="%s/1.0"#', $upperName), $value)) { - $response->headers->set('Surrogate-Control', preg_replace(sprintf('#,\s*content="%s/1.0"#', $upperName), '', $value)); - } elseif (preg_match(sprintf('#content="%s/1.0",\s*#', $upperName), $value)) { - $response->headers->set('Surrogate-Control', preg_replace(sprintf('#content="%s/1.0",\s*#', $upperName), '', $value)); + } elseif (preg_match(\sprintf('#,\s*content="%s/1.0"#', $upperName), $value)) { + $response->headers->set('Surrogate-Control', preg_replace(\sprintf('#,\s*content="%s/1.0"#', $upperName), '', $value)); + } elseif (preg_match(\sprintf('#content="%s/1.0",\s*#', $upperName), $value)) { + $response->headers->set('Surrogate-Control', preg_replace(\sprintf('#content="%s/1.0",\s*#', $upperName), '', $value)); } } diff --git a/HttpCache/Esi.php b/HttpCache/Esi.php index e8faf0fdbd..92b41a5dd6 100644 --- a/HttpCache/Esi.php +++ b/HttpCache/Esi.php @@ -44,14 +44,14 @@ public function addSurrogateControl(Response $response) public function renderIncludeTag(string $uri, ?string $alt = null, bool $ignoreErrors = true, string $comment = ''): string { - $html = sprintf('', + $html = \sprintf('', $uri, $ignoreErrors ? ' onerror="continue"' : '', - $alt ? sprintf(' alt="%s"', $alt) : '' + $alt ? \sprintf(' alt="%s"', $alt) : '' ); if (!empty($comment)) { - return sprintf("\n%s", $comment, $html); + return \sprintf("\n%s", $comment, $html); } return $html; diff --git a/HttpCache/HttpCache.php b/HttpCache/HttpCache.php index bce0e99b5e..8d1a3a5791 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -158,7 +158,7 @@ public function getLog(): string { $log = []; foreach ($this->traces as $request => $traces) { - $log[] = sprintf('%s: %s', $request, implode(', ', $traces)); + $log[] = \sprintf('%s: %s', $request, implode(', ', $traces)); } return implode('; ', $log); diff --git a/HttpCache/ResponseCacheStrategy.php b/HttpCache/ResponseCacheStrategy.php index bf7ec78f20..05670967a5 100644 --- a/HttpCache/ResponseCacheStrategy.php +++ b/HttpCache/ResponseCacheStrategy.php @@ -37,7 +37,7 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface private int $embeddedResponses = 0; private bool $isNotCacheableResponseEmbedded = false; private int $age = 0; - private \DateTimeInterface|null|false $lastModified = null; + private \DateTimeInterface|false|null $lastModified = null; private array $flagDirectives = [ 'no-cache' => null, 'no-store' => null, @@ -228,7 +228,7 @@ private function storeRelativeAgeDirective(string $directive, ?int $value, ?int } if (false !== $this->ageDirectives[$directive]) { - $value = min($value ?? PHP_INT_MAX, $expires ?? PHP_INT_MAX); + $value = min($value ?? \PHP_INT_MAX, $expires ?? \PHP_INT_MAX); $value -= $age; $this->ageDirectives[$directive] = null !== $this->ageDirectives[$directive] ? min($this->ageDirectives[$directive], $value) : $value; } diff --git a/HttpCache/Ssi.php b/HttpCache/Ssi.php index 8cf4e49077..9e0839d63d 100644 --- a/HttpCache/Ssi.php +++ b/HttpCache/Ssi.php @@ -38,7 +38,7 @@ public function addSurrogateControl(Response $response) public function renderIncludeTag(string $uri, ?string $alt = null, bool $ignoreErrors = true, string $comment = ''): string { - return sprintf('', $uri); + return \sprintf('', $uri); } public function process(Request $request, Response $response): Response diff --git a/HttpCache/Store.php b/HttpCache/Store.php index 7f7f1a1a14..473537d85b 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -45,7 +45,7 @@ public function __construct(string $root, array $options = []) { $this->root = $root; if (!is_dir($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) { - throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root)); + throw new \RuntimeException(\sprintf('Unable to create the store directory (%s).', $this->root)); } $this->keyCache = new \SplObjectStorage(); $this->options = array_merge([ diff --git a/HttpCache/SubRequestHandler.php b/HttpCache/SubRequestHandler.php index 253071f07d..4caf3daf2e 100644 --- a/HttpCache/SubRequestHandler.php +++ b/HttpCache/SubRequestHandler.php @@ -51,16 +51,16 @@ public static function handle(HttpKernelInterface $kernel, Request $request, int $trustedValues = []; foreach (array_reverse($request->getClientIps()) as $ip) { $trustedIps[] = $ip; - $trustedValues[] = sprintf('for="%s"', $ip); + $trustedValues[] = \sprintf('for="%s"', $ip); } if ($ip !== $remoteAddr) { $trustedIps[] = $remoteAddr; - $trustedValues[] = sprintf('for="%s"', $remoteAddr); + $trustedValues[] = \sprintf('for="%s"', $remoteAddr); } // set trusted values, reusing as much as possible the global trusted settings if (Request::HEADER_FORWARDED & $trustedHeaderSet) { - $trustedValues[0] .= sprintf(';host="%s";proto=%s', $request->getHttpHost(), $request->getScheme()); + $trustedValues[0] .= \sprintf(';host="%s";proto=%s', $request->getHttpHost(), $request->getScheme()); $request->headers->set('Forwarded', $v = implode(', ', $trustedValues)); $request->server->set('HTTP_FORWARDED', $v); } diff --git a/HttpClientKernel.php b/HttpClientKernel.php index 7c719e8e61..ebda2750da 100644 --- a/HttpClientKernel.php +++ b/HttpClientKernel.php @@ -36,7 +36,7 @@ final class HttpClientKernel implements HttpKernelInterface public function __construct(?HttpClientInterface $client = null) { if (null === $client && !class_exists(HttpClient::class)) { - throw new \LogicException(sprintf('You cannot use "%s" as the HttpClient component is not installed. Try running "composer require symfony/http-client".', __CLASS__)); + throw new \LogicException(\sprintf('You cannot use "%s" as the HttpClient component is not installed. Try running "composer require symfony/http-client".', __CLASS__)); } $this->client = $client ?? HttpClient::create(); diff --git a/HttpKernel.php b/HttpKernel.php index 6460bebbdd..886fca9cf5 100644 --- a/HttpKernel.php +++ b/HttpKernel.php @@ -162,7 +162,7 @@ private function handleRaw(Request $request, int $type = self::MAIN_REQUEST): Re // load controller if (false === $controller = $this->resolver->getController($request)) { - throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". The route is wrongly configured.', $request->getPathInfo())); + throw new NotFoundHttpException(\sprintf('Unable to find the controller for path "%s". The route is wrongly configured.', $request->getPathInfo())); } $event = new ControllerEvent($this, $controller, $request, $type); @@ -188,7 +188,7 @@ private function handleRaw(Request $request, int $type = self::MAIN_REQUEST): Re if ($event->hasResponse()) { $response = $event->getResponse(); } else { - $msg = sprintf('The controller must return a "Symfony\Component\HttpFoundation\Response" object but it returned %s.', $this->varToString($response)); + $msg = \sprintf('The controller must return a "Symfony\Component\HttpFoundation\Response" object but it returned %s.', $this->varToString($response)); // the user may have forgotten to return something if (null === $response) { @@ -278,20 +278,20 @@ private function handleThrowable(\Throwable $e, Request $request, int $type): Re private function varToString(mixed $var): string { if (\is_object($var)) { - return sprintf('an object of type %s', $var::class); + return \sprintf('an object of type %s', $var::class); } if (\is_array($var)) { $a = []; foreach ($var as $k => $v) { - $a[] = sprintf('%s => ...', $k); + $a[] = \sprintf('%s => ...', $k); } - return sprintf('an array ([%s])', mb_substr(implode(', ', $a), 0, 255)); + return \sprintf('an array ([%s])', mb_substr(implode(', ', $a), 0, 255)); } if (\is_resource($var)) { - return sprintf('a resource (%s)', get_resource_type($var)); + return \sprintf('a resource (%s)', get_resource_type($var)); } if (null === $var) { @@ -307,11 +307,11 @@ private function varToString(mixed $var): string } if (\is_string($var)) { - return sprintf('a string ("%s%s")', mb_substr($var, 0, 255), mb_strlen($var) > 255 ? '...' : ''); + return \sprintf('a string ("%s%s")', mb_substr($var, 0, 255), mb_strlen($var) > 255 ? '...' : ''); } if (is_numeric($var)) { - return sprintf('a number (%s)', (string) $var); + return \sprintf('a number (%s)', (string) $var); } return (string) $var; diff --git a/Kernel.php b/Kernel.php index 761461f616..9a9aa07ab0 100644 --- a/Kernel.php +++ b/Kernel.php @@ -89,7 +89,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl public function __construct(string $environment, bool $debug) { if (!$this->environment = $environment) { - throw new \InvalidArgumentException(sprintf('Invalid environment provided to "%s": the environment cannot be empty.', get_debug_type($this))); + throw new \InvalidArgumentException(\sprintf('Invalid environment provided to "%s": the environment cannot be empty.', get_debug_type($this))); } $this->debug = $debug; @@ -216,7 +216,7 @@ public function getBundles(): array public function getBundle(string $name): BundleInterface { if (!isset($this->bundles[$name])) { - throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the "registerBundles()" method of your "%s.php" file?', $name, get_debug_type($this))); + throw new \InvalidArgumentException(\sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the "registerBundles()" method of your "%s.php" file?', $name, get_debug_type($this))); } return $this->bundles[$name]; @@ -225,11 +225,11 @@ public function getBundle(string $name): BundleInterface public function locateResource(string $name): string { if ('@' !== $name[0]) { - throw new \InvalidArgumentException(sprintf('A resource name must start with @ ("%s" given).', $name)); + throw new \InvalidArgumentException(\sprintf('A resource name must start with @ ("%s" given).', $name)); } if (str_contains($name, '..')) { - throw new \RuntimeException(sprintf('File name "%s" contains invalid characters (..).', $name)); + throw new \RuntimeException(\sprintf('File name "%s" contains invalid characters (..).', $name)); } $bundleName = substr($name, 1); @@ -243,7 +243,7 @@ public function locateResource(string $name): string return $file; } - throw new \InvalidArgumentException(sprintf('Unable to find file "%s".', $name)); + throw new \InvalidArgumentException(\sprintf('Unable to find file "%s".', $name)); } public function getEnvironment(): string @@ -265,7 +265,7 @@ public function getProjectDir(): string $r = new \ReflectionObject($this); if (!is_file($dir = $r->getFileName())) { - throw new \LogicException(sprintf('Cannot auto-detect project dir for kernel of class "%s".', $r->name)); + throw new \LogicException(\sprintf('Cannot auto-detect project dir for kernel of class "%s".', $r->name)); } $dir = $rootDir = \dirname($dir); @@ -295,7 +295,7 @@ public function getContainer(): ContainerInterface */ public function setAnnotatedClassCache(array $annotatedClasses): void { - file_put_contents(($this->warmupDir ?: $this->getBuildDir()).'/annotations.map', sprintf('warmupDir ?: $this->getBuildDir()).'/annotations.map', \sprintf('registerBundles() as $bundle) { $name = $bundle->getName(); if (isset($this->bundles[$name])) { - throw new \LogicException(sprintf('Trying to register two bundles with the same name "%s".', $name)); + throw new \LogicException(\sprintf('Trying to register two bundles with the same name "%s".', $name)); } $this->bundles[$name] = $bundle; } @@ -375,7 +375,7 @@ protected function getContainerClass(): string $class = str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container'; if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $class)) { - throw new \InvalidArgumentException(sprintf('The environment "%s" contains invalid characters, it can only contain characters allowed in PHP class names.', $this->environment)); + throw new \InvalidArgumentException(\sprintf('The environment "%s" contains invalid characters, it can only contain characters allowed in PHP class names.', $this->environment)); } return $class; @@ -604,10 +604,10 @@ protected function buildContainer(): ContainerBuilder foreach (['cache' => $this->getCacheDir(), 'build' => $this->warmupDir ?: $this->getBuildDir(), 'logs' => $this->getLogDir()] as $name => $dir) { if (!is_dir($dir)) { if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new \RuntimeException(sprintf('Unable to create the "%s" directory (%s).', $name, $dir)); + throw new \RuntimeException(\sprintf('Unable to create the "%s" directory (%s).', $name, $dir)); } } elseif (!is_writable($dir)) { - throw new \RuntimeException(sprintf('Unable to write in the "%s" directory (%s).', $name, $dir)); + throw new \RuntimeException(\sprintf('Unable to write in the "%s" directory (%s).', $name, $dir)); } } diff --git a/Log/Logger.php b/Log/Logger.php index 50578a25e7..93c1dbc95b 100644 --- a/Log/Logger.php +++ b/Log/Logger.php @@ -74,13 +74,13 @@ public function __construct(?string $minLevel = null, $output = null, ?callable } if (!isset(self::LEVELS[$minLevel])) { - throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $minLevel)); + throw new InvalidArgumentException(\sprintf('The log level "%s" does not exist.', $minLevel)); } $this->minLevelIndex = self::LEVELS[$minLevel]; $this->formatter = null !== $formatter ? $formatter(...) : $this->format(...); if ($output && false === $this->handle = \is_string($output) ? @fopen($output, 'a') : $output) { - throw new InvalidArgumentException(sprintf('Unable to open "%s".', $output)); + throw new InvalidArgumentException(\sprintf('Unable to open "%s".', $output)); } $this->debug = $debug; } @@ -93,7 +93,7 @@ public function enableDebug(): void public function log($level, $message, array $context = []): void { if (!isset(self::LEVELS[$level])) { - throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level)); + throw new InvalidArgumentException(\sprintf('The log level "%s" does not exist.', $level)); } if (self::LEVELS[$level] < $this->minLevelIndex) { @@ -155,7 +155,7 @@ private function format(string $level, string $message, array $context, bool $pr $message = strtr($message, $replacements); } - $log = sprintf('[%s] %s', $level, $message); + $log = \sprintf('[%s] %s', $level, $message); if ($prefixDate) { $log = date(\DateTimeInterface::RFC3339).' '.$log; } diff --git a/Profiler/FileProfilerStorage.php b/Profiler/FileProfilerStorage.php index d2372c30e3..f1e28bc2b8 100644 --- a/Profiler/FileProfilerStorage.php +++ b/Profiler/FileProfilerStorage.php @@ -33,12 +33,12 @@ class FileProfilerStorage implements ProfilerStorageInterface public function __construct(string $dsn) { if (!str_starts_with($dsn, 'file:')) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use FileStorage with an invalid dsn "%s". The expected format is "file:/path/to/the/storage/folder".', $dsn)); + throw new \RuntimeException(\sprintf('Please check your configuration. You are trying to use FileStorage with an invalid dsn "%s". The expected format is "file:/path/to/the/storage/folder".', $dsn)); } $this->folder = substr($dsn, 5); if (!is_dir($this->folder) && false === @mkdir($this->folder, 0777, true) && !is_dir($this->folder)) { - throw new \RuntimeException(sprintf('Unable to create the storage directory (%s).', $this->folder)); + throw new \RuntimeException(\sprintf('Unable to create the storage directory (%s).', $this->folder)); } } @@ -144,7 +144,7 @@ public function write(Profile $profile): bool // Create directory $dir = \dirname($file); if (!is_dir($dir) && false === @mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new \RuntimeException(sprintf('Unable to create the storage directory (%s).', $dir)); + throw new \RuntimeException(\sprintf('Unable to create the storage directory (%s).', $dir)); } } diff --git a/Profiler/Profile.php b/Profiler/Profile.php index 08e7b65a21..91ae51e958 100644 --- a/Profiler/Profile.php +++ b/Profiler/Profile.php @@ -232,7 +232,7 @@ public function getChildByToken(string $token): ?self public function getCollector(string $name): DataCollectorInterface { if (!isset($this->collectors[$name])) { - throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name)); + throw new \InvalidArgumentException(\sprintf('Collector "%s" does not exist.', $name)); } return $this->collectors[$name]; diff --git a/Profiler/Profiler.php b/Profiler/Profiler.php index fd5b28531e..65adf0f17d 100644 --- a/Profiler/Profiler.php +++ b/Profiler/Profiler.php @@ -239,7 +239,7 @@ public function has(string $name): bool public function get(string $name): DataCollectorInterface { if (!isset($this->collectors[$name])) { - throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name)); + throw new \InvalidArgumentException(\sprintf('Collector "%s" does not exist.', $name)); } return $this->collectors[$name]; diff --git a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php index 1b4c20672a..033b23a2b3 100644 --- a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php @@ -173,7 +173,7 @@ public function testNullPayloadAndNotDefaultOrNullableArgument() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $this->assertSame(422, $e->getStatusCode()); } @@ -198,7 +198,7 @@ public function testQueryNullPayloadAndNotDefaultOrNullableArgument() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $this->assertSame(404, $e->getStatusCode()); } @@ -222,7 +222,7 @@ public function testWithoutValidatorAndCouldNotDenormalize() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $this->assertInstanceOf(PartialDenormalizationException::class, $e->getPrevious()); } @@ -250,12 +250,12 @@ public function testValidationNotPassed() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertSame(422, $e->getStatusCode()); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); - $this->assertSame(sprintf('This value should be of type %s.', class_exists(InvalidTypeException::class) ? 'string' : 'unknown'), $validationFailedException->getViolations()[0]->getMessage()); + $this->assertSame(\sprintf('This value should be of type %s.', class_exists(InvalidTypeException::class) ? 'string' : 'unknown'), $validationFailedException->getViolations()[0]->getMessage()); } } @@ -281,7 +281,7 @@ public function testValidationNotPerformedWhenPartialDenormalizationReturnsViola try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); @@ -306,7 +306,7 @@ public function testUnsupportedMedia() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $this->assertSame(415, $e->getStatusCode()); } @@ -419,7 +419,7 @@ public function testQueryStringParameterTypeMismatch() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); @@ -479,7 +479,7 @@ public function testRequestInputTypeMismatch() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); @@ -588,7 +588,7 @@ public function testAcceptFormatNotPassed(mixed $acceptFormat, string $contentTy try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $this->assertSame(415, $e->getStatusCode()); $this->assertSame($expectedExceptionMessage, $e->getMessage()); @@ -684,7 +684,7 @@ public function testValidationGroupsNotPassed(string $method, ValueResolver $att try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); @@ -749,7 +749,7 @@ public function testQueryValidationErrorCustomStatusCode() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertSame(400, $e->getStatusCode()); @@ -780,12 +780,12 @@ public function testRequestPayloadValidationErrorCustomStatusCode() try { $resolver->onKernelControllerArguments($event); - $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + $this->fail(\sprintf('Expected "%s" to be thrown.', HttpException::class)); } catch (HttpException $e) { $validationFailedException = $e->getPrevious(); $this->assertSame(400, $e->getStatusCode()); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); - $this->assertSame(sprintf('This value should be of type %s.', class_exists(InvalidTypeException::class) ? 'string' : 'unknown'), $validationFailedException->getViolations()[0]->getMessage()); + $this->assertSame(\sprintf('This value should be of type %s.', class_exists(InvalidTypeException::class) ? 'string' : 'unknown'), $validationFailedException->getViolations()[0]->getMessage()); } } } diff --git a/Tests/Controller/ArgumentResolverTest.php b/Tests/Controller/ArgumentResolverTest.php index 5d26396fbe..ba8728eb54 100644 --- a/Tests/Controller/ArgumentResolverTest.php +++ b/Tests/Controller/ArgumentResolverTest.php @@ -432,13 +432,13 @@ public function controllerDisablingResolver(#[ValueResolver(RequestAttributeValu public function controllerTargetingManyResolvers( #[ValueResolver(RequestAttributeValueResolver::class)] #[ValueResolver(DefaultValueResolver::class)] - int $foo + int $foo, ) { } public function controllerTargetingUnknownResolver( #[ValueResolver('foo')] - int $bar + int $bar, ) { } } diff --git a/Tests/Controller/TraceableArgumentResolverTest.php b/Tests/Controller/TraceableArgumentResolverTest.php index 43bbb13e6b..baac744ba8 100644 --- a/Tests/Controller/TraceableArgumentResolverTest.php +++ b/Tests/Controller/TraceableArgumentResolverTest.php @@ -28,7 +28,7 @@ public function testStopwatchEventIsStoppedWhenResolverThrows() $stopwatch = $this->createStub(Stopwatch::class); $stopwatch->method('start')->willReturn($stopwatchEvent); - $resolver = new class() implements ArgumentResolverInterface { + $resolver = new class implements ArgumentResolverInterface { public function getArguments(Request $request, callable $controller): array { throw new \Exception(); diff --git a/Tests/Controller/TraceableControllerResolverTest.php b/Tests/Controller/TraceableControllerResolverTest.php index ecd4a23736..fcdb6bea97 100644 --- a/Tests/Controller/TraceableControllerResolverTest.php +++ b/Tests/Controller/TraceableControllerResolverTest.php @@ -28,7 +28,7 @@ public function testStopwatchEventIsStoppedWhenResolverThrows() $stopwatch = $this->createStub(Stopwatch::class); $stopwatch->method('start')->willReturn($stopwatchEvent); - $resolver = new class() implements ControllerResolverInterface { + $resolver = new class implements ControllerResolverInterface { public function getController(Request $request): callable|false { throw new \Exception(); diff --git a/Tests/DataCollector/ConfigDataCollectorTest.php b/Tests/DataCollector/ConfigDataCollectorTest.php index efee6742ea..00da7a7801 100644 --- a/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/Tests/DataCollector/ConfigDataCollectorTest.php @@ -41,7 +41,7 @@ public function testCollect() $this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug()); $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL), $c->hasZendOpcache()); $this->assertSame(\extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL), $c->hasApcu()); - $this->assertSame(sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); + $this->assertSame(\sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); $this->assertContains($c->getSymfonyState(), ['eol', 'eom', 'dev', 'stable']); $eom = \DateTimeImmutable::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE)->format('F Y'); @@ -69,7 +69,7 @@ public function testCollectWithoutKernel() $this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug()); $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL), $c->hasZendOpcache()); $this->assertSame(\extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL), $c->hasApcu()); - $this->assertSame(sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); + $this->assertSame(\sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); $this->assertContains($c->getSymfonyState(), ['eol', 'eom', 'dev', 'stable']); $eom = \DateTimeImmutable::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE)->format('F Y'); diff --git a/Tests/DataCollector/RequestDataCollectorTest.php b/Tests/DataCollector/RequestDataCollectorTest.php index 04649f9ef3..65608851de 100644 --- a/Tests/DataCollector/RequestDataCollectorTest.php +++ b/Tests/DataCollector/RequestDataCollectorTest.php @@ -89,7 +89,7 @@ public function testControllerInspection($name, $callable, $expected) $c->collect($request, $response); $c->lateCollect(); - $this->assertSame($expected, $c->getController()->getValue(true), sprintf('Testing: %s', $name)); + $this->assertSame($expected, $c->getController()->getValue(true), \sprintf('Testing: %s', $name)); } public static function provideControllerCallables(): array @@ -118,7 +118,7 @@ public static function provideControllerCallables(): array 'Closure', fn () => 'foo', [ - 'class' => \PHP_VERSION_ID >= 80400 ? sprintf('{closure:%s():%d}', __METHOD__, __LINE__ - 2) : __NAMESPACE__.'\{closure}', + 'class' => \PHP_VERSION_ID >= 80400 ? \sprintf('{closure:%s():%d}', __METHOD__, __LINE__ - 2) : __NAMESPACE__.'\{closure}', 'method' => null, 'file' => __FILE__, 'line' => __LINE__ - 5, @@ -301,7 +301,7 @@ public function testItCollectsTheSessionTraceProperly() $this->assertSame('getMetadataBag', $trace[0]['function']); $this->assertSame(self::class, $class = $trace[1]['class']); - $this->assertSame(sprintf('%s:%s', $class, $line), $usages[0]['name']); + $this->assertSame(\sprintf('%s:%s', $class, $line), $usages[0]['name']); } public function testStatelessCheck() @@ -412,7 +412,7 @@ private function getCookieByName(Response $response, $name) } } - throw new \InvalidArgumentException(sprintf('Cookie named "%s" is not in response', $name)); + throw new \InvalidArgumentException(\sprintf('Cookie named "%s" is not in response', $name)); } /** diff --git a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index 0a8c488edc..f121322bb5 100644 --- a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -679,7 +679,7 @@ public function fooAction( string $apiKey, #[Target('image.storage')] ControllerDummy $service1, - ControllerDummy $service2 + ControllerDummy $service2, ) { } } diff --git a/Tests/EventListener/CacheAttributeListenerTest.php b/Tests/EventListener/CacheAttributeListenerTest.php index 0afae63a0a..1542b35e74 100644 --- a/Tests/EventListener/CacheAttributeListenerTest.php +++ b/Tests/EventListener/CacheAttributeListenerTest.php @@ -227,7 +227,7 @@ public function testEtagNotModifiedResponse(string $expression) $request = $this->createRequest(new Cache(etag: $expression)); $request->attributes->set('id', '12345'); - $request->headers->add(['If-None-Match' => sprintf('"%s"', hash('sha256', $entity->getId()))]); + $request->headers->add(['If-None-Match' => \sprintf('"%s"', hash('sha256', $entity->getId()))]); $listener = new CacheAttributeListener(); $controllerArgumentsEvent = new ControllerArgumentsEvent($this->getKernel(), fn (TestEntity $test) => new Response(), [$entity], $request, null); diff --git a/Tests/EventListener/SessionListenerTest.php b/Tests/EventListener/SessionListenerTest.php index 3064fca51f..fe700c927f 100644 --- a/Tests/EventListener/SessionListenerTest.php +++ b/Tests/EventListener/SessionListenerTest.php @@ -336,7 +336,7 @@ public function testSessionCookieSetWhenOtherNativeVariablesSet() public function testOnlyTriggeredOnMainRequest() { - $listener = new class() extends AbstractSessionListener { + $listener = new class extends AbstractSessionListener { protected function getSession(): ?SessionInterface { return null; diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index 39f00a0139..afd79e1d59 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -769,7 +769,7 @@ public function testHitBackendOnlyOnceWhenCacheWasLocked() $this->request('GET', '/'); // warm the cache // Use a store that simulates a cache entry being locked upon first attempt - $this->store = new class(sys_get_temp_dir() . '/http_cache') extends Store { + $this->store = new class(sys_get_temp_dir().'/http_cache') extends Store { private bool $hasLock = false; public function lock(Request $request): bool @@ -1418,7 +1418,7 @@ public function testEsiCacheIncludesEmbeddedResponseContentWhenMainResponseFails 'headers' => [ 'Cache-Control' => 's-maxage=10', // stays fresh 'Last-Modified' => 'Mon, 12 Aug 2024 10:05:00 +0000', - ] + ], ], ]); @@ -1475,7 +1475,7 @@ public function testEsiCacheIncludesEmbeddedResponseContentWhenMainResponseFails 'headers' => [ 'Cache-Control' => 's-maxage=0', // goes stale immediately 'Last-Modified' => 'Mon, 12 Aug 2024 10:05:00 +0000', - ] + ], ], ]); @@ -1540,7 +1540,7 @@ public function testEsiCacheIncludesEmbeddedResponseContentWhenMainAndEmbeddedRe 'headers' => [ 'Cache-Control' => 's-maxage=10', 'Last-Modified' => 'Mon, 12 Aug 2024 10:00:00 +0000', - ] + ], ], ]); diff --git a/Tests/HttpCache/HttpCacheTestCase.php b/Tests/HttpCache/HttpCacheTestCase.php index 88f6bed56f..b05d913666 100644 --- a/Tests/HttpCache/HttpCacheTestCase.php +++ b/Tests/HttpCache/HttpCacheTestCase.php @@ -115,7 +115,7 @@ public function request($method, $uri = '/', $server = [], $cookies = [], $esi = $this->kernel->reset(); - if (! $this->store) { + if (!$this->store) { $this->store = $this->createStore(); } @@ -188,6 +188,6 @@ public static function clearDirectory($directory) protected function createStore(): Store { - return new Store(sys_get_temp_dir() . '/http_cache'); + return new Store(sys_get_temp_dir().'/http_cache'); } } diff --git a/Tests/HttpCache/ResponseCacheStrategyTest.php b/Tests/HttpCache/ResponseCacheStrategyTest.php index ef3f495011..a4650643cb 100644 --- a/Tests/HttpCache/ResponseCacheStrategyTest.php +++ b/Tests/HttpCache/ResponseCacheStrategyTest.php @@ -400,14 +400,14 @@ public function testCacheControlMerging(array $expects, array $main, array $surr } elseif ('age' === $key) { $this->assertSame($value, $response->getAge()); } elseif (true === $value) { - $this->assertTrue($response->headers->hasCacheControlDirective($key), sprintf('Cache-Control header must have "%s" flag', $key)); + $this->assertTrue($response->headers->hasCacheControlDirective($key), \sprintf('Cache-Control header must have "%s" flag', $key)); } elseif (false === $value) { $this->assertFalse( $response->headers->hasCacheControlDirective($key), - sprintf('Cache-Control header must NOT have "%s" flag', $key) + \sprintf('Cache-Control header must NOT have "%s" flag', $key) ); } else { - $this->assertSame($value, $response->headers->getCacheControlDirective($key), sprintf('Cache-Control flag "%s" should be "%s"', $key, $value)); + $this->assertSame($value, $response->headers->getCacheControlDirective($key), \sprintf('Cache-Control flag "%s" should be "%s"', $key, $value)); } } } diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 94c498a0f2..268f8c7d25 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -65,7 +65,7 @@ public function testConstructor() public function testEmptyEnv() { $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage(sprintf('Invalid environment provided to "%s": the environment cannot be empty.', KernelForTest::class)); + $this->expectExceptionMessage(\sprintf('Invalid environment provided to "%s": the environment cannot be empty.', KernelForTest::class)); new KernelForTest('', false); } @@ -321,7 +321,7 @@ public function doStuff() } } EOF -, <<<'EOF' + , <<<'EOF' setParameter('test.extension-registered', true); From 451a4a1812471377ccca7cb9a135fa80d407ae6d Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Tue, 24 Jun 2025 14:17:47 +0100 Subject: [PATCH 205/210] Fix various bool-type coercions --- Tests/EventListener/SessionListenerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/EventListener/SessionListenerTest.php b/Tests/EventListener/SessionListenerTest.php index fe700c927f..995930e68b 100644 --- a/Tests/EventListener/SessionListenerTest.php +++ b/Tests/EventListener/SessionListenerTest.php @@ -104,13 +104,13 @@ public static function provideSessionOptions(): \Generator yield 'set_cookiesecure_auto_by_symfony_false_by_php' => [ 'phpSessionOptions' => ['secure' => false], - 'sessionOptions' => ['cookie_path' => '/test/', 'cookie_httponly' => 'auto', 'cookie_secure' => 'auto', 'cookie_samesite' => Cookie::SAMESITE_LAX], + 'sessionOptions' => ['cookie_path' => '/test/', 'cookie_httponly' => true, 'cookie_secure' => 'auto', 'cookie_samesite' => Cookie::SAMESITE_LAX], 'expectedSessionOptions' => ['cookie_path' => '/test/', 'cookie_domain' => '', 'cookie_secure' => false, 'cookie_httponly' => true, 'cookie_samesite' => Cookie::SAMESITE_LAX], ]; yield 'set_cookiesecure_auto_by_symfony_true_by_php' => [ 'phpSessionOptions' => ['secure' => true], - 'sessionOptions' => ['cookie_path' => '/test/', 'cookie_httponly' => 'auto', 'cookie_secure' => 'auto', 'cookie_samesite' => Cookie::SAMESITE_LAX], + 'sessionOptions' => ['cookie_path' => '/test/', 'cookie_httponly' => true, 'cookie_secure' => 'auto', 'cookie_samesite' => Cookie::SAMESITE_LAX], 'expectedSessionOptions' => ['cookie_path' => '/test/', 'cookie_domain' => '', 'cookie_secure' => true, 'cookie_httponly' => true, 'cookie_samesite' => Cookie::SAMESITE_LAX], ]; From b81dcdbe34b8e8f7b3fc7b2a47fa065d5bf30726 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 31 Jul 2025 11:23:30 +0200 Subject: [PATCH 206/210] Update VERSION for 6.4.24 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 9a9aa07ab0..281b82a96d 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.4.24-DEV'; + public const VERSION = '6.4.24'; public const VERSION_ID = 60424; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 24; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2026'; public const END_OF_LIFE = '11/2027'; From acf463ac20aba652a1e6e02d7b2f6d9476a18202 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 31 Jul 2025 11:35:03 +0200 Subject: [PATCH 207/210] Bump Symfony version to 6.4.25 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 281b82a96d..e9de050f24 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.4.24'; - public const VERSION_ID = 60424; + public const VERSION = '6.4.25-DEV'; + public const VERSION_ID = 60425; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 24; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 25; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2026'; public const END_OF_LIFE = '11/2027'; From 6ecc895559ec0097e221ed2fd5eb44d5fede083c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 31 Jul 2025 12:45:04 +0200 Subject: [PATCH 208/210] Update VERSION for 7.3.2 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 7bc59a9e68..d8be61d6c6 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.3.2-DEV'; + public const VERSION = '7.3.2'; public const VERSION_ID = 70302; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 3; public const RELEASE_VERSION = 2; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2026'; public const END_OF_LIFE = '01/2026'; From a839550dd70d9c55e4e82cf59f1b8285aaafb13d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 31 Jul 2025 12:54:53 +0200 Subject: [PATCH 209/210] Bump Symfony version to 7.3.3 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index d8be61d6c6..42123cea19 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '7.3.2'; - public const VERSION_ID = 70302; + public const VERSION = '7.3.3-DEV'; + public const VERSION_ID = 70303; public const MAJOR_VERSION = 7; public const MINOR_VERSION = 3; - public const RELEASE_VERSION = 2; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 3; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2026'; public const END_OF_LIFE = '01/2026'; From 4ed8624311f09586823ef14e9001516a1c59f4b2 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 1 Aug 2025 17:44:34 +0200 Subject: [PATCH 210/210] Fix wrong boolean values --- Tests/DataCollector/LoggerDataCollectorTest.php | 2 +- .../RegisterControllerArgumentLocatorsPassTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/DataCollector/LoggerDataCollectorTest.php b/Tests/DataCollector/LoggerDataCollectorTest.php index 3e1654247b..8babfe4a7d 100644 --- a/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/Tests/DataCollector/LoggerDataCollectorTest.php @@ -33,7 +33,7 @@ public function testCollectWithUnexpectedFormat() $c = new LoggerDataCollector($logger, __DIR__.'/'); $c->lateCollect(); - $compilerLogs = $c->getCompilerLogs()->getValue('message'); + $compilerLogs = $c->getCompilerLogs()->getValue(true); $this->assertSame([ ['message' => 'Removed service "Psr\Container\ContainerInterface"; reason: private alias.'], diff --git a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index f121322bb5..62d0cde969 100644 --- a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -505,7 +505,7 @@ public function testAutowireAttribute() $this->assertInstanceOf(\stdClass::class, $locator->get('serviceAsValue')); $this->assertInstanceOf(\stdClass::class, $locator->get('expressionAsValue')); $this->assertSame('bar', $locator->get('rawValue')); - $this->stringContains('Symfony_Component_HttpKernel_Tests_Fixtures_Suit_APP_SUIT', $locator->get('suit')); + $this->assertStringContainsString('Symfony_Component_HttpKernel_Tests_Fixtures_Suit_APP_SUIT', $locator->get('suit')); $this->assertSame('@bar', $locator->get('escapedRawValue')); $this->assertSame('foo', $locator->get('customAutowire')); $this->assertInstanceOf(FooInterface::class, $autowireCallable = $locator->get('autowireCallable')); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy