-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[10.x] Use Symfony Response in exception handler #48226
Conversation
What does this achieve? |
Improved typing, since the current implementation is incorrect. Take this line for example. It returns a If I were to extend a method in the current handler and return
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably the right fix is to add in JsonResponse to the union, like we did for redirect response.
What is the point of listing all these child classes? IMO just the Symfony Response class should be there, all other responses extend that class anyway. |
The point is that the laravel responses have additional methods available, that are not in the symfony response class. if we wanted to just not properly type things with some parent, we could just put object everywhere - see my point? |
@GrahamCampbell This is just an API contract between the framework and the framework users, methods that are explicitly |
Accurate type contracts are just as important. As is, the type contract is saying that only Laravel's subclasses of the Symfony response classes are valid. Is that really the intended contract here? Truthfully, #47328 should have been flagged as a B/C break and not accepted in 10.x; narrowing the return types on a contract should be considered a breaking change. |
This change partially reverts #47328.
The Symfony Response is more accurate because it is the return type of the
render
method in the contract. Plus,Illuminate\Http\JsonResponse
is a subtype of\Symfony\Component\HttpFoundation\Response
but not ofIlluminate\Http\Response
.I did not revert the return type of
toIlluminateResponse
.