-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Add named constructor on JsonResponse #19552
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
[HttpFoundation] Add named constructor on JsonResponse #19552
Conversation
@@ -59,6 +59,14 @@ public static function create($data = null, $status = 200, $headers = array()) | |||
} | |||
|
|||
/** | |||
* Make easier the creation of JsonResponse from raw json | |||
*/ | |||
public static function fromJsonString($data = null, $status = 200, $headers = array()) |
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.
What about createFromString
createFromJsonString
? or just createFromJson
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.
Btw createFromString
somewhat implies a callback (JSONP) is parsed as well.. so you know ;-)
Edit: i guess we dont wanna go that way.
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.
No problem to switch to createFromJsonString
. I'm used to remove the create
prefix but if everyone prefer with it, I'm ok !
To make easier construction with raw json
4a14137
to
6d5a65d
Compare
👍 |
1 similar comment
👍 |
Thank you @tyx. |
… (tyx) This PR was merged into the 3.2-dev branch. Discussion ---------- [HttpFoundation] Add named constructor on JsonResponse | Q | A | ------------- | --- | Branch? | "master" | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | To make easier construction with raw json. It is a simple addition but having something like : ```php return new JsonResponse($content, Response::HTTP_OK, [], true); ``` and ```php return new JsonResponse($content, Response::HTTP_OK, []); ``` is not very obvious to get the difference without going to read the JsonResponse constructor. Commits ------- 6d5a65d Add named constructor on JsonResponse
To make easier construction with raw json. It is a simple addition but having something like :
and
is not very obvious to get the difference without going to read the JsonResponse constructor.