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