mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Allow Stringable in sprintf() values
This commit is contained in:
parent
83485f3fcf
commit
aa04c0063b
@ -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()
|
||||
|
@ -125,6 +125,18 @@ class CoreStubsTest extends TestCase
|
||||
'$a===' => 'string',
|
||||
],
|
||||
];
|
||||
yield 'sprintf accepts Stringable values' => [
|
||||
'code' => '<?php
|
||||
|
||||
$a = sprintf(
|
||||
"%s",
|
||||
new class implements Stringable { public function __toString(): string { return "hello"; } },
|
||||
);
|
||||
',
|
||||
'assertions' => [],
|
||||
'ignored_issues' => [],
|
||||
'php_version' => '8.0',
|
||||
];
|
||||
yield 'json_encode returns a non-empty-string provided JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE' => [
|
||||
'code' => '<?php
|
||||
$a = json_encode([], JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
|
||||
|
Loading…
Reference in New Issue
Block a user