[composer-based] Bond RedirectToRouteRector to symfony/framework-bundle 2.6 - #991
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reopens #990 without the dependency change.
composer.jsonis untouched here.RedirectToRouteRectorrewrites 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: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
ComposerPackageConstraintFilterresolves the constraint against the installed packages, andRectorNodeTraverserapplies it unconditionally — including during the rule's own test run.symfony/framework-bundleis not installed here, so the rule was filtered out and all 5 fixtures failed.Adding it to
require-devis not an option: it does not resolve at any major against the current constraints.^8.1conflicts withsymfony/console < 8.1whilerector/rector-srcpinssymfony/console ^6.4.24;^7.4needsdependency-injection/routingat^7.4, currently^6.4;^6.4needshttp-kernel ^6.4andconfig ^6.1|^7.0, currently^7.4and^8.1.rectorphp/rector-src#8264 added a hook for exactly this, and the test points at a standalone
composer.json:{ "require": { "symfony/framework-bundle": "^2.6" } }That hook is merged, so the suite is green on the current
rector/rector-srcdev-main — 584 tests, including the 7RedirectToRouteRectorcases. ECS, PHPStan, class-leak, Finalize Classes and Composer Validate pass as well.