vscode-intelephense
vscode-intelephense copied to clipboard
No auto-complete suggestion on class parameter that is defined inside conditional block
Describe the bug When a class parameter is initialized inside a conditional block, it does not give auto-complete suggestions unless there is some type of initialization outside of the conditional as well (even if you just initialize it to null).
To Reproduce
<?php
class TestObject {
public function methodOne($arg1 = null) {
}
}
class MyClass {
public $obj = null;
public function run() {
// $this->obj = null;
if (1 == 1) {
$this->obj = new TestObject();
}
$this->obj-> // No auto-complete here until line 14 is uncommented.
}
}
Expected behavior Auto-complete suggestions should be offered on parameters defined within a conditional block.
Screenshots
Works if class parameter is initialized to null within function.
Works if using a local variable, even with no other initialization.
DOESN'T work without initialization within function, even though it was initialized in the class definition.
Platform and version OS: CentOS Linux 7 Core (Remoting from Windows 11 Pro) VS Code: 1.71.0 Intelephense: v1.8.2