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 function.
 16:  * @property-read array $defaultParameters
 17:  * @property-read bool $closure
 18:  * @property-read Extension $extension
 19:  * @property-read Parameter[] $parameters
 20:  * @property-read bool $disabled
 21:  * @property-read bool $deprecated
 22:  * @property-read bool $internal
 23:  * @property-read bool $userDefined
 24:  * @property-read string $docComment
 25:  * @property-read int $endLine
 26:  * @property-read string $extensionName
 27:  * @property-read string $fileName
 28:  * @property-read string $name
 29:  * @property-read string $namespaceName
 30:  * @property-read int $numberOfParameters
 31:  * @property-read int $numberOfRequiredParameters
 32:  * @property-read string $shortName
 33:  * @property-read int $startLine
 34:  * @property-read array $staticVariables
 35:  */
 36: class GlobalFunction extends \ReflectionFunction
 37: {
 38:     /** @var string|\Closure */
 39:     private $value;
 40: 
 41: 
 42:     public function __construct($name)
 43:     {
 44:         parent::__construct($this->value = $name);
 45:     }
 46: 
 47: 
 48:     /**
 49:      * @deprecated
 50:      */
 51:     public function toCallback()
 52:     {
 53:         return new Nette\Callback($this->value);
 54:     }
 55: 
 56: 
 57:     public function __toString()
 58:     {
 59:         return $this->getName() . '()';
 60:     }
 61: 
 62: 
 63:     public function getClosure()
 64:     {
 65:         return PHP_VERSION_ID < 50400
 66:             ? Nette\Utils\Callback::closure($this->value)
 67:             : parent::getClosure();
 68:     }
 69: 
 70: 
 71:     /********************* Reflection layer ****************d*g**/
 72: 
 73: 
 74:     /**
 75:      * @return Extension
 76:      */
 77:     public function getExtension()
 78:     {
 79:         return ($name = $this->getExtensionName()) ? new Extension($name) : NULL;
 80:     }
 81: 
 82: 
 83:     /**
 84:      * @return Parameter[]
 85:      */
 86:     public function getParameters()
 87:     {
 88:         foreach ($res = parent::getParameters() as $key => $val) {
 89:             $res[$key] = new Parameter($this->value, $val->getName());
 90:         }
 91:         return $res;
 92:     }
 93: 
 94: 
 95:     /********************* Nette\Annotations support ****************d*g**/
 96: 
 97: 
 98:     /**
 99:      * Has method specified annotation?
100:      * @param  string
101:      * @return bool
102:      */
103:     public function hasAnnotation($name)
104:     {
105:         $res = AnnotationsParser::getAll($this);
106:         return !empty($res[$name]);
107:     }
108: 
109: 
110:     /**
111:      * Returns an annotation value.
112:      * @param  string
113:      * @return IAnnotation
114:      */
115:     public function getAnnotation($name)
116:     {
117:         $res = AnnotationsParser::getAll($this);
118:         return isset($res[$name]) ? end($res[$name]) : NULL;
119:     }
120: 
121: 
122:     /**
123:      * Returns all annotations.
124:      * @return IAnnotation[][]
125:      */
126:     public function getAnnotations()
127:     {
128:         return AnnotationsParser::getAll($this);
129:     }
130: 
131: 
132:     /**
133:      * Returns value of annotation 'description'.
134:      * @return string
135:      */
136:     public function getDescription()
137:     {
138:         return $this->getAnnotation('description');
139:     }
140: 
141: 
142:     /********************* Nette\Object behaviour ****************d*g**/
143: 
144: 
145:     public function __call($name, $args)
146:     {
147:         return ObjectMixin::call($this, $name, $args);
148:     }
149: 
150: 
151:     public function &__get($name)
152:     {
153:         return ObjectMixin::get($this, $name);
154:     }
155: 
156: 
157:     public function __set($name, $value)
158:     {
159:         ObjectMixin::set($this, $name, $value);
160:     }
161: 
162: 
163:     public function __isset($name)
164:     {
165:         return ObjectMixin::has($this, $name);
166:     }
167: 
168: 
169:     public function __unset($name)
170:     {
171:         ObjectMixin::remove($this, $name);
172:     }
173: 
174: }
175: 
Nette 2.3-20161221 API API documentation generated by ApiGen 2.8.0