Namespaces

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

Classes

  • Annotation
  • AnnotationsParser
  • ClassType
  • Extension
  • GlobalFunction
  • Method
  • Parameter
  • Property

Interfaces

  • IAnnotation
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Nette Framework (http://nette.org)
  5:  *
  6:  * Copyright (c) 2004, 2011 David Grudl (http://davidgrudl.com)
  7:  *
  8:  * For the full copyright and license information, please view
  9:  * the file license.txt that was distributed with this source code.
 10:  */
 11: 
 12: namespace Nette\Reflection;
 13: 
 14: use Nette,
 15:     Nette\ObjectMixin;
 16: 
 17: 
 18: 
 19: /**
 20:  * Reports information about a function.
 21:  *
 22:  * @author     David Grudl
 23:  */
 24: class GlobalFunction extends \ReflectionFunction
 25: {
 26:     /** @var string|Closure */
 27:     private $value;
 28: 
 29: 
 30:     public function __construct($name)
 31:     {
 32:         parent::__construct($this->value = $name);
 33:     }
 34: 
 35: 
 36: 
 37:     /**
 38:      * @return array
 39:      */
 40:     public function getDefaultParameters()
 41:     {
 42:         return Method::buildDefaultParameters(parent::getParameters());
 43:     }
 44: 
 45: 
 46: 
 47:     /**
 48:      * Invokes function using named parameters.
 49:      * @param  array
 50:      * @return mixed
 51:      */
 52:     public function invokeNamedArgs($args)
 53:     {
 54:         return $this->invokeArgs(Method::combineArgs($this->getDefaultParameters(), $args));
 55:     }
 56: 
 57: 
 58: 
 59:     /**
 60:      * @return Nette\Callback
 61:      */
 62:     public function toCallback()
 63:     {
 64:         return new Nette\Callback($this->value);
 65:     }
 66: 
 67: 
 68: 
 69:     public function __toString()
 70:     {
 71:         return 'Function ' . $this->getName() . '()';
 72:     }
 73: 
 74: 
 75: 
 76:     public function getClosure()
 77:     {
 78:         return $this->isClosure() ? $this->value : NULL;
 79:     }
 80: 
 81: 
 82: 
 83:     /********************* Reflection layer ****************d*g**/
 84: 
 85: 
 86: 
 87:     /**
 88:      * @return Extension
 89:      */
 90:     public function getExtension()
 91:     {
 92:         return ($name = $this->getExtensionName()) ? new Extension($name) : NULL;
 93:     }
 94: 
 95: 
 96: 
 97:     public function getParameters()
 98:     {
 99:         foreach ($res = parent::getParameters() as $key => $val) {
100:             $res[$key] = new Parameter($this->value, $val->getName());
101:         }
102:         return $res;
103:     }
104: 
105: 
106: 
107:     /********************* Nette\Object behaviour ****************d*g**/
108: 
109: 
110: 
111:     /**
112:      * @return ClassType
113:      */
114:     public static function getReflection()
115:     {
116:         return new ClassType(get_called_class());
117:     }
118: 
119: 
120: 
121:     public function __call($name, $args)
122:     {
123:         return ObjectMixin::call($this, $name, $args);
124:     }
125: 
126: 
127: 
128:     public function &__get($name)
129:     {
130:         return ObjectMixin::get($this, $name);
131:     }
132: 
133: 
134: 
135:     public function __set($name, $value)
136:     {
137:         return ObjectMixin::set($this, $name, $value);
138:     }
139: 
140: 
141: 
142:     public function __isset($name)
143:     {
144:         return ObjectMixin::has($this, $name);
145:     }
146: 
147: 
148: 
149:     public function __unset($name)
150:     {
151:         ObjectMixin::remove($this, $name);
152:     }
153: 
154: }
155: 
Nette Framework 2.0beta1 API API documentation generated by ApiGen 2.3.0