Skip to content

[HttpFoundation] [Response] replaced hard coded http status by constants #11401

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

Conversation

fmagnan
Copy link

@fmagnan fmagnan commented Jul 16, 2014

Q A
Bug fix? [no]
New feature? [no]
BC breaks? [no]
Deprecations? [no]
Tests pass? [yes]
Fixed tickets []
License MIT
Doc PR []

Http status were defined via constants but constants were not used in class so I replaced all calls to hard coded status by corresponding constant.

Franck Magnan added 2 commits July 16, 2014 18:01
…constant

Http status constants were present but not used everywhere in class
@@ -80,6 +80,7 @@ class Response
const HTTP_LOOP_DETECTED = 508; // RFC5842
const HTTP_NOT_EXTENDED = 510; // RFC2774
const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; // RFC6585
const HTTP_MAX_LIMIT = 600;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not an HTTP status code, it should not be publicly set as a constant like others.

@fabpot
Copy link
Member

fabpot commented Jul 16, 2014

👎 I don't see any value and I find it way less readable.

@stof
Copy link
Member

stof commented Jul 16, 2014

I'm also -1 on this for readability

@sstok
Copy link
Contributor

sstok commented Jul 16, 2014

👎 constants are useful for the application, but here it does not add anything.
And I even remember this being proposed in the past, and rejected for the same reason.

Yep. Fount it #9808

@cordoval
Copy link
Contributor

not at the core no 👎

@fmagnan
Copy link
Author

fmagnan commented Jul 17, 2014

Hi guys, thanks for your replies!

@fabpot, @stof, I'm not agree with you. If you think self::HTTP_NOT_FOUND is less readable than 404, why not. But IMHO, self::HTTP_SEE_OTHER (for instance) is more readable than 303 because everybody don't know all HTTP status by heart.

@sstok thanks for the reference, I didn't find it. I see other people think the same as me :)

@GromNaN thanks for your note, we could use a private/protected variable for this limit.

@GromNaN
Copy link
Member

GromNaN commented Jul 17, 2014

@fmagnan like an accountant need to learn the chart of accounts, web developers need to know HTTP status codes. The wording HTTP_SEE_OTHER doesn't contain the information that the code is in the class "300" (redirect).

@fmagnan
Copy link
Author

fmagnan commented Jul 17, 2014

@GromNaN code must give as much information as it can and from that perspective, HTTP_SEE_OTHER is better than a number

But decision is yours, not mine, and if you prefer deal with integers instead of labels, as you wish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants