mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Prevent mixed|null when function param is mixed with a null default value
This commit is contained in:
parent
4a5dbcaebc
commit
5579fd469b
@ -825,7 +825,9 @@ final class FunctionLikeNodeScanner
|
||||
$this->codebase->analysis_php_version_id,
|
||||
);
|
||||
|
||||
if ($is_nullable) {
|
||||
if ($param_type->isMixed()) {
|
||||
$is_nullable = false;
|
||||
} elseif ($is_nullable) {
|
||||
$param_type = $param_type->getBuilder()->addType(new TNull)->freeze();
|
||||
} else {
|
||||
$is_nullable = $param_type->isNullable();
|
||||
|
@ -355,6 +355,20 @@ class ArgTest extends TestCase
|
||||
|
||||
var_caller("foo");',
|
||||
],
|
||||
'mixedNullable' => [
|
||||
'code' => '<?php
|
||||
class A {
|
||||
public function __construct(public mixed $default = null) {
|
||||
}
|
||||
}
|
||||
$a = new A;
|
||||
$_v = $a->default;',
|
||||
'assertions' => [
|
||||
'$_v===' => 'mixed',
|
||||
],
|
||||
'ignored_issues' => [],
|
||||
'php_version' => '8.0',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user