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: */
20: class PropertyReflection extends ReflectionProperty
21: {
22:
23: public function __toString()
24: {
25: return 'Property ' . parent::getDeclaringClass()->getName() . '::$' . $this->getName();
26: }
27:
28:
29:
30: /********************* Reflection layer ****************d*g**/
31:
32:
33:
34: /**
35: * @return ClassReflection
36: */
37: public function getDeclaringClass()
38: {
39: return new ClassReflection(parent::getDeclaringClass()->getName());
40: }
41:
42:
43:
44: /********************* Annotations support ****************d*g**/
45:
46:
47:
48: /**
49: * Has property specified annotation?
50: * @param string
51: * @return bool
52: */
53: public function hasAnnotation($name)
54: {
55: $res = AnnotationsParser::getAll($this);
56: return !empty($res[$name]);
57: }
58:
59:
60:
61: /**
62: * Returns an annotation value.
63: * @param string
64: * @return IAnnotation
65: */
66: public function getAnnotation($name)
67: {
68: $res = AnnotationsParser::getAll($this);
69: return isset($res[$name]) ? end($res[$name]) : NULL;
70: }
71:
72:
73:
74: /**
75: * Returns all annotations.
76: * @return array
77: */
78: public function getAnnotations()
79: {
80: return AnnotationsParser::getAll($this);
81: }
82:
83:
84:
85: /********************* Object behaviour ****************d*g**/
86:
87:
88:
89: /**
90: * @return ClassReflection
91: */
92: public function getReflection()
93: {
94: return new ClassReflection($this);
95: }
96:
97:
98:
99: public function __call($name, $args)
100: {
101: return ObjectMixin::call($this, $name, $args);
102: }
103:
104:
105:
106: public function &__get($name)
107: {
108: return ObjectMixin::get($this, $name);
109: }
110:
111:
112:
113: public function __set($name, $value)
114: {
115: return ObjectMixin::set($this, $name, $value);
116: }
117:
118:
119:
120: public function __isset($name)
121: {
122: return ObjectMixin::has($this, $name);
123: }
124:
125:
126:
127: public function __unset($name)
128: {
129: ObjectMixin::remove($this, $name);
130: }
131:
132: }
133: