1 | <?php namespace Limoncello\Flute\Validation\JsonApi\Execution; |
||
30 | class JsonApiQueryRulesSerializer extends RulesSerializer implements JsonApiQueryRulesSerializerInterface |
||
31 | { |
||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | private $serializedRules = []; |
||
36 | |||
37 | /** Index key */ |
||
38 | protected const FILTER_RULES = 0; |
||
39 | |||
40 | /** Index key */ |
||
41 | protected const FIELD_SET_RULES = self::FILTER_RULES + 1; |
||
42 | |||
43 | /** Index key */ |
||
44 | protected const SORTS_RULE = self::FIELD_SET_RULES + 1; |
||
45 | |||
46 | /** Index key */ |
||
47 | protected const INCLUDES_RULE = self::SORTS_RULE + 1; |
||
48 | |||
49 | /** Index key */ |
||
50 | protected const PAGE_OFFSET_RULE = self::INCLUDES_RULE + 1; |
||
51 | |||
52 | /** Index key */ |
||
53 | protected const PAGE_LIMIT_RULE = self::PAGE_OFFSET_RULE + 1; |
||
54 | |||
55 | /** Index key */ |
||
56 | protected const SINGLE_RULE_INDEX = 0; |
||
57 | |||
58 | /** Serialized indexes key */ |
||
59 | protected const SERIALIZED_RULES = 0; |
||
60 | |||
61 | /** Serialized rules key */ |
||
62 | protected const SERIALIZED_BLOCKS = self::SERIALIZED_RULES + 1; |
||
63 | |||
64 | /** |
||
65 | * @inheritdoc |
||
66 | */ |
||
67 | 43 | public function addRulesFromClass(string $rulesClass): JsonApiQueryRulesSerializerInterface |
|
85 | |||
86 | /** |
||
87 | * @param string $name |
||
88 | * @param RuleInterface[]|null $filterRules |
||
89 | * @param RuleInterface[]|null $fieldSetRules |
||
90 | * @param RuleInterface|null $sortsRule |
||
91 | * @param RuleInterface|null $includesRule |
||
92 | * @param RuleInterface|null $pageOffsetRule |
||
93 | * @param RuleInterface|null $pageLimitRule |
||
94 | * |
||
95 | * @return self |
||
96 | * |
||
97 | * @SuppressWarnings(PHPMD.CyclomaticComplexity) |
||
98 | * @SuppressWarnings(PHPMD.NPathComplexity) |
||
99 | */ |
||
100 | 43 | public function addQueryRules( |
|
134 | |||
135 | /** |
||
136 | * @inheritdoc |
||
137 | */ |
||
138 | 43 | public function getData(): array |
|
145 | |||
146 | /** |
||
147 | * @inheritdoc |
||
148 | */ |
||
149 | 52 | public static function readBlocks(array $serializedData): array |
|
153 | |||
154 | /** |
||
155 | * @inheritdoc |
||
156 | */ |
||
157 | 43 | public static function hasRules(string $name, array $serializedData): bool |
|
164 | |||
165 | /** |
||
166 | * @inheritdoc |
||
167 | */ |
||
168 | 32 | public static function readRules(string $name, array $serializedData): array |
|
174 | |||
175 | /** |
||
176 | * @inheritdoc |
||
177 | */ |
||
178 | 22 | public static function readFilterRulesIndexes(array $serializedRules): ?array |
|
182 | |||
183 | /** |
||
184 | * @inheritdoc |
||
185 | */ |
||
186 | 2 | public static function readFieldSetRulesIndexes(array $serializedRules): ?array |
|
190 | |||
191 | /** |
||
192 | * @inheritdoc |
||
193 | */ |
||
194 | 16 | public static function readSortsRuleIndexes(array $serializedRules): ?array |
|
198 | |||
199 | /** |
||
200 | * @inheritdoc |
||
201 | */ |
||
202 | 16 | public static function readIncludesRuleIndexes(array $serializedRules): ?array |
|
206 | |||
207 | /** |
||
208 | * @inheritdoc |
||
209 | */ |
||
210 | 31 | public static function readPageOffsetRuleIndexes(array $serializedRules): ?array |
|
214 | |||
215 | /** |
||
216 | * @inheritdoc |
||
217 | */ |
||
218 | 31 | public static function readPageLimitRuleIndexes(array $serializedRules): ?array |
|
222 | |||
223 | /** |
||
224 | * @inheritdoc |
||
225 | */ |
||
226 | 22 | public static function readRuleMainIndexes(array $ruleIndexes): ?array |
|
230 | |||
231 | /** |
||
232 | * @inheritdoc |
||
233 | */ |
||
234 | 30 | public static function readRuleMainIndex(array $ruleIndexes): ?int |
|
241 | |||
242 | /** |
||
243 | * @inheritdoc |
||
244 | */ |
||
245 | 30 | public static function readRuleStartIndexes(array $ruleIndexes): array |
|
249 | |||
250 | /** |
||
251 | * @inheritdoc |
||
252 | */ |
||
253 | 30 | public static function readRuleEndIndexes(array $ruleIndexes): array |
|
257 | |||
258 | /** |
||
259 | * @param string $rulesClass |
||
260 | * |
||
261 | * @return bool |
||
262 | */ |
||
263 | 43 | private static function isRulesClass(string $rulesClass): bool |
|
269 | } |
||
270 |
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: