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: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34:
35: class Parameter extends \ReflectionParameter
36: {
37:
38: private $function;
39:
40:
41: public function __construct($function, $parameter)
42: {
43: parent::__construct($this->function = $function, $parameter);
44: }
45:
46:
47:
48: 49: 50:
51: public function getClass()
52: {
53: return ($ref = parent::getClass()) ? new ClassType($ref->getName()) : NULL;
54: }
55:
56:
57:
58: 59: 60:
61: public function getClassName()
62: {
63: try {
64: return ($ref = parent::getClass()) ? $ref->getName() : NULL;
65: } catch (\ReflectionException $e) {
66: if (preg_match('#Class (.+) does not exist#', $e->getMessage(), $m)) {
67: return $m[1];
68: }
69: throw $e;
70: }
71: }
72:
73:
74:
75: 76: 77:
78: public function getDeclaringClass()
79: {
80: return ($ref = parent::getDeclaringClass()) ? new ClassType($ref->getName()) : NULL;
81: }
82:
83:
84:
85: 86: 87:
88: public function getDeclaringFunction()
89: {
90: return is_array($this->function)
91: ? new Method($this->function[0], $this->function[1])
92: : new GlobalFunction($this->function);
93: }
94:
95:
96:
97: public function __toString()
98: {
99: return 'Parameter $' . parent::getName() . ' in ' . $this->getDeclaringFunction();
100: }
101:
102:
103:
104:
105:
106:
107:
108: 109: 110:
111: public static function getReflection()
112: {
113: return new ClassType(get_called_class());
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: