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 function.
 15:  * @property-read array $defaultParameters
 16:  * @property-read bool $closure
 17:  * @property-read Extension $extension
 18:  * @property-read Parameter[] $parameters
 19:  * @property-read bool $disabled
 20:  * @property-read bool $deprecated
 21:  * @property-read bool $internal
 22:  * @property-read bool $userDefined
 23:  * @property-read string $docComment
 24:  * @property-read int $endLine
 25:  * @property-read string $extensionName
 26:  * @property-read string $fileName
 27:  * @property-read string $name
 28:  * @property-read string $namespaceName
 29:  * @property-read int $numberOfParameters
 30:  * @property-read int $numberOfRequiredParameters
 31:  * @property-read string $shortName
 32:  * @property-read int $startLine
 33:  * @property-read array $staticVariables
 34:  */
 35: class GlobalFunction extends \ReflectionFunction
 36: {
 37:     use Nette\SmartObject;
 38: 
 39:     /** @var string|\Closure */
 40:     private $value;
 41: 
 42: 
 43:     public function __construct($name)
 44:     {
 45:         parent::__construct($this->value = $name);
 46:     }
 47: 
 48: 
 49:     /**
 50:      * @deprecated
 51:      */
 52:     public function toCallback()
 53:     {
 54:         return new Nette\Callback($this->value);
 55:     }
 56: 
 57: 
 58:     public function __toString()
 59:     {
 60:         return $this->getName() . '()';
 61:     }
 62: 
 63: 
 64:     /********************* Reflection layer ****************d*g**/
 65: 
 66: 
 67:     /**
 68:      * @return Extension
 69:      */
 70:     public function getExtension()
 71:     {
 72:         return ($name = $this->getExtensionName()) ? new Extension($name) : null;
 73:     }
 74: 
 75: 
 76:     /**
 77:      * @return Parameter[]
 78:      */
 79:     public function getParameters()
 80:     {
 81:         foreach ($res = parent::getParameters() as $key => $val) {
 82:             $res[$key] = new Parameter($this->value, $val->getName());
 83:         }
 84:         return $res;
 85:     }
 86: 
 87: 
 88:     /********************* Nette\Annotations support ****************d*g**/
 89: 
 90: 
 91:     /**
 92:      * Has method specified annotation?
 93:      * @param  string
 94:      * @return bool
 95:      */
 96:     public function hasAnnotation($name)
 97:     {
 98:         $res = AnnotationsParser::getAll($this);
 99:         return !empty($res[$name]);
100:     }
101: 
102: 
103:     /**
104:      * Returns an annotation value.
105:      * @param  string
106:      * @return IAnnotation
107:      */
108:     public function getAnnotation($name)
109:     {
110:         $res = AnnotationsParser::getAll($this);
111:         return isset($res[$name]) ? end($res[$name]) : null;
112:     }
113: 
114: 
115:     /**
116:      * Returns all annotations.
117:      * @return IAnnotation[][]
118:      */
119:     public function getAnnotations()
120:     {
121:         return AnnotationsParser::getAll($this);
122:     }
123: 
124: 
125:     /**
126:      * Returns value of annotation 'description'.
127:      * @return string
128:      */
129:     public function getDescription()
130:     {
131:         return $this->getAnnotation('description');
132:     }
133: }
134: 
Nette 2.4-20180918 API API documentation generated by ApiGen 2.8.0