ReturnTypeFromStrictTernaryRector

Add method return type based on strict ternary values

 final class SomeClass
 {
-    public function getValue($number)
+    public function getValue($number): int
     {
         return $number ? 100 : 500;
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\Class_\ReturnTypeFromStrictTernaryRector;

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