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: * @package Nette\Reflection
11: */
12:
13:
14:
15: /**
16: * Reports information about a function.
17: *
18: * @author David Grudl
19: * @property-read array $defaultParameters
20: * @property-read bool $closure
21: * @property-read ExtensionReflection $extension
22: * @property-read ParameterReflection[] $parameters
23: * @property-read bool $disabled
24: * @property-read bool $deprecated
25: * @property-read bool $internal
26: * @property-read bool $userDefined
27: * @property-read string $docComment
28: * @property-read int $endLine
29: * @property-read string $extensionName
30: * @property-read string $fileName
31: * @property-read string $name
32: * @property-read string $namespaceName
33: * @property-read int $numberOfParameters
34: * @property-read int $numberOfRequiredParameters
35: * @property-read string $shortName
36: * @property-read int $startLine
37: * @property-read array $staticVariables
38: * @package Nette\Reflection
39: */
40: class FunctionReflection extends ReflectionFunction
41: {
42: /** @var string|Closure */
43: private $value;
44:
45:
46: public function __construct($name)
47: {
48: parent::__construct($this->value = $name);
49: }
50:
51:
52:
53: /**
54: * @return Callback
55: */
56: public function toCallback()
57: {
58: return new Callback($this->value);
59: }
60:
61:
62:
63: public function __toString()
64: {
65: return 'Function ' . $this->getName() . '()';
66: }
67:
68:
69:
70: public function getClosure()
71: {
72: return $this->isClosure() ? $this->value : NULL;
73: }
74:
75:
76:
77: /********************* Reflection layer ****************d*g**/
78:
79:
80:
81: /**
82: * @return ExtensionReflection
83: */
84: public function getExtension()
85: {
86: return ($name = $this->getExtensionName()) ? new ExtensionReflection($name) : NULL;
87: }
88:
89:
90:
91: /**
92: * @return ParameterReflection[]
93: */
94: public function getParameters()
95: {
96: foreach ($res = parent::getParameters() as $key => $val) {
97: $res[$key] = new ParameterReflection($this->value, $val->getName());
98: }
99: return $res;
100: }
101:
102:
103:
104: /********************* Object behaviour ****************d*g**/
105:
106:
107:
108: /**
109: * @return ClassReflection
110: */
111: public function getReflection()
112: {
113: return new ClassReflection($this);
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: