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

Classes

Interfaces

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