1: <?php
2:
3: /**
4: * This file is part of the Nette Framework.
5: *
6: * Copyright (c) 2004, 2010 David Grudl (http://davidgrudl.com)
7: *
8: * This source file is subject to the "Nette license", and/or
9: * GPL license. For more information please see http://nette.org
10: * @package Nette\Reflection
11: */
12:
13:
14:
15: /**
16: * Reports information about a function.
17: *
18: * @author David Grudl
19: */
20: class FunctionReflection extends ReflectionFunction
21: {
22: /** @var string|Closure */
23: private $value;
24:
25:
26: public function __construct($name)
27: {
28: parent::__construct($this->value = $name);
29: }
30:
31:
32:
33: public function __toString()
34: {
35: return 'Function ' . $this->getName() . '()';
36: }
37:
38:
39:
40: public function getClosure()
41: {
42: return $this->isClosure() ? $this->value : NULL;
43: }
44:
45:
46:
47: /********************* Reflection layer ****************d*g**/
48:
49:
50:
51: /**
52: * @return ExtensionReflection
53: */
54: public function getExtension()
55: {
56: return ($name = $this->getExtensionName()) ? new ExtensionReflection($name) : NULL;
57: }
58:
59:
60:
61: public function getParameters()
62: {
63: foreach ($res = parent::getParameters() as $key => $val) {
64: $res[$key] = new ParameterReflection($this->value, $val->getName());
65: }
66: return $res;
67: }
68:
69:
70:
71: /********************* Object behaviour ****************d*g**/
72:
73:
74:
75: /**
76: * @return ClassReflection
77: */
78: public function getReflection()
79: {
80: return new ClassReflection($this);
81: }
82:
83:
84:
85: public function __call($name, $args)
86: {
87: return ObjectMixin::call($this, $name, $args);
88: }
89:
90:
91:
92: public function &__get($name)
93: {
94: return ObjectMixin::get($this, $name);
95: }
96:
97:
98:
99: public function __set($name, $value)
100: {
101: return ObjectMixin::set($this, $name, $value);
102: }
103:
104:
105:
106: public function __isset($name)
107: {
108: return ObjectMixin::has($this, $name);
109: }
110:
111:
112:
113: public function __unset($name)
114: {
115: throw new MemberAccessException("Cannot unset the property {$this->reflection->name}::\$$name.");
116: }
117:
118: }
119: