10000 bug #52797 [VarExporter] Fix lazy ghost trait when using nullsafe ope… · symfonyaml/symfony@fd5bc71 · GitHub
[go: up one dir, main page]

Skip to content

Commit fd5bc71

Browse files
bug symfony#52797 [VarExporter] Fix lazy ghost trait when using nullsafe operator (nicolas-grekas)
This PR was merged into the 6.3 branch. Discussion ---------- [VarExporter] Fix lazy ghost trait when using nullsafe operator | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix symfony#52793 | License | MIT My bad. Tests coming. The issue happens only when using the nullsafe operator so the short-term workaround is using isset + ternary instead. Commits ------- 7c7adab [VarExporter] Fix lazy ghost trait when using nullsafe operator
2 parents 0db5e7e + 7c7adab commit fd5bc71

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Symfony/Component/VarExporter/LazyGhostTrait.php

Lines changed: 3 additions & 2 deletions
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][$property][3] = new \ReflectionProperty($scope ?? $class, $name);
180181
} else {
181182
$property = null;
182183
}

src/Symfony/Component/VarExporter/Tests/Fixtures/LazyGho 9C5A st/ChildMagicClass.php

Lines changed: 9 additions & 0 deletions
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".parent::class."\0".'data' => [parent::class, '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)
0