Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Utils
  • none
  • Tracy
    • Bridges
      • Nette

Classes

  • Annotation
  • AnnotationsParser
  • ClassType
  • Extension
  • GlobalFunction
  • Helpers
  • 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 (https://davidgrudl.com)
  6:  */
  7: 
  8: namespace Nette\Reflection;
  9: 
 10: use Nette;
 11: use Nette\Utils\ObjectMixin;
 12: 
 13: 
 14: /**
 15:  * Reports information about a method's parameter.
 16:  * @property-read ClassType $class
 17:  * @property-read string $className
 18:  * @property-read ClassType $declaringClass
 19:  * @property-read Method $declaringFunction
 20:  * @property-read string $name
 21:  * @property-read bool $passedByReference
 22:  * @property-read bool $array
 23:  * @property-read int $position
 24:  * @property-read bool $optional
 25:  * @property-read bool $defaultValueAvailable
 26:  * @property-read mixed $defaultValue
 27:  */
 28: class Parameter 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 ClassType
 42:      */
 43:     public function getClass()
 44:     {
 45:         return ($ref = parent::getClass()) ? new ClassType($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 ClassType
 67:      */
 68:     public function getDeclaringClass()
 69:     {
 70:         return ($ref = parent::getDeclaringClass()) ? new ClassType($ref->getName()) : NULL;
 71:     }
 72: 
 73: 
 74:     /**
 75:      * @return Method|GlobalFunction
 76:      */
 77:     public function getDeclaringFunction()
 78:     {
 79:         return is_array($this->function)
 80:             ? new Method($this->function[0], $this->function[1])
 81:             : new GlobalFunction($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 '$' . parent::getName() . ' in ' . $this->getDeclaringFunction();
105:     }
106: 
107: 
108:     /********************* Nette\Object behaviour ****************d*g**/
109: 
110: 
111:     public function __call($name, $args)
112:     {
113:         return ObjectMixin::call($this, $name, $args);
114:     }
115: 
116: 
117:     public function &__get($name)
118:     {
119:         return ObjectMixin::get($this, $name);
120:     }
121: 
122: 
123:     public function __set($name, $value)
124:     {
125:         ObjectMixin::set($this, $name, $value);
126:     }
127: 
128: 
129:     public function __isset($name)
130:     {
131:         return ObjectMixin::has($this, $name);
132:     }
133: 
134: 
135:     public function __unset($name)
136:     {
137:         ObjectMixin::remove($this, $name);
138:     }
139: 
140: }
141: 
Nette 2.3-20161221 API API documentation generated by ApiGen 2.8.0