Remove nullsafe check on method call on a Collection type
use Doctrine\Common\Collections\Collection;
class SomeClass
{
private Collection $collection;
public function run()
{
- return $this->collection?->empty();
+ return $this->collection->empty();
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\Doctrine\TypedCollections\Rector\NullsafeMethodCall\RemoveNullsafeOnCollectionRector;
return RectorConfig::configure()
->withRules([
RemoveNullsafeOnCollectionRector::class,
]);