TYPO3 CMS  TYPO3_8-7
PropertyReflection.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 PropertyReflection extends \ReflectionProperty
21 {
25  protected $docCommentParser;
26 
34  public function isTaggedWith($tag)
35  {
36  $result = $this->getDocCommentParser()->isTaggedWith($tag);
37  return $result;
38  }
39 
45  public function getTagsValues()
46  {
47  return $this->getDocCommentParser()->getTagsValues();
48  }
49 
56  public function getTagValues($tag)
57  {
58  return $this->getDocCommentParser()->getTagValues($tag);
59  }
60 
69  public function getValue($object = null)
70  {
71  if (!is_object($object)) {
72  throw new Exception('$object is of type ' . gettype($object) . ', instance of class ' . $this->class . ' expected.', 1210859212);
73  }
74  if ($this->isPublic()) {
75  return parent::getValue($object);
76  }
77  if ($this->isPrivate()) {
78  throw new Exception('Cannot return value of private property "' . $this->name . '.', 1210859206);
79  }
80  parent::setAccessible(true);
81  return parent::getValue($object);
82  }
83 
90  protected function getDocCommentParser()
91  {
92  if (!is_object($this->docCommentParser)) {
93  $this->docCommentParser = new DocCommentParser();
94  $this->docCommentParser->parseDocComment($this->getDocComment());
95  }
97  }
98 }