8000 From 16b9b36f81631155546d9f05271dd027c83c3dd4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 Oct 2023 17:07:40 -0700 Subject: [PATCH 01/31] Update VERSION for 5.4.30 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 10e943ca0f..0db848bc1e 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.30-DEV'; + public const VERSION = '5.4.30'; public const VERSION_ID = 50430; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 30; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From 9e1c9cbb70f080fc0212e8eb213a4845ff407f5b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 Oct 2023 17:57:51 -0700 Subject: [PATCH 02/31] Bump Symfony version to 5.4.31 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 0db848bc1e..9fc6b36fc5 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.30'; - public const VERSION_ID = 50430; + public const VERSION = '5.4.31-DEV'; + public const VERSION_ID = 50431; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 30; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 31; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From 75338c6a98a9b5294ae84002f54edccc112cfc62 Mon Sep 17 00:00:00 2001 From: Dominik Ulrich Date: Thu, 2 Nov 2023 15:45:40 +0100 Subject: [PATCH 03/31] [HttpKernel] Preventing error 500 when function putenv is disabled --- Kernel.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Kernel.php b/Kernel.php index 9fc6b36fc5..c31a4b7ca3 100644 --- a/Kernel.php +++ b/Kernel.php @@ -778,7 +778,9 @@ private function preBoot(): ContainerInterface $this->startTime = microtime(true); } if ($this->debug && !isset($_ENV['SHELL_VERBOSITY']) && !isset($_SERVER['SHELL_VERBOSITY'])) { - putenv('SHELL_VERBOSITY=3'); + if (\function_exists('putenv')) { + putenv('SHELL_VERBOSITY=3'); + } $_ENV['SHELL_VERBOSITY'] = 3; $_SERVER['SHELL_VERBOSITY'] = 3; } From dba872e8e6247cccb605626a133491b6c4b307c6 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 7 Nov 2023 18:20:03 +0100 Subject: [PATCH 04/31] [HttpKernel] Fix PHP deprecation --- DataCollector/LoggerDataCollector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataCollector/LoggerDataCollector.php b/DataCollector/LoggerDataCollector.php index 2bbd2a039e..7b1896ac29 100644 --- a/DataCollector/LoggerDataCollector.php +++ b/DataCollector/LoggerDataCollector.php @@ -224,7 +224,7 @@ private function getContainerDeprecationLogs(): array private function getContainerCompilerLogs(string $compilerLogsFilepath = null): array { - if (!is_file($compilerLogsFilepath)) { + if (!$compilerLogsFilepath || !is_file($compilerLogsFilepath)) { return []; } From d2fad58d32a7b4864d205a7289602a27ce75018c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 10 Nov 2023 14:39:09 +0100 Subject: [PATCH 05/31] Update VERSION for 5.4.31 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index c31a4b7ca3..21e1b67a8a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.31-DEV'; + public const VERSION = '5.4.31'; public const VERSION_ID = 50431; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 31; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From d1f3844d3b1c43cbc5ceae4b13b1f11d04657966 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 10 Nov 2023 14:43:24 +0100 Subject: [PATCH 06/31] Bump Symfony version to 5.4.32 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 21e1b67a8a..ed855c2e04 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.31'; - public const VERSION_ID = 50431; + public const VERSION = '5.4.32-DEV'; + public const VERSION_ID = 50432; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 31; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 32; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From 929202375ccf44a309c34aeca8305408442ebcc1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 10 Nov 2023 14:47:32 +0100 Subject: [PATCH 07/31] Update VERSION for 6.3.8 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 86c8c0e285..ae1343252e 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.3.8-DEV'; + public const VERSION = '6.3.8'; public const VERSION_ID = 60308; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 3; public const RELEASE_VERSION = 8; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2024'; public const END_OF_LIFE = '01/2024'; From 512447e684065c04743a5bcce91f0e9f83b23153 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 10 Nov 2023 14:52:27 +0100 Subject: [PATCH 08/31] Bump Symfony version to 6.3.9 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index ae1343252e..1fa48bd3b4 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.3.8'; - public const VERSION_ID = 60308; + public const VERSION = '6.3.9-DEV'; + public const VERSION_ID = 60309; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 3; - 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/2024'; public const END_OF_LIFE = '01/2024'; From 442472752e3adc9810a7e425824497dc22f75acf Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 29 Nov 2023 11:12:28 +0100 Subject: [PATCH 09/31] Update VERSION for 5.4.32 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index ed855c2e04..c4675f51ef 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.32-DEV'; + public const VERSION = '5.4.32'; public const VERSION_ID = 50432; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 32; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From 24d63410c821b994bd6530d2a11cb2e911994056 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 29 Nov 2023 11:18:28 +0100 Subject: [PATCH 10/31] Bump Symfony version to 5.4.33 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index c4675f51ef..b7482dc108 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.32'; - public const VERSION_ID = 50432; + public const VERSION = '5.4.33-DEV'; + public const VERSION_ID = 50433; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 32; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 33; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From d63fe6b1e3ad2f037f6f000a6fc867fa8934f35c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 29 Nov 2023 11:24:27 +0100 Subject: [PATCH 11/31] Update VERSION for 6.3.9 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1fa48bd3b4..41f48a3a56 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.3.9-DEV'; + public const VERSION = '6.3.9'; public const VERSION_ID = 60309; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 3; public const RELEASE_VERSION = 9; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2024'; public const END_OF_LIFE = '01/2024'; From 874f929e6851181383ee04ea517c0c44eff7f694 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 29 Nov 2023 11:34:21 +0100 Subject: [PATCH 12/31] Bump Symfony version to 6.3.10 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 41f48a3a56..ddbb1b8423 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.3.9'; - public const VERSION_ID = 60309; + public const VERSION = '6.3.10-DEV'; + public const VERSION_ID = 60310; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 3; - 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/2024'; public const END_OF_LIFE = '01/2024'; From 892636f9279f953dc266dc088f900b03eecb4ffa Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 1 Dec 2023 17:51:11 +0100 Subject: [PATCH 13/31] Update VERSION for 5.4.33 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index b7482dc108..3cfc3af9a0 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.33-DEV'; + public const VERSION = '5.4.33'; public const VERSION_ID = 50433; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 33; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From 7833512a9f15fc7d3f1581aba26c615d84972e74 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 1 Dec 2023 17:56:05 +0100 Subject: [PATCH 14/31] Bump Symfony version to 5.4.34 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 3cfc3af9a0..37a0b0110c 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.33'; - public const VERSION_ID = 50433; + public const VERSION = '5.4.34-DEV'; + public const VERSION_ID = 50434; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 33; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 34; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From 8d8e7aa60593fd0a2e3c1cea08cc687314841b61 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 1 Dec 2023 17:57:27 +0100 Subject: [PATCH 15/31] Update VERSION for 6.3.10 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index ddbb1b8423..f7b33bab29 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.3.10-DEV'; + public const VERSION = '6.3.10'; public const VERSION_ID = 60310; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 3; public const RELEASE_VERSION = 10; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2024'; public const END_OF_LIFE = '01/2024'; From c630226bf404bf9a44ddefe5a29e988d6da265ff Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 1 Dec 2023 18:00:27 +0100 Subject: [PATCH 16/31] Bump Symfony version to 6.3.11 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index f7b33bab29..1b581a7718 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.3.10'; - public const VERSION_ID = 60310; + public const VERSION = '6.3.11-DEV'; + public const VERSION_ID = 60311; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 3; - 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/2024'; public const END_OF_LIFE = '01/2024'; From 15e74b4da2c1fd75d7c5e96e7fa90c1b126d7e45 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Mon, 4 Dec 2023 13:07:31 +0100 Subject: [PATCH 17/31] [HttpKernel] Catch `TypeError` if the wrong type is used in `BackedEnumValueResolver` --- .../BackedEnumValueResolver.php | 2 +- .../BackedEnumValueResolverTest.php | 13 +++++++++++++ Tests/Fixtures/IntEnum.php | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 Tests/Fixtures/IntEnum.php diff --git a/Controller/ArgumentResolver/BackedEnumValueResolver.php b/Controller/ArgumentResolver/BackedEnumValueResolver.php index 4f0ca76d30..620e2de080 100644 --- a/Controller/ArgumentResolver/BackedEnumValueResolver.php +++ b/Controller/ArgumentResolver/BackedEnumValueResolver.php @@ -86,7 +86,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable try { return [$enumType::from($value)]; - } catch (\ValueError $e) { + } catch (\ValueError|\TypeError $e) { throw new NotFoundHttpException(sprintf('Could not resolve the "%s $%s" controller argument: ', $argument->getType(), $argument->getName()).$e->getMessage(), $e); } } diff --git a/Tests/Controller/ArgumentResolver/BackedEnumValueResolverTest.php b/Tests/Controller/ArgumentResolver/BackedEnumValueResolverTest.php index 9e29862736..9dc6a08312 100644 --- a/Tests/Controller/ArgumentResolver/BackedEnumValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/BackedEnumValueResolverTest.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpKernel\Controller\ArgumentResolver\BackedEnumValueResolver; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\HttpKernel\Tests\Fixtures\IntEnum; use Symfony\Component\HttpKernel\Tests\Fixtures\Suit; class BackedEnumValueResolverTest extends TestCase @@ -134,6 +135,18 @@ public function testResolveThrowsOnUnexpectedType() $resolver->resolve($request, $metadata); } + public function testResolveThrowsOnTypeError() + { + $resolver = new BackedEnumValueResolver(); + $request = self::createRequest(['suit' => 'value']); + $metadata = self::createArgumentMetadata('suit', IntEnum::class); + + $this->expectException(NotFoundHttpException::class); + $this->expectExceptionMessage('Could not resolve the "Symfony\Component\HttpKernel\Tests\Fixtures\IntEnum $suit" controller argument: Symfony\Component\HttpKernel\Tests\Fixtures\IntEnum::from(): Argument #1 ($value) must be of type int, string given'); + + $resolver->resolve($request, $metadata); + } + private static function createRequest(array $attributes = []): Request { return new Request([], [], $attributes); diff --git a/Tests/Fixtures/IntEnum.php b/Tests/Fixtures/IntEnum.php new file mode 100644 index 0000000000..8f694553b9 --- /dev/null +++ b/Tests/Fixtures/IntEnum.php @@ -0,0 +1,18 @@ + + * + * 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; + +enum IntEnum: int +{ + case One = 1; + case Two = 2; +} From 90c21ba90c9807686e9cecdcb22870bd3dd82df6 Mon Sep 17 00:00:00 2001 From: HypeMC Date: Mon, 4 Dec 2023 20:14:47 +0100 Subject: [PATCH 18/31] [HttpKernel] Fix request attribute value ignored with pinned resolvers --- Controller/ArgumentResolver.php | 1 + Tests/Controller/ArgumentResolverTest.php | 49 ++++++++++++++++++++--- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/Controller/ArgumentResolver.php b/Controller/ArgumentResolver.php index 3b0f89509f..6643cc58ee 100644 --- a/Controller/ArgumentResolver.php +++ b/Controller/ArgumentResolver.php @@ -73,6 +73,7 @@ public function getArguments(Request $request, callable $controller, \Reflection $argumentValueResolvers = [ $this->namedResolvers->get($resolverName), + new RequestAttributeValueResolver(), new DefaultValueResolver(), ]; } diff --git a/Tests/Controller/ArgumentResolverTest.php b/Tests/Controller/ArgumentResolverTest.php index ef44f45bae..d34b0b4b45 100644 --- a/Tests/Controller/ArgumentResolverTest.php +++ b/Tests/Controller/ArgumentResolverTest.php @@ -22,6 +22,8 @@ use Symfony\Component\HttpKernel\Controller\ArgumentResolver\DefaultValueResolver; use Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestAttributeValueResolver; use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; +use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; +use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadataFactory; use Symfony\Component\HttpKernel\Exception\ResolverNotFoundException; use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\ExtendingRequest; @@ -298,17 +300,21 @@ public function testTargetedResolver() public function testTargetedResolverWithDefaultValue() { - $resolver = self::getResolver([], [RequestAttributeValueResolver::class => new RequestAttributeValueResolver()]); + $resolver = self::getResolver([], [TestEntityValueResolver::class => new TestEntityValueResolver()]); $request = Request::create('/'); $controller = $this->controllerTargetingResolverWithDefaultValue(...); - $this->assertSame([2], $resolver->getArguments($request, $controller)); + /** @var Post[] $arguments */ + $arguments = $resolver->getArguments($request, $controller); + + $this->assertCount(1, $arguments); + $this->assertSame('Default', $arguments[0]->title); } public function testTargetedResolverWithNullableValue() { - $resolver = self::getResolver([], [RequestAttributeValueResolver::class => new RequestAttributeValueResolver()]); + $resolver = self::getResolver([], [TestEntityValueResolver::class => new TestEntityValueResolver()]); $request = Request::create('/'); $controller = $this->controllerTargetingResolverWithNullableValue(...); @@ -316,6 +322,17 @@ public function testTargetedResolverWithNullableValue() $this->assertSame([null], $resolver->getArguments($request, $controller)); } + public function testTargetedResolverWithRequestAttributeValue() + { + $resolver = self::getResolver([], [TestEntityValueResolver::class => new TestEntityValueResolver()]); + + $request = Request::create('/'); + $request->attributes->set('foo', $object = new Post('Random '.time())); + $controller = $this->controllerTargetingResolverWithTestEntity(...); + + $this->assertSame([$object], $resolver->getArguments($request, $controller)); + } + public function testDisabledResolver() { $resolver = self::getResolver(namedResolvers: []); @@ -393,11 +410,15 @@ public function controllerTargetingResolver(#[ValueResolver(DefaultValueResolver { } - public function controllerTargetingResolverWithDefaultValue(#[ValueResolver(RequestAttributeValueResolver::class)] int $foo = 2) + public function controllerTargetingResolverWithDefaultValue(#[ValueResolver(TestEntityValueResolver::class)] Post $foo = new Post('Default')) + { + } + + public function controllerTargetingResolverWithNullableValue(#[ValueResolver(TestEntityValueResolver::class)] ?Post $foo) { } - public function controllerTargetingResolverWithNullableValue(#[ValueResolver(RequestAttributeValueResolver::class)] ?int $foo) + public function controllerTargetingResolverWithTestEntity(#[ValueResolver(TestEntityValueResolver::class)] Post $foo) { } @@ -422,3 +443,21 @@ public function controllerTargetingUnknownResolver( function controller_function($foo, $foobar) { } + +class TestEntityValueResolver implements ValueResolverInterface +{ + public function resolve(Request $request, ArgumentMetadata $argument): iterable + { + return Post::class === $argument->getType() && $request->request->has('title') + ? [new Post($request->request->get('title'))] + : []; + } +} + +class Post +{ + public function __construct( + public readonly string $title, + ) { + } +} From 657709df573c927372b693a55920e98e48bcd81e Mon Sep 17 00:00:00 2001 From: HypeMC Date: Sun, 17 Dec 2023 17:29:14 +0100 Subject: [PATCH 19/31] [HttpKernel] Don't validate partially denormalized object --- .../RequestPayloadValueResolver.php | 2 +- .../RequestPayloadValueResolverTest.php | 60 ++++++++++++++++--- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/Controller/ArgumentResolver/RequestPayloadValueResolver.php b/Controller/ArgumentResolver/RequestPayloadValueResolver.php index 8083dd78ef..38ee7758a7 100644 --- a/Controller/ArgumentResolver/RequestPayloadValueResolver.php +++ b/Controller/ArgumentResolver/RequestPayloadValueResolver.php @@ -119,7 +119,7 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event): vo $payload = $e->getData(); } - if (null !== $payload) { + if (null !== $payload && !\count($violations)) { $violations->addAll($this->validator->validate($payload, null, $argument->validationGroups ?? null)); } diff --git a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php index 4ca326392b..179f14a127 100644 --- a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php @@ -27,7 +27,6 @@ use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Component\Serializer\Serializer; use Symfony\Component\Validator\Constraints as Assert; -use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationList; use Symfony\Component\Validator\Exception\ValidationFailedException; use Symfony\Component\Validator\Validator\ValidatorInterface; @@ -226,14 +225,11 @@ public function testWithoutValidatorAndCouldNotDenormalize() public function testValidationNotPassed() { $content = '{"price": 50, "title": ["not a string"]}'; - $payload = new RequestPayload(50); $serializer = new Serializer([new ObjectNormalizer()], ['json' => new JsonEncoder()]); $validator = $this->createMock(ValidatorInterface::class); - $validator->expects($this->once()) - ->method('validate') - ->with($payload) - ->willReturn(new ConstraintViolationList([new ConstraintViolation('Test', null, [], '', null, '')])); + $validator->expects($this->never()) + ->method('validate'); $resolver = new RequestPayloadValueResolver($serializer, $validator); @@ -253,7 +249,36 @@ public function testValidationNotPassed() $validationFailedException = $e->getPrevious(); $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); $this->assertSame('This value should be of type unknown.', $validationFailedException->getViolations()[0]->getMessage()); - $this->assertSame('Test', $validationFailedException->getViolations()[1]->getMessage()); + } + } + + public function testValidationNotPerformedWhenPartialDenormalizationReturnsViolation() + { + $content = '{"password": "abc"}'; + $serializer = new Serializer([new ObjectNormalizer()], ['json' => new JsonEncoder()]); + + $validator = $this->createMock(ValidatorInterface::class); + $validator->expects($this->never()) + ->method('validate'); + + $resolver = new RequestPayloadValueResolver($serializer, $validator); + + $argument = new ArgumentMetadata('invalid', User::class, false, false, null, false, [ + MapRequestPayload::class => new MapRequestPayload(), + ]); + $request = Request::create('/', 'POST', server: ['CONTENT_TYPE' => 'application/json'], content: $content); + + $kernel = $this->createMock(HttpKernelInterface::class); + $arguments = $resolver->resolve($request, $argument); + $event = new ControllerArgumentsEvent($kernel, function () {}, $arguments, $request, HttpKernelInterface::MAIN_REQUEST); + + try { + $resolver->onKernelControllerArguments($event); + $this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class)); + } catch (HttpException $e) { + $validationFailedException = $e->getPrevious(); + $this->assertInstanceOf(ValidationFailedException::class, $validationFailedException); + $this->assertSame('This value should be of type unknown.', $validationFailedException->getViolations()[0]->getMessage()); } } @@ -612,3 +637,24 @@ public function __construct(public readonly float $price) { } } + +class User +{ + public function __construct( + #[Assert\NotBlank, Assert\Email] + private string $email, + #[Assert\NotBlank] + private string $password, + ) { + } + + public function getEmail(): string + { + return $this->email; + } + + public function getPassword(): string + { + return $this->password; + } +} From 32d551a398b6479f3746deda8006dc7966d0426a Mon Sep 17 00:00:00 2001 From: Florian Merle Date: Thu, 14 Dec 2023 14:10:16 +0100 Subject: [PATCH 20/31] [HttpKernel] Move @internal from AbstractSessionListener class to its methods and properties --- EventListener/AbstractSessionListener.php | 29 +++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/EventListener/AbstractSessionListener.php b/EventListener/AbstractSessionListener.php index cb994cd77d..979154be9a 100644 --- a/EventListener/AbstractSessionListener.php +++ b/EventListener/AbstractSessionListener.php @@ -36,13 +36,15 @@ * * @author Johannes M. Schmitt * @author Tobias Schultze - * - * @internal */ abstract class AbstractSessionListener implements EventSubscriberInterface, ResetInterface { public const NO_AUTO_CACHE_CONTROL_HEADER = 'Symfony-Session-NoAutoCacheControl'; + + /** + * @internal + */ protected $container; private $sessionUsageStack = []; private $debug; @@ -52,6 +54,9 @@ abstract class AbstractSessionListener implements EventSubscriberInterface, Rese */ private $sessionOptions; + /** + * @internal + */ public function __construct(ContainerInterface $container = null, bool $debug = false, array $sessionOptions = []) { $this->container = $container; @@ -59,6 +64,9 @@ public function __construct(ContainerInterface $container = null, bool $debug = $this->sessionOptions = $sessionOptions; } + /** + * @internal + */ public function onKernelRequest(RequestEvent $event) { if (!$event->isMainRequest()) { @@ -94,6 +102,9 @@ public function onKernelRequest(RequestEvent $event) $this->sessionUsageStack[] = $session instanceof Session ? $session->getUsageIndex() : 0; } + /** + * @internal + */ public function onKernelResponse(ResponseEvent $event) { if (!$event->isMainRequest() || (!$this->container->has('initialized_session') && !$event->getRequest()->hasSession())) { @@ -222,6 +233,9 @@ public function onKernelResponse(ResponseEvent $event) } } + /** + * @internal + */ public function onFinishRequest(FinishRequestEvent $event) { if ($event->isMainRequest()) { @@ -229,6 +243,9 @@ public function onFinishRequest(FinishRequestEvent $event) } } + /** + * @internal + */ public function onSessionUsage(): void { if (!$this->debug) { @@ -264,6 +281,9 @@ public function onSessionUsage(): void throw new UnexpectedSessionUsageException('Session was used while the request was declared stateless.'); } + /** + * @internal + */ public static function getSubscribedEvents(): array { return [ @@ -274,6 +294,9 @@ public static function getSubscribedEvents(): array ]; } + /** + * @internal + */ public function reset(): void { if (\PHP_SESSION_ACTIVE === session_status()) { @@ -291,6 +314,8 @@ public function reset(): void /** * Gets the session obje 10000 ct. * + * @internal + * * @return SessionInterface|null */ abstract protected function getSession(); From bd55eb869a7c2fd5dc26f91c759396e95e893233 Mon Sep 17 00:00:00 2001 From: Jacek Kobus Date: Fri, 15 Dec 2023 01:02:08 +0100 Subject: [PATCH 21/31] [HttpFoundation][FrameworkBundle] Fix default locale is ignored when set_locale_from_accept_language is used --- EventListener/LocaleListener.php | 6 ++++-- Tests/EventListener/LocaleListenerTest.php | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/EventListener/LocaleListener.php b/EventListener/LocaleListener.php index f19e13649e..2c09e22bda 100644 --- a/EventListener/LocaleListener.php +++ b/EventListener/LocaleListener.php @@ -68,8 +68,10 @@ private function setLocale(Request $request) { if ($locale = $request->attributes->get('_locale')) { $request->setLocale($locale); - } elseif ($this->useAcceptLanguageHeader && $this->enabledLocales && ($preferredLanguage = $request->getPreferredLanguage($this->enabledLocales))) { - $request->setLocale($preferredLanguage); + } elseif ($this->useAcceptLanguageHeader && $this->enabledLocales) { + if ($request->getLanguages() && $preferredLanguage = $request->getPreferredLanguage($this->enabledLocales)) { + $request->setLocale($preferredLanguage); + } $request->attributes->set('_vary_by_language', true); } } diff --git a/Tests/EventListener/LocaleListenerTest.php b/Tests/EventListener/LocaleListenerTest.php index 04d9517474..e22950ddd9 100644 --- a/Tests/EventListener/LocaleListenerTest.php +++ b/Tests/EventListener/LocaleListenerTest.php @@ -130,6 +130,28 @@ public function testRequestPreferredLocaleFromAcceptLanguageHeader() $this->assertEquals('fr', $request->getLocale()); } + public function testRequestDefaultLocaleIfNoAcceptLanguageHeaderIsPresent() + { + $request = new Request(); + $listener = new LocaleListener($this->requestStack, 'de', null, true, ['lt', 'de']); + $event = $this->getEvent($request); + + $listener->setDefaultLocale($event); + $listener->onKernelRequest($event); + $this->assertEquals('de', $request->getLocale()); + } + + public function testRequestVaryByLanguageAttributeIsSetIfUsingAcceptLanguageHeader() + { + $request = new Request(); + $listener = new LocaleListener($this->requestStack, 'de', null, true, ['lt', 'de']); + $event = $this->getEvent($request); + + $listener->setDefaultLocale($event); + $listener->onKernelRequest($event); + $this->assertTrue($request->attributes->get('_vary_by_language')); + } + public function testRequestSecondPreferredLocaleFromAcceptLanguageHeader() { $request = Request::create('/'); From f2b00c66d1c7ef12f3fc625af2a0bc5d5857db7b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 30 Dec 2023 14:02:02 +0100 Subject: [PATCH 22/31] Update VERSION for 5.4.34 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 37a0b0110c..bd6b152b8a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.34-DEV'; + public const VERSION = '5.4.34'; public const VERSION_ID = 50434; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 34; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From 611c427441119f2c61f9e661e56c3445e9e8b02d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 30 Dec 2023 14:07:02 +0100 Subject: [PATCH 23/31] Bump Symfony version to 5.4.35 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index bd6b152b8a..877b11494a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.34'; - public const VERSION_ID = 50434; + public const VERSION = '5.4.35-DEV'; + public const VERSION_ID = 50435; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 34; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 35; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From 9e9966d27dfe612898ffb3c507a1db2f29faefd1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 30 Dec 2023 14:09:13 +0100 Subject: [PATCH 24/31] Update VERSION for 6.3.11 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1b581a7718..c55a03eebd 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.3.11-DEV'; + public const VERSION = '6.3.11'; public const VERSION_ID = 60311; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 3; public const RELEASE_VERSION = 11; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2024'; public const END_OF_LIFE = '01/2024'; From 83ce0db2c05250cb48eed22df5aea33170344e40 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 30 Dec 2023 14:13:37 +0100 Subject: [PATCH 25/31] Bump Symfony version to 6.3.12 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index c55a03eebd..f7f233d8a5 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.3.11'; - public const VERSION_ID = 60311; + public const VERSION = '6.3.12-DEV'; + public const VERSION_ID = 60312; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 3; - public const RELEASE_VERSION = 11; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 12; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2024'; public const END_OF_LIFE = '01/2024'; From c31bb9215c334f38669066c2766b0a830b6f008d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 23 Jan 2024 14:51:25 +0100 Subject: [PATCH 26/31] Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value --- CacheWarmer/CacheWarmerAggregate.php | 2 +- Config/FileLocator.php | 2 +- Controller/ArgumentResolver.php | 2 +- Controller/ContainerControllerResolver.php | 2 +- Controller/ControllerResolver.php | 2 +- ControllerMetadata/ArgumentMetadata.php | 2 +- DataCollector/AjaxDataCollector.php | 2 +- DataCollector/ConfigDataCollector.php | 4 ++-- DataCollector/DataCollectorInterface.php | 2 +- DataCollector/DumpDataCollector.php | 4 ++-- DataCollector/EventDataCollector.php | 4 ++-- DataCollector/ExceptionDataCollector.php | 2 +- DataCollector/LoggerDataCollector.php | 6 +++--- DataCollector/MemoryDataCollector.php | 2 +- DataCollector/RequestDataCollector.php | 4 ++-- DataCollector/RouterDataCollector.php | 2 +- DataCollector/TimeDataCollector.php | 4 ++-- Debug/FileLinkFormatter.php | 2 +- EventListener/AbstractSessionListener.php | 2 +- EventListener/DebugHandlersListener.php | 4 ++-- EventListener/DumpListener.php | 2 +- EventListener/ErrorListener.php | 4 ++-- EventListener/LocaleListener.php | 2 +- EventListener/ProfilerListener.php | 2 +- EventListener/RouterListener.php | 4 ++-- EventListener/SurrogateListener.php | 2 +- Exception/AccessDeniedHttpException.php | 2 +- Exception/BadRequestHttpException.php | 2 +- Exception/ConflictHttpException.php | 2 +- Exception/GoneHttpException.php | 2 +- Exception/HttpException.php | 2 +- Exception/LengthRequiredHttpException.php | 2 +- Exception/MethodNotAllowedHttpException.php | 2 +- Exception/NotAcceptableHttpException.php | 2 +- Exception/NotFoundHttpException.php | 2 +- Exception/PreconditionFailedHttpException.php | 2 +- Exception/PreconditionRequiredHttpException.php | 2 +- Exception/ServiceUnavailableHttpException.php | 2 +- Exception/TooManyRequestsHttpException.php | 2 +- Exception/UnauthorizedHttpException.php | 2 +- Exception/UnprocessableEntityHttpException.php | 2 +- Exception/UnsupportedMediaTypeHttpException.php | 2 +- Fragment/AbstractSurrogateFragmentRenderer.php | 2 +- Fragment/FragmentUriGenerator.php | 4 ++-- Fragment/FragmentUriGeneratorInterface.php | 2 +- Fragment/HIncludeFragmentRenderer.php | 2 +- Fragment/InlineFragmentRenderer.php | 2 +- HttpCache/Esi.php | 2 +- HttpCache/HttpCache.php | 4 ++-- HttpCache/Ssi.php | 2 +- HttpCache/Store.php | 2 +- HttpCache/SurrogateInterface.php | 2 +- HttpClientKernel.php | 2 +- HttpKernel.php | 4 ++-- HttpKernelBrowser.php | 2 +- Log/DebugLoggerInterface.php | 4 ++-- Log/Logger.php | 2 +- Profiler/FileProfilerStorage.php | 6 +++--- Profiler/Profiler.php | 6 +++--- Profiler/ProfilerStorageInterface.php | 2 +- Tests/Controller/ContainerControllerResolverTest.php | 2 +- Tests/Controller/ControllerResolverTest.php | 2 +- Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php | 4 ++-- Tests/DependencyInjection/FragmentRendererPassTest.php | 2 +- .../RegisterControllerArgumentLocatorsPassTest.php | 4 ++-- .../RemoveEmptyControllerArgumentLocatorsPassTest.php | 4 ++-- Tests/EventListener/ErrorListenerTest.php | 2 +- Tests/EventListener/TestSessionListenerTest.php | 2 +- Tests/Exception/AccessDeniedHttpExceptionTest.php | 2 +- Tests/Exception/BadRequestHttpExceptionTest.php | 2 +- Tests/Exception/ConflictHttpExceptionTest.php | 2 +- Tests/Exception/GoneHttpExceptionTest.php | 2 +- Tests/Exception/HttpExceptionTest.php | 2 +- Tests/Exception/LengthRequiredHttpExceptionTest.php | 2 +- Tests/Exception/MethodNotAllowedHttpExceptionTest.php | 2 +- Tests/Exception/NotAcceptableHttpExceptionTest.php | 2 +- Tests/Exception/NotFoundHttpExceptionTest.php | 2 +- Tests/Exception/PreconditionFailedHttpExceptionTest.php | 2 +- Tests/Exception/PreconditionRequiredHttpExceptionTest.php | 2 +- Tests/Exception/ServiceUnavailableHttpExceptionTest.php | 2 +- Tests/Exception/TooManyRequestsHttpExceptionTest.php | 2 +- Tests/Exception/UnauthorizedHttpExceptionTest.php | 2 +- Tests/Exception/UnprocessableEntityHttpExceptionTest.php | 2 +- Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php | 2 +- Tests/HttpCache/HttpCacheTestCase.php | 2 +- Tests/HttpCache/TestHttpKernel.php | 2 +- Tests/HttpKernelTest.php | 2 +- Tests/KernelTest.php | 2 +- 88 files changed, 109 insertions(+), 109 deletions(-) diff --git a/CacheWarmer/CacheWarmerAggregate.php b/CacheWarmer/CacheWarmerAggregate.php index 67f9ed50b4..730f0f7bb7 100644 --- a/CacheWarmer/CacheWarmerAggregate.php +++ b/CacheWarmer/CacheWarmerAggregate.php @@ -29,7 +29,7 @@ class CacheWarmerAggregate implements CacheWarmerInterface /** * @param iterable $warmers */ - public function __construct(iterable $warmers = [], bool $debug = false, string $deprecationLogsFilepath = null) + public function __construct(iterable $warmers = [], bool $debug = false, ?string $deprecationLogsFilepath = null) { $this->warmers = $warmers; $this->debug = $debug; diff --git a/Config/FileLocator.php b/Config/FileLocator.php index 6eca98635c..4b98437535 100644 --- a/Config/FileLocator.php +++ b/Config/FileLocator.php @@ -33,7 +33,7 @@ public function __construct(KernelInterface $kernel) /** * {@inheritdoc} */ - public function locate(string $file, string $currentPath = null, bool $first = true) + public function locate(string $file, ?string $currentPath = null, bool $first = true) { if (isset($file[0]) && '@' === $file[0]) { $resource = $this->kernel->locateResource($file); diff --git a/Controller/ArgumentResolver.php b/Controller/ArgumentResolver.php index a54140b7e5..76ef79741b 100644 --- a/Controller/ArgumentResolver.php +++ b/Controller/ArgumentResolver.php @@ -33,7 +33,7 @@ final class ArgumentResolver implements ArgumentResolverInterface /** * @param iterable $argumentValueResolvers */ - public function __construct(ArgumentMetadataFactoryInterface $argumentMetadataFactory = null, iterable $argumentValueResolvers = []) + public function __construct(?ArgumentMetadataFactoryInterface $argumentMetadataFactory = null, iterable $argumentValueResolvers = []) { $this->argumentMetadataFactory = $argumentMetadataFactory ?? new ArgumentMetadataFactory(); $this->argumentValueResolvers = $argumentValueResolvers ?: self::getDefaultArgumentValueResolvers(); diff --git a/Controller/ContainerControllerResolver.php b/Controller/ContainerControllerResolver.php index 3b9468465c..b7f77d00b3 100644 --- a/Controller/ContainerControllerResolver.php +++ b/Controller/ContainerControllerResolver.php @@ -25,7 +25,7 @@ class ContainerControllerResolver extends ControllerResolver { protected $container; - public function __construct(ContainerInterface $container, LoggerInterface $logger = null) + public function __construct(ContainerInterface $container, ?LoggerInterface $logger = null) { $this->container = $container; diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 8abbadd48b..e6b4b8055c 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -25,7 +25,7 @@ class ControllerResolver implements ControllerResolverInterface { private $logger; - public function __construct(LoggerInterface $logger = null) + public function __construct(?LoggerInterface $logger = null) { $this->logger = $logger; } diff --git a/ControllerMetadata/ArgumentMetadata.php b/ControllerMetadata/ArgumentMetadata.php index 0c5b1da36d..5046c84b04 100644 --- a/ControllerMetadata/ArgumentMetadata.php +++ b/ControllerMetadata/ArgumentMetadata.php @@ -137,7 +137,7 @@ public function getAttribute(): ?ArgumentInterface /** * @return object[] */ - public function getAttributes(string $name = null, int $flags = 0): array + public function getAttributes(?string $name = null, int $flags = 0): array { if (!$name) { return $this->attributes; diff --git a/DataCollector/AjaxDataCollector.php b/DataCollector/AjaxDataCollector.php index fda6a4eaaa..31764f09f4 100644 --- a/DataCollector/AjaxDataCollector.php +++ b/DataCollector/AjaxDataCollector.php @@ -21,7 +21,7 @@ */ class AjaxDataCollector extends DataCollector { - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, ?\Throwable $exception = null) { // all collecting is done client side } diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index 9819507aab..72f79c5bf7 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -32,7 +32,7 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte /** * Sets the Kernel associated with this Request. */ - public function setKernel(KernelInterface $kernel = null) + public function setKernel(?KernelInterface $kernel = null) { $this->kernel = $kernel; } @@ -40,7 +40,7 @@ public function setKernel(KernelInterface $kernel = null) /** * {@inheritdoc} */ - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, ?\Throwable $exception = null) { $eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE); $eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE); diff --git a/DataCollector/DataCollectorInterface.php b/DataCollector/DataCollectorInterface.php index 1cb865fd66..8aca94802d 100644 --- a/DataCollector/DataCollectorInterface.php +++ b/DataCollector/DataCollectorInterface.php @@ -25,7 +25,7 @@ interface DataCollectorInterface extends ResetInterface /** * Collects data for the given Request and Response. */ - public function collect(Request $request, Response $response, \Throwable $exception = null); + public function collect(Request $request, Response $response, ?\Throwable $exception = null); /** * Returns the name of the collector. diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 9a85c19267..3311bd400e 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -47,7 +47,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface * @param string|FileLinkFormatter|null $fileLinkFormat * @param DataDumperInterface|Connection|null $dumper */ - public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null, string $charset = null, RequestStack $requestStack = null, $dumper = null) + public function __construct(?Stopwatch $stopwatch = null, $fileLinkFormat = null, ?string $charset = null, ?RequestStack $requestStack = null, $dumper = null) { $fileLinkFormat = $fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); $this->stopwatch = $stopwatch; @@ -101,7 +101,7 @@ public function dump(Data $data) } } - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, ?\Throwable $exception = null) { if (!$this->dataCount) { $this->data = []; diff --git a/DataCollector/EventDataCollector.php b/DataCollector/EventDataCollector.php index a813553364..3f6ef4f7c6 100644 --- a/DataCollector/EventDataCollector.php +++ b/DataCollector/EventDataCollector.php @@ -30,7 +30,7 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter private $requestStack; private $currentRequest; - public function __construct(EventDispatcherInterface $dispatcher = null, RequestStack $requestStack = null) + public function __construct(?EventDispatcherInterface $dispatcher = null, ?RequestStack $requestStack = null) { $this->dispatcher = $dispatcher; $this->requestStack = $requestStack; @@ -39,7 +39,7 @@ public function __construct(EventDispatcherInterface $dispatcher = null, Request /** * {@inheritdoc} */ - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, ?\Throwable $exception = null) { $this->currentRequest = $this->requestStack && $this->requestStack->getMainRequest() !== $request ? $request : null; $this->data = [ diff --git a/DataCollector/ExceptionDataCollector.php b/DataCollector/ExceptionDataCollector.php index 14bbbb364b..d93b813951 100644 --- a/DataCollector/ExceptionDataCollector.php +++ b/DataCollector/ExceptionDataCollector.php @@ -25,7 +25,7 @@ class ExceptionDataCollector extends DataCollector /** * {@inheritdoc} */ - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, ?\Throwable $exception = null) { if (null !== $exception) { $this->data = [ diff --git a/DataCollector/LoggerDataCollector.php b/DataCollector/LoggerDataCollector.php index 7b1896ac29..0d6df48cd9 100644 --- a/DataCollector/LoggerDataCollector.php +++ b/DataCollector/LoggerDataCollector.php @@ -30,7 +30,7 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte private $requestStack; private $processedLogs; - public function __construct(object $logger = null, string $containerPathPrefix = null, RequestStack $requestStack = null) + public function __construct(?object $logger = null, ?string $containerPathPrefix = null, ?RequestStack $requestStack = null) { if (null !== $logger && $logger instanceof DebugLoggerInterface) { $this->logger = $logger; @@ -43,7 +43,7 @@ public function __construct(object $logger = null, string $containerPathPrefix = /** * {@inheritdoc} */ - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, ?\Throwable $exception = null) { $this->currentRequest = $this->requestStack && $this->requestStack->getMainRequest() !== $request ? $request : null; } @@ -222,7 +222,7 @@ private function getContainerDeprecationLogs(): array return $logs; } - private function getContainerCompilerLogs(string $compilerLogsFilepath = null): array + private function getContainerCompilerLogs(?string $compilerLogsFilepath = null): array { if (!$compilerLogsFilepath || !is_file($compilerLogsFilepath)) { return []; diff --git a/DataCollector/MemoryDataCollector.php b/DataCollector/MemoryDataCollector.php index 3affae298c..62d048ad16 100644 --- a/DataCollector/MemoryDataCollector.php +++ b/DataCollector/MemoryDataCollector.php @@ -29,7 +29,7 @@ public function __construct() /** * {@inheritdoc} */ - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, ?\Throwable $exception = null) { $this->updateMemoryUsage(); } diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index 5717000f29..c56013c2ea 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -38,7 +38,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter private $sessionUsages = []; private $requestStack; - public function __construct(RequestStack $requestStack = null) + public function __construct(?RequestStack $requestStack = null) { $this->controllers = new \SplObjectStorage(); $this->requestStack = $requestStack; @@ -47,7 +47,7 @@ public function __construct(RequestStack $requestStack = null) /** * {@inheritdoc} */ - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, ?\Throwable $exception = null) { // attributes are serialized and as they can be anything, they need to be converted to strings. $attributes = []; diff --git a/DataCollector/RouterDataCollector.php b/DataCollector/RouterDataCollector.php index 372ede0378..f3735fe56f 100644 --- a/DataCollector/RouterDataCollector.php +++ b/DataCollector/RouterDataCollector.php @@ -36,7 +36,7 @@ public function __construct() * * @final */ - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, ?\Throwable $exception = null) { if ($response instanceof RedirectResponse) { $this->data['redirect'] = true; diff --git a/DataCollector/TimeDataCollector.php b/DataCollector/TimeDataCollector.php index fa8bb4a52a..13a62e6329 100644 --- a/DataCollector/TimeDataCollector.php +++ b/DataCollector/TimeDataCollector.php @@ -27,7 +27,7 @@ class TimeDataCollector extends DataCollector implements LateDataCollectorInterf private $kernel; private $stopwatch; - public function __construct(KernelInterface $kernel = null, Stopwatch $stopwatch = null) + public function __construct(?KernelInterface $kernel = null, ?Stopwatch $stopwatch = null) { $this->kernel = $kernel; $this->stopwatch = $stopwatch; @@ -37,7 +37,7 @@ public function __construct(KernelInterface $kernel = null, Stopwatch $stopwatch /** * {@inheritdoc} */ - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, ?\Throwable $exception = null) { if (null !== $this->kernel) { $startTime = $this->kernel->getStartTime(); diff --git a/Debug/FileLinkFormatter.php b/Debug/FileLinkFormatter.php index 39d4d3b501..8ec7e38d3d 100644 --- a/Debug/FileLinkFormatter.php +++ b/Debug/FileLinkFormatter.php @@ -43,7 +43,7 @@ class FileLinkFormatter * @param string|array|null $fileLinkFormat * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand */ - public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, $urlFormat = null) + public function __construct($fileLinkFormat = null, ?RequestStack $requestStack = null, ?string $baseDir = null, $urlFormat = null) { if (!\is_array($fileLinkFormat) && $fileLinkFormat = (self::FORMATS[$fileLinkFormat] ?? $fileLinkFormat) ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) { $i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: \strlen($f); diff --git a/EventListener/AbstractSessionListener.php b/EventListener/AbstractSessionListener.php index 979154be9a..a339f44a0b 100644 --- a/EventListener/AbstractSessionListener.php +++ b/EventListener/AbstractSessionListener.php @@ -57,7 +57,7 @@ abstract class AbstractSessionListener implements EventSubscriberInterface, Rese /** * @internal */ - public function __construct(ContainerInterface $container = null, bool $debug = false, array $sessionOptions = []) + public function __construct(?ContainerInterface $container = null, bool $debug = false, array $sessionOptions = []) { $this->container = $container; $this->debug = $debug; diff --git a/EventListener/DebugHandlersListener.php b/EventListener/DebugHandlersListener.php index bd124f94d0..da71d08629 100644 --- a/EventListener/DebugHandlersListener.php +++ b/EventListener/DebugHandlersListener.php @@ -49,7 +49,7 @@ class DebugHandlersListener implements EventSubscriberInterface * @param bool $scream Enables/disables screaming mode, where even silenced errors are logged * @param bool $scope Enables/disables scoping mode */ - public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = \E_ALL, ?int $throwAt = \E_ALL, bool $scream = true, $scope = true, $deprecationLogger = null, $fileLinkFormat = null) + public function __construct(?callable $exceptionHandler = null, ?LoggerInterface $logger = null, $levels = \E_ALL, ?int $throwAt = \E_ALL, bool $scream = true, $scope = true, $deprecationLogger = null, $fileLinkFormat = null) { if (!\is_bool($scope)) { trigger_deprecation('symfony/http-kernel', '5.4', 'Passing a $fileLinkFormat is deprecated.'); @@ -73,7 +73,7 @@ public function __construct(callable $exceptionHandler = null, LoggerInterface $ /** * Configures the error handler. */ - public function configure(object $event = null) + public function configure(?object $event = null) { if ($event instanceof ConsoleEvent && !\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) { return; diff --git a/EventListener/DumpListener.php b/EventListener/DumpListener.php index 30908a4f45..f7f9bd693f 100644 --- a/EventListener/DumpListener.php +++ b/EventListener/DumpListener.php @@ -29,7 +29,7 @@ class DumpListener implements EventSubscriberInterface private $dumper; private $connection; - public function __construct(ClonerInterface $cloner, DataDumperInterface $dumper, Connection $connection = null) + public function __construct(ClonerInterface $cloner, DataDumperInterface $dumper, ?Connection $connection = null) { $this->cloner = $cloner; $this->dumper = $dumper; diff --git a/EventListener/ErrorListener.php b/EventListener/ErrorListener.php index b6fd0a357d..668a908e57 100644 --- a/EventListener/ErrorListener.php +++ b/EventListener/ErrorListener.php @@ -41,7 +41,7 @@ class ErrorListener implements EventSubscriberInterface /** * @param array|null}> $exceptionsMapping */ - public function __construct($controller, LoggerInterface $logger = null, bool $debug = false, array $exceptionsMapping = []) + public function __construct($controller, ?LoggerInterface $logger = null, bool $debug = false, array $exceptionsMapping = []) { $this->controller = $controller; $this->logger = $logger; @@ -155,7 +155,7 @@ public static function getSubscribedEvents(): array /** * Logs an exception. */ - protected function logException(\Throwable $exception, string $message, string $logLevel = null): void + protected function logException(\Throwable $exception, string $message, ?string $logLevel = null): void { if (null !== $this->logger) { if (null !== $logLevel) { diff --git a/EventListener/LocaleListener.php b/EventListener/LocaleListener.php index 2c09e22bda..a4073eaac8 100644 --- a/EventListener/LocaleListener.php +++ b/EventListener/LocaleListener.php @@ -35,7 +35,7 @@ class LocaleListener implements EventSubscriberInterface private $useAcceptLanguageHeader; private $enabledLocales; - public function __construct(RequestStack $requestStack, string $defaultLocale = 'en', RequestContextAwareInterface $router = null, bool $useAcceptLanguageHeader = false, array $enabledLocales = []) + public function __construct(RequestStack $requestStack, string $defaultLocale = 'en', ?RequestContextAwareInterface $router = null, bool $useAcceptLanguageHeader = false, array $enabledLocales = []) { $this->defaultLocale = $defaultLocale; $this->requestStack = $requestStack; diff --git a/EventListener/ProfilerListener.php b/EventListener/ProfilerListener.php index adbafe62e9..e4261871b0 100644 --- a/EventListener/ProfilerListener.php +++ b/EventListener/ProfilerListener.php @@ -48,7 +48,7 @@ class ProfilerListener implements EventSubscriberInterface * @param bool $onlyException True if the profiler only collects data when an exception occurs, false otherwise * @param bool $onlyMainRequests True if the profiler only collects data when the request is the main request, false otherwise */ - public function __construct(Profiler $profiler, RequestStack $requestStack, RequestMatcherInterface $matcher = null, bool $onlyException = false, bool $onlyMainRequests = false, string $collectParameter = null) + public function __construct(Profiler $profiler, RequestStack $requestStack, ?RequestMatcherInterface $matcher = null, bool $onlyException = false, bool $onlyMainRequests = false, ?string $collectParameter = null) { $this->profiler = $profiler; $this->matcher = $matcher; diff --git a/EventListener/RouterListener.php b/EventListener/RouterListener.php index 7c4da98928..8c1bc0ac6e 100644 --- a/EventListener/RouterListener.php +++ b/EventListener/RouterListener.php @@ -55,7 +55,7 @@ class RouterListener implements EventSubscriberInterface * * @throws \InvalidArgumentException */ - public function __construct($matcher, RequestStack $requestStack, RequestContext $context = null, LoggerInterface $logger = null, string $projectDir = null, bool $debug = true) + public function __construct($matcher, RequestStack $requestStack, ?RequestContext $context = null, ?LoggerInterface $logger = null, ?string $projectDir = null, bool $debug = true) { if (!$matcher instanceof UrlMatcherInterface && !$matcher instanceof RequestMatcherInterface) { throw new \InvalidArgumentException('Matcher must either implement UrlMatcherInterface or RequestMatcherInterface.'); @@ -73,7 +73,7 @@ public function __construct($matcher, RequestStack $requestStack, RequestContext $this->debug = $debug; } - private function setCurrentRequest(Request $request = null) + private function setCurrentRequest(?Request $request = null) { if (null !== $request) { try { diff --git a/EventListener/SurrogateListener.php b/EventListener/SurrogateListener.php index 9081bff652..dbf3846db6 100644 --- a/EventListener/SurrogateListener.php +++ b/EventListener/SurrogateListener.php @@ -28,7 +28,7 @@ class SurrogateListener implements EventSubscriberInterface { private $surrogate; - public function __construct(SurrogateInterface $surrogate = null) + public function __construct(?SurrogateInterface $surrogate = null) { $this->surrogate = $surrogate; } diff --git a/Exception/AccessDeniedHttpException.php b/Exception/AccessDeniedHttpException.php index 58680a3278..a93954a4c2 100644 --- a/Exception/AccessDeniedHttpException.php +++ b/Exception/AccessDeniedHttpException.php @@ -22,7 +22,7 @@ class AccessDeniedHttpException extends HttpException * @param \Throwable|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Exception/BadRequestHttpException.php b/Exception/BadRequestHttpException.php index f530f7db49..343769c958 100644 --- a/Exception/BadRequestHttpException.php +++ b/Exception/BadRequestHttpException.php @@ -21,7 +21,7 @@ class BadRequestHttpException extends HttpException * @param \Throwable|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Exception/ConflictHttpException.php b/Exception/ConflictHttpException.php index 79c36041c3..541e9f12e0 100644 --- a/Exception/ConflictHttpException.php +++ b/Exception/ConflictHttpException.php @@ -21,7 +21,7 @@ class ConflictHttpException extends HttpException * @param \Throwable|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Exception/GoneHttpException.php b/Exception/GoneHttpException.php index 9ea65057b3..1a36a53125 100644 --- a/Exception/GoneHttpException.php +++ b/Exception/GoneHttpException.php @@ -21,7 +21,7 @@ class GoneHttpException extends HttpException * @param \Throwable|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Exception/HttpException.php b/Exception/HttpException.php index 249fe366d5..c308893712 100644 --- a/Exception/HttpException.php +++ b/Exception/HttpException.php @@ -21,7 +21,7 @@ class HttpException extends \RuntimeException implements HttpExceptionInterface private $statusCode; private $headers; - public function __construct(int $statusCode, ?string $message = '', \Throwable $previous = null, array $headers = [], ?int $code = 0) + public function __construct(int $statusCode, ?string $message = '', ?\Throwable $previous = null, array $headers = [], ?int $code = 0) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Exception/LengthRequiredHttpException.php b/Exception/LengthRequiredHttpException.php index fcac137852..7531ecfb6c 100644 --- a/Exception/LengthRequiredHttpException.php +++ b/Exception/LengthRequiredHttpException.php @@ -21,7 +21,7 @@ class LengthRequiredHttpException extends HttpException * @param \Throwable|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Exception/MethodNotAllowedHttpException.php b/Exception/MethodNotAllowedHttpException.php index 37576bcacb..e3dc84111e 100644 --- a/Exception/MethodNotAllowedHttpException.php +++ b/Exception/MethodNotAllowedHttpException.php @@ -22,7 +22,7 @@ class MethodNotAllowedHttpException extends HttpException * @param \Throwable|null $previous The previous exception * @param int|null $code The internal exception code */ - public function __construct(array $allow, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = []) + public function __construct(array $allow, ?string $message = '', ?\Throwable $previous = null, ?int $code = 0, array $headers = []) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Exception/NotAcceptableHttpException.php b/Exception/NotAcceptableHttpException.php index 5a422406ba..9283dcd997 100644 --- a/Exception/NotAcceptableHttpException.php +++ b/Exception/NotAcceptableHttpException.php @@ -21,7 +21,7 @@ class NotAcceptableHttpException extends HttpException * @param \Throwable|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Exception/NotFoundHttpException.php b/Exception/NotFoundHttpException.php index a475113c5f..d0adb03c72 100644 --- a/Exception/NotFoundHttpException.php +++ b/Exception/NotFoundHttpException.php @@ -21,7 +21,7 @@ class NotFoundHttpException extends HttpException * @param \Throwable|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Exception/PreconditionFailedHttpException.php b/Exception/PreconditionFailedHttpException.php index e23740a28d..30ce081535 100644 --- a/Exception/PreconditionFailedHttpException.php +++ b/Exception/PreconditionFailedHttpException.php @@ -21,7 +21,7 @@ class PreconditionFailedHttpException extends HttpException * @param \Throwable|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Exception/PreconditionRequiredHttpException.php b/Exception/PreconditionRequiredHttpException.php index 5c31fae822..4f8a484f65 100644 --- a/Exception/PreconditionRequiredHttpException.php +++ b/Exception/PreconditionRequiredHttpException.php @@ -23,7 +23,7 @@ class PreconditionRequiredHttpException extends HttpException * @param \Throwable|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Exception/ServiceUnavailableHttpException.php b/Exception/ServiceUnavailableHttpException.php index d5681bbeb3..16efd93493 100644 --- a/Exception/ServiceUnavailableHttpException.php +++ b/Exception/ServiceUnavailableHttpException.php @@ -22,7 +22,7 @@ class ServiceUnavailableHttpException extends HttpException * @param \Throwable|null $previous The previous exception * @param int|null $code The internal exception code */ - public function __construct($retryAfter = null, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = []) + public function __construct($retryAfter = null, ?string $message = '', ?\Throwable $previous = null, ?int $code = 0, array $headers = []) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Exception/TooManyRequestsHttpException.php b/Exception/TooManyRequestsHttpException.php index fd74402b5d..81148f1619 100644 --- a/Exception/TooManyRequestsHttpException.php +++ b/Exception/TooManyRequestsHttpException.php @@ -24,7 +24,7 @@ class TooManyRequestsHttpException extends HttpException * @param \Throwable|null $previous The previous exception * @param int|null $code The internal exception code */ - public function __construct($retryAfter = null, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = []) + public function __construct($retryAfter = null, ?string $message = '', ?\Throwable $previous = null, ?int $code = 0, array $headers = []) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Exception/UnauthorizedHttpException.php b/Exception/UnauthorizedHttpException.php index aeb9713a3d..e1b8acec58 100644 --- a/Exception/UnauthorizedHttpException.php +++ b/Exception/UnauthorizedHttpException.php @@ -22,7 +22,7 @@ class UnauthorizedHttpException extends HttpException * @param \Throwable|null $previous The previous exception * @param int|null $code The internal exception code */ - public function __construct(string $challenge, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = []) + public function __construct(string $challenge, ?string $message = '', ?\Throwable $previous = null, ?int $code = 0, array $headers = []) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Exception/UnprocessableEntityHttpException.php b/Exception/UnprocessableEntityHttpException.php index 7b828b1d92..5dc7b98665 100644 --- a/Exception/UnprocessableEntityHttpException.php +++ b/Exception/UnprocessableEntityHttpException.php @@ -21,7 +21,7 @@ class UnprocessableEntityHttpException extends HttpException * @param \Throwable|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Exception/UnsupportedMediaTypeHttpException.php b/Exception/UnsupportedMediaTypeHttpException.php index 7908423f42..35e20a01e3 100644 --- a/Exception/UnsupportedMediaTypeHttpException.php +++ b/Exception/UnsupportedMediaTypeHttpException.php @@ -21,7 +21,7 @@ class UnsupportedMediaTypeHttpException extends HttpException * @param \Throwable|null $previous The previous exception * @param int $code The internal exception code */ - public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []) { if (null === $message) { trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__); diff --git a/Fragment/AbstractSurrogateFragmentRenderer.php b/Fragment/AbstractSurrogateFragmentRenderer.php index 4e4d028b48..a1a5759d52 100644 --- a/Fragment/AbstractSurrogateFragmentRenderer.php +++ b/Fragment/AbstractSurrogateFragmentRenderer.php @@ -34,7 +34,7 @@ abstract class AbstractSurrogateFragmentRenderer extends RoutableFragmentRendere * * @param FragmentRendererInterface $inlineStrategy The inline strategy to use when the surrogate is not supported */ - public function __construct(SurrogateInterface $surrogate = null, FragmentRendererInterface $inlineStrategy, UriSigner $signer = null) + public function __construct(?SurrogateInterface $surrogate = null, FragmentRendererInterface $inlineStrategy, ?UriSigner $signer = null) { $this->surrogate = $surrogate; $this->inlineStrategy = $inlineStrategy; diff --git a/Fragment/FragmentUriGenerator.php b/Fragment/FragmentUriGenerator.php index 4c0fac997a..6ab0b81451 100644 --- a/Fragment/FragmentUriGenerator.php +++ b/Fragment/FragmentUriGenerator.php @@ -28,7 +28,7 @@ final class FragmentUriGenerator implements FragmentUriGeneratorInterface private $signer; private $requestStack; - public function __construct(string $fragmentPath, UriSigner $signer = null, RequestStack $requestStack = null) + public function __construct(string $fragmentPath, ?UriSigner $signer = null, ?RequestStack $requestStack = null) { $this->fragmentPath = $fragmentPath; $this->signer = $signer; @@ -38,7 +38,7 @@ public function __construct(string $fragmentPath, UriSigner $signer = null, Requ /** * {@inheritDoc} */ - public function generate(ControllerReference $controller, Request $request = null, bool $absolute = false, bool $strict = true, bool $sign = true): string + public function generate(ControllerReference $controller, ?Request $request = null, bool $absolute = false, bool $strict = true, bool $sign = true): string { if (null === $request && (null === $this->requestStack || null === $request = $this->requestStack->getCurrentRequest())) { throw new \LogicException('Generating a fragment URL can only be done when handling a Request.'); diff --git a/Fragment/FragmentUriGeneratorInterface.php b/Fragment/FragmentUriGeneratorInterface.php index b211f5e373..040011b55b 100644 --- a/Fragment/FragmentUriGeneratorInterface.php +++ b/Fragment/FragmentUriGeneratorInterface.php @@ -28,5 +28,5 @@ interface FragmentUriGeneratorInterface * @param bool $strict Whether to allow non-scalar attributes or not * @param bool $sign Whether to sign the URL or not */ - public function generate(ControllerReference $controller, Request $request = null, bool $absolute = false, bool $strict = true, bool $sign = true): string; + public function generate(ControllerReference $controller, ?Request $request = null, bool $absolute = false, bool $strict = true, bool $sign = true): string; } diff --git a/Fragment/HIncludeFragmentRenderer.php b/Fragment/HIncludeFragmentRenderer.php index bd3eb5cd54..a23ffcc7cc 100644 --- a/Fragment/HIncludeFragmentRenderer.php +++ b/Fragment/HIncludeFragmentRenderer.php @@ -32,7 +32,7 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer /** * @param string|null $globalDefaultTemplate The global default content (it can be a template name or the content) */ - public function __construct(Environment $twig = null, UriSigner $signer = null, string $globalDefaultTemplate = null, string $charset = 'utf-8') + public function __construct(?Environment $twig = null, ?UriSigner $signer = null, ?string $globalDefaultTemplate = null, string $charset = 'utf-8') { $this->twig = $twig; $this->globalDefaultTemplate = $globalDefaultTemplate; diff --git a/Fragment/InlineFragmentRenderer.php b/Fragment/InlineFragmentRenderer.php index ea45fdcb3f..60421f0965 100644 --- a/Fragment/InlineFragmentRenderer.php +++ b/Fragment/InlineFragmentRenderer.php @@ -30,7 +30,7 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer private $kernel; private $dispatcher; - public function __construct(HttpKernelInterface $kernel, EventDispatcherInterface $dispatcher = null) + public function __construct(HttpKernelInterface $kernel, ?EventDispatcherInterface $dispatcher = null) { $this->kernel = $kernel; $this->dispatcher = $dispatcher; diff --git a/HttpCache/Esi.php b/HttpCache/Esi.php index 9f45324932..5e7d17a779 100644 --- a/HttpCache/Esi.php +++ b/HttpCache/Esi.php @@ -45,7 +45,7 @@ public function addSurrogateControl(Response $response) /** * {@inheritdoc} */ - public function renderIncludeTag(string $uri, string $alt = null, bool $ignoreErrors = true, string $comment = '') + public function renderIncludeTag(string $uri, ?string $alt = null, bool $ignoreErrors = true, string $comment = '') { $html = sprintf('', $uri, diff --git a/HttpCache/HttpCache.php b/HttpCache/HttpCache.php index b01bd72260..9bffc8add0 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -81,7 +81,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface * This setting is overridden by the stale-if-error HTTP Cache-Control extension * (see RFC 5861). */ - public function __construct(HttpKernelInterface $kernel, StoreInterface $store, SurrogateInterface $surrogate = null, array $options = []) + public function __construct(HttpKernelInterface $kernel, StoreInterface $store, ?SurrogateInterface $surrogate = null, array $options = []) { $this->store = $store; $this->kernel = $kernel; @@ -471,7 +471,7 @@ protected function fetch(Request $request, bool $catch = false) * * @return Response */ - protected function forward(Request $request, bool $catch = false, Response $entry = null) + protected function forward(Request $request, bool $catch = false, ?Response $entry = null) { if ($this->surrogate) { $this->surrogate->addSurrogateCapability($request); diff --git a/HttpCache/Ssi.php b/HttpCache/Ssi.php index 61909100e6..d7903ff13e 100644 --- a/HttpCache/Ssi.php +++ b/HttpCache/Ssi.php @@ -42,7 +42,7 @@ public function addSurrogateControl(Response $response) /** * {@inheritdoc} */ - public function renderIncludeTag(string $uri, string $alt = null, bool $ignoreErrors = true, string $comment = '') + public function renderIncludeTag(string $uri, ?string $alt = null, bool $ignoreErrors = true, string $comment = '') { return sprintf('', $uri); } diff --git a/HttpCache/Store.php b/HttpCache/Store.php index 9d7f3e4f69..f4810b2ab6 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -475,7 +475,7 @@ private function persistResponse(Response $response): array /** * Restores a Response from the HTTP headers and body. */ - private function restoreResponse(array $headers, string $path = null): ?Response + private function restoreResponse(array $headers, ?string $path = null): ?Response { $status = $headers['X-Status'][0]; unset($headers['X-Status']); diff --git a/HttpCache/SurrogateInterface.php b/HttpCache/SurrogateInterface.php index 557f4e959e..12ed055247 100644 --- a/HttpCache/SurrogateInterface.php +++ b/HttpCache/SurrogateInterface.php @@ -64,7 +64,7 @@ public function needsParsing(Response $response); * * @return string */ - public function renderIncludeTag(string $uri, string $alt = null, bool $ignoreErrors = true, string $comment = ''); + public function renderIncludeTag(string $uri, ?string $alt = null, bool $ignoreErrors = true, string $comment = ''); /** * Replaces a Response Surrogate tags with the included resource content. diff --git a/HttpClientKernel.php b/HttpClientKernel.php index 58ca82e5a8..2b4620bb54 100644 --- a/HttpClientKernel.php +++ b/HttpClientKernel.php @@ -33,7 +33,7 @@ final class HttpClientKernel implements HttpKernelInterface { private $client; - public function __construct(HttpClientInterface $client = null) + 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__)); diff --git a/HttpKernel.php b/HttpKernel.php index 38102e2525..f4b4b8ff2e 100644 --- a/HttpKernel.php +++ b/HttpKernel.php @@ -55,7 +55,7 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface protected $requestStack; private $argumentResolver; - public function __construct(EventDispatcherInterface $dispatcher, ControllerResolverInterface $resolver, RequestStack $requestStack = null, ArgumentResolverInterface $argumentResolver = null) + public function __construct(EventDispatcherInterface $dispatcher, ControllerResolverInterface $resolver, ?RequestStack $requestStack = null, ?ArgumentResolverInterface $argumentResolver = null) { $this->dispatcher = $dispatcher; $this->resolver = $resolver; @@ -100,7 +100,7 @@ public function terminate(Request $request, Response $response) /** * @internal */ - public function terminateWithException(\Throwable $exception, Request $request = null) + public function terminateWithException(\Throwable $exception, ?Request $request = null) { if (!$request = $request ?: $this->requestStack->getMainRequest()) { throw $exception; diff --git a/HttpKernelBrowser.php b/HttpKernelBrowser.php index 643134f1bb..5c6506cca9 100644 --- a/HttpKernelBrowser.php +++ b/HttpKernelBrowser.php @@ -36,7 +36,7 @@ class HttpKernelBrowser extends AbstractBrowser /** * @param array $server The server parameters (equivalent of $_SERVER) */ - public function __construct(HttpKernelInterface $kernel, array $server = [], History $history = null, CookieJar $cookieJar = null) + public function __construct(HttpKernelInterface $kernel, array $server = [], ?History $history = null, ?CookieJar $cookieJar = null) { // These class properties must be set before calling the parent constructor, as it may depend on it. $this->kernel = $kernel; diff --git a/Log/DebugLoggerInterface.php b/Log/DebugLoggerInterface.php index 19ff0db181..d5167fcc9b 100644 --- a/Log/DebugLoggerInterface.php +++ b/Log/DebugLoggerInterface.php @@ -29,14 +29,14 @@ interface DebugLoggerInterface * * @return array */ - public function getLogs(Request $request = null); + public function getLogs(?Request $request = null); /** * Returns the number of errors. * * @return int */ - public function countErrors(Request $request = null); + public function countErrors(?Request $request = null); /** * Removes all log records. diff --git a/Log/Logger.php b/Log/Logger.php index c2a45bb951..a37c0cf1c3 100644 --- a/Log/Logger.php +++ b/Log/Logger.php @@ -42,7 +42,7 @@ class Logger extends AbstractLogger /** * @param string|resource|null $output */ - public function __construct(string $minLevel = null, $output = null, callable $formatter = null) + public function __construct(?string $minLevel = null, $output = null, ?callable $formatter = null) { if (null === $minLevel) { $minLevel = null === $output || 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::ERROR : LogLevel::WARNING; diff --git a/Profiler/FileProfilerStorage.php b/Profiler/FileProfilerStorage.php index e20a15c3fa..6fa24f1117 100644 --- a/Profiler/FileProfilerStorage.php +++ b/Profiler/FileProfilerStorage.php @@ -47,7 +47,7 @@ public function __construct(string $dsn) /** * {@inheritdoc} */ - public function find(?string $ip, ?string $url, ?int $limit, ?string $method, int $start = null, int $end = null, string $statusCode = null): array + public function find(?string $ip, ?string $url, ?int $limit, ?string $method, ?int $start = null, ?int $end = null, ?string $statusCode = null): array { $file = $this->getIndexFilename(); @@ -265,7 +265,7 @@ protected function readLineFromFile($file) return '' === $line ? null : $line; } - protected function createProfileFromData(string $token, array $data, Profile $parent = null) + protected function createProfileFromData(string $token, array $data, ?Profile $parent = null) { $profile = new Profile($token); $profile->setIp($data['ip']); @@ -292,7 +292,7 @@ protected function createProfileFromData(string $token, array $data, Profile $pa return $profile; } - private function doRead($token, Profile $profile = null): ?Profile + private function doRead($token, ?Profile $profile = null): ?Profile { if (!$token || !file_exists($file = $this->getFilename($token))) { return null; diff --git a/Profiler/Profiler.php b/Profiler/Profiler.php index d07b887c02..412a859251 100644 --- a/Profiler/Profiler.php +++ b/Profiler/Profiler.php @@ -37,7 +37,7 @@ class Profiler implements ResetInterface private $initiallyEnabled = true; private $enabled = true; - public function __construct(ProfilerStorageInterface $storage, LoggerInterface $logger = null, bool $enable = true) + public function __construct(ProfilerStorageInterface $storage, ?LoggerInterface $logger = null, bool $enable = true) { $this->storage = $storage; $this->logger = $logger; @@ -124,7 +124,7 @@ public function purge() * * @see https://php.net/datetime.formats for the supported date/time formats */ - public function find(?string $ip, ?string $url, ?int $limit, ?string $method, ?string $start, ?string $end, string $statusCode = null) + public function find(?string $ip, ?string $url, ?int $limit, ?string $method, ?string $start, ?string $end, ?string $statusCode = null) { return $this->storage->find($ip, $url, $limit, $method, $this->getTimestamp($start), $this->getTimestamp($end), $statusCode); } @@ -134,7 +134,7 @@ public function find(?string $ip, ?string $url, ?int $limit, ?string $method, ?s * * @return Profile|null */ - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, ?\Throwable $exception = null) { if (false === $this->enabled) { return null; diff --git a/Profiler/ProfilerStorageInterface.php b/Profiler/ProfilerStorageInterface.php index 95d72f46b3..6b23c1a225 100644 --- a/Profiler/ProfilerStorageInterface.php +++ b/Profiler/ProfilerStorageInterface.php @@ -33,7 +33,7 @@ interface ProfilerStorageInterface * @param int|null $start The start date to search from * @param int|null $end The end date to search to */ - public function find(?string $ip, ?string $url, ?int $limit, ?string $method, int $start = null, int $end = null): array; + public function find(?string 9515 $ip, ?string $url, ?int $limit, ?string $method, ?int $start = null, ?int $end = null): array; /** * Reads data associated with the given token. diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index 9d127436cf..9960e851d2 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -228,7 +228,7 @@ public static function getUndefinedControllers(): array return $tests; } - protected function createControllerResolver(LoggerInterface $logger = null, ContainerInterface $container = null) + protected function createControllerResolver(?LoggerInterface $logger = null, ?ContainerInterface $container = null) { if (!$container) { $container = $this->createMockContainer(); diff --git a/Tests/Controller/ControllerResolverTest.php b/Tests/Controller/ControllerResolverTest.php index 621d948197..e76821bf18 100644 --- a/Tests/Controller/ControllerResolverTest.php +++ b/Tests/Controller/ControllerResolverTest.php @@ -187,7 +187,7 @@ public static function getUndefinedControllers() ]; } - protected function createControllerResolver(LoggerInterface $logger = null) + protected function createControllerResolver(?LoggerInterface $logger = null) { return new ControllerResolver($logger); } diff --git a/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php b/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php index 6c3f2a1ea8..ae75b09f42 100644 --- a/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php +++ b/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php @@ -167,7 +167,7 @@ private function signature1(self $foo, array $bar, callable $baz) { } - private function signature2(self $foo = null, FakeClassThatDoesNotExist $bar = null, ImportedAndFake $baz = null) + private function signature2(?self $foo = null, ?FakeClassThatDoesNotExist $bar = null, ?ImportedAndFake $baz = null) { } @@ -179,7 +179,7 @@ private function signature4($foo = 'default', $bar = 500, $baz = []) { } - private function signature5(array $foo = null, $bar = null) + private function signature5(?array $foo = null, $bar = null) { } } diff --git a/Tests/DependencyInjection/FragmentRendererPassTest.php b/Tests/DependencyInjection/FragmentRendererPassTest.php index ab0efe32f5..89e2eed6e8 100644 --- a/Tests/DependencyInjection/FragmentRendererPassTest.php +++ b/Tests/DependencyInjection/FragmentRendererPassTest.php @@ -60,7 +60,7 @@ public function testValidContentRenderer() class RendererService implements FragmentRendererInterface { - public function render($uri, Request $request = null, array $options = []): Response + public function render($uri, ?Request $request = null, array $options = []): Response { } diff --git a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index 69e1cc8cd6..92f0cce54a 100644 --- a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -508,11 +508,11 @@ public function fooAction(\Acme\NonExistentClass $nonExistent) class NonExistentClassOptionalController { - public function fooAction(NonExistentClass $nonExistent = null) + public function fooAction(?NonExistentClass $nonExistent = null) { } - public function barAction(NonExistentClass $nonExistent = null, $bar) + public function barAction(?NonExistentClass $nonExistent = null, $bar) { } } diff --git a/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php index b9dd84d592..8c99b882d3 100644 --- a/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php @@ -81,7 +81,7 @@ public function testInvoke() class RemoveTestController1 { - public function fooAction(\stdClass $bar, ClassNotInContainer $baz = null) + public function fooAction(\stdClass $bar, ?ClassNotInContainer $baz = null) { } } @@ -92,7 +92,7 @@ public function setTestCase(TestCase $test) { } - public function fooAction(ClassNotInContainer $bar = null) + public function fooAction(?ClassNotInContainer $bar = null) { } } diff --git a/Tests/EventListener/ErrorListenerTest.php b/Tests/EventListener/ErrorListenerTest.php index b97737218c..623b50cd0c 100644 --- a/Tests/EventListener/ErrorListenerTest.php +++ b/Tests/EventListener/ErrorListenerTest.php @@ -222,7 +222,7 @@ public static function controllerProvider() class TestLogger extends Logger implements DebugLoggerInterface { - public function countErrors(Request $request = null): int + public function countErrors(?Request $request = null): int { return \count($this->logs['critical']); } diff --git a/Tests/EventListener/TestSessionListenerTest.php b/Tests/EventListener/TestSessionListenerTest.php index bb989b3302..7e42653dff 100644 --- a/Tests/EventListener/TestSessionListenerTest.php +++ b/Tests/EventListener/TestSessionListenerTest.php @@ -158,7 +158,7 @@ public function testDoesNotThrowIfRequestDoesNotHaveASession() $this->assertTrue(true); } - private function filterResponse(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, Response $response = null) + private function filterResponse(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, ?Response $response = null) { $request->setSession($this->session); $response = $response ?? new Response(); diff --git a/Tests/Exception/AccessDeniedHttpExceptionTest.php b/Tests/Exception/AccessDeniedHttpExceptionTest.php index a810255b1e..4ce91afac8 100644 --- a/Tests/Exception/AccessDeniedHttpExceptionTest.php +++ b/Tests/Exception/AccessDeniedHttpExceptionTest.php @@ -16,7 +16,7 @@ class AccessDeniedHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new AccessDeniedHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/BadRequestHttpExceptionTest.php b/Tests/Exception/BadRequestHttpExceptionTest.php index 2e09653fa7..4dfb2cbc01 100644 --- a/Tests/Exception/BadRequestHttpExceptionTest.php +++ b/Tests/Exception/BadRequestHttpExceptionTest.php @@ -16,7 +16,7 @@ class BadRequestHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new BadRequestHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/ConflictHttpExceptionTest.php b/Tests/Exception/ConflictHttpExceptionTest.php index dbab2acff5..4f0b554511 100644 --- a/Tests/Exception/ConflictHttpExceptionTest.php +++ b/Tests/Exception/ConflictHttpExceptionTest.php @@ -16,7 +16,7 @@ class ConflictHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new ConflictHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/GoneHttpExceptionTest.php b/Tests/Exception/GoneHttpExceptionTest.php index 2582ab71b3..775db75b92 100644 --- a/Tests/Exception/GoneHttpExceptionTest.php +++ b/Tests/Exception/GoneHttpExceptionTest.php @@ -16,7 +16,7 @@ class GoneHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new GoneHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/HttpExceptionTest.php b/Tests/Exception/HttpExceptionTest.php index fad9e796f4..781cb85eb6 100644 --- a/Tests/Exception/HttpExceptionTest.php +++ b/Tests/Exception/HttpExceptionTest.php @@ -63,7 +63,7 @@ public function testThrowableIsAllowedForPrevious() $this->assertSame($previous, $exception->getPrevious()); } - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new HttpException(200, $message, $previous, $headers, $code); } diff --git a/Tests/Exception/LengthRequiredHttpExceptionTest.php b/Tests/Exception/LengthRequiredHttpExceptionTest.php index 5525870e1e..4e1c3f645f 100644 --- a/Tests/Exception/LengthRequiredHttpExceptionTest.php +++ b/Tests/Exception/LengthRequiredHttpExceptionTest.php @@ -16,7 +16,7 @@ class LengthRequiredHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new LengthRequiredHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/MethodNotAllowedHttpExceptionTest.php b/Tests/Exception/MethodNotAllowedHttpExceptionTest.php index 61ecb84da4..a5cc1f70e1 100644 --- a/Tests/Exception/MethodNotAllowedHttpExceptionTest.php +++ b/Tests/Exception/MethodNotAllowedHttpExceptionTest.php @@ -45,7 +45,7 @@ public function testHeadersSetter($headers) $this->assertSame($headers, $exception->getHeaders()); } - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new MethodNotAllowedHttpException(['get'], $message, $previous, $code, $headers); } diff --git a/Tests/Exception/NotAcceptableHttpExceptionTest.php b/Tests/Exception/NotAcceptableHttpExceptionTest.php index 6df823ada0..97c460b5cd 100644 --- a/Tests/Exception/NotAcceptableHttpExceptionTest.php +++ b/Tests/Exception/NotAcceptableHttpExceptionTest.php @@ -16,7 +16,7 @@ class NotAcceptableHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new NotAcceptableHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/NotFoundHttpExceptionTest.php b/Tests/Exception/NotFoundHttpExceptionTest.php index 8152a727fd..45fee0457a 100644 --- a/Tests/Exception/NotFoundHttpExceptionTest.php +++ b/Tests/Exception/NotFoundHttpExceptionTest.php @@ -16,7 +16,7 @@ class NotFoundHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new NotFoundHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/PreconditionFailedHttpExceptionTest.php b/Tests/Exception/PreconditionFailedHttpExceptionTest.php index d215792875..f7750d9a63 100644 --- a/Tests/Exception/PreconditionFailedHttpExceptionTest.php +++ b/Tests/Exception/PreconditionFailedHttpExceptionTest.php @@ -16,7 +16,7 @@ class PreconditionFailedHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new PreconditionFailedHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/PreconditionRequiredHttpExceptionTest.php b/Tests/Exception/PreconditionRequiredHttpExceptionTest.php index 452b226c49..6373d2718f 100644 --- a/Tests/Exception/PreconditionRequiredHttpExceptionTest.php +++ b/Tests/Exception/PreconditionRequiredHttpExceptionTest.php @@ -16,7 +16,7 @@ class PreconditionRequiredHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new PreconditionRequiredHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/ServiceUnavailableHttpExceptionTest.php b/Tests/Exception/ServiceUnavailableHttpExceptionTest.php index 4f0aa3a458..34172b446a 100644 --- a/Tests/Exception/ServiceUnavailableHttpExceptionTest.php +++ b/Tests/Exception/ServiceUnavailableHttpExceptionTest.php @@ -45,7 +45,7 @@ public function testHeadersSetter($headers) $this->assertSame($headers, $exception->getHeaders()); } - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new ServiceUnavailableHttpException(null, $message, $previous, $code, $headers); } diff --git a/Tests/Exception/TooManyRequestsHttpExceptionTest.php b/Tests/Exception/TooManyRequestsHttpExceptionTest.php index 4dc2e41ea5..995e56d554 100644 --- a/Tests/Exception/TooManyRequestsHttpExceptionTest.php +++ b/Tests/Exception/TooManyRequestsHttpExceptionTest.php @@ -45,7 +45,7 @@ public function testHeadersSetter($headers) $this->assertSame($headers, $exception->getHeaders()); } - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new TooManyRequestsHttpException(null, $message, $previous, $code, $headers); } diff --git a/Tests/Exception/UnauthorizedHttpExceptionTest.php b/Tests/Exception/UnauthorizedHttpExceptionTest.php index dda2777c91..3797ce0dd0 100644 --- a/Tests/Exception/UnauthorizedHttpExceptionTest.php +++ b/Tests/Exception/UnauthorizedHttpExceptionTest.php @@ -45,7 +45,7 @@ public function testHeadersSetter($headers) $this->assertSame($headers, $exception->getHeaders()); } - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new UnauthorizedHttpException('Challenge', $message, $previous, $code, $headers); } diff --git a/Tests/Exception/UnprocessableEntityHttpExceptionTest.php b/Tests/Exception/UnprocessableEntityHttpExceptionTest.php index 8b4ece20ee..6d5c309088 100644 --- a/Tests/Exception/UnprocessableEntityHttpExceptionTest.php +++ b/Tests/Exception/UnprocessableEntityHttpExceptionTest.php @@ -16,7 +16,7 @@ class UnprocessableEntityHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new UnprocessableEntityHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php b/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php index 0295d61e0a..2407b0a85b 100644 --- a/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php +++ b/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php @@ -16,7 +16,7 @@ class UnsupportedMediaTypeHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException + protected function createException(string $message = '', ?\Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new UnsupportedMediaTypeHttpException($message, $previous, $code, $headers); } diff --git a/Tests/HttpCache/HttpCacheTestCase.php b/Tests/HttpCache/HttpCacheTestCase.php index c8b48ff811..d60abb1032 100644 --- a/Tests/HttpCache/HttpCacheTestCase.php +++ b/Tests/HttpCache/HttpCacheTestCase.php @@ -147,7 +147,7 @@ public function getMetaStorageValues() } // A basic response with 200 status code and a tiny body. - public function setNextResponse($statusCode = 200, array $headers = [], $body = 'Hello World', \Closure $customizer = null) + public function setNextResponse($statusCode = 200, array $headers = [], $body = 'Hello World', ?\Closure $customizer = null) { $this->kernel = new TestHttpKernel($body, $statusCode, $headers, $customizer); } diff --git a/Tests/HttpCache/TestHttpKernel.php b/Tests/HttpCache/TestHttpKernel.php index 471212f5e3..871e8e36f0 100644 --- a/Tests/HttpCache/TestHttpKernel.php +++ b/Tests/HttpCache/TestHttpKernel.php @@ -29,7 +29,7 @@ class TestHttpKernel extends HttpKernel implements ControllerResolverInterface, protected $catch = false; protected $backendRequest; - public function __construct($body, $status, $headers, \Closure $customizer = null) + public function __construct($body, $status, $headers, ?\Closure $customizer = null) { $this->body = $body; $this->status = $status; diff --git a/Tests/HttpKernelTest.php b/Tests/HttpKernelTest.php index 09e7b9a524..8ac289d5d2 100644 --- a/Tests/HttpKernelTest.php +++ b/Tests/HttpKernelTest.php @@ -391,7 +391,7 @@ public function testInconsistentClientIpsOnMainRequests() Request::setTrustedProxies([], -1); } - private function getHttpKernel(EventDispatcherInterface $eventDispatcher, $controller = null, RequestStack $requestStack = null, array $arguments = []) + private function getHttpKernel(EventDispatcherInterface $eventDispatcher, $controller = null, ?RequestStack $requestStack = null, array $arguments = []) { if (null === $controller) { $controller = function () { return new Response('Hello'); }; diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index d60924b9ad..74cd34cde3 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -713,7 +713,7 @@ class CustomProjectDirKernel extends Kernel implements WarmableInterface private $buildContainer; private $httpKernel; - public function __construct(\Closure $buildContainer = null, HttpKernelInterface $httpKernel = null, $env = 'custom') + public function __construct(?\Closure $buildContainer = null, ?HttpKernelInterface $httpKernel = null, $env = 'custom') { parent::__construct($env, true); From bf82b46592c3fea59eefa64ce053ff8cbd9d60b0 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 23 Jan 2024 15:23:03 +0100 Subject: [PATCH 27/31] Fix implicitly-required parameters --- Fragment/AbstractSurrogateFragmentRenderer.php | 2 +- .../RegisterControllerArgumentLocatorsPassTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Fragment/AbstractSurrogateFragmentRenderer.php b/Fragment/AbstractSurrogateFragmentRenderer.php index a1a5759d52..8a21f6bfc1 100644 --- a/Fragment/AbstractSurrogateFragmentRenderer.php +++ b/Fragment/AbstractSurrogateFragmentRenderer.php @@ -34,7 +34,7 @@ abstract class AbstractSurrogateFragmentRenderer extends RoutableFragmentRendere * * @param FragmentRendererInterface $inlineStrategy The inline strategy to use when the surrogate is not supported */ - public function __construct(?SurrogateInterface $surrogate = null, FragmentRendererInterface $inlineStrategy, ?UriSigner $signer = null) + public function __construct(?SurrogateInterface $surrogate, FragmentRendererInterface $inlineStrategy, ?UriSigner $signer = null) { $this->surrogate = $surrogate; $this->inlineStrategy = $inlineStrategy; diff --git a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index 92f0cce54a..3dec2e912a 100644 --- a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -512,7 +512,7 @@ public function fooAction(?NonExistentClass $nonExistent = null) { } - public function barAction(?NonExistentClass $nonExistent = null, $bar) + public function barAction(?NonExistentClass $nonExistent, $bar) { } } From 2cfddcf59bd9424d68277d36e67df0cec6203a4b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 23 Jan 2024 15:42:10 +0100 Subject: [PATCH 28/31] Fix bad merge --- .../EventListener/TestSessionListenerTest.php | 222 ------------------ 1 file changed, 222 deletions(-) delete mode 100644 Tests/EventListener/TestSessionListenerTest.php diff --git a/Tests/EventListener/TestSessionListenerTest.php b/Tests/EventListener/TestSessionListenerTest.php deleted file mode 100644 index 7e42653dff..0000000000 --- a/Tests/EventListener/TestSessionListenerTest.php +++ /dev/null @@ -1,222 +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\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\HttpKernel\Event\RequestEvent; -use Symfony\Component\HttpKernel\Event\ResponseEvent; -use Symfony\Component\HttpKernel\EventListener\AbstractTestSessionListener; -use Symfony\Component\HttpKernel\EventListener\TestSessionListener; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * SessionListenerTest. - * - * Tests SessionListener. - * - * @author Bulat Shakirzyanov - * - * @group legacy - */ -class TestSessionListenerTest extends TestCase -{ - /** - * @var TestSessionListener - */ - private $listener; - - /** - * @var SessionInterface - */ - private $session; - - protected function setUp(): void - { - $this->listener = $this->getMockForAbstractClass(AbstractTestSessionListener::class); - $this->session = $this->getSession(); - $this->listener->expects($this->any()) - ->method('getSession') - ->willReturn($this->session); - } - - public function testShouldSaveMainRequestSession() - { - $this->sessionHasBeenStarted(); - $this->sessionMustBeSaved(); - - $this->filterResponse(new Request()); - } - - public function testShouldNotSaveSubRequestSession() - { - $this->sessionMustNotBeSaved(); - - $this->filterResponse(new Request(), HttpKernelInterface::SUB_REQUEST); - } - - public function testDoesNotDeleteCookieIfUsingSessionLifetime() - { - $this->sessionHasBeenStarted(); - - @ini_set('session.cookie_lifetime', 0); - - $response = $this->filterResponse(new Request(), HttpKernelInterface::MAIN_REQUEST); - $cookies = $response->headers->getCookies(); - - $this->assertEquals(0, reset($cookies)->getExpiresTime()); - } - - /** - * @requires function \Symfony\Component\HttpFoundation\Session\Session::isEmpty - */ - public function testEmptySessionDoesNotSendCookie() - { - $this->sessionHasBeenStarted(); - $this->sessionIsEmpty(); - - $response = $this->filterResponse(new Request(), HttpKernelInterface::MAIN_REQUEST); - - $this->assertSame([], $response->headers->getCookies()); - } - - public function testEmptySessionWithNewSessionIdDoesSendCookie() - { - $this->sessionHasBeenStarted(); - $this->sessionIsEmpty(); - $this->fixSessionId('456'); - - $kernel = $this->createMock(HttpKernelInterface::class); - $request = Request::create('/', 'GET', [], ['MOCKSESSID' => '123']); - $request->setSession($this->getSession()); - $event = new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST); - $this->listener->onKernelRequest($event); - - $response = $this->filterResponse(new Request(), HttpKernelInterface::MAIN_REQUEST); - - $this->assertNotEmpty($response->headers->getCookies()); - } - - /** - * @dataProvider anotherCookieProvider - */ - public function testSessionWithNewSessionIdAndNewCookieDoesNotSendAnotherCookie($existing, array $expected) - { - $this->sessionHasBeenStarted(); - $this->sessionIsEmpty(); - $this->fixSessionId('456'); - - $kernel = $this->createMock(HttpKernelInterface::class); - $request = Request::create('/', 'GET', [], ['MOCKSESSID' => '123']); - $request->setSession($this->getSession()); - $event = new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST); - $this->listener->onKernelRequest($event); - - $response = new Response('', 200, ['Set-Cookie' => $existing]); - - $response = $this->filterResponse(new Request(), HttpKernelInterface::MAIN_REQUEST, $response); - - $this->assertSame($expected, $response->headers->all()['set-cookie']); - } - - public static function anotherCookieProvider() - { - return [ - 'same' => ['MOCKSESSID=789; path=/', ['MOCKSESSID=789; path=/']], - 'different domain' => ['MOCKSESSID=789; path=/; domain=example.com', ['MOCKSESSID=789; path=/; domain=example.com', 'MOCKSESSID=456; path=/']], - 'different path' => ['MOCKSESSID=789; path=/foo', ['MOCKSESSID=789; path=/foo', 'MOCKSESSID=456; path=/']], - ]; - } - - public function testUnstartedSessionIsNotSave() - { - $this->sessionHasNotBeenStarted(); - $this->sessionMustNotBeSaved(); - - $this->filterResponse(new Request()); - } - - public function testDoesNotThrowIfRequestDoesNotHaveASession() - { - $kernel = $this->createMock(HttpKernelInterface::class); - $event = new ResponseEvent($kernel, new Request(), HttpKernelInterface::MAIN_REQUEST, new Response()); - - $this->listener->onKernelResponse($event); - - $this->assertTrue(true); - } - - private function filterResponse(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, ?Response $response = null) - { - $request->setSession($this->session); - $response = $response ?? new Response(); - $kernel = $this->createMock(HttpKernelInterface::class); - $event = new ResponseEvent($kernel, $request, $type, $response); - - $this->listener->onKernelResponse($event); - - $this->assertSame($response, $event->getResponse()); - - return $response; - } - - private function sessionMustNotBeSaved() - { - $this->session->expects($this->never()) - ->method('save'); - } - - private function sessionMustBeSaved() - { - $this->session->expects($this->once()) - ->method('save'); - } - - private function sessionHasBeenStarted() - { - $this->session->expects($this->once()) - ->method('isStarted') - ->willReturn(true); - } - - private function sessionHasNotBeenStarted() - { - $this->session->expects($this->once()) - ->method('isStarted') - ->willReturn(false); - } - - private function sessionIsEmpty() - { - $this->session->expects($this->once()) - ->method('isEmpty') - ->willReturn(true); - } - - private function fixSessionId($sessionId) - { - $this->session->expects($this->any()) - ->method('getId') - ->willReturn($sessionId); - } - - private function getSession() - { - $mock = $this->createMock(Session::class); - $mock->expects($this->any())->method('getName')->willReturn('MOCKSESSID'); - - return $mock; - } -} From ab183eafea59e709b855c36e51810444f3d9f252 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 23 Jan 2024 16:58:36 +0100 Subject: [PATCH 29/31] fix method signatures --- Fragment/AbstractSurrogateFragmentRenderer.php | 2 +- .../RegisterControllerArgumentLocatorsPassTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Fragment/AbstractSurrogateFragmentRenderer.php b/Fragment/AbstractSurrogateFragmentRenderer.php index dbc941868b..05625f904a 100644 --- a/Fragment/AbstractSurrogateFragmentRenderer.php +++ b/Fragment/AbstractSurrogateFragmentRenderer.php @@ -34,7 +34,7 @@ abstract class AbstractSurrogateFragmentRenderer extends RoutableFragmentRendere * * @param FragmentRendererInterface $inlineStrategy The inline strategy to use when the surrogate is not supported */ - public function __construct(?SurrogateInterface $surrogate = null, FragmentRendererInterface $inlineStrategy, ?UriSigner $signer = null) + public function __construct(?SurrogateInterface $surrogate, FragmentRendererInterface $inlineStrategy, ?UriSigner $signer = null) { $this->surrogate = $surrogate; $this->inlineStrategy = $inlineStrategy; diff --git a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index 557adaf633..1e0d6e33be 100644 --- a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -583,7 +583,7 @@ public function fooAction(?NonExistentClass $nonExistent = null) { } - public function barAction(?NonExistentClass $nonExistent = null, $bar) + public function barAction(?NonExistentClass $nonExistent, $bar) { } } From e8f4efbe69fce88800dbd4714c92f3e506be49be Mon Sep 17 00:00:00 2001 From: Jeroeny Date: Wed, 18 Oct 2023 10:56:22 +0200 Subject: [PATCH 30/31] Fix RequestPayloadValueResolver handling error with no ExpectedTypes --- .../RequestPayloadValueResolver.php | 8 +++-- .../RequestPayloadValueResolverTest.php | 35 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Controller/ArgumentResolver/RequestPayloadValueResolver.php b/Controller/ArgumentResolver/RequestPayloadValueResolver.php index 38ee7758a7..1179f7c098 100644 --- a/Controller/ArgumentResolver/RequestPayloadValueResolver.php +++ b/Controller/ArgumentResolver/RequestPayloadValueResolver.php @@ -108,11 +108,15 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event): vo } catch (PartialDenormalizationException $e) { $trans = $this->translator ? $this->translator->trans(...) : fn ($m, $p) => strtr($m, $p); foreach ($e->getErrors() as $error) { - $parameters = ['{{ type }}' => implode('|', $error->getExpectedTypes())]; + $parameters = []; + $template = 'This value was of an unexpected type.'; + if ($expectedTypes = $error->getExpectedTypes()) { + $template = 'This value should be of type {{ type }}.'; + $parameters['{{ type }}'] = implode('|', $expectedTypes); + } if ($error->canUseMessageForUser()) { $parameters['hint'] = $error->getMessage(); } - $template = 'This value should be of type {{ type }}.'; $message = $trans($template, $parameters, 'validators'); $violations->add(new ConstraintViolation($message, $template, $parameters, null, $error->getPath(), null)); } diff --git a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php index 179f14a127..dcf6c8dcaa 100644 --- a/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php @@ -23,9 +23,12 @@ use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\Encoder\XmlEncoder; +use Symfony\Component\Serializer\Exception\NotNormalizableValueException; use Symfony\Component\Serializer\Exception\PartialDenormalizationException; +use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Component\Serializer\Serializer; +use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\ConstraintViolationList; use Symfony\Component\Validator\Exception\ValidationFailedException; @@ -332,6 +335,34 @@ public function testRequestContentValidationPassed() $this->assertEquals([$payload], $event->getArguments()); } + /** + * @testWith [null] + * [[]] + */ + public function testRequestContentWithUntypedErrors(?array $types) + { + $this->expectException(HttpException::class); + $this->expectExceptionMessage('This value was of an unexpected type.'); + $serializer = $this->createMock(SerializerDenormalizer::class); + + if (null === $types) { + $exception = new NotNormalizableValueException('Error with no types'); + } else { + $exception = NotNormalizableValueException::createForUnexpectedDataType('Error with no types', '', []); + } + $serializer->method('deserialize')->willThrowException(new PartialDenormalizationException([], [$exception])); + + $resolver = new RequestPayloadValueResolver($serializer, $this->createMock(ValidatorInterface::class)); + $request = Request::create('/', 'POST', server: ['CONTENT_TYPE' => 'application/json'], content: '{"price": 50}'); + + $arguments = $resolver->resolve($request, new ArgumentMetadata('valid', RequestPayload::class, false, false, null, false, [ + MapRequestPayload::class => new MapRequestPayload(), + ])); + $event = new ControllerArgumentsEvent($this->createMock(HttpKernelInterface::class), function () {}, $arguments, $request, HttpKernelInterface::MAIN_REQUEST); + + $resolver->onKernelControllerArguments($event); + } + public function testQueryStringValidationPassed() { $payload = new RequestPayload(50); @@ -638,6 +669,10 @@ public function __construct(public readonly float $price) } } +interface SerializerDenormalizer extends SerializerInterface, DenormalizerInterface +{ +} + class User { public function __construct( From f7d160e46a6e0d3183e7a3846d4e3b4d04d5898b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 30 Jan 2024 21:05:26 +0100 Subject: [PATCH 31/31] Update VERSION for 6.3.12 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index f7f233d8a5..f97437a028 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.3.12-DEV'; + public const VERSION = '6.3.12'; public const VERSION_ID = 60312; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 3; public const RELEASE_VERSION = 12; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2024'; public const END_OF_LIFE = '01/2024'; 0