From 5f0fda51aad92f4039abcd2c592ae70c79f324c7 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois <2144837+alexandre-daubois@users.noreply.github.com> Date: Thu, 7 Mar 2024 10:44:39 +0100 Subject: [PATCH 1/4] [FrameworkBundle] Fix PHP 8.4 deprecation --- Console/Descriptor/TextDescriptor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Console/Descriptor/TextDescriptor.php b/Console/Descriptor/TextDescriptor.php index 56bb0fbd9..39dc8fb21 100644 --- a/Console/Descriptor/TextDescriptor.php +++ b/Console/Descriptor/TextDescriptor.php @@ -559,7 +559,7 @@ private function formatControllerLink($controller, string $anchorText, ?callable } elseif (!\is_string($controller)) { return $anchorText; } elseif (str_contains($controller, '::')) { - $r = new \ReflectionMethod($controller); + $r = new \ReflectionMethod(...explode('::', $controller, 2)); } else { $r = new \ReflectionFunction($controller); } From 832c180418a14ae86751dc4ced63608bed2271c0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 13 Mar 2024 18:38:56 +0100 Subject: [PATCH 2/4] [FrameworkBundle] Fix typo --- Command/CacheClearCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Command/CacheClearCommand.php b/Command/CacheClearCommand.php index 20df3f69e..b245dd7a6 100644 --- a/Command/CacheClearCommand.php +++ b/Command/CacheClearCommand.php @@ -156,7 +156,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } if ($this->isNfs($realBuildDir)) { - $io->note('For better performances, you should move the cache and log directories to a non-shared folder of the VM.'); + $io->note('For better performance, you should move the cache and log directories to a non-shared folder of the VM.'); $fs->remove($realBuildDir); } else { $fs->rename($realBuildDir, $oldBuildDir); From 322b40a1235d85e93b3440cad59c67d73cdb5d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Thu, 14 Mar 2024 19:12:43 +0100 Subject: [PATCH 3/4] [FrameworkBundle] Fix mailer config with XML --- DependencyInjection/Configuration.php | 3 ++- Resources/config/schema/symfony-1.0.xsd | 2 +- .../Fixtures/php/mailer_with_dsn.php | 2 +- .../Fixtures/xml/mailer_with_dsn.xml | 3 +-- .../Fixtures/xml/mailer_with_transports.xml | 4 ++-- .../Fixtures/yml/mailer_with_dsn.yml | 1 - .../FrameworkExtensionTestCase.php | 22 ++++++++++++------- .../XmlFrameworkExtensionTest.php | 1 - 8 files changed, 21 insertions(+), 17 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 487759a87..57be2f199 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -1559,7 +1559,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode, callable $e continue; } if (\is_array($scopedConfig['retry_failed'])) { - $scopedConfig['retry_failed'] = $scopedConfig['retry_failed'] + $config['default_options']['retry_failed']; + $scopedConfig['retry_failed'] += $config['default_options']['retry_failed']; } } @@ -1897,6 +1897,7 @@ private function addMailerSection(ArrayNodeDefinition $rootNode, callable $enabl ->end() ->arrayNode('envelope') ->info('Mailer Envelope configuration') + ->fixXmlConfig('recipient') ->children() ->scalarNode('sender')->end() ->arrayNode('recipients') diff --git a/Resources/config/schema/symfony-1.0.xsd b/Resources/config/schema/symfony-1.0.xsd index faee50e25..60e87a1bc 100644 --- a/Resources/config/schema/symfony-1.0.xsd +++ b/Resources/config/schema/symfony-1.0.xsd @@ -703,7 +703,7 @@ - + diff --git a/Tests/DependencyInjection/Fixtures/php/mailer_with_dsn.php b/Tests/DependencyInjection/Fixtures/php/mailer_with_dsn.php index df2ca46e4..2f10631f0 100644 --- a/Tests/DependencyInjection/Fixtures/php/mailer_with_dsn.php +++ b/Tests/DependencyInjection/Fixtures/php/mailer_with_dsn.php @@ -8,7 +8,7 @@ 'dsn' => 'smtp://example.com', 'envelope' => [ 'sender' => 'sender@example.org', - 'recipients' => ['redirected@example.org', 'redirected1@example.org'], + 'recipients' => ['redirected@example.org'], ], 'headers' => [ 'from' => 'from@example.org', diff --git a/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml b/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml index be53f59bc..06109accc 100644 --- a/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml +++ b/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml @@ -10,8 +10,7 @@ sender@example.org - redirected@example.org - redirected1@example.org + redirected@example.org from@example.org bcc1@example.org diff --git a/Tests/DependencyInjection/Fixtures/xml/mailer_with_transports.xml b/Tests/DependencyInjection/Fixtures/xml/mailer_with_transports.xml index cbe538d33..56a6e61af 100644 --- a/Tests/DependencyInjection/Fixtures/xml/mailer_with_transports.xml +++ b/Tests/DependencyInjection/Fixtures/xml/mailer_with_transports.xml @@ -12,8 +12,8 @@ smtp://example2.com sender@example.org - redirected@example.org - redirected1@example.org + redirected@example.org + redirected1@example.org from@example.org bcc1@example.org diff --git a/Tests/DependencyInjection/Fixtures/yml/mailer_with_dsn.yml b/Tests/DependencyInjection/Fixtures/yml/mailer_with_dsn.yml index f8b3c87c4..7aa79560d 100644 --- a/Tests/DependencyInjection/Fixtures/yml/mailer_with_dsn.yml +++ b/Tests/DependencyInjection/Fixtures/yml/mailer_with_dsn.yml @@ -5,7 +5,6 @@ framework: sender: sender@example.org recipients: - redirected@example.org - - redirected1@example.org headers: from: from@example.org bcc: [bcc1@example.org, bcc2@example.org] diff --git a/Tests/DependencyInjection/FrameworkExtensionTestCase.php b/Tests/DependencyInjection/FrameworkExtensionTestCase.php index 5e955d016..7555b7530 100644 --- a/Tests/DependencyInjection/FrameworkExtensionTestCase.php +++ b/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -318,7 +318,7 @@ public function testWorkflows() $this->assertSame('state_machine.pull_request.metadata_store', (string) $metadataStoreReference); $metadataStoreDefinition = $container->getDefinition('state_machine.pull_request.metadata_store'); - $this->assertSame(Workflow\Metadata\InMemoryMetadataStore::class, $metadataStoreDefinition->getClass()); + $this->assertSame(InMemoryMetadataStore::class, $metadataStoreDefinition->getClass()); $this->assertSame(InMemoryMetadataStore::class, $metadataStoreDefinition->getClass()); $workflowMetadata = $metadataStoreDefinition->getArgument(0); @@ -1940,21 +1940,27 @@ public function testHttpClientFullDefaultOptions() ], $defaultOptions['peer_fingerprint']); } - public static function provideMailer(): array + public static function provideMailer(): iterable { - return [ - ['mailer_with_dsn', ['main' => 'smtp://example.com']], - ['mailer_with_transports', [ + yield [ + 'mailer_with_dsn', + ['main' => 'smtp://example.com'], + ['redirected@example.org'], + ]; + yield [ + 'mailer_with_transports', + [ 'transport1' => 'smtp://example1.com', 'transport2' => 'smtp://example2.com', - ]], + ], + ['redirected@example.org', 'redirected1@example.org'], ]; } /** * @dataProvider provideMailer */ - public function testMailer(string $configFile, array $expectedTransports) + public function testMailer(string $configFile, array $expectedTransports, array $expectedRecipients) { $container = $this->createContainerFromFile($configFile); @@ -1966,7 +1972,7 @@ public function testMailer(string $configFile, array $expectedTransports) $this->assertTrue($container->hasDefinition('mailer.envelope_listener')); $l = $container->getDefinition('mailer.envelope_listener'); $this->assertSame('sender@example.org', $l->getArgument(0)); - $this->assertSame(['redirected@example.org', 'redirected1@example.org'], $l->getArgument(1)); + $this->assertSame($expectedRecipients, $l->getArgument(1)); $this->assertEquals(new Reference('messenger.default_bus', ContainerInterface::NULL_ON_INVALID_REFERENCE), $container->getDefinition('mailer.mailer')->getArgument(1)); $this->assertTrue($container->hasDefinition('mailer.message_listener')); diff --git a/Tests/DependencyInjection/XmlFrameworkExtensionTest.php b/Tests/DependencyInjection/XmlFrameworkExtensionTest.php index 4a2ff788b..3b388812f 100644 --- a/Tests/DependencyInjection/XmlFrameworkExtensionTest.php +++ b/Tests/DependencyInjection/XmlFrameworkExtensionTest.php @@ -14,7 +14,6 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -use Symfony\Component\RateLimiter\Policy\SlidingWindowLimiter; class XmlFrameworkExtensionTest extends FrameworkExtensionTestCase { From 49093e57c7eea2ecd1603b0218c797fc37514ae9 Mon Sep 17 00:00:00 2001 From: Indra Gunawan Date: Mon, 18 Mar 2024 01:10:56 +0800 Subject: [PATCH 4/4] [Serializer] Fixed BackedEnumNormalizer priority for translatable enum --- Resources/config/serializer.php | 2 +- Tests/Fixtures/TranslatableBackedEnum.php | 27 +++++++++++++++++++++++ Tests/Functional/SerializerTest.php | 11 +++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Tests/Fixtures/TranslatableBackedEnum.php diff --git a/Resources/config/serializer.php b/Resources/config/serializer.php index 2311df0fc..f70d60429 100644 --- a/Resources/config/serializer.php +++ b/Resources/config/serializer.php @@ -219,6 +219,6 @@ ]) ->set('serializer.normalizer.backed_enum', BackedEnumNormalizer::class) - ->tag('serializer.normalizer', ['priority' => -915]) + ->tag('serializer.normalizer', ['priority' => -880]) ; }; diff --git a/Tests/Fixtures/TranslatableBackedEnum.php b/Tests/Fixtures/TranslatableBackedEnum.php new file mode 100644 index 000000000..775276d84 --- /dev/null +++ b/Tests/Fixtures/TranslatableBackedEnum.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures; + +use Symfony\Contracts\Translation\TranslatableInterface; +use Symfony\Contracts\Translation\TranslatorInterface; + +enum TranslatableBackedEnum: string implements TranslatableInterface +{ + case Get = 'GET'; + + public function trans(TranslatorInterface $translator, ?string $locale = null): string + { + return match ($this) { + self::Get => 'custom_get_string', + }; + } +} diff --git a/Tests/Functional/SerializerTest.php b/Tests/Functional/SerializerTest.php index 630bfb7cd..2856816d1 100644 --- a/Tests/Functional/SerializerTest.php +++ b/Tests/Functional/SerializerTest.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; +use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\TranslatableBackedEnum; + /** * @author Kévin Dunglas */ @@ -67,6 +69,15 @@ public static function provideNormalizersAndEncodersWithDefaultContextOption(): ['serializer.encoder.csv.alias'], ]; } + + public function testSerializeTranslatableBackedEnum() + { + static::bootKernel(['test_case' => 'Serializer']); + + $serializer = static::getContainer()->get('serializer.alias'); + + $this->assertEquals('GET', $serializer->serialize(TranslatableBackedEnum::Get, 'yaml')); + } } class Foo