1 | <?php |
||
7 | class Formatter |
||
8 | { |
||
9 | /** |
||
10 | * Parse node name to namespace prefix and local name |
||
11 | * |
||
12 | * @param string $name |
||
13 | * |
||
14 | * @return array<int,string|null> |
||
15 | */ |
||
16 | public static function parseQualifiedName(string $name): array |
||
22 | |||
23 | /** |
||
24 | * Get local name from node name |
||
25 | * |
||
26 | * @param string $name |
||
27 | * |
||
28 | * @return string|null |
||
29 | */ |
||
30 | public static function getLocalName(string $name): ?string |
||
34 | |||
35 | /** |
||
36 | * Get namespace prefix from node name |
||
37 | * |
||
38 | * @param string $name |
||
39 | * |
||
40 | * @return string|null |
||
41 | */ |
||
42 | public static function getNamespacePrefix(string $name): ?string |
||
46 | |||
47 | /** |
||
48 | * Validate element name |
||
49 | * |
||
50 | * @param string $value |
||
51 | * |
||
52 | * @return void |
||
53 | * |
||
54 | * @throws \InvalidArgumentException |
||
55 | */ |
||
56 | private static function validateElementName(string $value): void |
||
66 | |||
67 | /** |
||
68 | * Normalize value. |
||
69 | * |
||
70 | * @param mixed $value |
||
71 | * |
||
72 | * @return mixed |
||
73 | */ |
||
74 | public static function encodeValue($value) |
||
82 | |||
83 | /** |
||
84 | * Normalize value. |
||
85 | * |
||
86 | * @param mixed $value |
||
87 | * |
||
88 | * @return mixed |
||
89 | */ |
||
90 | public static function decodeValue($value) |
||
106 | } |
||
107 |
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: