Skip to content

Commit

Permalink
bugfix: allow object assertions for mixed
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Bösing <[email protected]>
  • Loading branch information
boesing committed Sep 15, 2023
1 parent 13ea0c2 commit 3e100b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Type/SimpleAssertionReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ private static function reconcileObject(
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();
Expand Down
16 changes: 16 additions & 0 deletions tests/AssertAnnotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2967,6 +2967,22 @@ final class Qoo extends AbstractSingleInstancePluginManager
'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',
],
];
}

Expand Down

0 comments on commit 3e100b1

Please sign in to comment.