| 1 | <?php |
||
| 16 | class SymfonyFramework |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @return string |
||
| 20 | */ |
||
| 21 | public static function getContainerResolvableRootWebPath(): string |
||
| 22 | { |
||
| 23 | return sprintf('%%kernel.project_dir%%/%s', self::isKernelLessThan(4) ? 'web' : 'public'); |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @param int $major |
||
| 28 | * @param int|null $minor |
||
| 29 | * @param int|null $patch |
||
| 30 | * |
||
| 31 | * @return bool |
||
| 32 | */ |
||
| 33 | public static function isKernelGreaterThanOrEqualTo(int $major, int $minor = null, int $patch = null): bool |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param int $major |
||
| 40 | * @param int|null $minor |
||
| 41 | * @param int|null $patch |
||
| 42 | * |
||
| 43 | * @return bool |
||
| 44 | */ |
||
| 45 | public static function isKernelLessThan(int $major, int $minor = null, int $patch = null): bool |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param string $operator |
||
| 52 | * @param int $major |
||
| 53 | * @param int|null $minor |
||
| 54 | * @param int|null $patch |
||
| 55 | * |
||
| 56 | * @return bool |
||
| 57 | */ |
||
| 58 | private static function kernelVersionCompare(string $operator, int $major, int $minor = null, int $patch = null): bool |
||
| 62 | } |
||
| 63 |
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
SomeClassto useselfinstead: