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