1 | <?php |
||
17 | class LazyObjectsFactory |
||
18 | { |
||
19 | const GENERATE_NEVER = 0; |
||
20 | const GENERATE_WHEN_NOT_EXISTS = 1; |
||
21 | const GENERATE_ALWAYS = 2; |
||
22 | /** |
||
23 | * @var \ProxyManager\Configuration |
||
24 | */ |
||
25 | private $configuration; |
||
26 | |||
27 | /** |
||
28 | * Cached checked class names |
||
29 | * |
||
30 | * @var string[] |
||
31 | */ |
||
32 | private $checkedClasses = array(); |
||
33 | |||
34 | /** |
||
35 | * @var LazyObjectsProxyGenerator|null |
||
36 | */ |
||
37 | private $generator; |
||
38 | |||
39 | /** |
||
40 | * @var int |
||
41 | */ |
||
42 | private $generationStrategy; |
||
43 | |||
44 | /** |
||
45 | * @param \ProxyManager\Configuration $configuration |
||
46 | * @param int $generationStrategy |
||
47 | */ |
||
48 | public function __construct(Configuration $configuration = null, $generationStrategy = self::GENERATE_WHEN_NOT_EXISTS) |
||
59 | |||
60 | /** |
||
61 | * @param $instance |
||
62 | * @param array $lazyProperties |
||
63 | * @param array $methodReplacements |
||
64 | * @return \Isolate\LazyObjects\WrappedObject |
||
65 | * @throws InvalidArgumentException |
||
66 | */ |
||
67 | public function createProxy($instance, array $lazyProperties = array(), array $methodReplacements = []) |
||
85 | |||
86 | /** |
||
87 | * Return proxy class name |
||
88 | * |
||
89 | * @param string $className |
||
90 | * @return string |
||
91 | */ |
||
92 | public function createProxyClass($className) |
||
96 | |||
97 | /** |
||
98 | * Generate a proxy from a class name |
||
99 | * @param string $className |
||
100 | * @return string proxy class name |
||
101 | */ |
||
102 | private function generateProxy($className) |
||
127 | |||
128 | /** |
||
129 | * Generates the provided `$proxyClassName` from the given `$className` and `$proxyParameters` |
||
130 | * @param string $proxyClassName |
||
131 | * @param string $className |
||
132 | * @param array $proxyParameters |
||
133 | * |
||
134 | * @return void |
||
135 | */ |
||
136 | private function generateProxyClass($proxyClassName, $className, array $proxyParameters) |
||
156 | } |
||
157 | |||
158 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.