mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 12:55:26 +01:00
make tests work in PHP < 8.2
This commit is contained in:
parent
1ff8518888
commit
9e463bbe75
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Psalm\Internal\Analyzer\Statements\Expression\Call;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use PhpParser;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Codebase;
|
||||
@ -1267,10 +1268,15 @@ final class ArgumentsAnalyzer
|
||||
$codebase = $statements_analyzer->getCodebase();
|
||||
$declaring_property_class = (string) $codebase->properties->getDeclaringClassForProperty(
|
||||
$property_id,
|
||||
false, # what does this do? @todo
|
||||
true,
|
||||
$statements_analyzer,
|
||||
);
|
||||
|
||||
try {
|
||||
$declaring_class_storage = $codebase->classlike_storage_provider->get($declaring_property_class);
|
||||
} catch (InvalidArgumentException $_) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($declaring_class_storage->properties[$prop_name])) {
|
||||
$property_storage = $declaring_class_storage->properties[$prop_name];
|
||||
@ -1310,7 +1316,7 @@ final class ArgumentsAnalyzer
|
||||
if ($arg->value instanceof PhpParser\Node\Expr\PropertyFetch
|
||||
&& $arg->value->name instanceof PhpParser\Node\Identifier) {
|
||||
$prop_name = $arg->value->name->name;
|
||||
if ($statements_analyzer->getFQCLN()) {
|
||||
if (!empty($statements_analyzer->getFQCLN())) {
|
||||
$fq_class_name = $statements_analyzer->getFQCLN();
|
||||
|
||||
self::handleByRefReadonlyArg(
|
||||
|
@ -112,6 +112,8 @@ class TKeyedArray extends Atomic
|
||||
if ($cloned->is_list) {
|
||||
$last_k = -1;
|
||||
$had_possibly_undefined = false;
|
||||
|
||||
/** @psalm-suppress InaccessibleProperty */
|
||||
ksort($cloned->properties);
|
||||
foreach ($cloned->properties as $k => $v) {
|
||||
if (is_string($k) || $last_k !== ($k-1) || ($had_possibly_undefined && !$v->possibly_undefined)) {
|
||||
|
@ -768,8 +768,11 @@ class ImmutableAnnotationTest extends TestCase
|
||||
'code' => '<?php
|
||||
namespace World;
|
||||
|
||||
final readonly class Foo
|
||||
final class Foo
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
*/
|
||||
public array $values;
|
||||
|
||||
public function __construct(array $values)
|
||||
@ -777,7 +780,10 @@ class ImmutableAnnotationTest extends TestCase
|
||||
$this->values = $values;
|
||||
}
|
||||
|
||||
public function bar(): mixed
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function bar()
|
||||
{
|
||||
return reset($this->values);
|
||||
}
|
||||
@ -788,8 +794,11 @@ class ImmutableAnnotationTest extends TestCase
|
||||
'code' => '<?php
|
||||
namespace World;
|
||||
|
||||
final readonly class Foo
|
||||
final class Foo
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
*/
|
||||
public array $values;
|
||||
|
||||
public function __construct(array $values)
|
||||
@ -806,8 +815,11 @@ class ImmutableAnnotationTest extends TestCase
|
||||
'code' => '<?php
|
||||
namespace World;
|
||||
|
||||
final readonly class Foo
|
||||
final class Foo
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
*/
|
||||
public array $values;
|
||||
|
||||
public function __construct(array $values)
|
||||
|
Loading…
Reference in New Issue
Block a user