vscode-intelephense
vscode-intelephense copied to clipboard
Boolean global completions
I am unsure if this is a bug/feature in Intelephense or an inaccuracy in the core_d.php
stubs (or a little of both).
The issue arises when intelephense.completion.fullyQualifyGlobalConstantsAndFunctions
is set to true
, causing the suggestion completion for false
to be set as \false
.
class A {
public function returnFalseOrString(bool $irrelevant) : false | string {
if($irrelevant) {
return "Some string";
}
return \false;
}
}
This causes error: Expected type 'false|string'. Found 'mixed'. intelephense(P1006)
In the core_d.php file, true and false are defined as global constants like this:
define('true', (bool)1, true);
define('false', (bool)0, true);
Temporary workaround:
If I Ctrl+Click the \false
statement to open the core_d.php file, Intelephense seems to "calculate" the value of \false as boolean
instead of mixed
. This works for a short period until Intelephense seems to forget the type and it reverts to mixed
.
There might be a bug causing intelephense not resolving value/type of global constants properly?
Suggestion:
Do not add (global) completions for true and false.
System
Intelephense 1.12.4 VSCode 1.92.2 Remote SSH-Container (Debian GNU/Linux 12 (bookworm)) PHP 8.2.16 Windows 10