Skip to content

Commit

Permalink
Merge branch '5.2' into 5.3
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nicolas-grekas committed Jun 24, 2021
2 parents 71719ab + 9f8fa61 commit 485c83a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ public static function dump($value, int $flags = 0): string
return self::dumpNull($flags);
case $value instanceof \DateTimeInterface:
return $value->format('c');
case $value instanceof \UnitEnum:
return sprintf('!php/const %s::%s', \get_class($value), $value->name);
case \is_object($value):
if ($value instanceof TaggedValue) {
return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags);
Expand Down
8 changes: 8 additions & 0 deletions Tests/Fixtures/FooUnitEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Symfony\Component\Yaml\Tests\Fixtures;

enum FooUnitEnum
{
case BAR;
}
9 changes: 9 additions & 0 deletions Tests/InlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Inline;
use Symfony\Component\Yaml\Tag\TaggedValue;
use Symfony\Component\Yaml\Tests\Fixtures\FooUnitEnum;
use Symfony\Component\Yaml\Yaml;

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

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

public function getDateTimeDumpTests()
{
$tests = [];
Expand Down

0 comments on commit 485c83a

Please sign in to comment.