f8ccc8105c
* 4.4: (43 commits) [PhpunitBridge] Read environment variable from superglobals [Bridge/PhpUnit] Fix PHP5.5 compat [PhpUnitBridge] More accurate grouping fixed CS [Form] remove comment about to-be-removed method as it is used in master by ButtonBuilder Extract unrecoverable exception to interface [FrameworkBundle] Fix calling Client::getProfile() before sending a request Fix type error [Security/Core] require libsodium >= 1.0.14 [Workflow] re-add workflow.definition tag to workflow services [Security/Core] Don't use ParagonIE_Sodium_Compat revert #30525 due to performance penalty collect called listeners information only once [Lock] fix missing inherit docs in RedisStore [Messenger] fix retrying handlers using DoctrineTransactionMiddleware [Mailgun Mailer] fixed issue when using html body [Messenger] make all stamps final and mark stamp not meant to be sent [HttpClient] fix timing measurements with NativeHttpClient add return type declaration use proper return types in ErrorHandler and ArgumentResolver ... |
||
---|---|---|
.. | ||
Exception | ||
Internal | ||
Tests | ||
.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).