1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

fix incorrect default stubs

This commit is contained in:
kkmuffme 2023-06-24 17:31:44 +02:00
parent 28b9e8dd95
commit 7f0217d1e3
2 changed files with 5 additions and 13 deletions

View File

@ -130,13 +130,7 @@ class SprintfReturnTypeProvider implements FunctionReturnTypeProviderInterface
'/%(?:\d+\$)?[-+]?(?:\d+|\*)(?:\.(?:\d+|\*))?[bcdouxXeEfFgGhHs]/',
$type->getSingleStringLiteral()->value,
) === 1) {
if ($event->getFunctionId() === 'printf') {
return null;
}
// the core stubs are wrong for these too, since these might be empty strings
// e.g. sprintf(\'%0.*s\', 0, "abc")
return Type::getString();
return null;
}
// assume a random, high number for tests

View File

@ -1279,9 +1279,7 @@ function preg_quote(string $str, ?string $delimiter = null) : string {}
* @psalm-pure
*
* @param string|int|float $values
* @return ($format is non-empty-string
* ? ($values is non-empty-string|int|float ? non-empty-string : string)
* : string)
* @return (PHP_MAJOR_VERSION is 8 ? string : string|false)
*
* @psalm-flow ($format, $values) -> return
*/
@ -1290,7 +1288,7 @@ function sprintf(string $format, ...$values) {}
/**
* @psalm-pure
* @param array<string|int|float> $values
* @return string|false
* @return (PHP_MAJOR_VERSION is 8 ? string : string|false)
* @psalm-ignore-falsable-return
*
* @psalm-flow ($format, $values) -> return
@ -1309,7 +1307,7 @@ function wordwrap(string $string, int $width = 75, string $break = "\n", bool $c
* @psalm-pure
*
* @param string|int|float $values
* @return int<0, max>
* @return (PHP_MAJOR_VERSION is 8 ? int<0, max> : int<0, max>|false)
*
* @psalm-taint-specialize
* @psalm-flow ($format, $values) -> return
@ -1320,7 +1318,7 @@ function printf(string $format, ...$values) {}
/**
* @param array<string|int|float> $values
* @return int<0, max>
* @return (PHP_MAJOR_VERSION is 8 ? int<0, max> : int<0, max>|false)
*
* @psalm-pure
* @psalm-taint-specialize