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:
parent
13ea0c241d
commit
3e100b15d9
@ -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();
|
||||
|
@ -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',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user