Skip to content

Commit

Permalink
Merge branch '6.4' into 7.0
Browse files Browse the repository at this point in the history
* 6.4:
  synchronize Redis proxy traits for different versions
  [Serializer] Fixed BackedEnumNormalizer priority for translatable enum
  [Config] Fix `YamlReferenceDumper` handling of array examples
  • Loading branch information
xabbuh committed Mar 27, 2024
2 parents 077a539 + 49093e5 commit 5ebf677
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Resources/config/serializer.php
Expand Up @@ -212,6 +212,6 @@
])

->set('serializer.normalizer.backed_enum', BackedEnumNormalizer::class)
->tag('serializer.normalizer', ['priority' => -915])
->tag('serializer.normalizer', ['priority' => -880])
;
};
27 changes: 27 additions & 0 deletions Tests/Fixtures/TranslatableBackedEnum.php
@@ -0,0 +1,27 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\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',
};
}
}
11 changes: 11 additions & 0 deletions Tests/Functional/SerializerTest.php
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;

use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\TranslatableBackedEnum;

/**
* @author Kévin Dunglas <dunglas@gmail.com>
*/
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5ebf677

Please sign in to comment.