$a = Users::model()->findByUid($uid);
echo $a->foo ?? 123;
findByUid has @return Users|null phpdoc.
If I simplify example code to
$a = null;
echo $a->foo ?? 123;
Then issue is not reproduced.
Duplicates #952
Hello @kalessil,
I think this is not a duplicate. I created the original #952 issue, which is fixed, but the error mentioned by @b1rdex is still happening: I am still getting "Null pointer exception may occur here" when the object is returned by a method. Consider the following example:
$object = ClassName::CallStaticMethodThatReturnsNullOrObject();
echo $object->someField ?? 'default value'; # <== This triggers the inspection
This should not trigger the "Return Null" inspection.
$object = null;
echo $object->someField ?? 'default value'; # <== This doesn't trigger the inspection
@thomasphansen : will re-evaluate with a fresh plugin build, thanks =)
Re-evaluated with a fresh build: fixed. I'll make a new release ~ in a week.
Most helpful comment
@thomasphansen : will re-evaluate with a fresh plugin build, thanks =)