rector icon indicating copy to clipboard operation
rector copied to clipboard

ResponseReturnTypeControllerActionRector does not consider kernel.view event

Open javaDeveloperKid opened this issue 3 years ago • 0 comments

Bug Report

This implementation https://github.com/rectorphp/rector-symfony/blob/main/src/Rector/ClassMethod/ResponseReturnTypeControllerActionRector.php is too generic. It adds Response return type without any check

  • controller action may not return instance of Response because uses kernel.view mechanism
  • returned type might be a subtype of Response. Of course adding Response will work but I think everyone would type hint this with an actual type when manually added.

I feel that Rector's author intention was to add Response RT when this->render() is called. I think we should check that this is what is returned;

Subject Details
Rector version e.g. v0.11.5 (invoke vendor/bin/rector --version)

Minimal PHP Code Causing Issue

Expected Behaviour

javaDeveloperKid avatar Sep 12 '22 21:09 javaDeveloperKid