-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Using a PHP class constant for a key in a YAML hash as a method argument produces an ErrorException #35179
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
Comments
Status: reviewed. That's not supported because we don't support spaces in mapping keys, so in your example the key is @nicolas-grekas Is that a bug fix or a new feature? 😕 |
I don't remember if we made a conscious decision not to support tags in making keys. We should check that first. Nonetheless, improving the reported error could still be done as a bugfix. |
I think this actually is a bug (see #35208 (comment) as well as #35318 for the fix). |
…n (xabbuh) This PR was merged into the 3.4 branch. Discussion ---------- [Yaml] fix PHP const mapping keys using the inline notation | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #35179 | License | MIT | Doc PR | Commits ------- 45461c7 fix PHP const mapping keys using the inline notation
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected: 4.4.2
Description
When trying to use a PHP class constant as a YAML key for a hash (as a method argument), I receive an
ErrorException
with the messageUninitialized string offset: 0
and code8
.How to reproduce
Using the following class and Symfony YAML and DI I receive an
ErrorException
with the messageUninitialized string offset: 0
and code8
.Possible Solution
Additional context
I am more than willing to bet that I am formatting the YAML incorrectly to accomplish this, but I have tried many variations of indentations and YAML hash expressions. Constants as YAML hash keys do work if I use them like the following. So my assumption of the behavior is that they should be able to be used for any valid YAML hash expression (like my example above).
I have quoted the constant for the key in my example above due to this comment. However, I have tried it without quoting and I receive an error about the colons (which I expect due to YAML processing).
Thank you =)
Update
I should probably also mention that the control case works as expected, i.e.
The text was updated successfully, but these errors were encountered: