Class SerializableClosure
A wrapper for closures enabling them to be serialized. IMPORTANT NOTE: This is highly experimental and needs further improvment and testing
A closure is serialized by deconstructing it into its parts, namely the string that represents its code and the paramaters it uses. The code is extracted with reflection and SplFileObject, the paramaters are extracted with reflection.
The code string and paramters are all that is serailized. On unserialize the code and paramters are used to reconstruct the closure using eval().
The usage of eval mean that SplFileObject can no longer be used on a reconstructed closure. However, this is solved by storing the previously extracted code for future use.
Any closure which is defined within a reconstructed closure can also not have SplFileObject used on it, as it was also defined by eval()'d code. To prevent this being a problem, all extracted code is processed so that an closures declared within have their own code isolated so that it may be used later when it is needed and would otherwise be un-obtainable with SplFileObject.
Package: utilities
Author: Martin Cassidy
Todo: imporove so that all type hinting usage of classes within a closure don't need to be fully qualified
Todo: test in PHP 5.4.x
Located at utilities/SerializableClosure.php
public
|
|
public
|
|
public
|
|
public
|
|
public
|