Skip to content

Commit

Permalink
Merge pull request #8875 from weirdan/fix-8872
Browse files Browse the repository at this point in the history
Fixes #8872
  • Loading branch information
weirdan committed Dec 10, 2022
2 parents a568b08 + a4ff9eb commit 16cdeb9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Psalm/Type/Atomic.php
Expand Up @@ -303,7 +303,10 @@ private static function createInner(
return $analysis_php_version_id !== null ? new TNamedObject($value) : new TNumeric();

case 'true':
return $analysis_php_version_id !== null ? new TNamedObject($value) : new TTrue();
if ($analysis_php_version_id === null || $analysis_php_version_id >= 8_02_00) {
return new TTrue();
}
return new TNamedObject($value);

case 'false':
if ($analysis_php_version_id === null || $analysis_php_version_id >= 8_00_00) {
Expand Down
25 changes: 25 additions & 0 deletions tests/ReturnTypeTest.php
Expand Up @@ -1154,6 +1154,31 @@ function f(object $p): Stringable {
'ignored_issues' => [],
'php_version' => '8.0',
],
'newReturnTypesInPhp82' => [
'code' => '<?php
function alwaysTrue(): true {
return true;
}
function alwaysFalse(): false {
return false;
}
function alwaysNull(): null {
return null;
}
$true = alwaysTrue();
$false = alwaysFalse();
$null = alwaysNull();
',
'assertions' => [
'$true===' => 'true',
'$false===' => 'false',
'$null===' => 'null',
],
'ignored_issues' => [],
'php_version' => '8.2',
],
];
}

Expand Down

0 comments on commit 16cdeb9

Please sign in to comment.