Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DependencyInjection] Improve ParameterNotFoundException when accessing a nested parameter#19584
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
wouterj commentedAug 10, 2016
travis failure unrelated |
| * @param string[] $alternatives Some parameter name alternatives | ||
| */ | ||
| publicfunction__construct($key,$sourceId =null,$sourceKey =null,\Exception$previous =null,array$alternatives =array()) | ||
| publicfunction__construct($key,$sourceId =null,$sourceKey =null,\Exception$previous =null,array$alternatives =array(),$nonNestedAlternative =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.
$nonNestedAlternative should be added to docblock, no?
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.
fixed
A common problem under beginners is to think that the dot notation is usedto access nested arrays saved in parameters. Adding a little extra detailto the exception message and a working alternative should help pointingthese people in the right direction before spending time debugging this.
1986299 tof7a47d8Compare| thrownewParameterNotFoundException($name,null,null,null,$alternatives); | ||
| $nonNestedAlternative =null; | ||
| if (!count($alternatives) &&false !==strpos($name,'.')) { | ||
| $namePartsLength =array_map('strlen',explode('.',$name)); |
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 using implode ?
fabpot commentedSep 14, 2016
Thank you@wouterj. |
A common problem under beginners is to think that the dot notation is used to access nested arrays saved in parameters (common here means someone asks help for this problem at least once a week on IRC). Adding a little extra detail to the exception message and a working alternative should help pointing these people in the right direction before spending time debugging this.
It's quite late in the night over here, so the wording of the exception message probably isn't great. I'm happy to accept better suggestions 😃