diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
index 2bea6308930c9..c0af4b709c4b2 100644
--- a/.github/workflows/unit-tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -26,7 +26,7 @@ jobs:
- php: '8.1'
mode: low-deps
- php: '8.2'
- mode: experimental
+ #mode: experimental
fail-fast: false
runs-on: ubuntu-20.04
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
index bc0041c20b64c..3032e41f132ea 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
@@ -13,9 +13,9 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\DBAL\Types\Type;
+use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Persistence\ManagerRegistry;
-use Doctrine\Persistence\Mapping\ClassMetadata;
use Doctrine\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectRepository;
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
@@ -111,7 +111,7 @@ protected function createEntityManagerMock($repositoryMock)
->willReturn($repositoryMock)
;
- $classMetadata = $this->createMock(ClassMetadata::class);
+ $classMetadata = $this->createMock(ClassMetadataInfo::class);
$classMetadata
->expects($this->any())
->method('hasField')
diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php
index 971f68cb74a58..b63a54b7bfbf0 100644
--- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php
+++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php
@@ -194,6 +194,7 @@ function ($definition) {
}
}
+#[\AllowDynamicProperties]
final class DummyClass implements DummyInterface, SunnyInterface
{
private $ref;
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddAnnotationsCachedReaderPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddAnnotationsCachedReaderPass.php
index 4f09e52bdcbd1..a0581ff21fb6f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddAnnotationsCachedReaderPass.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddAnnotationsCachedReaderPass.php
@@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
+use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -28,14 +29,18 @@ public function process(ContainerBuilder $container)
// "annotation_reader" at build time don't get any cache
foreach ($container->findTaggedServiceIds('annotations.cached_reader') as $id => $tags) {
$reader = $container->getDefinition($id);
+ $reader->setPublic(false);
$properties = $reader->getProperties();
if (isset($properties['cacheProviderBackup'])) {
$provider = $properties['cacheProviderBackup']->getValues()[0];
unset($properties['cacheProviderBackup']);
$reader->setProperties($properties);
- $container->set($id, null);
- $container->setDefinition($id, $reader->replaceArgument(1, $provider));
+ $reader->replaceArgument(1, $provider);
+ } elseif (4 <= \count($arguments = $reader->getArguments()) && $arguments[3] instanceof ServiceClosureArgument) {
+ $arguments[1] = $arguments[3]->getValues()[0];
+ unset($arguments[3]);
+ $reader->setArguments($arguments);
}
}
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
index 0d52c684b27d0..39351b15aca9c 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@@ -1463,9 +1463,10 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
$container
->getDefinition('annotations.cached_reader')
+ ->setPublic(true) // set to false in AddAnnotationsCachedReaderPass
->replaceArgument(2, $config['debug'])
- // temporary property to lazy-reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
- ->setProperty('cacheProviderBackup', new ServiceClosureArgument(new Reference($cacheService)))
+ // reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
+ ->addArgument(new ServiceClosureArgument(new Reference($cacheService)))
->addTag('annotations.cached_reader')
;
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php
index bc68c74fd7776..a57561aa3337c 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php
@@ -56,6 +56,7 @@ public static function configureStatic1()
class BarUserClass
{
+ public $foo;
public $bar;
public function __construct(BarClass $bar)
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo.php
index 20bc928b9728c..c8a6b347a0029 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo.php
@@ -4,6 +4,7 @@
class FooClass
{
+ public $qux;
public $foo;
public $moo;
diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php
index aacb94ad37f2f..462b6b1129d9e 100644
--- a/src/Symfony/Component/DomCrawler/Crawler.php
+++ b/src/Symfony/Component/DomCrawler/Crawler.php
@@ -1214,11 +1214,11 @@ private function convertToHtmlEntities(string $htmlContent, string $charset = 'U
set_error_handler(function () { throw new \Exception(); });
try {
- return mb_convert_encoding($htmlContent, 'HTML-ENTITIES', $charset);
+ return mb_encode_numericentity($htmlContent, [0x80, 0xFFFF, 0, 0xFFFF], $charset);
} catch (\Exception|\ValueError $e) {
try {
$htmlContent = iconv($charset, 'UTF-8', $htmlContent);
- $htmlContent = mb_convert_encoding($htmlContent, 'HTML-ENTITIES', 'UTF-8');
+ $htmlContent = mb_encode_numericentity($htmlContent, [0x80, 0xFFFF, 0, 0xFFFF], 'UTF-8');
} catch (\Exception|\ValueError $e) {
}
diff --git a/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php b/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php
index 3c66d8b9ac452..b9ebd6b1c6cc9 100644
--- a/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php
+++ b/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php
@@ -17,6 +17,8 @@
*/
class MockStream
{
+ public $context;
+
/**
* Opens file or URL.
*
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectDummy.php b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectDummy.php
index ac610f098607f..788313c2b8562 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectDummy.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectDummy.php
@@ -2,6 +2,7 @@
namespace Symfony\Component\Serializer\Tests\Normalizer\Features;
+#[\AllowDynamicProperties]
class ObjectDummy
{
protected $foo;
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php
index 81ba1224bbfe5..14d117ddbb77d 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php
@@ -33,6 +33,7 @@ class ImageValidatorTest extends ConstraintValidatorTestCase
protected $imageLandscape;
protected $imagePortrait;
protected $image4By3;
+ protected $image16By9;
protected $imageCorrupted;
protected function createValidator()
diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
index 8409a0c741325..88e5ba9284030 100644
--- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
+++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
@@ -978,7 +978,7 @@ protected function dumpLine($depth, $endOfValue = false)
}
$this->lastDepth = $depth;
- $this->line = mb_convert_encoding($this->line, 'HTML-ENTITIES', 'UTF-8');
+ $this->line = mb_encode_numericentity($this->line, [0x80, 0xFFFF, 0, 0xFFFF], 'UTF-8');
if (-1 === $depth) {
AbstractDumper::dumpLine(0);
diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php
index e39adfa78710d..71c34f7646940 100644
--- a/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php
+++ b/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php
@@ -175,7 +175,7 @@ public function testHtmlDump()
trace: {
%s%eVarDumper%eTests%eCaster%eExceptionCasterTest.php:%d
- …%d
+ …%d
}
}
diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php
index ff308aaa0ccd2..5bba4e55fc8d7 100644
--- a/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php
+++ b/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php
@@ -166,11 +166,13 @@ public function testCastObjectStorageDumpsInfo()
public function testCastArrayObject()
{
- $var = new \ArrayObject([123]);
+ $var = new
+ #[\AllowDynamicProperties]
+ class([123]) extends \ArrayObject {};
$var->foo = 234;
$expected = << 123
diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php b/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php
index e5ad368330f1c..9921dc715a4dd 100644
--- a/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php
+++ b/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php
@@ -66,7 +66,7 @@ public function testGet()
6 => {$intMax}
"str" => "d&%s;j&%s;\\n"
7 => b"""
- é\\x00test\\t\\n
+ é\\x00test\\t\\n
ing
"""
"[]" => []
diff --git a/src/Symfony/Component/VarDumper/Tests/Fixtures/dumb-var.php b/src/Symfony/Component/VarDumper/Tests/Fixtures/dumb-var.php
index 67e53badb6445..4ea8c8ba6ec08 100644
--- a/src/Symfony/Component/VarDumper/Tests/Fixtures/dumb-var.php
+++ b/src/Symfony/Component/VarDumper/Tests/Fixtures/dumb-var.php
@@ -3,6 +3,7 @@
namespace Symfony\Component\VarDumper\Tests\Fixture;
if (!class_exists(\Symfony\Component\VarDumper\Tests\Fixture\DumbFoo::class)) {
+ #[\AllowDynamicProperties]
class DumbFoo
{
public $foo = 'foo';
diff --git a/src/Symfony/Component/VarExporter/Internal/Exporter.php b/src/Symfony/Component/VarExporter/Internal/Exporter.php
index 4c49d87da61bf..c46eb50aa988d 100644
--- a/src/Symfony/Component/VarExporter/Internal/Exporter.php
+++ b/src/Symfony/Component/VarExporter/Internal/Exporter.php
@@ -108,7 +108,15 @@ public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount
}
$properties = ['SplObjectStorage' => ["\0" => $properties]];
$arrayValue = (array) $value;
- } elseif ($value instanceof \Serializable || $value instanceof \__PHP_Incomplete_Class) {
+ } elseif ($value instanceof \Serializable
+ || $value instanceof \__PHP_Incomplete_Class
+ || $value instanceof \DatePeriod
+ || (\PHP_VERSION_ID >= 80200 && (
+ $value instanceof \DateTimeInterface
+ || $value instanceof \DateTimeZone
+ || $value instanceof \DateInterval
+ ))
+ ) {
++$objectsCount;
$objectsPool[$value] = [$id = \count($objectsPool), serialize($value), [], 0];
$value = new Reference($id);
diff --git a/src/Symfony/Component/VarExporter/Internal/Hydrator.php b/src/Symfony/Component/VarExporter/Internal/Hydrator.php
index 364d292d916e7..5ed6bdc948e63 100644
--- a/src/Symfony/Component/VarExporter/Internal/Hydrator.php
+++ b/src/Symfony/Component/VarExporter/Internal/Hydrator.php
@@ -55,45 +55,14 @@ public static function hydrate($objects, $values, $properties, $value, $wakeups)
public static function getHydrator($class)
{
- if ('stdClass' === $class) {
- return self::$hydrators[$class] = static function ($properties, $objects) {
- foreach ($properties as $name => $values) {
- foreach ($values as $i => $v) {
- $objects[$i]->$name = $v;
- }
- }
- };
- }
-
- if (!class_exists($class) && !interface_exists($class, false) && !trait_exists($class, false)) {
- throw new ClassNotFoundException($class);
- }
- $classReflector = new \ReflectionClass($class);
-
- if (!$classReflector->isInternal()) {
- return self::$hydrators[$class] = (self::$hydrators['stdClass'] ?? self::getHydrator('stdClass'))->bindTo(null, $class);
- }
-
- if ($classReflector->name !== $class) {
- return self::$hydrators[$classReflector->name] ?? self::getHydrator($classReflector->name);
- }
-
switch ($class) {
- case 'ArrayIterator':
- case 'ArrayObject':
- $constructor = \Closure::fromCallable([$classReflector->getConstructor(), 'invokeArgs']);
-
- return self::$hydrators[$class] = static function ($properties, $objects) use ($constructor) {
+ case 'stdClass':
+ return self::$hydrators[$class] = static function ($properties, $objects) {
foreach ($properties as $name => $values) {
- if ("\0" !== $name) {
- foreach ($values as $i => $v) {
- $objects[$i]->$name = $v;
- }
+ foreach ($values as $i => $v) {
+ $objects[$i]->$name = $v;
}
}
- foreach ($properties["\0"] ?? [] as $i => $v) {
- $constructor($objects[$i], $v);
- }
};
case 'ErrorException':
@@ -122,6 +91,38 @@ public static function getHydrator($class)
};
}
+ if (!class_exists($class) && !interface_exists($class, false) && !trait_exists($class, false)) {
+ throw new ClassNotFoundException($class);
+ }
+ $classReflector = new \ReflectionClass($class);
+
+ switch ($class) {
+ case 'ArrayIterator':
+ case 'ArrayObject':
+ $constructor = \Closure::fromCallable([$classReflector->getConstructor(), 'invokeArgs']);
+
+ return self::$hydrators[$class] = static function ($properties, $objects) use ($constructor) {
+ foreach ($properties as $name => $values) {
+ if ("\0" !== $name) {
+ foreach ($values as $i => $v) {
+ $objects[$i]->$name = $v;
+ }
+ }
+ }
+ foreach ($properties["\0"] ?? [] as $i => $v) {
+ $constructor($objects[$i], $v);
+ }
+ };
+ }
+
+ if (!$classReflector->isInternal()) {
+ return self::$hydrators[$class] = (self::$hydrators['stdClass'] ?? self::getHydrator('stdClass'))->bindTo(null, $class);
+ }
+
+ if ($classReflector->name !== $class) {
+ return self::$hydrators[$classReflector->name] ?? self::getHydrator($classReflector->name);
+ }
+
$propertySetters = [];
foreach ($classReflector->getProperties() as $propertyReflector) {
if (!$propertyReflector->isStatic()) {
diff --git a/src/Symfony/Component/VarExporter/Tests/Fixtures/array-object.php b/src/Symfony/Component/VarExporter/Tests/Fixtures/array-object.php
index 4e2d4d13a3d89..22fb5c9b247d9 100644
--- a/src/Symfony/Component/VarExporter/Tests/Fixtures/array-object.php
+++ b/src/Symfony/Component/VarExporter/Tests/Fixtures/array-object.php
@@ -2,8 +2,8 @@
return \Symfony\Component\VarExporter\Internal\Hydrator::hydrate(
$o = [
- clone (($p = &\Symfony\Component\VarExporter\Internal\Registry::$prototypes)['ArrayObject'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('ArrayObject')),
- clone $p['ArrayObject'],
+ clone (($p = &\Symfony\Component\VarExporter\Internal\Registry::$prototypes)['Symfony\\Component\\VarExporter\\Tests\\ArrayObject'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('Symfony\\Component\\VarExporter\\Tests\\ArrayObject')),
+ clone ($p['ArrayObject'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('ArrayObject')),
],
null,
[],
diff --git a/src/Symfony/Component/VarExporter/Tests/Fixtures/datetime-legacy.php b/src/Symfony/Component/VarExporter/Tests/Fixtures/datetime-legacy.php
new file mode 100644
index 0000000000000..7b217c5fb21b0
--- /dev/null
+++ b/src/Symfony/Component/VarExporter/Tests/Fixtures/datetime-legacy.php
@@ -0,0 +1,92 @@
+ 'O:10:"DatePeriod":6:{s:5:"start";O:8:"DateTime":3:{s:4:"date";s:26:"2012-07-01 00:00:00.000000";s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+00:00";}s:7:"current";N;s:3:"end";N;s:8:"interval";O:12:"DateInterval":16:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:7;s:1:"h";i:0;s:1:"i";i:0;s:1:"s";i:0;s:1:"f";d:0;s:7:"weekday";i:0;s:16:"weekday_behavior";i:0;s:17:"first_last_day_of";i:0;s:6:"invert";i:0;s:4:"days";b:0;s:12:"special_type";i:0;s:14:"special_amount";i:0;s:21:"have_weekday_relative";i:0;s:21:"have_special_relative";i:0;}s:11:"recurrences";i:5;s:18:"include_start_date";b:1;}',
+ ]),
+ null,
+ [
+ 'stdClass' => [
+ 'date' => [
+ '1970-01-01 00:00:00.000000',
+ '1970-01-01 00:00:00.000000',
+ ],
+ 'timezone_type' => [
+ 1,
+ 1,
+ 3,
+ ],
+ 'timezone' => [
+ '+00:00',
+ '+00:00',
+ 'Europe/Paris',
+ ],
+ 'y' => [
+ 3 => 0,
+ ],
+ 'm' => [
+ 3 => 0,
+ ],
+ 'd' => [
+ 3 => 7,
+ ],
+ 'h' => [
+ 3 => 0,
+ ],
+ 'i' => [
+ 3 => 0,
+ ],
+ 's' => [
+ 3 => 0,
+ ],
+ 'f' => [
+ 3 => 0.0,
+ ],
+ 'weekday' => [
+ 3 => 0,
+ ],
+ 'weekday_behavior' => [
+ 3 => 0,
+ ],
+ 'first_last_day_of' => [
+ 3 => 0,
+ ],
+ 'invert' => [
+ 3 => 0,
+ ],
+ 'days' => [
+ 3 => false,
+ ],
+ 'special_type' => [
+ 3 => 0,
+ ],
+ 'special_amount' => [
+ 3 => 0,
+ ],
+ 'have_weekday_relative' => [
+ 3 => 0,
+ ],
+ 'have_special_relative' => [
+ 3 => 0,
+ ],
+ ],
+ ],
+ [
+ $o[0],
+ $o[1],
+ $o[2],
+ $o[3],
+ $o[4],
+ ],
+ [
+ 1 => 0,
+ 1,
+ 2,
+ 3,
+ ]
+);
diff --git a/src/Symfony/Component/VarExporter/Tests/Fixtures/datetime.php b/src/Symfony/Component/VarExporter/Tests/Fixtures/datetime.php
index 1c916458c4f1a..1de8fa03f0919 100644
--- a/src/Symfony/Component/VarExporter/Tests/Fixtures/datetime.php
+++ b/src/Symfony/Component/VarExporter/Tests/Fixtures/datetime.php
@@ -1,25 +1,21 @@
[
- 'date' => [
- '1970-01-01 00:00:00.000000',
- ],
- 'timezone_type' => [
- 1,
- ],
- 'timezone' => [
- '+00:00',
- ],
- ],
+ $o[0],
+ $o[1],
+ $o[2],
+ $o[3],
+ $o[4],
],
- $o[0],
- [
- 1 => 0,
- ]
+ []
);
diff --git a/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php b/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php
index 744e576c0a0c9..cbd223642320b 100644
--- a/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php
+++ b/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php
@@ -53,16 +53,16 @@ public function testInstantiate()
$expected = [
"\0".__NAMESPACE__."\Bar\0priv" => 123,
"\0".__NAMESPACE__."\Foo\0priv" => 234,
+ 'dyn' => 345,
];
- $actual = (array) Instantiator::instantiate(Bar::class, ['priv' => 123], [Foo::class => ['priv' => 234]]);
+ $actual = (array) Instantiator::instantiate(Bar::class, ['dyn' => 345, 'priv' => 123], [Foo::class => ['priv' => 234]]);
ksort($actual);
$this->assertSame($expected, $actual);
- $e = Instantiator::instantiate('Exception', ['foo' => 123, 'trace' => [234]]);
+ $e = Instantiator::instantiate('Exception', ['trace' => [234]]);
- $this->assertSame(123, $e->foo);
$this->assertSame([234], $e->getTrace());
}
}
@@ -72,6 +72,7 @@ class Foo
private $priv;
}
+#[\AllowDynamicProperties]
class Bar extends Foo
{
private $priv;
diff --git a/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php b/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php
index fffccd4b53db1..f87e4e9b01d1e 100644
--- a/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php
+++ b/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php
@@ -95,7 +95,9 @@ public function testExport(string $testName, $value, bool $staticValueExpected =
$dump = "= 70406 || !\in_array($testName, ['array-object', 'array-iterator', 'array-object-custom', 'spl-object-storage', 'final-array-iterator', 'final-error'], true)) {
+ if (\PHP_VERSION_ID < 80200 && 'datetime' === $testName) {
+ $fixtureFile = __DIR__.'/Fixtures/'.$testName.'-legacy.php';
+ } elseif (\PHP_VERSION_ID >= 70406 || !\in_array($testName, ['array-object', 'array-iterator', 'array-object-custom', 'spl-object-storage', 'final-array-iterator', 'final-error'], true)) {
$fixtureFile = __DIR__.'/Fixtures/'.$testName.'.php';
} elseif (\PHP_VERSION_ID < 70400) {
$fixtureFile = __DIR__.'/Fixtures/'.$testName.'-legacy.php';
@@ -127,9 +129,15 @@ public function provideExport()
yield ['bool', true, true];
yield ['simple-array', [123, ['abc']], true];
yield ['partially-indexed-array', [5 => true, 1 => true, 2 => true, 6 => true], true];
- yield ['datetime', \DateTime::createFromFormat('U', 0)];
-
- $value = new \ArrayObject();
+ yield ['datetime', [
+ \DateTime::createFromFormat('U', 0),
+ \DateTimeImmutable::createFromFormat('U', 0),
+ new \DateTimeZone('Europe/Paris'),
+ new \DateInterval('P7D'),
+ new \DatePeriod('R4/2012-07-01T00:00:00Z/P7D'),
+ ]];
+
+ $value = \PHP_VERSION_ID >= 70406 ? new ArrayObject() : new \ArrayObject();
$value[0] = 1;
$value->foo = new \ArrayObject();
$value[1] = $value;
@@ -436,3 +444,8 @@ public function unserialize($ser)
throw new \BadMethodCallException();
}
}
+
+#[\AllowDynamicProperties]
+class ArrayObject extends \ArrayObject
+{
+}