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

bugfix: allow object assertions for mixed

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
This commit is contained in:
Maximilian Bösing 2023-09-15 20:19:54 +02:00
parent 13ea0c241d
commit 3e100b15d9
No known key found for this signature in database
GPG Key ID: 9A8988C93CEC81A3
2 changed files with 17 additions and 1 deletions

View File

@ -1600,7 +1600,7 @@ class SimpleAssertionReconciler extends Reconciler
bool $is_equality
): Union {
if ($existing_var_type->hasMixed()) {
return Type::getObject();
return new Union([$assertion_type]);
}
$old_var_type_string = $existing_var_type->getId();

View File

@ -2967,6 +2967,22 @@ class AssertAnnotationTest extends TestCase
'ignored_issues' => [],
'php_version' => '8.1',
],
'objectShapeAssertion' => [
'code' => '<?php
/** @psalm-assert object{foo:string,bar:int} $value */
function assertObjectShape(mixed $value): void
{}
/** @var mixed $value */
$value = null;
assertObjectShape($value);
',
'assertions' => [
'$value===' => 'object{foo:string, bar:int}',
],
'ignored_issues' => [],
'php_version' => '8.0',
],
];
}