Add basic ? nullable type to class methods and functions, as of PHP 7.1
 final class SomeClass
 {
-    public function getData()
+    public function getData(): ?int
     {
         if (rand(0, 1)) {
             return null;
         }
         return 100;
     }
 }
                        Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNullableTypeRector;
return RectorConfig::configure()
    ->withRules([
        ReturnNullableTypeRector::class,
    ]);