Change && and || between nullable objects to instanceof compares
function someFunction(?SomeClass $someClass)
{
- if ($someClass && $someClass->someMethod()) {
+ if ($someClass instanceof SomeClass && $someClass->someMethod()) {
return 'yes';
}
return 'no';
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\BooleanAnd\BinaryOpNullableToInstanceofRector;
return RectorConfig::configure()
->withRules([
BinaryOpNullableToInstanceofRector::class,
]);