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
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
      • Traits
    • Reflection
    • Security
    • Tokenizer
    • Utils
  • Tracy
    • Bridges
      • Nette
  • none

Classes

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

Interfaces

  • IAnnotation
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  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: 
 12: 
 13: /**
 14:  * Reports information about a method.
 15:  * @property-read array $defaultParameters
 16:  * @property-read ClassType $declaringClass
 17:  * @property-read Method $prototype
 18:  * @property-read Extension $extension
 19:  * @property-read Parameter[] $parameters
 20:  * @property-read IAnnotation[][] $annotations
 21:  * @property-read string $description
 22:  * @property-read bool $public
 23:  * @property-read bool $private
 24:  * @property-read bool $protected
 25:  * @property-read bool $abstract
 26:  * @property-read bool $final
 27:  * @property-read bool $static
 28:  * @property-read bool $constructor
 29:  * @property-read bool $destructor
 30:  * @property-read int $modifiers
 31:  * @property-write bool $accessible
 32:  * @property-read bool $closure
 33:  * @property-read bool $deprecated
 34:  * @property-read bool $internal
 35:  * @property-read bool $userDefined
 36:  * @property-read string $docComment
 37:  * @property-read int $endLine
 38:  * @property-read string $extensionName
 39:  * @property-read string $fileName
 40:  * @property-read string $name
 41:  * @property-read string $namespaceName
 42:  * @property-read int $numberOfParameters
 43:  * @property-read int $numberOfRequiredParameters
 44:  * @property-read string $shortName
 45:  * @property-read int $startLine
 46:  * @property-read array $staticVariables
 47:  */
 48: class Method extends \ReflectionMethod
 49: {
 50:     use Nette\SmartObject;
 51: 
 52:     /**
 53:      * @param  string|object
 54:      * @param  string
 55:      * @return static
 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:     /********************* Reflection layer ****************d*g**/
 79: 
 80: 
 81:     /**
 82:      * @return ClassType
 83:      */
 84:     public function getDeclaringClass()
 85:     {
 86:         return new ClassType(parent::getDeclaringClass()->getName());
 87:     }
 88: 
 89: 
 90:     /**
 91:      * @return static
 92:      */
 93:     public function getPrototype()
 94:     {
 95:         $prototype = parent::getPrototype();
 96:         return new static($prototype->getDeclaringClass()->getName(), $prototype->getName());
 97:     }
 98: 
 99: 
100:     /**
101:      * @return Extension
102:      */
103:     public function getExtension()
104:     {
105:         return ($name = $this->getExtensionName()) ? new Extension($name) : null;
106:     }
107: 
108: 
109:     /**
110:      * @return Parameter[]
111:      */
112:     public function getParameters()
113:     {
114:         $me = [parent::getDeclaringClass()->getName(), $this->getName()];
115:         foreach ($res = parent::getParameters() as $key => $val) {
116:             $res[$key] = new Parameter($me, $val->getName());
117:         }
118:         return $res;
119:     }
120: 
121: 
122:     /********************* Nette\Annotations support ****************d*g**/
123: 
124: 
125:     /**
126:      * Has method specified annotation?
127:      * @param  string
128:      * @return bool
129:      */
130:     public function hasAnnotation($name)
131:     {
132:         $res = AnnotationsParser::getAll($this);
133:         return !empty($res[$name]);
134:     }
135: 
136: 
137:     /**
138:      * Returns an annotation value.
139:      * @param  string
140:      * @return IAnnotation
141:      */
142:     public function getAnnotation($name)
143:     {
144:         $res = AnnotationsParser::getAll($this);
145:         return isset($res[$name]) ? end($res[$name]) : null;
146:     }
147: 
148: 
149:     /**
150:      * Returns all annotations.
151:      * @return IAnnotation[][]
152:      */
153:     public function getAnnotations()
154:     {
155:         return AnnotationsParser::getAll($this);
156:     }
157: 
158: 
159:     /**
160:      * Returns value of annotation 'description'.
161:      * @return string
162:      */
163:     public function getDescription()
164:     {
165:         return $this->getAnnotation('description');
166:     }
167: }
168: 
Nette 2.4-20180918 API API documentation generated by ApiGen 2.8.0