1 | <?php namespace Limoncello\Flute\Validation\JsonApi\Execution; |
||
30 | class JsonApiDataRulesSerializer extends RulesSerializer implements JsonApiDataRulesSerializerInterface |
||
31 | { |
||
32 | /** Serialized indexes key */ |
||
33 | protected const SERIALIZED_RULES = 0; |
||
34 | |||
35 | /** Serialized rules key */ |
||
36 | protected const SERIALIZED_BLOCKS = self::SERIALIZED_RULES + 1; |
||
37 | |||
38 | /** Index key */ |
||
39 | protected const ID_SERIALIZED = 0; |
||
40 | |||
41 | /** Index key */ |
||
42 | protected const TYPE_SERIALIZED = self::ID_SERIALIZED + 1; |
||
43 | |||
44 | /** Index key */ |
||
45 | protected const ATTRIBUTES_SERIALIZED = self::TYPE_SERIALIZED + 1; |
||
46 | |||
47 | /** Index key */ |
||
48 | protected const TO_ONE_SERIALIZED = self::ATTRIBUTES_SERIALIZED + 1; |
||
49 | |||
50 | /** Index key */ |
||
51 | protected const TO_MANY_SERIALIZED = self::TO_ONE_SERIALIZED + 1; |
||
52 | |||
53 | /** |
||
54 | * @var array |
||
55 | */ |
||
56 | private $serializedRules = []; |
||
57 | |||
58 | /** |
||
59 | * @inheritdoc |
||
60 | */ |
||
61 | 28 | public function addRulesFromClass(string $rulesClass): JsonApiDataRulesSerializerInterface |
|
78 | |||
79 | /** |
||
80 | * @inheritdoc |
||
81 | */ |
||
82 | 44 | public function addDataRules( |
|
107 | |||
108 | /** |
||
109 | * @inheritdoc |
||
110 | * |
||
111 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
112 | */ |
||
113 | 44 | public function getData(): array |
|
120 | |||
121 | /** |
||
122 | * @inheritdoc |
||
123 | */ |
||
124 | 26 | public static function readRules(string $rulesClass, array $serializedData): array |
|
132 | |||
133 | /** |
||
134 | * @inheritdoc |
||
135 | */ |
||
136 | 26 | public static function hasRules(string $name, array $serializedData): bool |
|
143 | |||
144 | /** |
||
145 | * @inheritdoc |
||
146 | */ |
||
147 | 26 | public static function readBlocks(array $serializedData): array |
|
155 | |||
156 | /** |
||
157 | * @inheritdoc |
||
158 | */ |
||
159 | 26 | public static function readIdRuleIndexes(array $serializedRules): array |
|
167 | |||
168 | /** |
||
169 | * @inheritdoc |
||
170 | */ |
||
171 | 26 | public static function readTypeRuleIndexes(array $serializedRules): array |
|
179 | |||
180 | /** |
||
181 | * @inheritdoc |
||
182 | */ |
||
183 | 26 | public static function readAttributeRulesIndexes(array $serializedRules): array |
|
191 | |||
192 | /** |
||
193 | * @inheritdoc |
||
194 | */ |
||
195 | 26 | public static function readToOneRulesIndexes(array $serializedRules): array |
|
203 | |||
204 | /** |
||
205 | * @inheritdoc |
||
206 | */ |
||
207 | 26 | public static function readToManyRulesIndexes(array $serializedRules): array |
|
215 | |||
216 | /** |
||
217 | * @inheritdoc |
||
218 | */ |
||
219 | 19 | public static function readRuleIndex(array $ruleIndexes): int |
|
223 | |||
224 | /** |
||
225 | * @inheritdoc |
||
226 | */ |
||
227 | 20 | public static function readRuleStartIndexes(array $ruleIndexes): array |
|
231 | |||
232 | /** |
||
233 | * @inheritdoc |
||
234 | */ |
||
235 | 20 | public static function readRuleEndIndexes(array $ruleIndexes): array |
|
239 | |||
240 | /** |
||
241 | * @inheritdoc |
||
242 | */ |
||
243 | 26 | public static function readRulesIndexes(array $arrayRuleIndexes): array |
|
247 | |||
248 | /** |
||
249 | * @inheritdoc |
||
250 | */ |
||
251 | 26 | public static function readRulesStartIndexes(array $arrayRuleIndexes): array |
|
255 | |||
256 | /** |
||
257 | * @inheritdoc |
||
258 | */ |
||
259 | 26 | public static function readRulesEndIndexes(array $arrayRuleIndexes): array |
|
263 | |||
264 | /** |
||
265 | * @inheritdoc |
||
266 | */ |
||
267 | 6 | public static function readSingleRuleIndexes(array $arrayRuleIndexes, string $name): array |
|
271 | |||
272 | /** |
||
273 | * @inheritdoc |
||
274 | */ |
||
275 | 21 | public static function hasRule(int $index, array $blocks): bool |
|
281 | |||
282 | /** |
||
283 | * @param string $rulesClass |
||
284 | * |
||
285 | * @return bool |
||
286 | */ |
||
287 | 28 | private static function isRulesClass(string $rulesClass): bool |
|
293 | } |
||
294 |
Let’s assume you have a class which uses late-static binding:
}
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: