driftingly/rector-laravel

`RedirectRouteToToRouteHelperRector` error on calls without `->with`

Closed this issue · 5 comments

The following fixture causes an error when run with the RedirectRouteToToRouteHelperRector rule.

Seems to be caused by $this->removeNode($methodCall);

<?php

namespace RectorLaravel\Tests\Rector\MethodCall\RedirectRouteToToRouteHelperRector\Fixture;

use Illuminate\Support\Facades\Redirect;

class Fixture
{
    public function store()
    {
        return redirect()->route('home');
    }

    public function update()
    {
        return Redirect::route('home');
    }
}

?>
-----
<?php

namespace RectorLaravel\Tests\Rector\MethodCall\RedirectRouteToToRouteHelperRector\Fixture;

use Illuminate\Support\Facades\Redirect;

class Fixture
{
    public function store()
    {
        return to_route('home');
    }

    public function update()
    {
        return to_route('home');
    }
}

?>

@hirenkeraliya Do you have any suggestions on this? I know it's been a while since you worked on this.

@driftingly Sure I will check and update you regarding this.

I encountered the same error when I have redirect()->back(); in the controller without using ->with. Unfortunately, I don't yet have sufficient knowledge of the code to be able to create a pull request. 😇

[ERROR] Could not process "/var/www/app/Http/Controllers/CountryCurrencyController.php" file, due to: "System error: "leaveNode() returned invalid value of type integer" Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new". On line: 150

@driftingly I am trying to fix this issue for the last couple of days. I tried too many things and the issue is the same. Can you please help me out with this?

The issue occurs when we try to remove the last method call of the chaining methods.

Maybe the issue is on the main rector leaveNode method. But I am not sure about that.

Closed by #106