SimplifyIfNullableReturnRector

Direct return on if nullable check before return

 class SomeClass
 {
     public function run()
     {
-        $value = $this->get();
-        if (! $value instanceof \stdClass) {
-            return null;
-        }
-
-        return $value;
+        return $this->get();
     }

     public function get(): ?stdClass {
     }
 }

Configure your rector.php:

<?php

use Rector\CodeQuality\Rector\If_\SimplifyIfNullableReturnRector;
use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withRules([
        SimplifyIfNullableReturnRector::class,
    ]);
SETS:  Code Quality