vscode-intelephense icon indicating copy to clipboard operation
vscode-intelephense copied to clipboard

No auto-complete suggestion on class parameter that is defined inside conditional block

Open crmccar opened this issue 2 years ago • 0 comments

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. Screenshot 2022-09-02 131029

Works if using a local variable, even with no other initialization. Screenshot 2022-09-02 131245

DOESN'T work without initialization within function, even though it was initialized in the class definition. Screenshot 2022-09-02 131136

Platform and version OS: CentOS Linux 7 Core (Remoting from Windows 11 Pro) VS Code: 1.71.0 Intelephense: v1.8.2

crmccar avatar Sep 02 '22 18:09 crmccar