ReturnTypeFromSymfonySerializerRector

Add return type from symfony serializer

 final class SomeClass
 {
     private \Symfony\Component\Serializer\Serializer $serializer;

-    public function resolveEntity($data)
+    public function resolveEntity($data): SomeType
     {
         return $this->serializer->deserialize($data, SomeType::class, 'json');
     }
 }

Configure your rector.php:

<?php

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

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