httpfoundation: Add getArray & getString helpers #37229
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#34363 deprecated working with arrays. For example, if you have form handling code like this:
You'll get a deprecation notice starting in 5.1. The suggested workaround from the discussion in #34363 would make it look like this:
which is not only way uglier, but also incomplete, since
'tags'
could be a string at this point. So it would really have to look like this:(if that even works? I haven't tested it).
So why not add a simple
getArray()
helper function? That also makes it easier for static analysis to verify that the code is actually correct.Also, I added a
getString()
method for symmetry. Because I really think according to the logic in #34363get
should be deprecated or at least redirected to agetString
function so that it's obvious what is going on, but I can also remove this part.I know there are no tests and documentation, but I wanted to check if there is even interest in merging something like this before I go through all that (so consider this RFC)