Phpinspectionsea: Wrong null pointer inspection triggered

Created on 20 Sep 2017  路  10Comments  路  Source: kalessil/phpinspectionsea

this is a class method with typehint public function ololo(City $city = null) and we have check for variable value

default

bug / false-positive fixed

Most helpful comment

Oh, a new bug related to NPEs. Today is NPEs inspection bug day =)

All 10 comments

Thanks for reporting.
What is the type of $city identified by PS? (hold CTRL and point to this variable).

default

I could reproduce it with:

class User { public function okay(): void { } }

function test(User $user = null)
{
    if (false) {
        // It applied here it works fine.
    }
    elseif ($user) {
        // But here not.
        $user->okay();
    }
}

Seems that only if() and else if() is validated, and elseif() is not.

thank you for problem localization

Oh, a new bug related to NPEs. Today is NPEs inspection bug day =)

This fixed, thank you @Koc for reporting and @rentalhost for precise diagnostics!

@kalessil @rentalhost Issue returns with last update

default

@Koc : do you mean Php Inspections (EA Extended) v2.3.11.1 update?

yes, Version: 2.3.11.1,

PhpStorm 2017.3 EAP
Build #PS-173.3415.21, built on October 25, 2017
PhpStorm EAP User
Expiration date: November 24, 2017
JRE: 1.8.0_152-release-1024-b6 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

@Koc : congrats, you've discovered a new case - reproduced and fixed

Was this page helpful?
0 / 5 - 0 ratings