1 | <?php declare(strict_types=1); |
||
35 | class IdentifierAndResource implements ResourceInterface |
||
36 | { |
||
37 | use ParseRelationshipDataTrait, ParseRelationshipLinksTrait; |
||
38 | |||
39 | /** @var string */ |
||
40 | public const MSG_NO_SCHEMA_FOUND = 'No Schema found for resource `%s` at path `%s`.'; |
||
41 | |||
42 | /** @var string */ |
||
43 | public const MSG_INVALID_OPERATION = 'Invalid operation.'; |
||
44 | |||
45 | /** |
||
46 | * @var EditableContextInterface |
||
47 | */ |
||
48 | private $context; |
||
49 | |||
50 | /** |
||
51 | * @var PositionInterface |
||
52 | */ |
||
53 | private $position; |
||
54 | |||
55 | /** |
||
56 | * @var FactoryInterface |
||
57 | */ |
||
58 | private $factory; |
||
59 | |||
60 | /** |
||
61 | * @var SchemaContainerInterface |
||
62 | */ |
||
63 | private $schemaContainer; |
||
64 | |||
65 | /** |
||
66 | * @var SchemaInterface |
||
67 | */ |
||
68 | private $schema; |
||
69 | |||
70 | /** |
||
71 | * @var mixed |
||
72 | */ |
||
73 | private $data; |
||
74 | |||
75 | /** |
||
76 | * @var string |
||
77 | */ |
||
78 | private $index; |
||
79 | |||
80 | /** |
||
81 | * @var string |
||
82 | */ |
||
83 | private $type; |
||
84 | |||
85 | /** |
||
86 | * @var null|array |
||
87 | */ |
||
88 | private $links = null; |
||
89 | |||
90 | /** |
||
91 | * @var null|array |
||
92 | */ |
||
93 | private $relationshipsCache = null; |
||
94 | |||
95 | /** |
||
96 | * @param EditableContextInterface $context |
||
97 | * @param PositionInterface $position |
||
98 | * @param FactoryInterface $factory |
||
99 | * @param SchemaContainerInterface $container |
||
100 | * @param mixed $data |
||
101 | */ |
||
102 | 65 | public function __construct( |
|
122 | |||
123 | /** |
||
124 | * @inheritdoc |
||
125 | */ |
||
126 | 65 | public function getPosition(): PositionInterface |
|
130 | |||
131 | /** |
||
132 | * @inheritdoc |
||
133 | */ |
||
134 | 65 | public function getId(): ?string |
|
138 | |||
139 | /** |
||
140 | * @inheritdoc |
||
141 | */ |
||
142 | 65 | public function getType(): string |
|
146 | |||
147 | /** |
||
148 | * @inheritdoc |
||
149 | */ |
||
150 | 35 | public function hasIdentifierMeta(): bool |
|
154 | |||
155 | /** |
||
156 | * @inheritdoc |
||
157 | */ |
||
158 | 2 | public function getIdentifierMeta() |
|
162 | |||
163 | /** |
||
164 | * @inheritdoc |
||
165 | */ |
||
166 | 62 | public function getAttributes(): iterable |
|
172 | |||
173 | /** |
||
174 | * @inheritdoc |
||
175 | * |
||
176 | * @SuppressWarnings(PHPMD.UndefinedVariable) PHPMD currently do not support `list` in `[]` syntax |
||
177 | */ |
||
178 | 64 | public function getRelationships(): iterable |
|
233 | |||
234 | /** |
||
235 | * @inheritdoc |
||
236 | */ |
||
237 | 62 | public function hasLinks(): bool |
|
243 | |||
244 | /** |
||
245 | * @inheritdoc |
||
246 | */ |
||
247 | 61 | public function getLinks(): iterable |
|
253 | |||
254 | /** |
||
255 | * @inheritdoc |
||
256 | */ |
||
257 | 62 | public function hasResourceMeta(): bool |
|
261 | |||
262 | /** |
||
263 | * @inheritdoc |
||
264 | */ |
||
265 | 1 | public function getResourceMeta() |
|
269 | |||
270 | /** |
||
271 | * @return EditableContextInterface |
||
272 | */ |
||
273 | 65 | protected function getContext(): EditableContextInterface |
|
277 | |||
278 | /** |
||
279 | * Read and parse links from schema. |
||
280 | */ |
||
281 | 62 | private function cacheLinks(): void |
|
292 | |||
293 | /** |
||
294 | * @param string $name |
||
295 | * @param array $description |
||
296 | * |
||
297 | * @return bool |
||
298 | */ |
||
299 | 49 | private function assertRelationshipNameAndDescription(string $name, array $description): bool |
|
312 | } |
||
313 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.