StringReturnTypeFromStrictStringReturnsRector

Add string return type based on returned strict string values

 final class SomeClass
 {
-    public function foo($condition, $value)
+    public function foo($condition, $value): string;
     {
         if ($value) {
             return 'yes';
         }

         return strtoupper($value);
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\StringReturnTypeFromStrictStringReturnsRector;

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