Having this code:

<?php declare(strict_types = 1);

class Test2
{
    public function A() : string
    {
        return "Test";
    }
}

$x = Test2::A();

Above the call to method A() is wrong, as it is no static method. It should be something like $x = (new Test2())->A();.

PHP Tools does not detect this wrong call. PHPStan does:

Static call to instance method Test2::A().

My suggestion

Please also detect and report those wrong calls.

5 days later

right, this is something that worked in PHP 5.x, and become a notice in later versions.

We should probably report that as an error now in 2022 ....

a month later

will be in the next pre-release/release!

thanks Uwe!

Just a little bit off-topic:

I'm currently working approximately 50 % inside JetBrain's PhpStorm and 50 % inside Visual Studio.

The integration in VS with PHP Tools is just awesome. I'm having a mixed solution with C# projects and PHP projects together that interact during runtime and thanks to PHP Tools, VS even allows me to debug both C# and PHP at the same time.

This combination is second to none and I'm very happy with it.

At the same time, PhpStorm is very good at managing larger PHP projects. It has tons of features like refactoring, error detection and it even allows to integrate tools like PHPStan, Psalm and other tools right into the IDE editor.

While I assume your goals with PHP Tools are different to what PhpStorm does, I still would recommend to look at what it does and maybe you can let inspire yourself to adapt one or another feature for PHP Tools 🙂.

    Write a Reply...