1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13:
14:
15: 16: 17: 18: 19: 20:
21: class FunctionReflection extends ReflectionFunction
22: {
23:
24: private $value;
25:
26:
27: public function __construct($name)
28: {
29: parent::__construct($this->value = $name);
30: }
31:
32:
33:
34: 35: 36:
37: public function getDefaultParameters()
38: {
39: return MethodReflection::buildDefaultParameters(parent::getParameters());
40: }
41:
42:
43:
44: 45: 46: 47: 48:
49: public function invokeNamedArgs($args)
50: {
51: return $this->invokeArgs(MethodReflection::combineArgs($this->getDefaultParameters(), $args));
52: }
53:
54:
55:
56: 57: 58:
59: public function toCallback()
60: {
61: return new Callback($this->value);
62: }
63:
64:
65:
66: public function __toString()
67: {
68: return 'Function ' . $this->getName() . '()';
69: }
70:
71:
72:
73: public function getClosure()
74: {
75: return $this->isClosure() ? $this->value : NULL;
76: }
77:
78:
79:
80:
81:
82:
83:
84: 85: 86:
87: public function getExtension()
88: {
89: return ($name = $this->getExtensionName()) ? new ExtensionReflection($name) : NULL;
90: }
91:
92:
93:
94: public function getParameters()
95: {
96: foreach ($res = parent::getParameters() as $key => $val) {
97: $res[$key] = new ParameterReflection($this->value, $val->getName());
98: }
99: return $res;
100: }
101:
102:
103:
104:
105:
106:
107:
108: 109: 110:
111: public function getReflection()
112: {
113: return new ClassReflection($this);
114: }
115:
116:
117:
118: public function __call($name, $args)
119: {
120: return ObjectMixin::call($this, $name, $args);
121: }
122:
123:
124:
125: public function &__get($name)
126: {
127: return ObjectMixin::get($this, $name);
128: }
129:
130:
131:
132: public function __set($name, $value)
133: {
134: return ObjectMixin::set($this, $name, $value);
135: }
136:
137:
138:
139: public function __isset($name)
140: {
141: return ObjectMixin::has($this, $name);
142: }
143:
144:
145:
146: public function __unset($name)
147: {
148: ObjectMixin::remove($this, $name);
149: }
150:
151: }
152: