Skip to content

Commit

Permalink
Merge pull request #10675 from robchett/prevent_nullable_mixed
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan authored Feb 10, 2024
2 parents 2a063ff + 5579fd4 commit ceaea62
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,9 @@ private function getTranslatedFunctionParam(
$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();
Expand Down
14 changes: 14 additions & 0 deletions tests/ArgTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,20 @@ function foo($a, ...$b) {}
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',
],
];
}

Expand Down

0 comments on commit ceaea62

Please sign in to comment.