Skip to content

Commit

Permalink
feature #53680 [DependencyInjection][Yaml] dump enums with the !php/e…
Browse files Browse the repository at this point in the history
…num tag (xabbuh)

This PR was merged into the 7.1 branch.

Discussion
----------

[DependencyInjection][Yaml] dump enums with the !php/enum tag

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Issues        | Fix #53636
| License       | MIT

Commits
-------

661cc42 dump enums with the !php/enum tag
  • Loading branch information
nicolas-grekas committed Jan 30, 2024
2 parents 6190a8f + 661cc42 commit 4a49af8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Yaml/Inline.php
Expand Up @@ -116,7 +116,7 @@ public static function dump(mixed $value, int $flags = 0): string
default => 'Y-m-d\TH:i:s.uP',
});
case $value instanceof \UnitEnum:
return sprintf('!php/const %s::%s', $value::class, $value->name);
return sprintf('!php/enum %s::%s', $value::class, $value->name);
case \is_object($value):
if ($value instanceof TaggedValue) {
return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Yaml/Tests/InlineTest.php
Expand Up @@ -715,7 +715,7 @@ public static function getNumericKeyData()

public function testDumpUnitEnum()
{
$this->assertSame("!php/const Symfony\Component\Yaml\Tests\Fixtures\FooUnitEnum::BAR", Inline::dump(FooUnitEnum::BAR));
$this->assertSame("!php/enum Symfony\Component\Yaml\Tests\Fixtures\FooUnitEnum::BAR", Inline::dump(FooUnitEnum::BAR));
}

public function testParseUnitEnum()
Expand Down

0 comments on commit 4a49af8

Please sign in to comment.