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

Classes

Interfaces

  • Overview
  • Package
  • 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 (http://davidgrudl.com)
  6:  * @package Nette\Reflection
  7:  */
  8: 
  9: 
 10: 
 11: /**
 12:  * Reports information about a method.
 13:  *
 14:  * @author     David Grudl
 15:  * @property-read array $defaultParameters
 16:  * @property-read NClassReflection $declaringClass
 17:  * @property-read NMethodReflection $prototype
 18:  * @property-read NExtensionReflection $extension
 19:  * @property-read NParameterReflection[] $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:  * @package Nette\Reflection
 48:  */
 49: class NMethodReflection extends ReflectionMethod
 50: {
 51: 
 52:     /**
 53:      * @param  string|object
 54:      * @param  string
 55:      * @return NMethodReflection
 56:      */
 57:     public static function from($class, $method)
 58:     {
 59:         return new self(is_object($class) ? get_class($class) : $class, $method);
 60:     }
 61: 
 62: 
 63:     /**
 64:      * @return NCallback
 65:      */
 66:     public function toCallback()
 67:     {
 68:         return new NCallback(parent::getDeclaringClass()->getName(), $this->getName());
 69:     }
 70: 
 71: 
 72:     public function __toString()
 73:     {
 74:         return 'Method ' . parent::getDeclaringClass()->getName() . '::' . $this->getName() . '()';
 75:     }
 76: 
 77: 
 78:     /********************* Reflection layer ****************d*g**/
 79: 
 80: 
 81:     /**
 82:      * @return NClassReflection
 83:      */
 84:     public function getDeclaringClass()
 85:     {
 86:         return new NClassReflection(parent::getDeclaringClass()->getName());
 87:     }
 88: 
 89: 
 90:     /**
 91:      * @return NMethodReflection
 92:      */
 93:     public function getPrototype()
 94:     {
 95:         $prototype = parent::getPrototype();
 96:         return new NMethodReflection($prototype->getDeclaringClass()->getName(), $prototype->getName());
 97:     }
 98: 
 99: 
100:     /**
101:      * @return NExtensionReflection
102:      */
103:     public function getExtension()
104:     {
105:         return ($name = $this->getExtensionName()) ? new NExtensionReflection($name) : NULL;
106:     }
107: 
108: 
109:     /**
110:      * @return NParameterReflection[]
111:      */
112:     public function getParameters()
113:     {
114:         $me = array(parent::getDeclaringClass()->getName(), $this->getName());
115:         foreach ($res = parent::getParameters() as $key => $val) {
116:             $res[$key] = new NParameterReflection($me, $val->getName());
117:         }
118:         return $res;
119:     }
120: 
121: 
122:     /********************* NAnnotations 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 = NAnnotationsParser::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 = NAnnotationsParser::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 NAnnotationsParser::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: 
169:     /********************* NObject behaviour ****************d*g**/
170: 
171: 
172:     /**
173:      * @return NClassReflection
174:      */
175:     public function getReflection()
176:     {
177:         return new NClassReflection($this);
178:     }
179: 
180: 
181:     public function __call($name, $args)
182:     {
183:         return NObjectMixin::call($this, $name, $args);
184:     }
185: 
186: 
187:     public function &__get($name)
188:     {
189:         return NObjectMixin::get($this, $name);
190:     }
191: 
192: 
193:     public function __set($name, $value)
194:     {
195:         NObjectMixin::set($this, $name, $value);
196:     }
197: 
198: 
199:     public function __isset($name)
200:     {
201:         return NObjectMixin::has($this, $name);
202:     }
203: 
204: 
205:     public function __unset($name)
206:     {
207:         NObjectMixin::remove($this, $name);
208:     }
209: 
210: }
211: 
Nette Framework 2.0.18 (for PHP 5.2, prefixed) API documentation generated by ApiGen 2.8.0