Skip to content

Commit c2091b5

Browse files
[VarExporter] Fix lazy ghost trait when using nullsafe operator
1 parent 0db5e7e commit c2091b5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Symfony/Component/VarExporter/LazyGhostTrait.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@ public function &__get($name): mixed
175175
if ($state && (null === $scope || isset($propertyScopes["\0$scope\0$name"]))) {
176176
if (LazyObjectState::STATUS_INITIALIZED_FULL === $state->status) {
177177
// Work around php/php-src#12695
178-
$property = $propertyScopes[null === $scope ? $name : "\0$scope\0$name"][3]
179-
?? (Hydrator::$propertyScopes[$this::class] = Hydrator::getPropertyScopes($this::class))[3];
178+
$property = null === $scope ? $name : "\0$scope\0$name";
179+
$property = $propertyScopes[$property][3]
180+
?? (Hydrator::$propertyScopes[$this::class] = Hydrator::getPropertyScopes($this::class))[$property][3];
180181
} else {
181182
$property = null;
182183
}

src/Symfony/Component/VarExporter/Tests/Fixtures/LazyGhost/ChildMagicClass.php

+9
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,14 @@ class ChildMagicClass extends MagicClass implements LazyObjectInterface
1818
{
1919
use LazyGhostTrait;
2020

21+
private const LAZY_OBJECT_PROPERTY_SCOPES = [
22+
"\0".self::class."\0".'data' => [self::class, 'data', null],
23+
"\0".self::class."\0".'lazyObjectState' => [self::class, 'lazyObjectState', null],
24+
"\0".'Symfony\\Component\\VarExporter\\Tests\\Fixtures\\LazyGhost\\MagicClass'."\0".'data' => ['Symfony\\Component\\VarExporter\\Tests\\Fixtures\\LazyGhost\\MagicClass', 'data', null],
25+
'cloneCounter' => [self::class, 'cloneCounter', null],
26+
'data' => [self::class, 'data', null],
27+
'lazyObjectState' => [self::class, 'lazyObjectState', null],
28+
];
29+
2130
private int $data = 123;
2231
}

0 commit comments

Comments
 (0)