1 | <?php |
||
22 | class ArrayScope extends AbstractScope |
||
23 | { |
||
24 | |||
25 | /** |
||
26 | * Scope constructor. |
||
27 | * @param ConfigurableTransform $transform |
||
28 | * @param string|null $scopeIdentifier |
||
29 | * @param array $parentScopes |
||
30 | */ |
||
31 | public function __construct( |
||
38 | |||
39 | /** |
||
40 | * Is Requested. |
||
41 | * |
||
42 | * Check if - in relation to the current scope - this specific segment is allowed. |
||
43 | * That means, if a.b.c is requested and the current scope is a.b, then c is allowed. If the current |
||
44 | * scope is a then c is not allowed, even if it is there and potentially transformable. |
||
45 | * |
||
46 | * @internal |
||
47 | * |
||
48 | * @param string $checkScopeSegment |
||
49 | * |
||
50 | * @return bool Returns the new number of elements in the array. |
||
51 | */ |
||
52 | protected function isRequested($checkScopeSegment): bool |
||
59 | |||
60 | /** |
||
61 | * Is Excluded. |
||
62 | * |
||
63 | * Check if - in relation to the current scope - this specific segment should |
||
64 | * be excluded. That means, if a.b.c is excluded and the current scope is a.b, |
||
65 | * then c will not be allowed in the transformation whether it appears in |
||
66 | * the list of default or available, requested includes. |
||
67 | * |
||
68 | * @internal |
||
69 | * |
||
70 | * @param string $checkScopeSegment |
||
71 | * |
||
72 | * @return bool |
||
73 | */ |
||
74 | protected function isExcluded($checkScopeSegment): bool |
||
81 | |||
82 | /** |
||
83 | * @param TransformerInterface|callable $transformer |
||
84 | * @param mixed $data |
||
85 | * @return array |
||
86 | */ |
||
87 | public function transform(callable $transformer, $data): array |
||
115 | |||
116 | /** |
||
117 | * @param callable $transformer |
||
118 | * @param string $key |
||
119 | * @return bool |
||
120 | */ |
||
121 | protected function includeValue(callable $transformer, string $key): bool |
||
138 | |||
139 | /** |
||
140 | * Filter the provided data with the requested filter fields for |
||
141 | * the scope resource |
||
142 | * |
||
143 | * @internal |
||
144 | * |
||
145 | * @param array $data |
||
146 | * |
||
147 | * @return array |
||
148 | */ |
||
149 | protected function filterFields(array $data): array |
||
164 | |||
165 | /** |
||
166 | * Return the requested filter fields for the scope resource |
||
167 | * |
||
168 | * @internal |
||
169 | * |
||
170 | * @return ParamBag|null |
||
171 | */ |
||
172 | protected function getFilterFields() |
||
178 | |||
179 | /** |
||
180 | * @param string $checkScopeSegment |
||
181 | * @return string |
||
182 | */ |
||
183 | private function scopeString(string $checkScopeSegment): string |
||
194 | } |
||
195 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.