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:
parent
a2dbd31371
commit
26a61c47c0
@ -1346,6 +1346,8 @@ class FunctionCallAnalyzer extends CallAnalyzer
|
||||
$class_type->defining_class
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$class_string_types[] = new Type\Atomic\TClassString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user