Packages

  • 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
  • ClassReflection
  • ExtensionReflection
  • FunctionReflection
  • MethodReflection
  • ParameterReflection
  • PropertyReflection

Interfaces

  • IAnnotation
  • Overview
  • Package
  • Class
  • Tree
  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 method.
 17:  *
 18:  * @author     David Grudl
 19:  * @property-read array $defaultParameters
 20:  * @property-read ClassReflection $declaringClass
 21:  * @property-read MethodReflection $prototype
 22:  * @property-read ExtensionReflection $extension
 23:  * @property-read array $parameters
 24:  * @property-read array $annotations
 25:  * @property-read string $description
 26:  * @property-read bool $public
 27:  * @property-read bool $private
 28:  * @property-read bool $protected
 29:  * @property-read bool $abstract
 30:  * @property-read bool $final
 31:  * @property-read bool $static
 32:  * @property-read bool $constructor
 33:  * @property-read bool $destructor
 34:  * @property-read int $modifiers
 35:  * @property-write bool $accessible
 36:  * @property-read bool $closure
 37:  * @property-read bool $deprecated
 38:  * @property-read bool $internal
 39:  * @property-read bool $userDefined
 40:  * @property-read string $docComment
 41:  * @property-read int $endLine
 42:  * @property-read string $extensionName
 43:  * @property-read string $fileName
 44:  * @property-read string $name
 45:  * @property-read string $namespaceName
 46:  * @property-read int $numberOfParameters
 47:  * @property-read int $numberOfRequiredParameters
 48:  * @property-read string $shortName
 49:  * @property-read int $startLine
 50:  * @property-read array $staticVariables
 51:  * @package Nette\Reflection
 52:  */
 53: class MethodReflection extends ReflectionMethod
 54: {
 55: 
 56:     /**
 57:      * @param  string|object
 58:      * @param  string
 59:      * @return MethodReflection
 60:      */
 61:     public static function from($class, $method)
 62:     {
 63:         return new self(is_object($class) ? get_class($class) : $class, $method);
 64:     }
 65: 
 66: 
 67: 
 68:     /**
 69:      * @return Callback
 70:      */
 71:     public function toCallback()
 72:     {
 73:         return new Callback(parent::getDeclaringClass()->getName(), $this->getName());
 74:     }
 75: 
 76: 
 77: 
 78:     public function __toString()
 79:     {
 80:         return 'Method ' . parent::getDeclaringClass()->getName() . '::' . $this->getName() . '()';
 81:     }
 82: 
 83: 
 84: 
 85:     /********************* Reflection layer ****************d*g**/
 86: 
 87: 
 88: 
 89:     /**
 90:      * @return ClassReflection
 91:      */
 92:     public function getDeclaringClass()
 93:     {
 94:         return new ClassReflection(parent::getDeclaringClass()->getName());
 95:     }
 96: 
 97: 
 98: 
 99:     /**
100:      * @return MethodReflection
101:      */
102:     public function getPrototype()
103:     {
104:         $prototype = parent::getPrototype();
105:         return new MethodReflection($prototype->getDeclaringClass()->getName(), $prototype->getName());
106:     }
107: 
108: 
109: 
110:     /**
111:      * @return ExtensionReflection
112:      */
113:     public function getExtension()
114:     {
115:         return ($name = $this->getExtensionName()) ? new ExtensionReflection($name) : NULL;
116:     }
117: 
118: 
119: 
120:     public function getParameters()
121:     {
122:         $me = array(parent::getDeclaringClass()->getName(), $this->getName());
123:         foreach ($res = parent::getParameters() as $key => $val) {
124:             $res[$key] = new ParameterReflection($me, $val->getName());
125:         }
126:         return $res;
127:     }
128: 
129: 
130: 
131:     /********************* Annotations support ****************d*g**/
132: 
133: 
134: 
135:     /**
136:      * Has method specified annotation?
137:      * @param  string
138:      * @return bool
139:      */
140:     public function hasAnnotation($name)
141:     {
142:         $res = AnnotationsParser::getAll($this);
143:         return !empty($res[$name]);
144:     }
145: 
146: 
147: 
148:     /**
149:      * Returns an annotation value.
150:      * @param  string
151:      * @return IAnnotation
152:      */
153:     public function getAnnotation($name)
154:     {
155:         $res = AnnotationsParser::getAll($this);
156:         return isset($res[$name]) ? end($res[$name]) : NULL;
157:     }
158: 
159: 
160: 
161:     /**
162:      * Returns all annotations.
163:      * @return array
164:      */
165:     public function getAnnotations()
166:     {
167:         return AnnotationsParser::getAll($this);
168:     }
169: 
170: 
171: 
172:     /**
173:      * Returns value of annotation 'description'.
174:      * @return string
175:      */
176:     public function getDescription()
177:     {
178:         return $this->getAnnotation('description');
179:     }
180: 
181: 
182: 
183:     /********************* Object behaviour ****************d*g**/
184: 
185: 
186: 
187:     /**
188:      * @return ClassReflection
189:      */
190:     public function getReflection()
191:     {
192:         return new ClassReflection($this);
193:     }
194: 
195: 
196: 
197:     public function __call($name, $args)
198:     {
199:         return ObjectMixin::call($this, $name, $args);
200:     }
201: 
202: 
203: 
204:     public function &__get($name)
205:     {
206:         return ObjectMixin::get($this, $name);
207:     }
208: 
209: 
210: 
211:     public function __set($name, $value)
212:     {
213:         return ObjectMixin::set($this, $name, $value);
214:     }
215: 
216: 
217: 
218:     public function __isset($name)
219:     {
220:         return ObjectMixin::has($this, $name);
221:     }
222: 
223: 
224: 
225:     public function __unset($name)
226:     {
227:         ObjectMixin::remove($this, $name);
228:     }
229: 
230: }
231: 
Nette Framework 2.0.1 (for PHP 5.2, un-prefixed) API API documentation generated by ApiGen 2.7.0