NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist · #2205 most downloaded on Packagist
Serialize Closure objects, including their context and binding
Last release 9 years ago
no release in 18 months
Release timing varies
gaps range from 9 days to 1.3 years
Most releases are documented
notes for 8 of 13 stable releases
Nothing withdrawn
no release was ever pulled
14 years old
15 releases · first in 2012
Added support for PHP Parser 4 and PHP 7.2.
Added support for PHP Parser 3 and PHP 7.1.
Added support for version 2.x of @nikic 's PHP Parser.
One column per quarter.
bindTo() method to SerializableClosure to match Closure's interface.hash_equals() implementation with the one in symfony/polyfill-php56.Serializer when the data being unserialized is invalid.opis/closure project for new discussions, ideas, and motivations.It's
ParseErrornotParseException.
Adds support for signing serialized closures .
var_dump() or print_r() on unserialized closures.Main class to interact with for serializing closures
ClosureParser into ClosureAnalyzer
AstAnalyzer - Uses PHPParser library; many featuresTokenAnalyzer - Uses token_get_all(); fastJeremeamia from the namespaceThere are lots of big changes again, but I'm finally happy with the project's structure. There is some more testing and docs to do, but there shouldn'
There are lots of big changes again, but I'm finally happy with the project's structure. There is some more testing and docs to do, but there shouldn't be any drastic changes at this point forward. Please see the README on the master branch for the latest information.
If you were relying directly on the ClosureParser object, then you will have breaking changes for sure. They likely will not be difficult to fix thoug…
nikic/PHPParser library. This parser is the most robust and allows you tojeremeamia/FunctionParser library. This library was$this inside of a closure. Unserialized closures from version 1 of SuperClosure$this, but this version canturbo_mode that turns all the non-essential features off, This will makeSuperClosure\serialize() function – If you have installed SuperClosure via Composer, then theSuperClosure\serialize() function will automagically be available. This allows you to easily serialize the closureJeremeamia from the namespace. However, there is a class alias automaticallySerializableClosure class toSuperClosure\SerializableClosure orJeremeamia\SuperClosure\SerializableClosure.It depends. Mostly no.
If you were just using the SerializableClosure object, then it should work exactly the same way as before.
$closure = new SerializableClosure($closure);
$serialized = serialize($closure);If you were relying directly on the ClosureParser object, then you will have breaking changes for sure. They likely
will not be difficult to fix though since SuperClosure is still a small library. Just keep in mind that there is now
more than one type of parser available.
use SuperClosure\SerializableClosure;
use SuperClosure\ClosureParser\Options;
use SuperClosure\ClosureParser\Ast\AstParser;
use SuperClosure\ClosureParser\Token\TokenParser;
// TRADITIONAL MODE (Same as in v1.0; uses "ROBUST MODE")
$closure = new SerializableClosure($closure);
$serialized = serialize($closure);
// ROBUST MODE (i.e., SLOW MODE) (Uses the AST parser with all features on)
$serialized = SuperClosure\serialize($closure);
// TURBO MODE (Uses the token parser, with all features off)
$serialized = SuperClosure\serialize($closure, array(Options::TURBO_MODE => true));
// The rest are examples of mixing and matching features
//-------------------------------------------------------
// Does everything else, but ignores closure bindings
// This is perfect for functions in PHP 5.4+ that are declared in a class, but do not reference `$this`
$serialized = SuperClosure\serialize($closure, array(
Options::HANDLE_CLOSURE_BINDINGS => false,
));
// Uses the Token parser implicitly, by disabling the features unique to the AST parser
$serialized = SuperClosure\serialize($closure, array(
Options::HANDLE_MAGIC_CONSTANTS => false,
Options::HANDLE_CLASS_NAMES => false,
));
// Uses the Token parser explicitly
$serialized = SuperClosure\serialize($closure, new TokenParser);
// This is equivalent to TURBO MODE. ZOOOOOOM!!!
$options = new Options(array(Options::VALIDATE_TOKENS => false));
$serialized = SuperClosure\serialize($closure, new TokenParser($options)));Note: This is the final 1.x release.
Note: This is the final 1.x release.
null.Updated Composer dependencies to use a tagged release of PHP Parser .
SerializableClosure class to be easier to extend.Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
If you were relying directly on the ClosureParser object, then you will have breaking changes for sure. They likely will not be difficult to fix thoug…
SuperClosure is getting an overhaul!
nikic/PHPParser library. This parser is the most robust and allows you tojeremeamia/FunctionParser library. This library was$this inside of a closure. Unserialized closures from version 1 of SuperClosure$this, but this version canturbo_mode that turns all the non-essential features off, This will makeserialize_closure() function – If you have installed SuperClosure via Composer, then theserialize_closure() function will automagically be available. This allows you to easily serialize the closure withautoload.php in favor of Composer's PSR-4 support.It depends. Mostly no.
If you were just using the SerializableClosure object, then it should work exactly the same way as before.
$closure = new SerializableClosure($closure);
$serialized = serialize($closure);If you were relying directly on the ClosureParser object, then you will have breaking changes for sure. They likely will not be difficult to fix though since SuperClosure is still a small library. Just keep in mind that there is now more than one type of parser available.
// ROBUST MODE (i.e., SLOW MODE) (Uses the AST parser with all features on)
$serialized = serialize_closure($closure);
// TURBO MODE (Uses the token parser, with all features off)
$serialized = serialize_closure($closure, array(SC_TURBO_MODE => true));
// The rest are examples of mixing and matching features
//-------------------------------------------------------
// Does everything else, but ignores closure bindings
// This is perfect for functions in PHP 5.4+ that are declared in a class, but do not reference `$this`
$serialized = serialize_closure($closure, array(
SC_HANDLE_CLOSURE_BINDINGS => false,
));
// Uses the Token parser explicitly
$serialized = serialize_closure($closure, array(
SC_PARSER_CLASS => SC_PARSER_TOKEN,
));
// Uses the Token parser implicitly, by disabling the features unique to the AST parser
$serialized = serialize_closure($closure, array(
SC_HANDLE_MAGIC_CONSTANTS => false,
SC_HANDLE_CLASS_NAMES => false,
));
// This is equivalent to TURBO MODE. ZOOOOOOM!!!
$serialized = serialize_closure($closure, array(
SC_PARSER_CLASS => SC_PARSER_TOKEN,
SC_VALIDATE_TOKENS => false,
));Your coding agent can read these notes before it upgrades. Set up the MCP server →