e9f0cfe9db
* 5.0: (31 commits) [HttpClient] NativeHttpClient should not send >1.1 protocol version [HttpClient] fix support for non-blocking resource streams [Mailer] Make sure you can pass custom headers to Mailgun [Mailer] Remove line breaks in email attachment content Update links to documentation [Validator] Add the missing translations for the Arabic (ar) locale ensure to expect no validation for the right reasons [Security-Guard] fixed 35203 missing name tag in param docblock [HttpClient] fix casting responses to PHP streams [PhpUnitBridge] Add test case for @expectedDeprecation annotation [PhpUnitBridge][SymfonyTestsListenerTrait] Remove $testsWithWarnings stack [FrameworkBundle] Fix getUser() phpdoc in AbstractController [Mailer] Fix addresses management in Sendgrid API payload [Mailer][MailchimpBridge] Fix missing attachments when sending via Mandrill API [Mailer][MailchimpBridge] Fix incorrect sender address when sender has name [HttpClient] fix capturing SSL certificates with NativeHttpClient Update year in license files Update year in license files [TwigBridge][Form] Added missing help messages in form themes Update year in license files ... |
||
---|---|---|
.. | ||
Exception | ||
Internal | ||
Tests | ||
.gitattributes | ||
.gitignore | ||
CHANGELOG.md | ||
composer.json | ||
Instantiator.php | ||
LICENSE | ||
phpunit.xml.dist | ||
README.md | ||
VarExporter.php |
VarExporter Component
The VarExporter component allows exporting any serializable PHP data structure to
plain PHP code. While doing so, it preserves all the semantics associated with
the serialization mechanism of PHP (__wakeup
, __sleep
, Serializable
,
__serialize
, __unserialize
).
It also provides an instantiator that allows creating and populating objects without calling their constructor nor any other methods.
The reason to use this component vs serialize()
or
igbinary is performance: thanks to
OPcache, the resulting code is significantly faster and more memory efficient
than using unserialize()
or igbinary_unserialize()
.
Unlike var_export()
, this works on any serializable PHP value.
It also provides a few improvements over var_export()
/serialize()
:
- the output is PSR-2 compatible;
- the output can be re-indented without messing up with
\r
or\n
in the data - missing classes throw a
ClassNotFoundException
instead of being unserialized toPHP_Incomplete_Class
objects; - references involving
SplObjectStorage
,ArrayObject
orArrayIterator
instances are preserved; Reflection*
,IteratorIterator
andRecursiveIteratorIterator
classes throw an exception when being serialized (their unserialized version is broken anyway, see https://bugs.php.net/76737).