* 5.0: (27 commits) Fix versions [Security/Http] Allow setting cookie security settings for delete_cookies [DI] fix generating TypedReference from PriorityTaggedServiceTrait [FrameworkBundle] revert to legacy wiring of the session when circular refs are detected bumped Symfony version to 3.4.40 updated VERSION for 3.4.39 update CONTRIBUTORS for 3.4.39 updated CHANGELOG for 3.4.39 [DomCrawler] Fix BC break in assertions breaking Panther [BrowserKit] fixed missing post request parameters in file uploads update Italian translation [Validator] Add missing Hungarian translations [Validator] Add the missing translations for the Arabic (ar) locale [Validator] Add missing vietnamese translations [Console] Fix OutputStream for PHP 7.4 add missing gitattributes for phpunit-bridge add German translations Bump Symfony version to 5.0.7 Update VERSION for 5.0.6 Update CHANGELOG for 5.0.6 ... |
||
---|---|---|
.. | ||
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).