1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13:
14:
15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31:
32: class ParameterReflection extends ReflectionParameter
33: {
34:
35: private $function;
36:
37:
38: public function __construct($function, $parameter)
39: {
40: parent::__construct($this->function = $function, $parameter);
41: }
42:
43:
44: 45: 46:
47: public function getClass()
48: {
49: return ($ref = parent::getClass()) ? new ClassReflection($ref->getName()) : NULL;
50: }
51:
52:
53: 54: 55:
56: public function getClassName()
57: {
58: try {
59: return ($ref = parent::getClass()) ? $ref->getName() : NULL;
60: } catch (ReflectionException $e) {
61: if (preg_match('#Class (.+) does not exist#', $e->getMessage(), $m)) {
62: return $m[1];
63: }
64: throw $e;
65: }
66: }
67:
68:
69: 70: 71:
72: public function getDeclaringClass()
73: {
74: return ($ref = parent::getDeclaringClass()) ? new ClassReflection($ref->getName()) : NULL;
75: }
76:
77:
78: 79: 80:
81: public function getDeclaringFunction()
82: {
83: return is_array($this->function)
84: ? new MethodReflection($this->function[0], $this->function[1])
85: : new FunctionReflection($this->function);
86: }
87:
88:
89: 90: 91:
92: public function isDefaultValueAvailable()
93: {
94: if (PHP_VERSION_ID === 50316) {
95: try {
96: $this->getDefaultValue();
97: return TRUE;
98: } catch (ReflectionException $e) {
99: return FALSE;
100: }
101: }
102: return parent::isDefaultValueAvailable();
103: }
104:
105:
106: public function __toString()
107: {
108: return 'Parameter $' . parent::getName() . ' in ' . $this->getDeclaringFunction();
109: }
110:
111:
112:
113:
114:
115: 116: 117:
118: public function getReflection()
119: {
120: return new ClassReflection($this);
121: }
122:
123:
124: public function __call($name, $args)
125: {
126: return ObjectMixin::call($this, $name, $args);
127: }
128:
129:
130: public function &__get($name)
131: {
132: return ObjectMixin::get($this, $name);
133: }
134:
135:
136: public function __set($name, $value)
137: {
138: return ObjectMixin::set($this, $name, $value);
139: }
140:
141:
142: public function __isset($name)
143: {
144: return ObjectMixin::has($this, $name);
145: }
146:
147:
148: public function __unset($name)
149: {
150: ObjectMixin::remove($this, $name);
151: }
152:
153: }
154: