1 | <?php |
||
18 | class Scope |
||
19 | { |
||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $scopeIdentifier; |
||
24 | |||
25 | /** |
||
26 | * @var Transform |
||
27 | */ |
||
28 | protected $transform; |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $parentScopes = []; |
||
34 | |||
35 | /** |
||
36 | * Scope constructor. |
||
37 | * @param Transform $transform |
||
38 | * @param string|null $scopeIdentifier |
||
39 | * @param array $parentScopes |
||
40 | */ |
||
41 | public function __construct( |
||
50 | |||
51 | /** |
||
52 | * @return Transform |
||
53 | */ |
||
54 | public function getTransform(): Transform |
||
58 | |||
59 | /** |
||
60 | * @param $key |
||
61 | * @return ParamBag |
||
62 | */ |
||
63 | public function getParams(string $key = null): ParamBag |
||
69 | |||
70 | /** |
||
71 | * Get the current identifier. |
||
72 | * |
||
73 | * @return string|null |
||
74 | */ |
||
75 | public function getScopeIdentifier() |
||
79 | |||
80 | /** |
||
81 | * Get the unique identifier for this scope. |
||
82 | * |
||
83 | * @param string $appendIdentifier |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | public function getIdentifier(string $appendIdentifier = null): string |
||
100 | |||
101 | /** |
||
102 | * Getter for parentScopes. |
||
103 | * |
||
104 | * @return array |
||
105 | */ |
||
106 | public function getParentScopes(): array |
||
110 | |||
111 | /** |
||
112 | * Is Requested. |
||
113 | * |
||
114 | * Check if - in relation to the current scope - this specific segment is allowed. |
||
115 | * That means, if a.b.c is requested and the current scope is a.b, then c is allowed. If the current |
||
116 | * scope is a then c is not allowed, even if it is there and potentially transformable. |
||
117 | * |
||
118 | * @internal |
||
119 | * |
||
120 | * @param string $checkScopeSegment |
||
121 | * |
||
122 | * @return bool Returns the new number of elements in the array. |
||
123 | */ |
||
124 | public function isRequested($checkScopeSegment): bool |
||
131 | |||
132 | /** |
||
133 | * Is Excluded. |
||
134 | * |
||
135 | * Check if - in relation to the current scope - this specific segment should |
||
136 | * be excluded. That means, if a.b.c is excluded and the current scope is a.b, |
||
137 | * then c will not be allowed in the transformation whether it appears in |
||
138 | * the list of default or available, requested includes. |
||
139 | * |
||
140 | * @internal |
||
141 | * |
||
142 | * @param string $checkScopeSegment |
||
143 | * |
||
144 | * @return bool |
||
145 | */ |
||
146 | public function isExcluded($checkScopeSegment): bool |
||
153 | |||
154 | /** |
||
155 | * @param TransformerInterface|callable $transformer |
||
156 | * @param mixed $data |
||
157 | * @return array |
||
158 | */ |
||
159 | public function transform(callable $transformer, $data): array |
||
183 | |||
184 | /** |
||
185 | * @param callable $transformer |
||
186 | * @param string $key |
||
187 | * @return bool |
||
188 | */ |
||
189 | protected function includeValue(callable $transformer, string $key): bool |
||
206 | |||
207 | /** |
||
208 | * @param $val |
||
209 | * @param $data |
||
210 | * @param string|null $key |
||
211 | * @return array|string|null |
||
212 | */ |
||
213 | protected function parseValue($val, $data, string $key = null) |
||
221 | |||
222 | /** |
||
223 | * @param string $identifier |
||
224 | * @return Scope |
||
225 | */ |
||
226 | public function childScope(string $identifier): Scope |
||
237 | |||
238 | /** |
||
239 | * Check, if this is the root scope. |
||
240 | * |
||
241 | * @return bool |
||
242 | */ |
||
243 | protected function isRootScope(): bool |
||
247 | |||
248 | /** |
||
249 | * Filter the provided data with the requested filter fields for |
||
250 | * the scope resource |
||
251 | * |
||
252 | * @internal |
||
253 | * |
||
254 | * @param array $data |
||
255 | * |
||
256 | * @return array |
||
257 | */ |
||
258 | protected function filterFields(array $data): array |
||
273 | |||
274 | /** |
||
275 | * Return the requested filter fields for the scope resource |
||
276 | * |
||
277 | * @internal |
||
278 | * |
||
279 | * @return ParamBag|null |
||
280 | */ |
||
281 | protected function getFilterFields() |
||
287 | |||
288 | /** |
||
289 | * @param string $checkScopeSegment |
||
290 | * @return string |
||
291 | */ |
||
292 | private function scopeString(string $checkScopeSegment): string |
||
303 | } |
||
304 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.