1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

fix is_object assertions

This commit is contained in:
Daniil Gentili 2023-04-20 14:03:20 +02:00
parent e2957a1631
commit baff6fb36a
2 changed files with 11 additions and 5 deletions

View File

@ -1609,11 +1609,7 @@ class SimpleAssertionReconciler extends Reconciler
&& self::areIntersectionTypesAllowed($codebase, $type)
) {
$object_types[] = $type->addIntersectionType($assertion_type);
$redundant = false;
} elseif ($type instanceof TNamedObject
&& $codebase->classlike_storage_provider->has($type->value)
&& $codebase->classlike_storage_provider->get($type->value)->final
) {
// This is wrong, a proper check for redundant object shape assertions should be added
$redundant = false;
} elseif ($type->isObjectType()) {
$object_types[] = $type;

View File

@ -1334,6 +1334,16 @@ class TypeTest extends TestCase
/** @param non-empty-array $a */
function expectNonEmptyArray(array $a): array { return $a; }',
],
'isObjectMakesObject' => [
'code' => '<?php
final class test {}
/** @var array|int|float|test|null */
$a = null;
if (\is_object($a)) {
}',
],
];
}