Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Utils
  • none
  • Tracy
    • Bridges
      • Nette

Classes

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

Interfaces

  • IAnnotation
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Nette Framework (https://nette.org)
  5:  * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
  6:  */
  7: 
  8: namespace Nette\Reflection;
  9: 
 10: use Nette;
 11: use Nette\Utils\ObjectMixin;
 12: 
 13: 
 14: /**
 15:  * Reports information about a method.
 16:  * @property-read array $defaultParameters
 17:  * @property-read ClassType $declaringClass
 18:  * @property-read Method $prototype
 19:  * @property-read Extension $extension
 20:  * @property-read Parameter[] $parameters
 21:  * @property-read IAnnotation[][] $annotations
 22:  * @property-read string $description
 23:  * @property-read bool $public
 24:  * @property-read bool $private
 25:  * @property-read bool $protected
 26:  * @property-read bool $abstract
 27:  * @property-read bool $final
 28:  * @property-read bool $static
 29:  * @property-read bool $constructor
 30:  * @property-read bool $destructor
 31:  * @property-read int $modifiers
 32:  * @property-write bool $accessible
 33:  * @property-read bool $closure
 34:  * @property-read bool $deprecated
 35:  * @property-read bool $internal
 36:  * @property-read bool $userDefined
 37:  * @property-read string $docComment
 38:  * @property-read int $endLine
 39:  * @property-read string $extensionName
 40:  * @property-read string $fileName
 41:  * @property-read string $name
 42:  * @property-read string $namespaceName
 43:  * @property-read int $numberOfParameters
 44:  * @property-read int $numberOfRequiredParameters
 45:  * @property-read string $shortName
 46:  * @property-read int $startLine
 47:  * @property-read array $staticVariables
 48:  */
 49: class Method extends \ReflectionMethod
 50: {
 51: 
 52:     /**
 53:      * @param  string|object
 54:      * @param  string
 55:      * @return self
 56:      */
 57:     public static function from($class, $method)
 58:     {
 59:         return new static(is_object($class) ? get_class($class) : $class, $method);
 60:     }
 61: 
 62: 
 63:     /**
 64:      * @deprecated
 65:      */
 66:     public function toCallback()
 67:     {
 68:         return new Nette\Callback(parent::getDeclaringClass()->getName(), $this->getName());
 69:     }
 70: 
 71: 
 72:     public function __toString()
 73:     {
 74:         return parent::getDeclaringClass()->getName() . '::' . $this->getName() . '()';
 75:     }
 76: 
 77: 
 78:     public function getClosure($object = NULL)
 79:     {
 80:         return PHP_VERSION_ID < 50400
 81:             ? Nette\Utils\Callback::closure($object ?: parent::getDeclaringClass()->getName(), $this->getName())
 82:             : parent::getClosure($object);
 83:     }
 84: 
 85: 
 86:     /********************* Reflection layer ****************d*g**/
 87: 
 88: 
 89:     /**
 90:      * @return ClassType
 91:      */
 92:     public function getDeclaringClass()
 93:     {
 94:         return new ClassType(parent::getDeclaringClass()->getName());
 95:     }
 96: 
 97: 
 98:     /**
 99:      * @return self
100:      */
101:     public function getPrototype()
102:     {
103:         $prototype = parent::getPrototype();
104:         return new static($prototype->getDeclaringClass()->getName(), $prototype->getName());
105:     }
106: 
107: 
108:     /**
109:      * @return Extension
110:      */
111:     public function getExtension()
112:     {
113:         return ($name = $this->getExtensionName()) ? new Extension($name) : NULL;
114:     }
115: 
116: 
117:     /**
118:      * @return Parameter[]
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 Parameter($me, $val->getName());
125:         }
126:         return $res;
127:     }
128: 
129: 
130:     /********************* Nette\Annotations support ****************d*g**/
131: 
132: 
133:     /**
134:      * Has method specified annotation?
135:      * @param  string
136:      * @return bool
137:      */
138:     public function hasAnnotation($name)
139:     {
140:         $res = AnnotationsParser::getAll($this);
141:         return !empty($res[$name]);
142:     }
143: 
144: 
145:     /**
146:      * Returns an annotation value.
147:      * @param  string
148:      * @return IAnnotation
149:      */
150:     public function getAnnotation($name)
151:     {
152:         $res = AnnotationsParser::getAll($this);
153:         return isset($res[$name]) ? end($res[$name]) : NULL;
154:     }
155: 
156: 
157:     /**
158:      * Returns all annotations.
159:      * @return IAnnotation[][]
160:      */
161:     public function getAnnotations()
162:     {
163:         return AnnotationsParser::getAll($this);
164:     }
165: 
166: 
167:     /**
168:      * Returns value of annotation 'description'.
169:      * @return string
170:      */
171:     public function getDescription()
172:     {
173:         return $this->getAnnotation('description');
174:     }
175: 
176: 
177:     /********************* Nette\Object behaviour ****************d*g**/
178: 
179: 
180:     public function __call($name, $args)
181:     {
182:         return ObjectMixin::call($this, $name, $args);
183:     }
184: 
185: 
186:     public function &__get($name)
187:     {
188:         return ObjectMixin::get($this, $name);
189:     }
190: 
191: 
192:     public function __set($name, $value)
193:     {
194:         ObjectMixin::set($this, $name, $value);
195:     }
196: 
197: 
198:     public function __isset($name)
199:     {
200:         return ObjectMixin::has($this, $name);
201:     }
202: 
203: 
204:     public function __unset($name)
205:     {
206:         ObjectMixin::remove($this, $name);
207:     }
208: 
209: }
210: 
Nette 2.3-20161221 API API documentation generated by ApiGen 2.8.0