1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Prevent mixed erasure in get_class call

This commit is contained in:
Brown 2020-07-16 13:56:42 -04:00
parent a2dbd31371
commit 26a61c47c0
2 changed files with 24 additions and 0 deletions

View File

@ -1346,6 +1346,8 @@ class FunctionCallAnalyzer extends CallAnalyzer
$class_type->defining_class
);
}
} else {
$class_string_types[] = new Type\Atomic\TClassString();
}
}

View File

@ -937,6 +937,28 @@ class SwitchTypeTest extends TestCase
echo "bar";
}'
],
'switchGetClassProperty' => [
'<?php
class A {}
class B {}
class C {
/** @var mixed */
public $a;
function foo() : void {
if (rand(0, 1)) {
$this->a = new A();
}
/** @psalm-suppress MixedArgument */
switch (get_class($this->a)) {
case B::class:
echo "here";
}
}
}',
],
];
}