1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00
This commit is contained in:
Vincent Langlet 2022-11-03 18:11:01 +01:00
parent dc977964c6
commit fbaf6afb30
2 changed files with 11 additions and 3 deletions

View File

@ -32,10 +32,16 @@ class CanContainObjectTypeVisitor extends NodeVisitor
{ {
if ( if (
$type instanceof Union $type instanceof Union
&& (
UnionTypeComparator::canBeContainedBy($this->codebase, new Union([new TObject()]), $type)
&& UnionTypeComparator::canBeContainedBy($this->codebase, $type, new Union([new TObject()])) && UnionTypeComparator::canBeContainedBy($this->codebase, $type, new Union([new TObject()]))
)
|| ||
$type instanceof Atomic $type instanceof Atomic
&& AtomicTypeComparator::isContainedBy($this->codebase, $type, new TObject()) && (
AtomicTypeComparator::isContainedBy($this->codebase, new TObject(), $type)
|| AtomicTypeComparator::isContainedBy($this->codebase, $type, new TObject())
)
) { ) {
$this->contains_object_type = true; $this->contains_object_type = true;
return NodeVisitor::STOP_TRAVERSAL; return NodeVisitor::STOP_TRAVERSAL;

View File

@ -751,12 +751,14 @@ class UnusedCodeTest extends TestCase
} }
} }
function test(Foo|int $foo): bool { function test(Foo|int $foo, mixed $bar, iterable $baz): bool {
try { try {
serialize(new Foo()); serialize(new Foo());
serialize([new Foo()]); serialize([new Foo()]);
serialize([[new Foo()]]); serialize([[new Foo()]]);
serialize($foo); serialize($foo);
serialize($bar);
serialize($baz);
unserialize(""); unserialize("");
} catch (\Throwable) { } catch (\Throwable) {
return false; return false;