We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skipping default values can significantly reduce serialized message size:
_main(); function _main() { $with_nulls = new FooWithNulls(42); $without_nulls = new FooWithoutNulls(42); echo 'With default values: ' . strlen(instance_serialize($with_nulls)) . PHP_EOL; echo 'Without default values: ' . strlen(instance_serialize($without_nulls)) . PHP_EOL; } /** @kphp-serializable */ final class FooWithNulls { /** @kphp-serialized-field 1 */ private int $x; /** @kphp-serialized-field 2 */ private ?int $a = null; /** @kphp-serialized-field 3 */ private ?int $b = null; /** @kphp-serialized-field 4 */ private ?int $c = null; /** @kphp-serialized-field 5 */ private ?int $d = null; /** @kphp-serialized-field 6 */ private ?int $e = null; public function __construct(int $x) { $this->x = $x; } } /** @kphp-serializable */ final class FooWithoutNulls { /** @kphp-serialized-field 1 */ private int $x; public function __construct(int $x) { $this->x = $x; } }
Output:
With default values: 13 Without default values: 3
This should be configurable just like in JsonEncoder.
JsonEncoder
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Skipping default values can significantly reduce serialized message size:
Output:
This should be configurable just like in
JsonEncoder
.The text was updated successfully, but these errors were encountered: