1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://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: * @package Nette\Reflection
20: */
21: class NFunctionReflection extends ReflectionFunction
22: {
23: /** @var string|Closure */
24: private $value;
25:
26:
27: public function __construct($name)
28: {
29: parent::__construct($this->value = $name);
30: }
31:
32:
33:
34: public function __toString()
35: {
36: return 'Function ' . $this->getName() . '()';
37: }
38:
39:
40:
41: public function getClosure()
42: {
43: return $this->isClosure() ? $this->value : NULL;
44: }
45:
46:
47:
48: /********************* Reflection layer ****************d*g**/
49:
50:
51:
52: /**
53: * @return NExtensionReflection
54: */
55: public function getExtension()
56: {
57: return ($name = $this->getExtensionName()) ? new NExtensionReflection($name) : NULL;
58: }
59:
60:
61:
62: public function getParameters()
63: {
64: foreach ($res = parent::getParameters() as $key => $val) {
65: $res[$key] = new NParameterReflection($this->value, $val->getName());
66: }
67: return $res;
68: }
69:
70:
71:
72: /********************* NObject behaviour ****************d*g**/
73:
74:
75:
76: /**
77: * @return NClassReflection
78: */
79: public function getReflection()
80: {
81: return new NClassReflection($this);
82: }
83:
84:
85:
86: public function __call($name, $args)
87: {
88: return NObjectMixin::call($this, $name, $args);
89: }
90:
91:
92:
93: public function &__get($name)
94: {
95: return NObjectMixin::get($this, $name);
96: }
97:
98:
99:
100: public function __set($name, $value)
101: {
102: return NObjectMixin::set($this, $name, $value);
103: }
104:
105:
106:
107: public function __isset($name)
108: {
109: return NObjectMixin::has($this, $name);
110: }
111:
112:
113:
114: public function __unset($name)
115: {
116: throw new MemberAccessException("Cannot unset the property {$this->reflection->name}::\$$name.");
117: }
118:
119: }
120: