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

Classes

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

Interfaces

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