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: return ($tmp = Nette\Utils\Strings::match($this, '#>\s+([a-z0-9_\\\\]+)#i')) ? $tmp[1] : NULL;
64: }
65:
66:
67:
68: 69: 70:
71: public function getDeclaringClass()
72: {
73: return ($ref = parent::getDeclaringClass()) ? new ClassType($ref->getName()) : NULL;
74: }
75:
76:
77:
78: 79: 80:
81: public function getDeclaringFunction()
82: {
83: return is_array($this->function)
84: ? new Method($this->function[0], $this->function[1])
85: : new GlobalFunction($this->function);
86: }
87:
88:
89:
90: public function __toString()
91: {
92: return 'Parameter $' . parent::getName() . ' in ' . $this->getDeclaringFunction();
93: }
94:
95:
96:
97:
98:
99:
100:
101: 102: 103:
104: public static function getReflection()
105: {
106: return new ClassType(get_called_class());
107: }
108:
109:
110:
111: public function __call($name, $args)
112: {
113: return ObjectMixin::call($this, $name, $args);
114: }
115:
116:
117:
118: public function &__get($name)
119: {
120: return ObjectMixin::get($this, $name);
121: }
122:
123:
124:
125: public function __set($name, $value)
126: {
127: return ObjectMixin::set($this, $name, $value);
128: }
129:
130:
131:
132: public function __isset($name)
133: {
134: return ObjectMixin::has($this, $name);
135: }
136:
137:
138:
139: public function __unset($name)
140: {
141: ObjectMixin::remove($this, $name);
142: }
143:
144: }
145: