Namespaces

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

Classes

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