mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Merge branch '5.x' of https://github.com/cgocast/psalm into 5.x
This commit is contained in:
commit
2eca720e9d
@ -115,7 +115,11 @@ class FileStatementsDiffer extends AstDiffer
|
||||
$b_code,
|
||||
);
|
||||
|
||||
$keep = [...$keep, ...$class_keep[0]];
|
||||
if ($diff_elem->old->getDocComment() === $diff_elem->new->getDocComment()) {
|
||||
$keep = [...$keep, ...$class_keep[0]];
|
||||
} else {
|
||||
$keep_signature = [...$keep_signature, ...$class_keep[0]];
|
||||
}
|
||||
$keep_signature = [...$keep_signature, ...$class_keep[1]];
|
||||
$add_or_delete = [...$add_or_delete, ...$class_keep[2]];
|
||||
$diff_map = [...$diff_map, ...$class_keep[3]];
|
||||
|
@ -1292,7 +1292,7 @@ function preg_quote(string $str, ?string $delimiter = null) : string {}
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string|int|float $values
|
||||
* @param string|stringable-object|int|float $values
|
||||
* @return (PHP_MAJOR_VERSION is 8 ? string : string|false)
|
||||
* @psalm-ignore-falsable-return
|
||||
*
|
||||
|
@ -199,5 +199,54 @@ class CacheTest extends TestCase
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
yield 'classDocblockChange' => [
|
||||
[
|
||||
[
|
||||
'files' => [
|
||||
'/src/A.php' => <<<'PHP'
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
class A {
|
||||
/**
|
||||
* @param T $baz
|
||||
*/
|
||||
public function foo($baz): void
|
||||
{
|
||||
}
|
||||
}
|
||||
PHP,
|
||||
],
|
||||
'issues' => [],
|
||||
],
|
||||
[
|
||||
'files' => [
|
||||
'/src/A.php' => <<<'PHP'
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @template K
|
||||
*/
|
||||
class A {
|
||||
/**
|
||||
* @param T $baz
|
||||
*/
|
||||
public function foo($baz): void
|
||||
{
|
||||
}
|
||||
}
|
||||
PHP,
|
||||
],
|
||||
'issues' => [
|
||||
'/src/A.php' => [
|
||||
"UndefinedDocblockClass: Docblock-defined class, interface or enum named T does not exist",
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -261,19 +261,6 @@ class ToStringTest extends TestCase
|
||||
fooFoo(new A());',
|
||||
'error_message' => 'InvalidArgument',
|
||||
],
|
||||
'implicitCastWithStrictTypesToEchoOrSprintf' => [
|
||||
'code' => '<?php declare(strict_types=1);
|
||||
class A {
|
||||
public function __toString(): string
|
||||
{
|
||||
return "hello";
|
||||
}
|
||||
}
|
||||
|
||||
echo(new A());
|
||||
sprintf("hello *", new A());',
|
||||
'error_message' => 'ImplicitToStringCast',
|
||||
],
|
||||
'implicitCast' => [
|
||||
'code' => '<?php
|
||||
class A {
|
||||
|
Loading…
Reference in New Issue
Block a user