Commit 8a1c711
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 support1 file changed
+4
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2032 | 2032 | | |
2033 | 2033 | | |
2034 | 2034 | | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
2035 | 2039 | | |
2036 | 2040 | | |
2037 | 2041 | | |
| |||
0 commit comments