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