Packages

  • 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

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

Interfaces

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