‪TYPO3CMS  11.5
Property.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
25 {
29  private ‪$name;
30 
34  private ‪$definition;
35 
39  private ‪$characteristics;
40 
45  public function ‪__construct(string ‪$name, array ‪$definition)
46  {
47  $this->name = ‪$name;
48  $this->characteristics = new ‪PropertyCharacteristics(‪$definition['propertyCharacteristicsBit']);
49  unset(‪$definition['propertyCharacteristicsBit']);
50 
51  $defaults = [
52  'c' => null, // cascade
53  'd' => null, // defaultValue
54  't' => null, // type
55  'e' => null, // elementType
56  'n' => false, // nullable
57  'v' => [], // validators
58  ];
59 
60  foreach ($defaults as $key => $defaultValue) {
61  if (!isset(‪$definition[$key])) {
62  ‪$definition[$key] = $defaultValue;
63  }
64  }
65 
66  $this->definition = ‪$definition;
67  }
68 
72  public function ‪getName(): string
73  {
74  return ‪$this->name;
75  }
76 
84  public function ‪getType(): ?string
85  {
86  return $this->definition['t'];
87  }
88 
99  public function ‪getElementType(): ?string
100  {
101  return $this->definition['e'];
102  }
103 
107  public function ‪isPublic(): bool
108  {
109  return $this->characteristics->get(‪PropertyCharacteristics::VISIBILITY_PUBLIC);
110  }
111 
115  public function ‪isProtected(): bool
116  {
117  return $this->characteristics->get(‪PropertyCharacteristics::VISIBILITY_PROTECTED);
118  }
119 
123  public function ‪isPrivate(): bool
124  {
125  return $this->characteristics->get(‪PropertyCharacteristics::VISIBILITY_PRIVATE);
126  }
127 
131  public function ‪isLazy(): bool
132  {
133  return $this->characteristics->get(‪PropertyCharacteristics::ANNOTATED_LAZY);
134  }
135 
139  public function ‪isTransient(): bool
140  {
141  return $this->characteristics->get(‪PropertyCharacteristics::ANNOTATED_TRANSIENT);
142  }
143 
144  public function ‪isNullable(): bool
145  {
146  return (bool)$this->definition['n'];
147  }
148 
152  public function ‪isInjectProperty(): bool
153  {
154  return $this->characteristics->get(‪PropertyCharacteristics::ANNOTATED_INJECT);
155  }
156 
160  public function ‪getValidators(): array
161  {
162  return $this->definition['v'];
163  }
164 
168  public function ‪getDefaultValue()
169  {
170  return $this->definition['d'];
171  }
172 
176  public function ‪getCascadeValue(): ?string
177  {
178  return $this->definition['c'];
179  }
180 }
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\PropertyCharacteristics\ANNOTATED_INJECT
‪const ANNOTATED_INJECT
Definition: PropertyCharacteristics.php:33
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\isProtected
‪bool isProtected()
Definition: Property.php:112
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\getType
‪string null getType()
Definition: Property.php:81
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\isLazy
‪bool isLazy()
Definition: Property.php:128
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\$definition
‪array $definition
Definition: Property.php:32
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\isTransient
‪bool isTransient()
Definition: Property.php:136
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\getDefaultValue
‪mixed getDefaultValue()
Definition: Property.php:165
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\__construct
‪__construct(string $name, array $definition)
Definition: Property.php:42
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\PropertyCharacteristics\ANNOTATED_LAZY
‪const ANNOTATED_LAZY
Definition: PropertyCharacteristics.php:31
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\$name
‪string $name
Definition: Property.php:28
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\PropertyCharacteristics\VISIBILITY_PUBLIC
‪const VISIBILITY_PUBLIC
Definition: PropertyCharacteristics.php:29
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\PropertyCharacteristics\VISIBILITY_PRIVATE
‪const VISIBILITY_PRIVATE
Definition: PropertyCharacteristics.php:27
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\isPublic
‪bool isPublic()
Definition: Property.php:104
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\isInjectProperty
‪bool isInjectProperty()
Definition: Property.php:149
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\getValidators
‪array getValidators()
Definition: Property.php:157
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\$characteristics
‪PropertyCharacteristics $characteristics
Definition: Property.php:36
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\PropertyCharacteristics
Definition: PropertyCharacteristics.php:26
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property
Definition: Property.php:25
‪TYPO3\CMS\Extbase\Reflection\ClassSchema
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\getName
‪string getName()
Definition: Property.php:69
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\isPrivate
‪bool isPrivate()
Definition: Property.php:120
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\getCascadeValue
‪string null getCascadeValue()
Definition: Property.php:173
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\getElementType
‪string null getElementType()
Definition: Property.php:96
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\PropertyCharacteristics\ANNOTATED_TRANSIENT
‪const ANNOTATED_TRANSIENT
Definition: PropertyCharacteristics.php:32
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\Property\isNullable
‪isNullable()
Definition: Property.php:141
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\PropertyCharacteristics\VISIBILITY_PROTECTED
‪const VISIBILITY_PROTECTED
Definition: PropertyCharacteristics.php:28