diff --git a/stubs/Php80.phpstub b/stubs/Php80.phpstub index 2f2d5bf0b9b..9a70506d912 100644 --- a/stubs/Php80.phpstub +++ b/stubs/Php80.phpstub @@ -247,6 +247,17 @@ function get_headers(string $url, bool $associative = false, $context = null) : */ function pack(string $format, mixed ...$values): string {} +/** + * @psalm-pure + * + * @param string|Stringable|int|float $values + * @return (PHP_MAJOR_VERSION is 8 ? string : string|false) + * @psalm-ignore-falsable-return + * + * @psalm-flow ($format, $values) -> return + */ +function sprintf(string $format, ...$values) {} + final class CurlHandle { private function __construct() diff --git a/tests/CoreStubsTest.php b/tests/CoreStubsTest.php index ed3d0b76327..b0189897090 100644 --- a/tests/CoreStubsTest.php +++ b/tests/CoreStubsTest.php @@ -125,6 +125,18 @@ function foo(string $foo): string '$a===' => 'string', ], ]; + yield 'sprintf accepts Stringable values' => [ + 'code' => ' [], + 'ignored_issues' => [], + 'php_version' => '8.0', + ]; yield 'json_encode returns a non-empty-string provided JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE' => [ 'code' => '