RemoveDrupalToStringTraitRector

Replace use of deprecated Drupal\Component\Utility\ToStringTrait with a direct __toString() method.

 use Drupal\Component\Utility\ToStringTrait;

 class MyClass {
-    use ToStringTrait;
+    public function __toString(): string {
+        return (string) $this->render();
+    }

     public function render() {
         return 'hello';
     }
 }

Configure your rector.php:

<?php

use DrupalRector\Drupal11\Rector\Deprecation\RemoveDrupalToStringTraitRector;
use Rector\Config\RectorConfig;

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

Other rules in the drupal/core 11.4 set