driftingly/rector-laravel

Bug: LARAVEL_STATIC_TO_INJECTION Rule

Closed this issue · 1 comments

This rule is converted in the wrong way that's laravel will not allow.

class SkipWithArguments
{
+    public function __construct(private \Illuminate\Routing\Redirector $redirector)
+    {
+    }
     public function run()
     {
-        return redirect('/destination')->back()->with('error', 'Incorrect credential.');
+        return $this->redirector->back('/destination')->back()->with('error', 'Incorrect credential.');
     }
}

As per the documentation of the laravel first parameter of the back method, it's an integer but it's passing a string.

@hirenkeraliya I guess the output should be like the following?

return $this->redirector->to('/destination')->back()->with('error', 'Incorrect credential.');

is changing to:

-new ArgumentFuncCallToMethodCall('redirect', 'Illuminate\Routing\Redirector', 'back'),
+new ArgumentFuncCallToMethodCall('redirect', 'Illuminate\Routing\Redirector', 'to'),

make it work? If yes, could you create PR for it? Thank you.