Changes defined return typehint of method and class.
class SomeClass
{
- public function getData()
+ public function getData(): array
{
}
}
Configure your rector.php
:
<?php
use PHPStan\Type\ArrayType;
use PHPStan\Type\MixedType;
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
return RectorConfig::configure()
->withConfiguredRule(AddReturnTypeDeclarationRector::class, [
new AddReturnTypeDeclaration('SomeClass', 'getData', new ArrayType(new MixedType(), new MixedType())),
]);