1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (http://nette.org)
5: *
6: * Copyright (c) 2004, 2011 David Grudl (http://davidgrudl.com)
7: *
8: * For the full copyright and license information, please view
9: * the file license.txt that was distributed with this source code.
10: * @package Nette\Reflection
11: */
12:
13:
14:
15: /**
16: * Reports information about a classes variable.
17: *
18: * @author David Grudl
19: * @package Nette\Reflection
20: */
21: class NPropertyReflection extends ReflectionProperty
22: {
23:
24: public function __toString()
25: {
26: return 'Property ' . parent::getDeclaringClass()->getName() . '::$' . $this->getName();
27: }
28:
29:
30:
31: /********************* Reflection layer ****************d*g**/
32:
33:
34:
35: /**
36: * @return NClassReflection
37: */
38: public function getDeclaringClass()
39: {
40: return new NClassReflection(parent::getDeclaringClass()->getName());
41: }
42:
43:
44:
45: /********************* NAnnotations support ****************d*g**/
46:
47:
48:
49: /**
50: * Has property specified annotation?
51: * @param string
52: * @return bool
53: */
54: public function hasAnnotation($name)
55: {
56: $res = NAnnotationsParser::getAll($this);
57: return !empty($res[$name]);
58: }
59:
60:
61:
62: /**
63: * Returns an annotation value.
64: * @param string
65: * @return IAnnotation
66: */
67: public function getAnnotation($name)
68: {
69: $res = NAnnotationsParser::getAll($this);
70: return isset($res[$name]) ? end($res[$name]) : NULL;
71: }
72:
73:
74:
75: /**
76: * Returns all annotations.
77: * @return array
78: */
79: public function getAnnotations()
80: {
81: return NAnnotationsParser::getAll($this);
82: }
83:
84:
85:
86: /**
87: * Returns value of annotation 'description'.
88: * @return string
89: */
90: public function getDescription()
91: {
92: return $this->getAnnotation('description');
93: }
94:
95:
96:
97: /********************* NObject behaviour ****************d*g**/
98:
99:
100:
101: /**
102: * @return NClassReflection
103: */
104: public function getReflection()
105: {
106: return new NClassReflection($this);
107: }
108:
109:
110:
111: public function __call($name, $args)
112: {
113: return NObjectMixin::call($this, $name, $args);
114: }
115:
116:
117:
118: public function &__get($name)
119: {
120: return NObjectMixin::get($this, $name);
121: }
122:
123:
124:
125: public function __set($name, $value)
126: {
127: return NObjectMixin::set($this, $name, $value);
128: }
129:
130:
131:
132: public function __isset($name)
133: {
134: return NObjectMixin::has($this, $name);
135: }
136:
137:
138:
139: public function __unset($name)
140: {
141: NObjectMixin::remove($this, $name);
142: }
143:
144: }
145: