Add return type declaration to a test method that returns type
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
- public function test()
+ public function test(): \stdClass
{
$value = new \stdClass();
return $value;
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddReturnTypeToDependedRector;
return RectorConfig::configure()
->withRules([
AddReturnTypeToDependedRector::class,
]);