Namespaces

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

Classes

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

Interfaces

  • IAnnotation
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Nette Framework (http://nette.org)
  5:  *
  6:  * Copyright (c) 2004 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 method's parameter.
 21:  *
 22:  * @author     David Grudl
 23:  * @property-read ClassType $class
 24:  * @property-read string $className
 25:  * @property-read ClassType $declaringClass
 26:  * @property-read Method $declaringFunction
 27:  * @property-read string $name
 28:  * @property-read bool $passedByReference
 29:  * @property-read bool $array
 30:  * @property-read int $position
 31:  * @property-read bool $optional
 32:  * @property-read bool $defaultValueAvailable
 33:  * @property-read mixed $defaultValue
 34:  */
 35: class Parameter extends \ReflectionParameter
 36: {
 37:     /** @var mixed */
 38:     private $function;
 39: 
 40: 
 41:     public function __construct($function, $parameter)
 42:     {
 43:         parent::__construct($this->function = $function, $parameter);
 44:     }
 45: 
 46: 
 47: 
 48:     /**
 49:      * @return ClassType
 50:      */
 51:     public function getClass()
 52:     {
 53:         return ($ref = parent::getClass()) ? new ClassType($ref->getName()) : NULL;
 54:     }
 55: 
 56: 
 57: 
 58:     /**
 59:      * @return string
 60:      */
 61:     public function getClassName()
 62:     {
 63:         try {
 64:             return ($ref = parent::getClass()) ? $ref->getName() : NULL;
 65:         } catch (\ReflectionException $e) {
 66:             if (preg_match('#Class (.+) does not exist#', $e->getMessage(), $m)) {
 67:                 return $m[1];
 68:             }
 69:             throw $e;
 70:         }
 71:     }
 72: 
 73: 
 74: 
 75:     /**
 76:      * @return ClassType
 77:      */
 78:     public function getDeclaringClass()
 79:     {
 80:         return ($ref = parent::getDeclaringClass()) ? new ClassType($ref->getName()) : NULL;
 81:     }
 82: 
 83: 
 84: 
 85:     /**
 86:      * @return Method|GlobalFunction
 87:      */
 88:     public function getDeclaringFunction()
 89:     {
 90:         return is_array($this->function)
 91:             ? new Method($this->function[0], $this->function[1])
 92:             : new GlobalFunction($this->function);
 93:     }
 94: 
 95: 
 96: 
 97:     /**
 98:      * @return bool
 99:      */
100:     public function isDefaultValueAvailable()
101:     {
102:         if (PHP_VERSION_ID === 50316) { // PHP bug #62988
103:             try {
104:                 $this->getDefaultValue();
105:                 return TRUE;
106:             } catch (\ReflectionException $e) {
107:                 return FALSE;
108:             }
109:         }
110:         return parent::isDefaultValueAvailable();
111:     }
112: 
113: 
114: 
115:     public function __toString()
116:     {
117:         return 'Parameter $' . parent::getName() . ' in ' . $this->getDeclaringFunction();
118:     }
119: 
120: 
121: 
122:     /********************* Nette\Object behaviour ****************d*g**/
123: 
124: 
125: 
126:     /**
127:      * @return ClassType
128:      */
129:     public static function getReflection()
130:     {
131:         return new ClassType(get_called_class());
132:     }
133: 
134: 
135: 
136:     public function __call($name, $args)
137:     {
138:         return ObjectMixin::call($this, $name, $args);
139:     }
140: 
141: 
142: 
143:     public function &__get($name)
144:     {
145:         return ObjectMixin::get($this, $name);
146:     }
147: 
148: 
149: 
150:     public function __set($name, $value)
151:     {
152:         return ObjectMixin::set($this, $name, $value);
153:     }
154: 
155: 
156: 
157:     public function __isset($name)
158:     {
159:         return ObjectMixin::has($this, $name);
160:     }
161: 
162: 
163: 
164:     public function __unset($name)
165:     {
166:         ObjectMixin::remove($this, $name);
167:     }
168: 
169: }
170: 
Nette Framework 2.0.10 API API documentation generated by ApiGen 2.8.0