Questions & Answers

PhpStorm does not show Missing parameter's type declaration warning

PhpStorm (version 2022.3.1) simply does not show "Missing parameter's type declaration warning".

In this piece of code I intentionally leave $name parameter in getId() method without type declaration and expect PhpStorm to highlight it:



class TestClass
    private int $id = 1;

    public function getId($name): int
        return $name === 'Citibank' ? 0 : $this->id;

But nothing happens.

I've checked Settings -> Editor -> Inspections -> PHP -> Type compatibility - the checkbox is checked, Scope - 'In All Scopes', Severity - 'Warning'.

I've also went through all the steps in File -> Repair IDE.

But still I get only one Weak Warning: 'Unused element: TestClass'.

Any ideas why is this happening? I know it looks more like a bug report, but I there's still a chance that it is a configuration problem or someone has encountered it before.

P.S. If anyone's willing to check my settings, here's exported file: google drive link.

2023-01-17 23:01:06
I can reproduce this, it looks like a bug to me. I can get it to report a missing return type, but not about the parameter type.
Answers(1) :

In the referenced version (2022.3.1) this is still tied to the existence of a DocBlock annotation. Only if the DocBlock exists will this be checked. There is an issue reporting this.