FlipTypeControlToUseExclusiveTypeRector

Flip type control from null compare to use exclusive instanceof object

 function process(?DateTime $dateTime)
 {
-    if ($dateTime === null) {
+    if (! $dateTime instanceof DateTime) {
         return;
     }
 }

Configure your rector.php:

<?php

use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withRules([
        FlipTypeControlToUseExclusiveTypeRector::class,
    ]);