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:      * @return NClassReflection
 46:      */
 47:     public function getClass()
 48:     {
 49:         return ($ref = parent::getClass()) ? new NClassReflection($ref->getName()) : NULL;
 50:     }
 51: 
 52: 
 53:     /**
 54:      * @return string
 55:      */
 56:     public function getClassName()
 57:     {
 58:         try {
 59:             return ($ref = parent::getClass()) ? $ref->getName() : NULL;
 60:         } catch (ReflectionException $e) {
 61:             if (preg_match('#Class (.+) does not exist#', $e->getMessage(), $m)) {
 62:                 return $m[1];
 63:             }
 64:             throw $e;
 65:         }
 66:     }
 67: 
 68: 
 69:     /**
 70:      * @return NClassReflection
 71:      */
 72:     public function getDeclaringClass()
 73:     {
 74:         return ($ref = parent::getDeclaringClass()) ? new NClassReflection($ref->getName()) : NULL;
 75:     }
 76: 
 77: 
 78:     /**
 79:      * @return NMethodReflection|NFunctionReflection
 80:      */
 81:     public function getDeclaringFunction()
 82:     {
 83:         return is_array($this->function)
 84:             ? new NMethodReflection($this->function[0], $this->function[1])
 85:             : new NFunctionReflection($this->function);
 86:     }
 87: 
 88: 
 89:     /**
 90:      * @return bool
 91:      */
 92:     public function isDefaultValueAvailable()
 93:     {
 94:         if (PHP_VERSION_ID === 50316) { // PHP bug #62988
 95:             try {
 96:                 $this->getDefaultValue();
 97:                 return TRUE;
 98:             } catch (ReflectionException $e) {
 99:                 return FALSE;
100:             }
101:         }
102:         return parent::isDefaultValueAvailable();
103:     }
104: 
105: 
106:     public function __toString()
107:     {
108:         return 'Parameter $' . parent::getName() . ' in ' . $this->getDeclaringFunction();
109:     }
110: 
111: 
112:     /********************* NObject behaviour ****************d*g**/
113: 
114: 
115:     /**
116:      * @return NClassReflection
117:      */
118:     public function getReflection()
119:     {
120:         return new NClassReflection($this);
121:     }
122: 
123: 
124:     public function __call($name, $args)
125:     {
126:         return NObjectMixin::call($this, $name, $args);
127:     }
128: 
129: 
130:     public function &__get($name)
131:     {
132:         return NObjectMixin::get($this, $name);
133:     }
134: 
135: 
136:     public function __set($name, $value)
137:     {
138:         return NObjectMixin::set($this, $name, $value);
139:     }
140: 
141: 
142:     public function __isset($name)
143:     {
144:         return NObjectMixin::has($this, $name);
145:     }
146: 
147: 
148:     public function __unset($name)
149:     {
150:         NObjectMixin::remove($this, $name);
151:     }
152: 
153: }
154: 
Nette Framework 2.0.12 (for PHP 5.2, prefixed) API API documentation generated by ApiGen 2.8.0