WhileNullableToInstanceofRector

Change while null compare to strict instanceof check

 final class SomeClass
 {
     public function run(?SomeClass $someClass)
     {
-        while ($someClass !== null) {
+        while ($someClass instanceof SomeClass) {
             // do something
         }
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\While_\WhileNullableToInstanceofRector;

return RectorConfig::configure()
    ->withRules([
        WhileNullableToInstanceofRector::class,
    ]);
SETS:  Instanceof