ReturnTypeFromStrictConstantReturnRector

Add strict type declaration based on returned constants

 class SomeClass
 {
     public const NAME = 'name';

-    public function run()
+    public function run(): string
     {
         return self::NAME;
     }
 }

Configure your rector.php:

<?php

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

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