1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (http://nette.org)
5: *
6: * Copyright (c) 2004 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: * @property-read ClassReflection $declaringClass
20: * @property-read array $annotations
21: * @property-read string $description
22: * @property-read string $name
23: * @property mixed $value
24: * @property-read bool $public
25: * @property-read bool $private
26: * @property-read bool $protected
27: * @property-read bool $static
28: * @property-read bool $default
29: * @property-read int $modifiers
30: * @property-read string $docComment
31: * @property-write bool $accessible
32: * @package Nette\Reflection
33: */
34: class PropertyReflection extends ReflectionProperty
35: {
36:
37: public function __toString()
38: {
39: return 'Property ' . parent::getDeclaringClass()->getName() . '::$' . $this->getName();
40: }
41:
42:
43:
44: /********************* Reflection layer ****************d*g**/
45:
46:
47:
48: /**
49: * @return ClassReflection
50: */
51: public function getDeclaringClass()
52: {
53: return new ClassReflection(parent::getDeclaringClass()->getName());
54: }
55:
56:
57:
58: /********************* Annotations support ****************d*g**/
59:
60:
61:
62: /**
63: * Has property specified annotation?
64: * @param string
65: * @return bool
66: */
67: public function hasAnnotation($name)
68: {
69: $res = AnnotationsParser::getAll($this);
70: return !empty($res[$name]);
71: }
72:
73:
74:
75: /**
76: * Returns an annotation value.
77: * @param string
78: * @return IAnnotation
79: */
80: public function getAnnotation($name)
81: {
82: $res = AnnotationsParser::getAll($this);
83: return isset($res[$name]) ? end($res[$name]) : NULL;
84: }
85:
86:
87:
88: /**
89: * Returns all annotations.
90: * @return array
91: */
92: public function getAnnotations()
93: {
94: return AnnotationsParser::getAll($this);
95: }
96:
97:
98:
99: /**
100: * Returns value of annotation 'description'.
101: * @return string
102: */
103: public function getDescription()
104: {
105: return $this->getAnnotation('description');
106: }
107:
108:
109:
110: /********************* Object behaviour ****************d*g**/
111:
112:
113:
114: /**
115: * @return ClassReflection
116: */
117: public function getReflection()
118: {
119: return new ClassReflection($this);
120: }
121:
122:
123:
124: public function __call($name, $args)
125: {
126: return ObjectMixin::call($this, $name, $args);
127: }
128:
129:
130:
131: public function &__get($name)
132: {
133: return ObjectMixin::get($this, $name);
134: }
135:
136:
137:
138: public function __set($name, $value)
139: {
140: return ObjectMixin::set($this, $name, $value);
141: }
142:
143:
144:
145: public function __isset($name)
146: {
147: return ObjectMixin::has($this, $name);
148: }
149:
150:
151:
152: public function __unset($name)
153: {
154: ObjectMixin::remove($this, $name);
155: }
156:
157: }
158: