Skip to content

[composer-based] Bond RedirectToRouteRector to symfony/framework-bundle 2.6 - #991

Merged
TomasVotruba merged 2 commits into
mainfrom
bond-redirect-to-route-rector
Aug 2, 2026
Merged

[composer-based] Bond RedirectToRouteRector to symfony/framework-bundle 2.6#991
TomasVotruba merged 2 commits into
mainfrom
bond-redirect-to-route-rector

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Aug 2, 2026

Copy link
Copy Markdown
Member

Reopens #990 without the dependency change. composer.json is untouched here.

RedirectToRouteRector rewrites the redirect helper pair into the shorter route helper:

 final class SomeController extends AbstractController
 {
     public function someAction()
     {
-        return $this->redirect($this->generateUrl('something', ['id' => $id]));
+        return $this->redirectToRoute('something', ['id' => $id]);
     }
 }

Controller::redirectToRoute() was added in symfony/framework-bundle 2.6, so the rule declares that package constraint and joins the composer-based set:

public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
    return new ComposerPackageConstraint('symfony/framework-bundle', '>=2.6');
}

A project on an older framework-bundle now gets the rule skipped instead of a call to a method that does not exist yet.

Testing a rule bonded to a package we cannot install

ComposerPackageConstraintFilter resolves the constraint against the installed packages, and RectorNodeTraverser applies it unconditionally — including during the rule's own test run. symfony/framework-bundle is not installed here, so the rule was filtered out and all 5 fixtures failed.

Adding it to require-dev is not an option: it does not resolve at any major against the current constraints. ^8.1 conflicts with symfony/console < 8.1 while rector/rector-src pins symfony/console ^6.4.24; ^7.4 needs dependency-injection/routing at ^7.4, currently ^6.4; ^6.4 needs http-kernel ^6.4 and config ^6.1|^7.0, currently ^7.4 and ^8.1.

rectorphp/rector-src#8264 added a hook for exactly this, and the test points at a standalone composer.json:

protected function provideComposerJsonFilePath(): string
{
    return __DIR__ . '/config/composer.json';
}
{
    "require": {
        "symfony/framework-bundle": "^2.6"
    }
}

That hook is merged, so the suite is green on the current rector/rector-src dev-main — 584 tests, including the 7 RedirectToRouteRector cases. ECS, PHPStan, class-leak, Finalize Classes and Composer Validate pass as well.

…le 2.6

Controller::redirectToRoute() was added in symfony/framework-bundle 2.6,
so the rule declares that constraint and is registered in the
composer-based set.
…in the test

The rule is bonded to symfony/framework-bundle, which is not installed
here, so it would be filtered out during its own test run.
@TomasVotruba
TomasVotruba merged commit 341a62c into main Aug 2, 2026
11 of 12 checks passed
@TomasVotruba
TomasVotruba deleted the bond-redirect-to-route-rector branch August 2, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant