Adds param type declaration based on PHPUnit provider return type declaration
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
/**
* @dataProvider provideData()
*/
- public function test($value)
+ public function test(string $value)
{
}
public static function provideData()
{
yield ['name'];
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeBasedOnPHPUnitDataProviderRector;
return RectorConfig::configure()
->withRules([
AddParamTypeBasedOnPHPUnitDataProviderRector::class,
]);