1 | <?php declare (strict_types = 1); |
||
27 | class Validation |
||
28 | { |
||
29 | /** @var string Namespace name for message keys. */ |
||
30 | const NAMESPACE_NAME = 'Limoncello.Flute.Validation'; |
||
31 | |||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | private static $messages = EnUsLocale::MESSAGES + [ |
||
36 | ErrorCodes::TYPE_MISSING => 'JSON API type should be specified.', |
||
37 | ErrorCodes::INVALID_ATTRIBUTES => 'JSON API attributes are invalid.', |
||
38 | ErrorCodes::UNKNOWN_ATTRIBUTE => 'Unknown JSON API attribute.', |
||
39 | ErrorCodes::INVALID_RELATIONSHIP_TYPE => 'The value should be a valid JSON API relationship type.', |
||
40 | ErrorCodes::INVALID_RELATIONSHIP => 'Invalid JSON API relationship.', |
||
41 | ErrorCodes::UNKNOWN_RELATIONSHIP => 'Unknown JSON API relationship.', |
||
42 | ErrorCodes::EXIST_IN_DATABASE_SINGLE => 'The value should be a valid identifier.', |
||
43 | ErrorCodes::EXIST_IN_DATABASE_MULTIPLE => 'The value should be valid identifiers.', |
||
44 | ErrorCodes::UNIQUE_IN_DATABASE_SINGLE => 'The value should be a unique identifier.', |
||
45 | ErrorCodes::INVALID_OPERATION_ARGUMENTS => 'Invalid Operation Arguments.', |
||
46 | ]; |
||
47 | |||
48 | /** |
||
49 | * @param int $errorCode |
||
50 | * |
||
51 | * @return string |
||
52 | */ |
||
53 | 21 | public static function convertCodeToDefaultMessage(int $errorCode): string |
|
57 | |||
58 | /** |
||
59 | * @inheritdoc |
||
60 | */ |
||
61 | 21 | protected static function getMessages(): array |
|
65 | } |
||
66 |
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: