opis/closure
A library that can be used to serialize closures (anonymous functions) and arbitrary data.
4.5.0
238M downloads/mo
#509 most downloaded on Packagist
opis/closure
What this package is like to depend on
Last release 5 months ago
05 Mar 2026
Ships unpredictably
gaps range from 9 days to 2.9 years
Most releases are documented
notes for 58 of 65 stable releases
Nothing withdrawn
no release was ever pulled
13 years old
65 releases · first in 2014
2 releases in the last 12 months
see the full history below
Release timeline
65 releases · Feb 2014 to Mar 2026
2015
2017
2019
2021
2023
2025
Releases
latest 60 of 65-
4.5.005 Mar 2026 -
4.4.020 Nov 2025 -
4.3.110 Jan 2025 -
4.3.008 Jan 2025Release notes
Open source →- Proper serialization of private properties
- Improved serialization/deserialization of properties having hooks (PHP 8.4)
- Skip virtual properties (PHP 8.4)
- Added
Opis\Closure\clear_cache() - Added
Opis\Closure\get_raw_properties()
Release notes
Open source →- Proper serialization of private properties
- Improved serialization/deserialization of properties having hooks (PHP 8.4)
- Skip virtual properties (PHP 8.4)
- Added
Opis\Closure\clear_cache() - Added
Opis\Closure\get_raw_properties()
-
4.2.107 Jan 2025 -
4.2.007 Jan 2025Release notes
Open source →- Added support for anonymous classes (also supports closures bound to anonymous classes)
- Fixed closure scope for some edge cases
- Improved parsers
Release notes
Open source →Changes
- Added support for anonymous classes (also supports closures bound to anonymous classes)
- Fixed closure scope for some edge cases
- Improved parsers
Internal changes
Added classes
AbastractInfoAbstractParserAnonymousClassInfoAnonymousClassParserReflectionClassCodeStream
Removed
ClosureStream(replaced byCodeStream)ClassInfo(replace byReflectionClass)
-
4.1.004 Jan 2025Release notes
Open source →- Improved closure parser
- Improved array & object serialization/unserialization
- Added
ClosureInfo::getClosure() - Fixed
ClosureInfo::getFactory()bindings and marked the method as internal
Release notes
Open source →Changes
- Improved closure parser
- Improved array & object serialization/deserialization
- Added
ClosureInfo::getClosure() - Fixed
ClosureInfo::getFactory()bindings and marked the method as internal
Internal changes
Added
ClassInfo::get()ClassInfo::clear()ClassInfo::isInternal()ClassInfo::isEnum()ClassInfo::refId()ClassInfois finalClassInfoconstructor is private
Removed
Serializer::getClassInfo()(replaced byClassInfo::get())Serializer::isEnum()(replaced byClassInfo::isEnum())
-
4.0.104 Jan 2025 -
4.0.028 Dec 2024Release notes
Open source →- complete rewrite of the library
- no dependencies
- arbitrary data serialization
- full PHP 8.x support
-
3.7.008 Jul 2025 -
3.6.327 Jan 2022Nothing published for this version
-
3.6.209 Apr 2021 -
3.6.107 Nov 2020 -
3.6.011 Oct 2020 -
3.5.706 Sep 2020 -
3.5.611 Aug 2020 -
3.5.517 Jun 2020Release notes
Open source →- Fixed a false-positive when using
Opis\Closure\ReflectionClosure::isScopeRequiredmethod
- Fixed a false-positive when using
-
3.5.407 Jun 2020Release notes
Open source →- Fixed a false-positive when using
Opis\Closure\ReflectionClosure::isScopeRequiredmethod - Fixed a bug related to
T_STRING_VARNAME
- Fixed a false-positive when using
-
3.5.325 May 2020Release notes
Open source →- Improved parser
- The class scope optimisation is no longer used. We always bind now to the closure's original class scope.
When the class scope was
null, the optimisation failed to work as expected and kept the wrongSerializableClosurescope.
-
3.5.221 May 2020Release notes
Open source →- Removed extra semicolon in short closures, since is not part of the closure's body.
-
3.5.129 Nov 2019 -
3.5.029 Nov 2019Release notes
Open source →- Added support for short closures (arrow functions)
- Added
isShortClosuremethod toOpis\Closure\ReflectionClosure
-
3.4.229 Nov 2019 -
3.4.119 Oct 2019 -
3.4.002 Sep 2019Release notes
Open source →- Added
createClosurestatic method inOpis\Closure\SerializableClosure. This method creates a new closure from arbitrary code, emulatingcreate_function, but without using eval
- Added
-
3.3.109 Jul 2019Release notes
Open source →- Use
sha1instead ofmd5for hashing file names inOpis\Closure\ReflectionClosureclass
- Use
-
3.3.031 May 2019Release notes
Open source →- Fixed a bug that prevented signed closures to properly work when the serialized string
contains invalid UTF-8 chars. Starting with this version
json_encodeis no longer used when signing a closure. Backward compatibility is maintained and all closures that were previously signed using the old method will continue to work.
- Fixed a bug that prevented signed closures to properly work when the serialized string
contains invalid UTF-8 chars. Starting with this version
-
3.2.005 May 2019Release notes
Open source →- Since an unsigned closure can be unserialized when no security provider is set,
there is no reason to treat differently a signed closure in the same situation.
Therefore, the
Opis\Closure\SecurityExceptionexception is no longer thrown when unserializing a signed closure, if no security provider is set.
- Since an unsigned closure can be unserialized when no security provider is set,
there is no reason to treat differently a signed closure in the same situation.
Therefore, the
-
3.1.622 Feb 2019Release notes
Open source →- Fixed a bug that occurred when trying to set properties of classes that were not defined in user-land. Those properties are now ignored.
-
3.1.514 Jan 2019 -
3.1.414 Jan 2019Release notes
Open source →- Added support for static methods that are named using PHP keywords or magic constants.
Ex:
A::new(),A::use(),A::if(),A::function(),A::__DIR__(), etc. - Used
@internalto mark classes & methods that are for internal use only and backward compatibility is not guaranteed.
- Added support for static methods that are named using PHP keywords or magic constants.
Ex:
-
3.1.306 Jan 2019Release notes
Open source →- Fixed a bug that prevented traits to be correctly resolved when used by an anonymous class
- Fixed a bug that occurred when
$thiskeyword was used inside an anonymous class
-
3.1.216 Dec 2018 -
3.1.102 Oct 2018Release notes
Open source →- Fixed a bug where
parentkeyword was treated like a class-name and scope was not added to the serialized closure - Fixed a bug where return type was not properly handled for nested closures
- Support for anonymous classes was improved
- Fixed a bug where
-
3.1.020 Sep 2018Release notes
Open source →- Added
transformUseVariablesandresolveUseVariablestoOpis\Closure\SerializableClosureclass. - Added
removeSecurityProviderstatic method toOpis\Closure\SerializableClosureclass. - Fixed some security related issues where a user was able to unserialize an unsigned closure, even when a security provider was in use.
- Added
-
3.0.1223 Feb 2018 -
3.0.1121 Jan 2018 -
3.0.1004 Jan 2018 -
3.0.904 Jan 2018Release notes
Open source →- Fixed a bug where the return type was not properly resolved. See issue 17
- Added more tests
-
3.0.817 Dec 2017 -
3.0.731 Oct 2017Release notes
Open source →- Bugfix: static properties are ignored now, since they are not serializable
-
3.0.606 Oct 2017 -
3.0.518 Sep 2017 -
3.0.418 Sep 2017Release notes
Open source →- [internal] Refactored
SerializableClosure::mapPointersmethod - [internal] Added a new optional argument to
SerializableClosure::unwrapClosures - [internal] Removed
SerializableClosure::getClosurePointermethod - Fixed various bugs
- [internal] Refactored
-
3.0.306 Sep 2017Release notes
Open source →- Fixed a bug related to nested object references
- [internal]
Opis\Closure\ClosureScopenow extendsSplObjectStorage - [internal] The
storageproperty was removed fromOpis\Closure\ClosureScope - [internal] The
instancesandobjectsproperties were removed fromOpis\Closure\ClosureContext
-
3.0.228 Aug 2017Release notes
Open source →- Fixed a bug where
$thisobject was not handled properly inside theSerializableClosre::serializemethod.
- Fixed a bug where
-
3.0.113 Apr 2017 -
3.0.007 Apr 2017Release notes
Open source →- Dropped PHP 5.3 support
- Moved source files from
libtosrcfolder - Removed second parameter from
Opis\Closure\SerializableClosure::frommethod and from constructor - Removed
Opis\Closure\{SecurityProviderInterface, DefaultSecurityProvider, SecureClosure}classes - Refactored how signed closures were handled
- Added
wrapClosuresandunwrapClosuresstatic methods toOpis\Closure\SerializableClosureclass - Added
Opis\Colosure\serializeandOpis\Closure\unserializefunctions - Improved serialization. You can now serialize arbitrary objects and the library will automatically wrap all closures
-
2.4.113 Apr 2017Nothing published for this version
-
2.4.016 Dec 2016Release notes
Open source →- The parser was refactored and improved
- Refactored
Opis\Closure\SerializableClosure::__invokemethod Opis\Closure\{ISecurityProvider, SecurityProvider}were addedOpis\Closure\{SecurityProviderInterface, DefaultSecurityProvider, SecureClosure}were deprecated and they will be removed in the next major versionsetSecretKeyandaddSecurityProviderstatic methods were added toOpis\Closure\SerializableClosure
-
2.3.215 Dec 2016 -
2.3.113 Dec 2016 -
2.3.017 Nov 2016Release notes
Open source →- Added
isBindingRequiredandisScopeRequiredto theOpis\Closure\ReflectionClosureclass - Automatically detects when the scope and/or the bound object of a closure needs to be serialized.
- Added
-
2.2.120 Aug 2016 -
2.2.026 Jul 2016Release notes
Open source →- Fixed CS
Opis\Closure\ClosureContext,Opis\Closure\ClosureScope,Opis\Closure\SelfReferenceandOpis\Closure\SecurityExceptionclasses were moved into separate files- Added support for PHP7 syntax
- Fixed some bugs in
Opis\Closure\ReflectionClosureclass - Improved closure parser
- Added an analyzer for SuperClosure library
-
2.1.030 Sep 2015Release notes
Open source →- Added support for the missing
__METHOD__,__FUNCTION__and__TRAIT__magic constants - Added some security related classes and interfaces:
Opis\Closure\SecurityProviderInterface,Opis\Closure\DefaultSecurityProvider,Opis\Closure\SecureClosure,Opis\Closure\SecurityException. - Fiexed a bug in
Opis\Closure\ReflectionClosure::getClassesmethod - Other minor bugfixes
- Added support for static closures
- Added public
isStaticmethod toOpis\Closure\ReflectionClosureclass
- Added support for the missing
-
2.0.123 Sep 2015 -
2.0.030 Jul 2015Release notes
Open source →- The closure parser was improved
- Class names are now automatically resolved
- Added support for the
#trackmedirective which allows tracking closure's residing source
-
1.3.018 Oct 2014 -
1.2.204 Aug 2014