1 | <?php |
||
25 | class FunctionProxy extends AbstractProxy |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * List of advices for functions |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | protected static $functionAdvices = []; |
||
34 | |||
35 | /** |
||
36 | * File namespace |
||
37 | * |
||
38 | * @var ReflectionFileNamespace |
||
39 | */ |
||
40 | protected $namespace; |
||
41 | |||
42 | /** |
||
43 | * Source code for functions |
||
44 | * |
||
45 | * @var array Name of the function => source code for it |
||
46 | */ |
||
47 | protected $functionsCode = []; |
||
48 | |||
49 | /** |
||
50 | * Constructs functions stub class from namespace Reflection |
||
51 | * |
||
52 | * @param ReflectionFileNamespace $namespace Reflection of namespace |
||
53 | * @param array $advices List of function advices |
||
54 | * |
||
55 | * @throws \InvalidArgumentException for invalid classes |
||
56 | */ |
||
57 | public function __construct(ReflectionFileNamespace $namespace, array $advices = []) |
||
71 | |||
72 | /** |
||
73 | * Returns a joinpoint for specific function in the namespace |
||
74 | * |
||
75 | * @param string $joinPointName Special joinpoint name |
||
76 | * @param string $namespace Name of the namespace |
||
77 | * |
||
78 | * @return FunctionInvocation |
||
79 | */ |
||
80 | public static function getJoinPoint($joinPointName, $namespace) |
||
98 | |||
99 | /** |
||
100 | * Inject advices for given trait |
||
101 | * |
||
102 | * NB This method will be used as a callback during source code evaluation to inject joinpoints |
||
103 | * |
||
104 | * @param string $namespace Aop child proxy class |
||
105 | * @param array|Advice[] $advices List of advices to inject into class |
||
106 | * |
||
107 | * @return void |
||
108 | */ |
||
109 | public static function injectJoinPoints($namespace, array $advices = []) |
||
113 | |||
114 | /** |
||
115 | * Override function with new body |
||
116 | * |
||
117 | * @param ReflectionFunction $function Function reflection |
||
118 | * @param string $body New body for function |
||
119 | * |
||
120 | * @return $this |
||
121 | */ |
||
122 | public function override(ReflectionFunction $function, $body) |
||
128 | |||
129 | /** |
||
130 | * {@inheritDoc} |
||
131 | */ |
||
132 | public function __toString() |
||
150 | |||
151 | /** |
||
152 | * Creates definition for trait method body |
||
153 | * |
||
154 | * @param ReflectionFunction $function Method reflection |
||
155 | * |
||
156 | * @return string new method body |
||
157 | */ |
||
158 | protected function getJoinpointInvocationBody(ReflectionFunction $function) |
||
181 | |||
182 | } |
||
183 |