NarrowJsonStreamerAutowiringTypeRector

Change deprecated autowired JsonStreamWriter and JsonStreamReader to their interfaces, if only write() or read() is called on them

-use Symfony\Component\JsonStreamer\JsonStreamWriter;
+use Symfony\Component\JsonStreamer\StreamWriterInterface;
 use Symfony\Component\TypeInfo\Type;

 final class SomeService
 {
     public function __construct(
-        private JsonStreamWriter $jsonStreamWriter
+        private StreamWriterInterface $jsonStreamWriter
     ) {
     }

     public function run(array $data): string
     {
         return (string) $this->jsonStreamWriter->write($data, Type::array());
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Symfony\Symfony82\Rector\Class_\NarrowJsonStreamerAutowiringTypeRector;

return RectorConfig::configure()
    ->withRules([
        NarrowJsonStreamerAutowiringTypeRector::class,
    ]);
PACKAGE:  symfony/json-streamer >=8.2