diff --git a/src/Psalm/Type/Atomic.php b/src/Psalm/Type/Atomic.php index ae2276cbb40..7e59efed2c7 100644 --- a/src/Psalm/Type/Atomic.php +++ b/src/Psalm/Type/Atomic.php @@ -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) { diff --git a/tests/ReturnTypeTest.php b/tests/ReturnTypeTest.php index 822f819c3d7..c2476e0fa12 100644 --- a/tests/ReturnTypeTest.php +++ b/tests/ReturnTypeTest.php @@ -1154,6 +1154,31 @@ function f(object $p): Stringable { 'ignored_issues' => [], 'php_version' => '8.0', ], + 'newReturnTypesInPhp82' => [ + 'code' => ' [ + '$true===' => 'true', + '$false===' => 'false', + '$null===' => 'null', + ], + 'ignored_issues' => [], + 'php_version' => '8.2', + ], ]; }