pdt icon indicating copy to clipboard operation
pdt copied to clipboard

PDT doesn't infer types from class properties until you explicitely affect it once

Open pounard opened this issue 4 years ago • 0 comments

Since 2020-03 and then still present in 2020-06, when you set a type on a class property, PDT seems unable to provide auto-completion for it until you do an explicit affectation somewhere in a method.

For example, with the following code:

class Bar
{
    public function hello()
    {
        echo "Hello";
    }
}

class Foo
{
    private Bar $bar;

    public function sayHello()
    {
        $this->bar-> // Here completion doesn't work.
    }
}

Nevertheless, if I write this code:

class Bar
{
    public function hello()
    {
        echo "Hello";
    }
}

class Foo
{
    private Bar $bar;

    public function __construct(Bar $bar)
    {
        $this->bar = $bar;
    }

    public function sayHello()
    {
        $this->bar->hello(); // Here completion works.
    }
}

Version is:

Eclipse IDE for PHP Developers (includes Incubating components)
Version: 2020-06 (4.16.0)
Build id: 20200615-1200

I have quite a few addons installed, including PDT Extensions, a few PHP unrelated extensions.

  • OS: Running ArchLinux, uname output: Linux guinevere 5.7.6-arch1-1 #1 SMP PREEMPT Thu, 25 Jun 2020 00:14:47 +0000 x86_64 GNU/Linux

pounard avatar Jul 03 '20 07:07 pounard