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:
48: public function getClass()
49: {
50: return ($ref = parent::getClass()) ? new ClassReflection($ref->getName()) : NULL;
51: }
52:
53:
54:
55: 56: 57:
58: public function getClassName()
59: {
60: try {
61: return ($ref = parent::getClass()) ? $ref->getName() : NULL;
62: } catch (ReflectionException $e) {
63: if (preg_match('#Class (.+) does not exist#', $e->getMessage(), $m)) {
64: return $m[1];
65: }
66: throw $e;
67: }
68: }
69:
70:
71:
72: 73: 74:
75: public function getDeclaringClass()
76: {
77: return ($ref = parent::getDeclaringClass()) ? new ClassReflection($ref->getName()) : NULL;
78: }
79:
80:
81:
82: 83: 84:
85: public function getDeclaringFunction()
86: {
87: return is_array($this->function)
88: ? new MethodReflection($this->function[0], $this->function[1])
89: : new FunctionReflection($this->function);
90: }
91:
92:
93:
94: 95: 96:
97: public function isDefaultValueAvailable()
98: {
99: if (PHP_VERSION_ID === 50316) {
100: try {
101: $this->getDefaultValue();
102: return TRUE;
103: } catch (ReflectionException $e) {
104: return FALSE;
105: }
106: }
107: return parent::isDefaultValueAvailable();
108: }
109:
110:
111:
112: public function __toString()
113: {
114: return 'Parameter $' . parent::getName() . ' in ' . $this->getDeclaringFunction();
115: }
116:
117:
118:
119:
120:
121:
122:
123: 124: 125:
126: public function getReflection()
127: {
128: return new ClassReflection($this);
129: }
130:
131:
132:
133: public function __call($name, $args)
134: {
135: return ObjectMixin::call($this, $name, $args);
136: }
137:
138:
139:
140: public function &__get($name)
141: {
142: return ObjectMixin::get($this, $name);
143: }
144:
145:
146:
147: public function __set($name, $value)
148: {
149: return ObjectMixin::set($this, $name, $value);
150: }
151:
152:
153:
154: public function __isset($name)
155: {
156: return ObjectMixin::has($this, $name);
157: }
158:
159:
160:
161: public function __unset($name)
162: {
163: ObjectMixin::remove($this, $name);
164: }
165:
166: }
167: