| Subject | Details |
| :------------- | :---------------------------------------------------------------------------- |
| Issue type | Bug/False-Positive |
| Plugin | Php Inspections (EA Extended) v3.0.9.1 |
| Language level | PHP 7.2 or higher |
<?php
class A
{
/** @var int */
private $id = 100;
public function getId(): int
{
return $this->id;
}
}
class B
{
/** @var A */
private $a;
public function getA(): ?A
{
return $this->a;
}
public function setA(A $a): void
{
$this->a = $a;
}
}
class TestNpe
{
public function test(B $b)
{
// FP NPE here
return $b->getA() && $b->getA()->getId();
}
}
There shouldn't be NPE warning because if the first part of condition $b->getA() will be false/null, the second $b->getA()->getId() will not be executed
PhpStorm 2018.3.1
Build #PS-183.4588.67, built on December 5, 2018
JRE: 1.8.0_152-release-1343-b16 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.6
Thank you for reporting @zakirovir6, not sure yet how I going to fix it yet, but let's hope it'll be simple enough =)
Fixed!
Most helpful comment
Fixed!