1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php namespace SuperClosure;
use SuperClosure\Exception\ClosureUnserializationException;
/**
* Interface for a serializer that is used to serialize Closure objects.
*/
interface SerializerInterface
{
/**
* Takes a Closure object, decorates it with a SerializableClosure object,
* then performs the serialization.
*
* @param \Closure $closure Closure to serialize.
*
* @return string Serialized closure.
*/
public function serialize(\Closure $closure);
/**
* Takes a serialized closure, performs the unserialization, and then
* extracts and returns a the Closure object.
*
* @param string $serialized Serialized closure.
*
* @throws ClosureUnserializationException if unserialization fails.
* @return \Closure Unserialized closure.
*/
public function unserialize($serialized);
/**
* Retrieves data about a closure including its code, context, and binding.
*
* The data returned is dependant on the `ClosureAnalyzer` implementation
* used and whether the `$forSerialization` parameter is set to true. If
* `$forSerialization` is true, then only data relevant to serializing the
* closure is returned.
*
* @param \Closure $closure Closure to analyze.
* @param bool $forSerialization Include only serialization data.
*
* @return \Closure
*/
public function getData(\Closure $closure, $forSerialization = false);
}