TYPO3 CMS  TYPO3_8-7
ClassReflection.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 class ClassReflection extends \ReflectionClass
21 {
25  protected $docCommentParser;
26 
35  public function getMethods($filter = null)
36  {
37  $extendedMethods = [];
38  $methods = $filter === null ? parent::getMethods() : parent::getMethods($filter);
39  foreach ($methods as $method) {
40  $extendedMethods[] = new MethodReflection($this->getName(), $method->getName());
41  }
42  return $extendedMethods;
43  }
44 
53  public function getMethod($name)
54  {
55  $parentMethod = parent::getMethod($name);
56  if (!is_object($parentMethod)) {
57  return $parentMethod;
58  }
59  return new MethodReflection($this->getName(), $parentMethod->getName());
60  }
61 
69  public function getConstructor()
70  {
71  $parentConstructor = parent::getConstructor();
72  if (!is_object($parentConstructor)) {
73  return $parentConstructor;
74  }
75  return new MethodReflection($this->getName(), $parentConstructor->getName());
76  }
77 
86  public function getProperties($filter = null)
87  {
88  $extendedProperties = [];
89  $properties = $filter === null ? parent::getProperties() : parent::getProperties($filter);
90  foreach ($properties as $property) {
91  $extendedProperties[] = new PropertyReflection($this->getName(), $property->getName());
92  }
93  return $extendedProperties;
94  }
95 
104  public function getProperty($name)
105  {
106  return new PropertyReflection($this->getName(), $name);
107  }
108 
116  public function getInterfaces()
117  {
118  $extendedInterfaces = [];
119  $interfaces = parent::getInterfaces();
120  foreach ($interfaces as $interface) {
121  $extendedInterfaces[] = new self($interface->getName());
122  }
123  return $extendedInterfaces;
124  }
125 
133  public function getParentClass()
134  {
135  $parentClass = parent::getParentClass();
136  return $parentClass === false ? false : new self($parentClass->getName());
137  }
138 
146  public function isTaggedWith($tag)
147  {
148  $result = $this->getDocCommentParser()->isTaggedWith($tag);
149  return $result;
150  }
151 
157  public function getTagsValues()
158  {
159  return $this->getDocCommentParser()->getTagsValues();
160  }
161 
168  public function getTagValues($tag)
169  {
170  return $this->getDocCommentParser()->getTagValues($tag);
171  }
172 
179  protected function getDocCommentParser()
180  {
181  if (!is_object($this->docCommentParser)) {
182  $this->docCommentParser = new DocCommentParser();
183  $this->docCommentParser->parseDocComment($this->getDocComment());
184  }
186  }
187 }