-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] deprecate HeaderBag::get() returning an array and add all($key) instead #32122
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] deprecate HeaderBag::get() returning an array and add all($key) instead #32122
Conversation
e9544ef
to
fad5ccb
Compare
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.
given now all()
vs getAll()
... im wondering if getValue() / getValues()
is the better name
overall 👍 for the intent
768bfef
to
3b7af3a
Compare
Maybe we should introduced the method firstly and then deprecate the get and remove the usage, because like this it would be hard to do both in the same PR. cc @ro0NL |
bf8c439
to
63a4a2d
Compare
I'm against deprecating |
So getValue becames get and we keep getValues. |
To be honest, I would prefer to not change anything :) |
I'd like some other opinion here @symfony/deciders |
I'm for keeping get() and make it always return a string (ie deprecate argument |
Same opinion as @nicolas-grekas |
63a4a2d
to
f8d3ffa
Compare
PR Updated |
I also think we should give
|
f8d3ffa
to
d47783a
Compare
@Tobion updated |
src/Symfony/Component/WebLink/Tests/EventListener/AddLinkHeaderListenerTest.php
Outdated
Show resolved
Hide resolved
aedda78
to
00bdb70
Compare
src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php
Show resolved
Hide resolved
src/Symfony/Component/WebLink/Tests/EventListener/AddLinkHeaderListenerTest.php
Show resolved
Hide resolved
00bdb70
to
d0cc721
Compare
if (1 <= \func_num_args() && null !== $key = func_get_arg(0)) { | ||
$key = str_replace('_', '-', strtolower($key)); | ||
|
||
return $this->headers[$key] ?? []; |
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.
This doesn't solve the problem in the linked issue (the get
method having 2 different return types depending on a parameter), now it's all
that can return either string[]
or string[][]
based on the presence of a parameter.
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.
that's fine to me, the proposed interface is a nice and consistent update
d0cc721
to
dba2c3f
Compare
c166e23
to
d544054
Compare
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.
I'm adding the missing UPGRADE/CHANGELOG lines.
d544054
to
2c5a8f1
Compare
Thank you @Simperfit. |
…an array and add all($key) instead (Simperfit) This PR was merged into the 4.4 branch. Discussion ---------- [HttpFoundation] deprecate HeaderBag::get() returning an array and add all($key) instead | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | maybe <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #31317 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | todo <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/roadmap): - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against branch 4.4. - Legacy code removals go to the master branch. --> the $first param has been deprecated in the get methid and we are adding a $key parameter to all to get all values from a key as arrays Do we deprecated the get method ? if so this will be a little bigger in terms of changes. Commits ------- 2c5a8f1 [HttpFoundation] deprecate using $first in get and added key in all
* @return array An array of headers | ||
*/ | ||
public function all() | ||
public function all(/*string $key = null*/) |
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.
That is a no-go for me. It introduces another of #31317 which this PR tried to fix.
Depending on the arguments it returns an array of arrays or an array of strings.
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.
I know it's the same as on the Messenger Envelope but that was on my todo to fix as was a pain to work with.
the $first param has been deprecated in the get methid
and we are adding a $key parameter to all to get all values from a key as arrays
Do we deprecated the get method ? if so this will be a little bigger in terms of changes.