[CodeQuality] Skip event and session params in ControllerMethodInjectionToConstructorRector - #1005
Merged
Merged
Conversation
…ionToConstructorRector
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.
Two params must never be moved to the constructor:
Symfony\Contracts\EventDispatcher\Eventsubtypes - an event subscriber method living inside a controller is not an action, the event is passed by the dispatcherSessionInterface- request-scoped, must stay in the action method signatureBoth skips are type-based, so any subtype is covered (e.g.
RequestEvent extends KernelEvent extends Event).Before/after
Reported from Mautic's
SecurityController, which implementsEventSubscriberInterface:Previously the rule turned
RequestEvent $requestEventinto a constructor dependency, breaking the listener.Same for session:
final class SomeController extends AbstractController { - public function __construct( - private readonly SessionInterface $session - ) { - } - - public function someAction() + public function someAction(SessionInterface $session) { - $this->session->invalidate(); + $session->invalidate(); } }Covered by 2 new fixtures.