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