diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index cb809abbaf..257c6f7a93 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -70,7 +70,7 @@ class EntityUserProviderTest extends TestCase { $user = new User(1, 1, 'user1'); - $repository = $this->createMock([ObjectRepository::class, UserLoaderInterface::class]); + $repository = $this->createMock(UserLoaderRepository::class); $repository ->expects($this->once()) ->method('loadUserByUsername') @@ -156,7 +156,7 @@ class EntityUserProviderTest extends TestCase public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided() { - $repository = $this->createMock([ObjectRepository::class, UserLoaderInterface::class]); + $repository = $this->createMock(UserLoaderRepository::class); $repository->expects($this->once()) ->method('loadUserByUsername') ->with('name') @@ -189,7 +189,7 @@ class EntityUserProviderTest extends TestCase { $user = new User(1, 1, 'user1'); - $repository = $this->createMock([interface_exists(ObjectRepository::class) ? ObjectRepository::class : LegacyObjectRepository::class, PasswordUpgraderInterface::class]); + $repository = $this->createMock(PasswordUpgraderRepository::class); $repository->expects($this->once()) ->method('upgradePassword') ->with($user, 'foobar'); @@ -233,3 +233,11 @@ class EntityUserProviderTest extends TestCase ]); } } + +abstract class UserLoaderRepository implements ObjectRepository, UserLoaderInterface +{ +} + +abstract class PasswordUpgraderRepository implements ObjectRepository, PasswordUpgraderInterface +{ +} diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php index 2bc6de0705..ba369e43f8 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php @@ -13,6 +13,7 @@ namespace Symfony\Bridge\PhpUnit\Legacy; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Warning; +use PHPUnit\Util\Annotation\Registry; use PHPUnit\Util\Test; /** @@ -66,9 +67,6 @@ class CoverageListenerTrait return; } - $r = new \ReflectionProperty(Test::class, 'annotationCache'); - $r->setAccessible(true); - $covers = $sutFqcn; if (!\is_array($sutFqcn)) { $covers = [$sutFqcn]; @@ -78,15 +76,42 @@ class CoverageListenerTrait } } + if (class_exists(Registry::class)) { + $this->addCoversForDocBlockInsideRegistry($test, $covers); + + return; + } + + $this->addCoversForClassToAnnotationCache($test, $covers); + } + + private function addCoversForClassToAnnotationCache($test, $covers) + { + $r = new \ReflectionProperty(Test::class, 'annotationCache'); + $r->setAccessible(true); + $cache = $r->getValue(); $cache = array_replace_recursive($cache, [ \get_class($test) => [ 'covers' => $covers, ], ]); + $r->setValue(Test::class, $cache); } + private function addCoversForDocBlockInsideRegistry($test, $covers) + { + $docBlock = Registry::getInstance()->forClassName(\get_class($test)); + + $symbolAnnotations = new \ReflectionProperty($docBlock, 'symbolAnnotations'); + $symbolAnnotations->setAccessible(true); + + $symbolAnnotations->setValue($docBlock, array_replace($docBlock->symbolAnnotations(), [ + 'covers' => $covers, + ])); + } + private function findSutFqcn($test) { if ($this->sutFqcnResolver) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php index a68c9f510c..efa3fbfb1f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php @@ -71,7 +71,7 @@ class WebTestCaseTest extends TestCase { $this->getResponseTester(new Response('', 302, ['Location' => 'https://example.com/']))->assertResponseRedirects('https://example.com/', 302); $this->expectException(AssertionFailedError::class); - $this->expectExceptionMessage('is redirected and has header "Location" with value "https://example.com/" and status code is 301.'); + $this->expectExceptionMessageMatches('#(:?\( )?is redirected and has header "Location" with value "https://example\.com/" (:?\) )?and status code is 301\.#'); $this->getResponseTester(new Response('', 302))->assertResponseRedirects('https://example.com/', 301); } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index d9ece4216d..46b8845614 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -382,10 +382,12 @@ class ProfilerControllerTest extends WebTestCase ->with($profile->getToken()) ->willReturn($profile); + $collectorsNames = array_keys($profile->getCollectors()); + $profiler ->expects($this->atLeastOnce()) ->method('has') - ->with($this->logicalXor($collectorsNames = array_keys($profile->getCollectors()))) + ->with($this->logicalXor(...$collectorsNames)) ->willReturn(true); $expectedTemplate = 'expected_template.html.twig'; diff --git a/src/Symfony/Component/Cache/DependencyInjection/CacheCollectorPass.php b/src/Symfony/Component/Cache/DependencyInjection/CacheCollectorPass.php index b534e5dc8a..6bbab9da4f 100644 --- a/src/Symfony/Component/Cache/DependencyInjection/CacheCollectorPass.php +++ b/src/Symfony/Component/Cache/DependencyInjection/CacheCollectorPass.php @@ -47,15 +47,13 @@ class CacheCollectorPass implements CompilerPassInterface } foreach ($container->findTaggedServiceIds($this->cachePoolTag) as $id => $attributes) { - $this->addToCollector($id, $container); + $poolName = $attributes[0]['name'] ?? $id; - if (($attributes[0]['name'] ?? $id) !== $id) { - $this->addToCollector($attributes[0]['name'], $container); - } + $this->addToCollector($id, $poolName, $container); } } - private function addToCollector(string $id, ContainerBuilder $container) + private function addToCollector(string $id, string $name, ContainerBuilder $container) { $definition = $container->getDefinition($id); if ($definition->isAbstract()) { @@ -77,7 +75,7 @@ class CacheCollectorPass implements CompilerPassInterface $container->setDefinition($id, $recorder); // Tell the collector to add the new instance - $collectorDefinition->addMethodCall('addInstance', [$id, new Reference($id)]); + $collectorDefinition->addMethodCall('addInstance', [$name, new Reference($id)]); $collectorDefinition->setPublic(false); } } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php index 3e723f1b6a..53295a1eef 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php @@ -16,8 +16,8 @@ use Symfony\Component\Cache\Adapter\AdapterInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\ChainAdapter; use Symfony\Component\Cache\Adapter\FilesystemAdapter; -use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\Tests\Fixtures\ExternalAdapter; +use Symfony\Component\Cache\Tests\Fixtures\PrunableAdapter; /** * @author Kévin Dunglas @@ -189,7 +189,7 @@ class ChainAdapterTest extends AdapterTestCase private function getPruneableMock(): AdapterInterface { - $pruneable = $this->createMock([PruneableInterface::class, AdapterInterface::class]); + $pruneable = $this->createMock(PrunableAdapter::class); $pruneable ->expects($this->atLeastOnce()) @@ -201,7 +201,7 @@ class ChainAdapterTest extends AdapterTestCase private function getFailingPruneableMock(): AdapterInterface { - $pruneable = $this->createMock([PruneableInterface::class, AdapterInterface::class]); + $pruneable = $this->createMock(PrunableAdapter::class); $pruneable ->expects($this->atLeastOnce()) diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php index e0111c1d6c..4d60f4cbd4 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php @@ -18,7 +18,7 @@ use Symfony\Component\Cache\Adapter\AdapterInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\TagAwareAdapter; -use Symfony\Component\Cache\PruneableInterface; +use Symfony\Component\Cache\Tests\Fixtures\PrunableAdapter; use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait; /** @@ -204,7 +204,7 @@ class TagAwareAdapterTest extends AdapterTestCase */ private function getPruneableMock(): AdapterInterface { - $pruneable = $this->createMock([PruneableInterface::class, AdapterInterface::class]); + $pruneable = $this->createMock(PrunableAdapter::class); $pruneable ->expects($this->atLeastOnce()) @@ -216,7 +216,7 @@ class TagAwareAdapterTest extends AdapterTestCase private function getFailingPruneableMock(): AdapterInterface { - $pruneable = $this->createMock([PruneableInterface::class, AdapterInterface::class]); + $pruneable = $this->createMock(PrunableAdapter::class); $pruneable ->expects($this->atLeastOnce()) diff --git a/src/Symfony/Component/Cache/Tests/DependencyInjection/CacheCollectorPassTest.php b/src/Symfony/Component/Cache/Tests/DependencyInjection/CacheCollectorPassTest.php index 8aff19fc3e..d0ea55313b 100644 --- a/src/Symfony/Component/Cache/Tests/DependencyInjection/CacheCollectorPassTest.php +++ b/src/Symfony/Component/Cache/Tests/DependencyInjection/CacheCollectorPassTest.php @@ -19,6 +19,8 @@ use Symfony\Component\Cache\Adapter\TraceableAdapter; use Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter; use Symfony\Component\Cache\DataCollector\CacheDataCollector; use Symfony\Component\Cache\DependencyInjection\CacheCollectorPass; +use Symfony\Component\Cache\Tests\Fixtures\ArrayCache; +use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; @@ -48,16 +50,51 @@ class CacheCollectorPassTest extends TestCase $this->assertEquals([ ['addInstance', ['fs', new Reference('fs')]], ['addInstance', ['tagged_fs', new Reference('tagged_fs')]], - ['addInstance', ['.php.inner', new Reference('.php.inner')]], - ['addInstance', ['php', new Reference('php')]], + ['addInstance', ['php', new Reference('.php.inner')]], ], $collector->getMethodCalls()); $this->assertSame(TraceableAdapter::class, $container->findDefinition('fs')->getClass()); $this->assertSame(TraceableTagAwareAdapter::class, $container->getDefinition('tagged_fs')->getClass()); $this->assertSame(TraceableAdapter::class, $container->findDefinition('.php.inner')->getClass()); - $this->assertSame(TraceableTagAwareAdapter::class, $container->getDefinition('php')->getClass()); + $this->assertSame(TagAwareAdapter::class, $container->getDefinition('php')->getClass()); $this->assertFalse($collector->isPublic(), 'The "data_collector.cache" should be private after processing'); } + + public function testProcessCacheObjectsAreDecorated() + { + $container = new ContainerBuilder(); + $collector = $container->register('data_collector.cache', CacheDataCollector::class); + + $container + ->register('cache.object', ArrayCache::class) + ->addTag('cache.pool', ['name' => 'cache.object']); + + $container + ->register('something_is_decorating_cache_object', TagAwareAdapter::class) + ->setPublic(true) + ->setDecoratedService('cache.object'); + + $container->register('some_service_using_cache_object', TraceableAdapter::class) + ->setPublic(true) + ->addArgument(new Reference('cache.object')); + + $container->addCompilerPass(new CacheCollectorPass(), PassConfig::TYPE_BEFORE_REMOVING); + + $container->compile(); + $this->assertCount(1, $collector->getMethodCalls()); + $this->assertEquals( + [ + [ + 'addInstance', + [ + 'cache.object', + new Reference('something_is_decorating_cache_object'), + ], + ], + ], + $collector->getMethodCalls() + ); + } } diff --git a/src/Symfony/Component/Cache/Tests/Fixtures/PrunableAdapter.php b/src/Symfony/Component/Cache/Tests/Fixtures/PrunableAdapter.php new file mode 100644 index 0000000000..9668ed595f --- /dev/null +++ b/src/Symfony/Component/Cache/Tests/Fixtures/PrunableAdapter.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Fixtures; + +use Symfony\Component\Cache\Adapter\AdapterInterface; +use Symfony\Component\Cache\PruneableInterface; + +abstract class PrunableAdapter implements AdapterInterface, PruneableInterface +{ +} diff --git a/src/Symfony/Component/Cache/Tests/Fixtures/PrunableCache.php b/src/Symfony/Component/Cache/Tests/Fixtures/PrunableCache.php new file mode 100644 index 0000000000..c1b3f74012 --- /dev/null +++ b/src/Symfony/Component/Cache/Tests/Fixtures/PrunableCache.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Fixtures; + +use Psr\SimpleCache\CacheInterface; +use Symfony\Component\Cache\PruneableInterface; + +abstract class PrunableCache implements CacheInterface, PruneableInterface +{ +} diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index e10e6c3dd5..58da243d9c 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -326,7 +326,7 @@ EOF; $this->asFiles = false; if ($this->preload && null !== $autoloadFile = $this->getAutoloadFile()) { - $autoloadFile = substr($this->export($autoloadFile), 2, -1); + $autoloadFile = trim($this->export($autoloadFile), '()\\'); $preloadedFiles = array_reverse($preloadedFiles); $preloadedFiles = implode("';\nrequire __DIR__.'/", $preloadedFiles); @@ -2123,9 +2123,7 @@ EOF; private function getAutoloadFile(): ?string { - if (null === $this->targetDirRegex) { - return null; - } + $file = null; foreach (spl_autoload_functions() as $autoloader) { if (!\is_array($autoloader)) { @@ -2144,14 +2142,14 @@ EOF; if (0 === strpos($class, 'ComposerAutoloaderInit') && $class::getLoader() === $autoloader[0]) { $file = \dirname((new \ReflectionClass($class))->getFileName(), 2).'/autoload.php'; - if (preg_match($this->targetDirRegex.'A', $file)) { + if (null !== $this->targetDirRegex && preg_match($this->targetDirRegex.'A', $file)) { return $file; } } } } - return null; + return $file; } private function getClasses(Definition $definition, string $id): array diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php index d2c800be67..b5a2008fa0 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php @@ -16,18 +16,6 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\StringToFloatTransform class StringToFloatTransformerTest extends TestCase { - private $transformer; - - protected function setUp(): void - { - $this->transformer = new StringToFloatTransformer(); - } - - protected function tearDown(): void - { - $this->transformer = null; - } - public function provideTransformations(): array { return [ diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php index d5ac4ad5c2..de6dfc2546 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php @@ -170,9 +170,9 @@ class ControllerResolverTest extends TestCase $controller = new ControllerTest(); return [ - ['foo', \Error::class, 'Class \'foo\' not found'], - ['oof::bar', \Error::class, 'Class \'oof\' not found'], - [['oof', 'bar'], \Error::class, 'Class \'oof\' not found'], + ['foo', \Error::class, \PHP_VERSION_ID < 80000 ? 'Class \'foo\' not found' : 'Class "foo" not found'], + ['oof::bar', \Error::class, \PHP_VERSION_ID < 80000 ? 'Class \'oof\' not found' : 'Class "oof" not found'], + [['oof', 'bar'], \Error::class, \PHP_VERSION_ID < 80000 ? 'Class \'oof\' not found' : 'Class "oof" not found'], ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::staticsAction', \InvalidArgumentException::class, 'The controller for URI "/" is not callable: Expected method "staticsAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest", did you mean "staticAction"?'], ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::privateAction', \InvalidArgumentException::class, 'The controller for URI "/" is not callable: Method "privateAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'], ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::protectedAction', \InvalidArgumentException::class, 'The controller for URI "/" is not callable: Method "protectedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'], diff --git a/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransport.php b/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransport.php index afa522ae97..adfcb55eaa 100644 --- a/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransport.php +++ b/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransport.php @@ -166,7 +166,11 @@ class EsmtpTransport extends SmtpTransport return; } catch (TransportExceptionInterface $e) { - $this->executeCommand("RSET\r\n", [250]); + try { + $this->executeCommand("RSET\r\n", [250]); + } catch (TransportExceptionInterface $_) { + // ignore this exception as it probably means that the server error was final + } // keep the error message, but tries the other authenticators $errors[$authenticator->getAuthKeyword()] = $e; diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php index 10fa472882..8c207cffc9 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php @@ -130,18 +130,6 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp */ public function getTypes(string $class, string $property, array $context = []): ?array { - if (\PHP_VERSION_ID >= 70400) { - try { - $reflectionProperty = new \ReflectionProperty($class, $property); - $type = $reflectionProperty->getType(); - if (null !== $type) { - return $this->extractFromReflectionType($type, $reflectionProperty->getDeclaringClass()); - } - } catch (\ReflectionException $e) { - // noop - } - } - if ($fromMutator = $this->extractFromMutator($class, $property)) { return $fromMutator; } @@ -161,6 +149,18 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp return $fromDefaultValue; } + if (\PHP_VERSION_ID >= 70400) { + try { + $reflectionProperty = new \ReflectionProperty($class, $property); + $type = $reflectionProperty->getType(); + if (null !== $type) { + return $this->extractFromReflectionType($type, $reflectionProperty->getDeclaringClass()); + } + } catch (\ReflectionException $e) { + // noop + } + } + return null; } diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php index 353a41b829..a2d2db5b80 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php @@ -414,6 +414,7 @@ class ReflectionExtractorTest extends TestCase { $this->assertEquals([new Type(Type::BUILTIN_TYPE_OBJECT, false, Dummy::class)], $this->extractor->getTypes(Php74Dummy::class, 'dummy')); $this->assertEquals([new Type(Type::BUILTIN_TYPE_BOOL, true)], $this->extractor->getTypes(Php74Dummy::class, 'nullableBoolProp')); + $this->assertEquals([new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING))], $this->extractor->getTypes(Php74Dummy::class, 'stringCollection')); } /** diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php74Dummy.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php74Dummy.php index 9d3146442d..ffc4f4cd37 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php74Dummy.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php74Dummy.php @@ -18,4 +18,14 @@ class Php74Dummy { public Dummy $dummy; private ?bool $nullableBoolProp; + /** @var string[] */ + private array $stringCollection; + + public function addStringCollection(string $string): void + { + } + + public function removeStringCollection(string $string): void + { + } } diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 01660e88f7..ff6ffa3100 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -1253,7 +1253,13 @@ class Parser for ($i = 1; isset($this->currentLine[$i]) && ']' !== $this->currentLine[$i]; ++$i) { } - $value .= trim($this->currentLine); + $trimmedValue = trim($this->currentLine); + + if ('' !== $trimmedValue && '#' === $trimmedValue[0]) { + continue; + } + + $value .= $trimmedValue; if (isset($this->currentLine[$i]) && ']' === $this->currentLine[$i]) { break; diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 664acdb8b5..4dfc5b58ce 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -1897,6 +1897,30 @@ YAML [new TaggedValue('foo', 'bar')], '[ !foo bar ]', ], + 'with-comments' => [ + [ + [new TaggedValue('foo', ['foo', 'baz'])], + ], + << [ + [ + [new TaggedValue('foo', ['foo', 'baz'])], + ], + <<