Skip to content

Function signature checking should be improved #473

Open
@zonuexe

Description

@zonuexe

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.

$map = [
'?' => '',
'IDNA_DEFAULT' => \PHP_VERSION_ID >= 80100 ? 'IDNA_DEFAULT' : '0',
'array|string|null $string' => 'array|string $string',
'array|string|null $from_encoding = null' => 'array|string|null $from_encoding = null',
'array|string|null $from_encoding' => 'array|string $from_encoding',
];
if (strtr($polyfillSignature, $map) !== $originalSignature) {
$warnings[] = TestListener::warning("Incompatible signature for PHP >= 8:\n- {$f['name']}$originalSignature\n+ {$f['name']}$polyfillSignature");
}

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 #471 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions