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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
<?php namespace Illuminate\Support;
use Jeremeamia\SuperClosure\SerializableClosure as SuperClosure;
/** * Extends SuperClosure for backwards compatibility. */ class SerializableClosure extends SuperClosure {
/** * The code for the closure * * @var string */ protected $code;
/** * The variables that were "used" or imported from the parent scope * * @var array */ protected $variables;
/** * Returns the code of the closure being serialized * * @return string */ public function getCode() { $this->determineCodeAndVariables();
return $this->code; }
/** * Returns the "used" variables of the closure being serialized * * @return array */ public function getVariables() { $this->determineCodeAndVariables();
return $this->variables; }
/** * Uses the serialize method directly to lazily fetch the code and variables if needed */ protected function determineCodeAndVariables() { if (!$this->code) { list($this->code, $this->variables) = unserialize($this->serialize()); } }
}
|