Skip to content

Commit 8a1c711

Browse files
committed
feature #59177 [JsonEncoder] Add native lazyghost support (mtarld)
This PR was merged into the 7.3 branch. Discussion ---------- [JsonEncoder] Add native lazyghost support | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | | License | MIT - Add support for native lazy ghost if available. - Improve var exporter lazy ghost usage, as it's not possible anymore to initialize a single property and letting the rest uninitialized. The object part of a stream generated decoder changed from: ```php $data = \Symfony\Component\JsonEncoder\Decode\Splitter::splitDict($stream, $offset, $length); $properties = []; foreach ($data as $k => $v) { match ($k) { 'id' => $properties['id'] = static function () use ($stream, $v, $options, $denormalizers, $instantiator, &$providers) { return \Symfony\Component\JsonEncoder\Decode\NativeDecoder::decodeStream($stream, $v[0], $v[1]); }, 'name' => $properties['name'] = static function () use ($stream, $v, $options, $denormalizers, $instantiator, &$providers) { return \Symfony\Component\JsonEncoder\Decode\NativeDecoder::decodeStream($stream, $v[0], $v[1]); }, default => null, }; } return $instantiator->instantiate(\Symfony\Component\JsonEncoder\Tests\Fixtures\Model\ClassicDummy::class, $properties); ``` to: ```php $data = \Symfony\Component\JsonEncoder\Decode\Splitter::splitDict($stream, $offset, $length); return $instantiator->instantiate(\Symfony\Component\JsonEncoder\Tests\Fixtures\Model\ClassicDummy::class, static function ($object) use ($stream, $data, $options, $denormalizers, $instantiator, &$providers) { foreach ($data as $k => $v) { match ($k) { 'id' => $object->id = \Symfony\Component\JsonEncoder\Decode\NativeDecoder::decodeStream($stream, $v[0], $v[1]), 'name' => $object->name = \Symfony\Component\JsonEncoder\Decode\NativeDecoder::decodeStream($stream, $v[0], $v[1]), default => null, }; } }); ``` Commits ------- ffccbc3e342 [JsonEncoder] Add native lazyghost support
2 parents 06e1348 + b77eac0 commit 8a1c711

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,6 +2032,10 @@ private function registerJsonEncoderConfiguration(array $config, ContainerBuilde
20322032
foreach ($config['paths'] as $namespace => $path) {
20332033
$loader->registerClasses($encodableDefinition, $namespace, $path);
20342034
}
2035+
2036+
if (\PHP_VERSION_ID >= 80400) {
2037+
$container->removeDefinition('.json_encoder.cache_warmer.lazy_ghost');
2038+
}
20352039
}
20362040

20372041
private function registerPropertyInfoConfiguration(ContainerBuilder $container, PhpFileLoader $loader): void

0 commit comments

Comments
 (0)