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:  * Reports information about a method's parameter.
 20:  *
 21:  * @author     David Grudl
 22:  * @property-read ClassType $class
 23:  * @property-read string $className
 24:  * @property-read ClassType $declaringClass
 25:  * @property-read Method $declaringFunction
 26:  * @property-read string $name
 27:  * @property-read bool $passedByReference
 28:  * @property-read bool $array
 29:  * @property-read int $position
 30:  * @property-read bool $optional
 31:  * @property-read bool $defaultValueAvailable
 32:  * @property-read mixed $defaultValue
 33:  */
 34: class Parameter extends \ReflectionParameter
 35: {
 36:     /** @var mixed */
 37:     private $function;
 38: 
 39: 
 40:     public function __construct($function, $parameter)
 41:     {
 42:         parent::__construct($this->function = $function, $parameter);
 43:     }
 44: 
 45: 
 46:     /**
 47:      * @return ClassType
 48:      */
 49:     public function getClass()
 50:     {
 51:         return ($ref = parent::getClass()) ? new ClassType($ref->getName()) : NULL;
 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:      * @return ClassType
 73:      */
 74:     public function getDeclaringClass()
 75:     {
 76:         return ($ref = parent::getDeclaringClass()) ? new ClassType($ref->getName()) : NULL;
 77:     }
 78: 
 79: 
 80:     /**
 81:      * @return Method|GlobalFunction
 82:      */
 83:     public function getDeclaringFunction()
 84:     {
 85:         return is_array($this->function)
 86:             ? new Method($this->function[0], $this->function[1])
 87:             : new GlobalFunction($this->function);
 88:     }
 89: 
 90: 
 91:     /**
 92:      * @return bool
 93:      */
 94:     public function isDefaultValueAvailable()
 95:     {
 96:         if (PHP_VERSION_ID === 50316) { // PHP bug #62988
 97:             try {
 98:                 $this->getDefaultValue();
 99:                 return TRUE;
100:             } catch (\ReflectionException $e) {
101:                 return FALSE;
102:             }
103:         }
104:         return parent::isDefaultValueAvailable();
105:     }
106: 
107: 
108:     public function __toString()
109:     {
110:         return 'Parameter $' . parent::getName() . ' in ' . $this->getDeclaringFunction();
111:     }
112: 
113: 
114:     /********************* Nette\Object behaviour ****************d*g**/
115: 
116: 
117:     /**
118:      * @return ClassType
119:      */
120:     public static function getReflection()
121:     {
122:         return new ClassType(get_called_class());
123:     }
124: 
125: 
126:     public function __call($name, $args)
127:     {
128:         return ObjectMixin::call($this, $name, $args);
129:     }
130: 
131: 
132:     public function &__get($name)
133:     {
134:         return ObjectMixin::get($this, $name);
135:     }
136: 
137: 
138:     public function __set($name, $value)
139:     {
140:         return ObjectMixin::set($this, $name, $value);
141:     }
142: 
143: 
144:     public function __isset($name)
145:     {
146:         return ObjectMixin::has($this, $name);
147:     }
148: 
149: 
150:     public function __unset($name)
151:     {
152:         ObjectMixin::remove($this, $name);
153:     }
154: 
155: }
156: 
Nette Framework 2.0.11 API API documentation generated by ApiGen 2.8.0