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 IAnnotation[][] $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: /********************* Reflection layer ****************d*g**/
44:
45:
46: /**
47: * @return ClassReflection
48: */
49: public function getDeclaringClass()
50: {
51: return new ClassReflection(parent::getDeclaringClass()->getName());
52: }
53:
54:
55: /********************* Annotations support ****************d*g**/
56:
57:
58: /**
59: * Has property specified annotation?
60: * @param string
61: * @return bool
62: */
63: public function hasAnnotation($name)
64: {
65: $res = AnnotationsParser::getAll($this);
66: return !empty($res[$name]);
67: }
68:
69:
70: /**
71: * Returns an annotation value.
72: * @param string
73: * @return IAnnotation
74: */
75: public function getAnnotation($name)
76: {
77: $res = AnnotationsParser::getAll($this);
78: return isset($res[$name]) ? end($res[$name]) : NULL;
79: }
80:
81:
82: /**
83: * Returns all annotations.
84: * @return IAnnotation[][]
85: */
86: public function getAnnotations()
87: {
88: return AnnotationsParser::getAll($this);
89: }
90:
91:
92: /**
93: * Returns value of annotation 'description'.
94: * @return string
95: */
96: public function getDescription()
97: {
98: return $this->getAnnotation('description');
99: }
100:
101:
102: /********************* Object behaviour ****************d*g**/
103:
104:
105: /**
106: * @return ClassReflection
107: */
108: public function getReflection()
109: {
110: return new ClassReflection($this);
111: }
112:
113:
114: public function __call($name, $args)
115: {
116: return ObjectMixin::call($this, $name, $args);
117: }
118:
119:
120: public function &__get($name)
121: {
122: return ObjectMixin::get($this, $name);
123: }
124:
125:
126: public function __set($name, $value)
127: {
128: return ObjectMixin::set($this, $name, $value);
129: }
130:
131:
132: public function __isset($name)
133: {
134: return ObjectMixin::has($this, $name);
135: }
136:
137:
138: public function __unset($name)
139: {
140: ObjectMixin::remove($this, $name);
141: }
142:
143: }
144: