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