Namespaces

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

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: use Nette\Utils\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 '$' . parent::getName() . ' in ' . $this->getDeclaringFunction();
107:     }
108: 
109: 
110:     /********************* Nette\Object behaviour ****************d*g**/
111: 
112: 
113:     public function __call($name, $args)
114:     {
115:         return ObjectMixin::call($this, $name, $args);
116:     }
117: 
118: 
119:     public function &__get($name)
120:     {
121:         return ObjectMixin::get($this, $name);
122:     }
123: 
124: 
125:     public function __set($name, $value)
126:     {
127:         ObjectMixin::set($this, $name, $value);
128:     }
129: 
130: 
131:     public function __isset($name)
132:     {
133:         return ObjectMixin::has($this, $name);
134:     }
135: 
136: 
137:     public function __unset($name)
138:     {
139:         ObjectMixin::remove($this, $name);
140:     }
141: 
142: }
143: 
Nette 2.2 API documentation generated by ApiGen 2.8.0