1 | <?php |
||
21 | class ReflectionFunction extends BaseReflectionFunction |
||
22 | { |
||
23 | use ReflectionFunctionLikeTrait, InternalPropertiesEmulationTrait; |
||
24 | |||
25 | /** |
||
26 | * Initializes reflection instance for given AST-node |
||
27 | * |
||
28 | * @param string|\Closure $functionName The name of the function to reflect or a closure. |
||
29 | * @param Function_|null $functionNode Function node AST |
||
30 | */ |
||
31 | 15 | public function __construct($functionName, Function_ $functionNode) |
|
32 | { |
||
33 | 15 | $namespaceParts = explode('\\', $functionName); |
|
34 | // Remove the last one part with function name |
||
35 | 15 | array_pop($namespaceParts); |
|
36 | 15 | $this->namespaceName = join('\\', $namespaceParts); |
|
37 | |||
38 | 15 | $this->functionLikeNode = $functionNode; |
|
39 | 15 | unset($this->name); |
|
40 | 15 | } |
|
41 | |||
42 | /** |
||
43 | * Emulating original behaviour of reflection |
||
44 | */ |
||
45 | 1 | public function ___debugInfo() |
|
46 | { |
||
47 | 1 | $nodeName = 'unknown'; |
|
48 | |||
49 | 1 | if ($this->functionLikeNode instanceof Function_) { |
|
50 | 1 | $nodeName = $this->functionLikeNode->name; |
|
51 | } |
||
52 | |||
53 | 1 | return ['name' => $nodeName]; |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * {@inheritDoc} |
||
58 | */ |
||
59 | 1 | public function getClosure() |
|
60 | { |
||
61 | 1 | $this->initializeInternalReflection(); |
|
62 | |||
63 | 1 | return parent::getClosure(); |
|
64 | } |
||
65 | |||
66 | /** |
||
67 | * {@inheritDoc} |
||
68 | */ |
||
69 | 1 | public function invoke($args = null) |
|
70 | { |
||
71 | 1 | $this->initializeInternalReflection(); |
|
72 | |||
73 | 1 | return call_user_func_array('parent::invoke', func_get_args()); |
|
74 | } |
||
75 | |||
76 | /** |
||
77 | * {@inheritDoc} |
||
78 | */ |
||
79 | 1 | public function invokeArgs(array $args) |
|
80 | { |
||
81 | 1 | $this->initializeInternalReflection(); |
|
82 | |||
83 | 1 | return parent::invokeArgs($args); |
|
84 | } |
||
85 | |||
86 | /** |
||
87 | * Checks if function is disabled |
||
88 | * |
||
89 | * Only internal functions can be disabled using disable_functions directive. |
||
90 | * User-defined functions are unaffected. |
||
91 | */ |
||
92 | 1 | public function isDisabled() |
|
96 | |||
97 | /** |
||
98 | * Returns textual representation of function |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | 1 | public function __toString() |
|
120 | |||
121 | |||
122 | /** |
||
123 | * Implementation of internal reflection initialization |
||
124 | * |
||
125 | * @return void |
||
126 | */ |
||
127 | 4 | protected function __initialize() |
|
131 | } |
||
132 |