Cleanup unneeded nullsafe operator
class HelloWorld {
public function getString(): string
{
return 'hello world';
}
}
function get(): HelloWorld
{
return new HelloWorld();
}
-echo get()?->getString();
+echo get()->getString();
Configure your rector.php
:
<?php
use Rector\CodeQuality\Rector\NullsafeMethodCall\CleanupUnneededNullsafeOperatorRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
CleanupUnneededNullsafeOperatorRector::class,
]);