Skip to content

Commit 485c83a

Browse files
Merge branch '5.2' into 5.3
* 5.2: [DI] fix fixture [ErrorHandler] fix handling buffered SilencedErrorContext [HttpClient] fix Psr18Client when allow_url_fopen=0 [DependencyInjection] Add support of PHP enumerations [Cache] handle prefixed redis connections when clearing pools [Cache] fix eventual consistency when using RedisTagAwareAdapter with a cluster [Uid] Fix fromString() with low base58 values [Validator][Translation] Add ExpressionLanguageSyntax en and fr [HttpKernel] [HttpCache] Keep s-maxage=0 from ESI sub-responses Avoid broken action URL in text notification mail [Cache] Disable locking on Windows by default [DependencyInjection] Fix binding "iterable $foo" when using the PHP-DSL [Config] fix tracking default values that reference the parent class [DependencyInjection] fix accepted types on FactoryTrait::factory() [VarDumper] Fix tests for PHP 8.1 [Mailer] fix encoding of addresses using SmtpTransport [MonologBridge] Fix the server:log help --filter sample
2 parents 71719ab + 9f8fa61 commit 485c83a

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

Inline.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ public static function dump($value, int $flags = 0): string
127127
return self::dumpNull($flags);
128128
case $value instanceof \DateTimeInterface:
129129
return $value->format('c');
130+
case $value instanceof \UnitEnum:
131+
return sprintf('!php/const %s::%s', \get_class($value), $value->name);
130132
case \is_object($value):
131133
if ($value instanceof TaggedValue) {
132134
return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags);

Tests/Fixtures/FooUnitEnum.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Symfony\Component\Yaml\Tests\Fixtures;
4+
5+
enum FooUnitEnum
6+
{
7+
case BAR;
8+
}

Tests/InlineTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Yaml\Exception\ParseException;
1717
use Symfony\Component\Yaml\Inline;
1818
use Symfony\Component\Yaml\Tag\TaggedValue;
19+
use Symfony\Component\Yaml\Tests\Fixtures\FooUnitEnum;
1920
use Symfony\Component\Yaml\Yaml;
2021

2122
class InlineTest extends TestCase
@@ -580,6 +581,14 @@ public function testDumpDateTime($dateTime, $expected)
580581
$this->assertSame($expected, Inline::dump($dateTime));
581582
}
582583

584+
/**
585+
* @requires PHP 8.1
586+
*/
587+
public function testDumpUnitEnum()
588+
{
589+
$this->assertSame("!php/const Symfony\Component\Yaml\Tests\Fixtures\FooUnitEnum::BAR", Inline::dump(FooUnitEnum::BAR));
590+
}
591+
583592
public function getDateTimeDumpTests()
584593
{
585594
$tests = [];

0 commit comments

Comments
 (0)