1 | <?php |
||
24 | class ConstructorExecutionTransformer implements SourceTransformer |
||
25 | { |
||
26 | /** |
||
27 | * List of constructor invocations per class |
||
28 | * |
||
29 | * @var array|ReflectionConstructorInvocation[] |
||
30 | */ |
||
31 | private static $constructorInvocationsCache = []; |
||
32 | |||
33 | /** |
||
34 | * Singletone |
||
35 | * |
||
36 | * @return static |
||
37 | */ |
||
38 | public static function getInstance() |
||
39 | { |
||
40 | static $instance; |
||
41 | if (!$instance) { |
||
42 | $instance = new static; |
||
43 | } |
||
44 | |||
45 | return $instance; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Rewrites all "new" expressions with our implementation |
||
50 | * |
||
51 | * @param StreamMetaData $metadata Metadata for source |
||
52 | * |
||
53 | * @return string See RESULT_XXX constants in the interface |
||
54 | */ |
||
55 | 13 | public function transform(StreamMetaData $metadata) |
|
86 | |||
87 | /** |
||
88 | * Magic interceptor for instance creation |
||
89 | * |
||
90 | * @param string $className Name of the class to construct |
||
91 | * |
||
92 | * @return object Instance of required object |
||
93 | */ |
||
94 | public function __get($className) |
||
98 | |||
99 | /** |
||
100 | * Magic interceptor for instance creation |
||
101 | * |
||
102 | * @param string $className Name of the class to construct |
||
103 | * @param array $args Arguments for the constructor |
||
104 | * |
||
105 | * @return object Instance of required object |
||
106 | */ |
||
107 | public function __call($className, array $args) |
||
111 | |||
112 | /** |
||
113 | * Default implementation for accessing joinpoint or creating a new one on-fly |
||
114 | * |
||
115 | * @param string $fullClassName Name of the class to create |
||
116 | * @param array $arguments Arguments for constructor |
||
117 | * |
||
118 | * @return object |
||
119 | */ |
||
120 | protected static function construct($fullClassName, array $arguments = []) |
||
144 | } |
||
145 |