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