Namespaces

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • None
  • PHP

Classes

  • Annotation
  • AnnotationsParser
  • ClassType
  • Extension
  • GlobalFunction
  • Method
  • Parameter
  • Property

Interfaces

  • IAnnotation
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  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:  */
 11: 
 12: namespace Nette\Reflection;
 13: 
 14: use Nette,
 15:     Nette\ObjectMixin;
 16: 
 17: 
 18: /**
 19:  * Reports information about a classes variable.
 20:  *
 21:  * @author     David Grudl
 22:  * @property-read ClassType $declaringClass
 23:  * @property-read IAnnotation[][] $annotations
 24:  * @property-read string $description
 25:  * @property-read string $name
 26:  * @property  mixed $value
 27:  * @property-read bool $public
 28:  * @property-read bool $private
 29:  * @property-read bool $protected
 30:  * @property-read bool $static
 31:  * @property-read bool $default
 32:  * @property-read int $modifiers
 33:  * @property-read string $docComment
 34:  * @property-write bool $accessible
 35:  */
 36: class Property extends \ReflectionProperty
 37: {
 38: 
 39:     public function __toString()
 40:     {
 41:         return 'Property ' . parent::getDeclaringClass()->getName() . '::$' . $this->getName();
 42:     }
 43: 
 44: 
 45:     /********************* Reflection layer ****************d*g**/
 46: 
 47: 
 48:     /**
 49:      * @return ClassType
 50:      */
 51:     public function getDeclaringClass()
 52:     {
 53:         return new ClassType(parent::getDeclaringClass()->getName());
 54:     }
 55: 
 56: 
 57:     /********************* Nette\Annotations support ****************d*g**/
 58: 
 59: 
 60:     /**
 61:      * Has property specified annotation?
 62:      * @param  string
 63:      * @return bool
 64:      */
 65:     public function hasAnnotation($name)
 66:     {
 67:         $res = AnnotationsParser::getAll($this);
 68:         return !empty($res[$name]);
 69:     }
 70: 
 71: 
 72:     /**
 73:      * Returns an annotation value.
 74:      * @param  string
 75:      * @return IAnnotation
 76:      */
 77:     public function getAnnotation($name)
 78:     {
 79:         $res = AnnotationsParser::getAll($this);
 80:         return isset($res[$name]) ? end($res[$name]) : NULL;
 81:     }
 82: 
 83: 
 84:     /**
 85:      * Returns all annotations.
 86:      * @return IAnnotation[][]
 87:      */
 88:     public function getAnnotations()
 89:     {
 90:         return AnnotationsParser::getAll($this);
 91:     }
 92: 
 93: 
 94:     /**
 95:      * Returns value of annotation 'description'.
 96:      * @return string
 97:      */
 98:     public function getDescription()
 99:     {
100:         return $this->getAnnotation('description');
101:     }
102: 
103: 
104:     /********************* Nette\Object behaviour ****************d*g**/
105: 
106: 
107:     /**
108:      * @return ClassType
109:      */
110:     public static function getReflection()
111:     {
112:         return new ClassType(get_called_class());
113:     }
114: 
115: 
116:     public function __call($name, $args)
117:     {
118:         return ObjectMixin::call($this, $name, $args);
119:     }
120: 
121: 
122:     public function &__get($name)
123:     {
124:         return ObjectMixin::get($this, $name);
125:     }
126: 
127: 
128:     public function __set($name, $value)
129:     {
130:         return ObjectMixin::set($this, $name, $value);
131:     }
132: 
133: 
134:     public function __isset($name)
135:     {
136:         return ObjectMixin::has($this, $name);
137:     }
138: 
139: 
140:     public function __unset($name)
141:     {
142:         ObjectMixin::remove($this, $name);
143:     }
144: 
145: }
146: 
Nette Framework 2.0.12 API API documentation generated by ApiGen 2.8.0