argument registration
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Reflection / MethodReflection.php
1 <?php
2
3 /* *
4 * This script belongs to the FLOW3 framework. *
5 * *
6 * It is free software; you can redistribute it and/or modify it under *
7 * the terms of the GNU Lesser General Public License as published by the *
8 * Free Software Foundation, either version 3 of the License, or (at your *
9 * option) any later version. *
10 * *
11 * This script is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
14 * General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with the script. *
18 * If not, see http://www.gnu.org/licenses/lgpl.html *
19 * *
20 * The TYPO3 project - inspiring people to share! *
21 * */
22
23 /**
24 * @package FLOW3
25 * @subpackage Reflection
26 * @version $Id: MethodReflection.php 1811 2009-01-28 12:04:49Z robert $
27 */
28
29 /**
30 * Extended version of the ReflectionMethod
31 *
32 * @package FLOW3
33 * @subpackage Reflection
34 * @version $Id: MethodReflection.php 1811 2009-01-28 12:04:49Z robert $
35 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
36 */
37 class Tx_ExtBase_Reflection_MethodReflection extends ReflectionMethod {
38
39 /**
40 * @var Tx_ExtBase_Reflection_DocCommentParser: An instance of the doc comment parser
41 */
42 protected $docCommentParser;
43
44 /**
45 * The constructor, initializes the reflection class
46 *
47 * @param string $className Name of the method's class
48 * @param string $methodName Name of the method to reflect
49 * @return void
50 * @author Robert Lemke <robert@typo3.org>
51 */
52 public function __construct($className, $methodName) {
53 parent::__construct($className, $methodName);
54 }
55
56 /**
57 * Returns the declaring class
58 *
59 * @return Tx_ExtBase_Reflection_ClassReflection The declaring class
60 * @author Robert Lemke <robert@typo3.org>
61 */
62 public function getDeclaringClass() {
63 return new Tx_ExtBase_Reflection_ClassReflection(parent::getDeclaringClass()->getName());
64 }
65
66 /**
67 * Replacement for the original getParameters() method which makes sure
68 * that Tx_ExtBase_Reflection_ParameterReflection objects are returned instead of the
69 * orginal ReflectionParameter instances.
70 *
71 * @return array of Tx_ExtBase_Reflection_ParameterReflection Parameter reflection objects of the parameters of this method
72 * @author Robert Lemke <robert@typo3.org>
73 */
74 public function getParameters() {
75 $extendedParameters = array();
76 foreach (parent::getParameters() as $parameter) {
77 $extendedParameters[] = new Tx_ExtBase_Reflection_ParameterReflection(array($this->getDeclaringClass()->getName(), $this->getName()), $parameter->getName());
78 }
79 return $extendedParameters;
80 }
81
82 /**
83 * Checks if the doc comment of this method is tagged with
84 * the specified tag
85 *
86 * @param string $tag Tag name to check for
87 * @return boolean TRUE if such a tag has been defined, otherwise FALSE
88 */
89 public function isTaggedWith($tag) {
90 $result = $this->getDocCommentParser()->isTaggedWith($tag);
91 return $result;
92 }
93
94 /**
95 * Returns an array of tags and their values
96 *
97 * @return array Tags and values
98 * @author Robert Lemke <robert@typo3.org>
99 */
100 public function getTagsValues() {
101 return $this->getDocCommentParser()->getTagsValues();
102 }
103
104 /**
105 * Returns the values of the specified tag
106 *
107 * @param string $tag Tag name to check for
108 * @return array Values of the given tag
109 * @author Robert Lemke <robert@typo3.org>
110 */
111 public function getTagValues($tag) {
112 return $this->getDocCommentParser()->getTagValues($tag);
113 }
114
115 /**
116 * Returns an instance of the doc comment parser and
117 * runs the parse() method.
118 *
119 * @return Tx_ExtBase_Reflection_DocCommentParser
120 * @author Robert Lemke <robert@typo3.org>
121 */
122 protected function getDocCommentParser() {
123 if (!is_object($this->docCommentParser)) {
124 $this->docCommentParser = new Tx_ExtBase_Reflection_DocCommentParser;
125 $this->docCommentParser->parseDocComment($this->getDocComment());
126 }
127 return $this->docCommentParser;
128 }
129 }
130
131 ?>