Packages

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

Classes

  • NAnnotation
  • NAnnotationsParser
  • NClassReflection
  • NExtensionReflection
  • NFunctionReflection
  • NMethodReflection
  • NParameterReflection
  • NPropertyReflection

Interfaces

  • IAnnotation
  • Overview
  • Package
  • 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:  * @package Nette\Reflection
 11:  */
 12: 
 13: 
 14: 
 15: /**
 16:  * Reports information about a function.
 17:  *
 18:  * @author     David Grudl
 19:  * @package Nette\Reflection
 20:  */
 21: class NFunctionReflection extends ReflectionFunction
 22: {
 23:     /** @var string|Closure */
 24:     private $value;
 25: 
 26: 
 27:     public function __construct($name)
 28:     {
 29:         parent::__construct($this->value = $name);
 30:     }
 31: 
 32: 
 33: 
 34:     /**
 35:      * @return array
 36:      */
 37:     public function getDefaultParameters()
 38:     {
 39:         return NMethodReflection::buildDefaultParameters(parent::getParameters());
 40:     }
 41: 
 42: 
 43: 
 44:     /**
 45:      * Invokes function using named parameters.
 46:      * @param  array
 47:      * @return mixed
 48:      */
 49:     public function invokeNamedArgs($args)
 50:     {
 51:         return $this->invokeArgs(NMethodReflection::combineArgs($this->getDefaultParameters(), $args));
 52:     }
 53: 
 54: 
 55: 
 56:     /**
 57:      * @return NCallback
 58:      */
 59:     public function toCallback()
 60:     {
 61:         return new NCallback($this->value);
 62:     }
 63: 
 64: 
 65: 
 66:     public function __toString()
 67:     {
 68:         return 'Function ' . $this->getName() . '()';
 69:     }
 70: 
 71: 
 72: 
 73:     public function getClosure()
 74:     {
 75:         return $this->isClosure() ? $this->value : NULL;
 76:     }
 77: 
 78: 
 79: 
 80:     /********************* Reflection layer ****************d*g**/
 81: 
 82: 
 83: 
 84:     /**
 85:      * @return NExtensionReflection
 86:      */
 87:     public function getExtension()
 88:     {
 89:         return ($name = $this->getExtensionName()) ? new NExtensionReflection($name) : NULL;
 90:     }
 91: 
 92: 
 93: 
 94:     public function getParameters()
 95:     {
 96:         foreach ($res = parent::getParameters() as $key => $val) {
 97:             $res[$key] = new NParameterReflection($this->value, $val->getName());
 98:         }
 99:         return $res;
100:     }
101: 
102: 
103: 
104:     /********************* NObject behaviour ****************d*g**/
105: 
106: 
107: 
108:     /**
109:      * @return NClassReflection
110:      */
111:     public function getReflection()
112:     {
113:         return new NClassReflection($this);
114:     }
115: 
116: 
117: 
118:     public function __call($name, $args)
119:     {
120:         return NObjectMixin::call($this, $name, $args);
121:     }
122: 
123: 
124: 
125:     public function &__get($name)
126:     {
127:         return NObjectMixin::get($this, $name);
128:     }
129: 
130: 
131: 
132:     public function __set($name, $value)
133:     {
134:         return NObjectMixin::set($this, $name, $value);
135:     }
136: 
137: 
138: 
139:     public function __isset($name)
140:     {
141:         return NObjectMixin::has($this, $name);
142:     }
143: 
144: 
145: 
146:     public function __unset($name)
147:     {
148:         NObjectMixin::remove($this, $name);
149:     }
150: 
151: }
152: 
Nette Framework 2.0beta1 (for PHP 5.2) API API documentation generated by ApiGen 2.3.0