Run Rector on your code to see what it can do for you:

 <?php
 
 interface FooInterface {}
 
 class Imp implements DoX
 {
-	public function run(): A|B
+	/**
+     * @return \A|\B
+     */
+    public function run()
     {
     	return new A();
     }
 }
PHP snippet to change

Applied Rules:

Not a change you expect?

Config  rector.php
Rector version: b855ff - released at 2026-01-22 19:37