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: * @package Nette\Reflection
7: */
8:
9:
10:
11: /**
12: * Reports information about a function.
13: *
14: * @author David Grudl
15: * @property-read array $defaultParameters
16: * @property-read bool $closure
17: * @property-read NExtensionReflection $extension
18: * @property-read NParameterReflection[] $parameters
19: * @property-read bool $disabled
20: * @property-read bool $deprecated
21: * @property-read bool $internal
22: * @property-read bool $userDefined
23: * @property-read string $docComment
24: * @property-read int $endLine
25: * @property-read string $extensionName
26: * @property-read string $fileName
27: * @property-read string $name
28: * @property-read string $namespaceName
29: * @property-read int $numberOfParameters
30: * @property-read int $numberOfRequiredParameters
31: * @property-read string $shortName
32: * @property-read int $startLine
33: * @property-read array $staticVariables
34: * @package Nette\Reflection
35: */
36: class NFunctionReflection extends ReflectionFunction
37: {
38: /** @var string|Closure */
39: private $value;
40:
41:
42: public function __construct($name)
43: {
44: parent::__construct($this->value = $name);
45: }
46:
47:
48: /**
49: * @return NCallback
50: */
51: public function toCallback()
52: {
53: return new NCallback($this->value);
54: }
55:
56:
57: public function __toString()
58: {
59: return 'Function ' . $this->getName() . '()';
60: }
61:
62:
63: public function getClosure()
64: {
65: return $this->isClosure() ? $this->value : NULL;
66: }
67:
68:
69: /********************* Reflection layer ****************d*g**/
70:
71:
72: /**
73: * @return NExtensionReflection
74: */
75: public function getExtension()
76: {
77: return ($name = $this->getExtensionName()) ? new NExtensionReflection($name) : NULL;
78: }
79:
80:
81: /**
82: * @return NParameterReflection[]
83: */
84: public function getParameters()
85: {
86: foreach ($res = parent::getParameters() as $key => $val) {
87: $res[$key] = new NParameterReflection($this->value, $val->getName());
88: }
89: return $res;
90: }
91:
92:
93: /********************* NObject behaviour ****************d*g**/
94:
95:
96: /**
97: * @return NClassReflection
98: */
99: public function getReflection()
100: {
101: return new NClassReflection($this);
102: }
103:
104:
105: public function __call($name, $args)
106: {
107: return NObjectMixin::call($this, $name, $args);
108: }
109:
110:
111: public function &__get($name)
112: {
113: return NObjectMixin::get($this, $name);
114: }
115:
116:
117: public function __set($name, $value)
118: {
119: NObjectMixin::set($this, $name, $value);
120: }
121:
122:
123: public function __isset($name)
124: {
125: return NObjectMixin::has($this, $name);
126: }
127:
128:
129: public function __unset($name)
130: {
131: NObjectMixin::remove($this, $name);
132: }
133:
134: }
135: