Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Conversation

@wouterj
Copy link
Member

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets-
LicenseMIT
Doc PRn/a

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 😃

linaori, ogizanagi, and chalasr reacted with thumbs up emoji
@wouterj
Copy link
MemberAuthor

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)

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?

Copy link
MemberAuthor

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.
@wouterjwouterjforce-pushed thedi/parameters-keys-error-experience branch from1986299 tof7a47d8CompareAugust 10, 2016 07:37
thrownewParameterNotFoundException($name,null,null,null,$alternatives);
$nonNestedAlternative =null;
if (!count($alternatives) &&false !==strpos($name,'.')) {
$namePartsLength =array_map('strlen',explode('.',$name));
Copy link
Contributor

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
Copy link
Member

Thank you@wouterj.

@wouterjwouterj deleted the di/parameters-keys-error-experience branchSeptember 15, 2016 07:36
@fabpotfabpot mentioned this pull requestOct 27, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@wouterj@fabpot@kashike@GuilhemN@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp