bmewburn / vscode-intelephense

PHP intellisense for Visual Studio Code
https://intelephense.com
Other
1.56k stars 92 forks source link

The bug of conditional return types #2921

Closed huangdijia closed 2 days ago

huangdijia commented 3 days ago
/**
 * @return ($a is null ? null : int)
 */
function test(?int $a = null)
{
    if (is_null($a)) {
        return null;
    }

    return $a;
}

Screenshots

$a = 1;
$b = test($a); // The return type is right
image
$a = null;
$b = test($a); // The return type is also right
image
$b = test(); // The return type is wrong
image

Platform and version

版本: 1.90.2 (Universal)
提交: 5437499feb04f7a586f677b155b039bc2b3669eb
日期: 2024-06-18T22:37:41.291Z
Electron: 29.4.0
ElectronBuildId: 9728852
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Darwin x64 20.6.0
image
bmewburn commented 3 days ago

Thankyou for reporting!