final class MultiCurrencyException extends NotPurchasableException
9
{
10
public function resolve(): bool
11
{
12
Yii::error('Cart position "' . $this->position->getName() . '" was removed from the cart because multi-currency cart is not available for now', 'hipanel.cart');
It seems like $this->position can be null; however, remove() does not accept null, maybe add an additional type check?
Unless you are absolutely sure that the expression can never be null because of
other conditions, we strongly recommend to add an additional type check to your
code:
/** @return stdClass|null */functionmayReturnNull(){}functiondoesNotAcceptNull(stdClass$x){}// With potential error.functionwithoutCheck(){$x=mayReturnNull();doesNotAcceptNull($x);// Potential error here.}// Safe - Alternative 1functionwithCheck1(){$x=mayReturnNull();if(!$xinstanceofstdClass){thrownew\LogicException('$x must be defined.');}doesNotAcceptNull($x);}// Safe - Alternative 2functionwithCheck2(){$x=mayReturnNull();if($xinstanceofstdClass){doesNotAcceptNull($x);}}
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: