Namespaces

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

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