From a6d5229dd9466e046674baad8449ad92ee24eddd Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Oct 2022 18:49:22 +0200 Subject: [PATCH 01/11] Update VERSION for 4.4.48 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 13636cc09f..54ea465379 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.48-DEV'; + public const VERSION = '4.4.48'; public const VERSION_ID = 40448; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 48; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 0924172f04193fc4123ee6e473984438f6d2eb5a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Oct 2022 19:50:38 +0200 Subject: [PATCH 02/11] Bump Symfony version to 4.4.49 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 54ea465379..ce28585fe1 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.48'; - public const VERSION_ID = 40448; + public const VERSION = '4.4.49-DEV'; + public const VERSION_ID = 40449; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 48; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 49; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From fc63c8c3e1036d424820cc993a4ea163778dc5c7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Oct 2022 19:52:18 +0200 Subject: [PATCH 03/11] Update VERSION for 5.4.15 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 700f16d3ce..ee902ea21c 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.15-DEV'; + public const VERSION = '5.4.15'; public const VERSION_ID = 50415; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 15; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From 3fb0dd9d9acd588e6b0dd756ce526c35398e958a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Oct 2022 19:59:25 +0200 Subject: [PATCH 04/11] Bump Symfony version to 5.4.16 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index ee902ea21c..7b47f6812b 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.15'; - public const VERSION_ID = 50415; + public const VERSION = '5.4.16-DEV'; + public const VERSION_ID = 50416; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 15; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 16; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From 22c820abe601e7328b56cec86626617139266f48 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Oct 2022 20:00:40 +0200 Subject: [PATCH 05/11] Update VERSION for 6.0.15 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 111cefd0f2..c59e058e28 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.0.15-DEV'; + public const VERSION = '6.0.15'; public const VERSION_ID = 60015; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 0; public const RELEASE_VERSION = 15; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2023'; public const END_OF_LIFE = '01/2023'; From e71b52c96c2a044f7d1666dc4c801af40eb8e836 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Oct 2022 20:04:55 +0200 Subject: [PATCH 06/11] Bump Symfony version to 6.0.16 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index c59e058e28..c9b6213279 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.0.15'; - public const VERSION_ID = 60015; + public const VERSION = '6.0.16-DEV'; + public const VERSION_ID = 60016; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 0; - public const RELEASE_VERSION = 15; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 16; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2023'; public const END_OF_LIFE = '01/2023'; From 629a7a50f6ce0cd5cc757943aefbb53c65f86c93 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Oct 2022 20:19:50 +0200 Subject: [PATCH 07/11] Bump Symfony version to 6.1.8 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 78193d31c6..67e42aa891 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.1.7'; - public const VERSION_ID = 60107; + public const VERSION = '6.1.8-DEV'; + public const VERSION_ID = 60108; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 1; - public const RELEASE_VERSION = 7; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 8; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2023'; public const END_OF_LIFE = '01/2023'; From c5907faca59447ad1458a40fdc758f53f93eab78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Fri, 4 Nov 2022 13:00:28 +0100 Subject: [PATCH 08/11] Fix deprecation notice when date argument is not nullable and null value is provided --- .../DateTimeValueResolver.php | 4 +--- .../DateTimeValueResolverTest.php | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Controller/ArgumentResolver/DateTimeValueResolver.php b/Controller/ArgumentResolver/DateTimeValueResolver.php index d8953f564b..e9a7494a4c 100644 --- a/Controller/ArgumentResolver/DateTimeValueResolver.php +++ b/Controller/ArgumentResolver/DateTimeValueResolver.php @@ -60,8 +60,6 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable $format = $attribute->format; } - $date = false; - if (null !== $format) { $date = $class::createFromFormat($format, $value); @@ -73,7 +71,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable $value = '@'.$value; } try { - $date = new $class($value); + $date = new $class($value ?? 'now'); } catch (\Exception) { $date = false; } diff --git a/Tests/Controller/ArgumentResolver/DateTimeValueResolverTest.php b/Tests/Controller/ArgumentResolver/DateTimeValueResolverTest.php index e1c3d662c6..b438c527a3 100644 --- a/Tests/Controller/ArgumentResolver/DateTimeValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/DateTimeValueResolverTest.php @@ -113,6 +113,26 @@ public function testNullableWithEmptyAttribute() $this->assertNull($results[0]); } + /** + * @dataProvider getTimeZones + */ + public function testNow(string $timezone) + { + date_default_timezone_set($timezone); + $resolver = new DateTimeValueResolver(); + + $argument = new ArgumentMetadata('dummy', \DateTime::class, false, false, null, false); + $request = self::requestWithAttributes(['dummy' => null]); + + /** @var \Generator $results */ + $results = $resolver->resolve($request, $argument); + $results = iterator_to_array($results); + + $this->assertCount(1, $results); + $this->assertEquals('0', $results[0]->diff(new \DateTimeImmutable())->format('%s')); + $this->assertSame($timezone, $results[0]->getTimezone()->getName(), 'Default timezone'); + } + public function testPreviouslyConvertedAttribute() { $resolver = new DateTimeValueResolver(); From 541739241846ad93b18f73cffeb239c987d1b62c Mon Sep 17 00:00:00 2001 From: MatTheCat Date: Wed, 9 Nov 2022 12:01:14 +0100 Subject: [PATCH 09/11] =?UTF-8?q?[HttpKernel]=20Don=E2=80=99t=20try=20to?= =?UTF-8?q?=20wire=20Response=20argument=20with=20controller.service=5Farg?= =?UTF-8?q?uments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...RegisterControllerArgumentLocatorsPass.php | 3 ++- ...sterControllerArgumentLocatorsPassTest.php | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index 8fd1f553e0..3dbaff5641 100644 --- a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -24,6 +24,7 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\TypedReference; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\SessionInterface; /** @@ -174,7 +175,7 @@ public function process(ContainerBuilder $container) $invalidBehavior = ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE; } - if (Request::class === $type || SessionInterface::class === $type) { + if (Request::class === $type || SessionInterface::class === $type || Response::class === $type) { continue; } diff --git a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index 1e3d25d440..a8fdd7975b 100644 --- a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -23,6 +23,7 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\DependencyInjection\TypedReference; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass; use Symfony\Component\HttpKernel\Tests\Fixtures\Suit; @@ -447,6 +448,20 @@ public function testBindWithTarget() ]; $this->assertEquals($expected, $locator->getArgument(0)); } + + public function testResponseArgumentIsIgnored() + { + $container = new ContainerBuilder(); + $resolver = $container->register('argument_resolver.service', 'stdClass')->addArgument([]); + + $container->register('foo', WithResponseArgument::class) + ->addTag('controller.service_arguments'); + + (new RegisterControllerArgumentLocatorsPass())->process($container); + + $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); + $this->assertEmpty(array_keys($locator), 'Response typed argument is ignored'); + } } class RegisterTestController @@ -527,3 +542,10 @@ public function fooAction( ) { } } + +class WithResponseArgument +{ + public function fooAction(Response $response, ?Response $nullableResponse) + { + } +} From bc62d956382ffbb9e1de5c5ef20fcebec2a1545a Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Mon, 21 Nov 2022 18:37:52 +0100 Subject: [PATCH 10/11] [HttpKernel] Fix message for unresovable arguments of invokable controllers --- .../NotTaggedControllerValueResolver.php | 5 +++-- .../NotTaggedControllerValueResolverTest.php | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php b/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php index d4971cc1a5..48ea6e742d 100644 --- a/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php +++ b/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php @@ -69,8 +69,9 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable } if (!$this->container->has($controller)) { - $i = strrpos($controller, ':'); - $controller = substr($controller, 0, $i).strtolower(substr($controller, $i)); + $controller = (false !== $i = strrpos($controller, ':')) + ? substr($controller, 0, $i).strtolower(substr($controller, $i)) + : $controller.'::__invoke'; } $what = sprintf('argument $%s of "%s()"', $argument->getName(), $controller); diff --git a/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php b/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php index 3cf2f0f185..4577b5a6d2 100644 --- a/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php @@ -98,6 +98,17 @@ public function testControllerNameIsAnArray() $resolver->resolve($request, $argument); } + public function testInvokableController() + { + $this->expectException(RuntimeException::class); + $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::__invoke()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?'); + $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); + $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); + $request = $this->requestWithAttributes(['_controller' => 'App\Controller\Mine']); + $this->assertTrue($resolver->supports($request, $argument)); + $resolver->resolve($request, $argument); + } + private function requestWithAttributes(array $attributes) { $request = Request::create('/'); From 6073eaed148f4c0b8d4ae33e7332b34327ef728e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 28 Nov 2022 19:20:59 +0100 Subject: [PATCH 11/11] Update VERSION for 6.1.8 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 67e42aa891..f279be7534 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.1.8-DEV'; + public const VERSION = '6.1.8'; public const VERSION_ID = 60108; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 1; public const RELEASE_VERSION = 8; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2023'; public const END_OF_LIFE = '01/2023';