polyfill
polyfill copied to clipboard
Function signature checking should be improved
These errors below looks strange:
40) Warning
Incompatible signature for PHP >= 8:
- mb_ucfirst(string $string, ?string $encoding = null): string
+ mb_ucfirst(string $string, ?string $encoding = null): string
41) Warning
Incompatible signature for PHP >= 8:
- mb_lcfirst(string $string, ?string $encoding = null): string
+ mb_lcfirst(string $string, ?string $encoding = null): string
Internal functions up to PHP 8.0 implicitly accepted null as a string. It seems that the type is declared as ?string instead of string for compatibility in polyfills up to php80.
https://github.com/symfony/polyfill/blob/df4793d8de3390de9bb0aaf02cff7fa67ddc4a2a/src/Util/TestListenerTrait.php#L126-L136
In the code below, ? is removed to check the difference between the internal function and the polyfill interface.
PHP 8.4 deprecates implicit nullable, so this test should be replaced with more stringent checks.
refs https://github.com/symfony/polyfill/pull/471#issuecomment-2028519354
The implicit null in internal functions actually exists until PHP 9.0. It is deprecated in PHP 8.1 but it still works.