-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Throw useful exception on bad XML argument tags #22527
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
Conversation
4bd1723
to
bbfcad4
Compare
Needs #22529 to be green. |
@@ -474,6 +476,9 @@ private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true, | |||
|
|||
switch ($arg->getAttribute('type')) { | |||
case 'service': | |||
if (!$arg->getAttribute('id')) { |
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.
hasAttribute
?
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.
An empty attribute is also invalid, so better as is IMHO
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.
Ok 👍
@@ -484,17 +489,23 @@ private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true, | |||
$arguments[$key] = new Expression($arg->nodeValue); | |||
break; | |||
case 'closure-proxy': | |||
if (!$arg->getAttribute('id')) { | |||
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="service" is missing an "id" attribute in "%s".', $name, $file)); |
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.
wrong type
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 thanks
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="service" is missing an "id" attribute in "%s".', $name, $file)); | ||
} | ||
if (!$arg->getAttribute('method')) { | ||
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="service" is missing a "method" attribute in "%s".', $name, $file)); |
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.
wrong type
ae21520
to
cdc24ba
Compare
rebased |
@@ -474,6 +476,9 @@ private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true, | |||
|
|||
switch ($arg->getAttribute('type')) { | |||
case 'service': | |||
if (!$arg->getAttribute('id')) { |
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.
Ok 👍
@@ -474,6 +476,9 @@ private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true, | |||
|
|||
switch ($arg->getAttribute('type')) { | |||
case 'service': | |||
if (!$arg->getAttribute('id')) { | |||
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="service" is missing an "id" attribute in "%s".', $name, $file)); |
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.
is missing or is empty?
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
cdc24ba
to
91828ec
Compare
Thank you @nicolas-grekas. |
…nicolas-grekas) This PR was merged into the 3.3-dev branch. Discussion ---------- [DI] Throw useful exception on bad XML argument tags | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #22525 | License | MIT | Doc PR | - I still think that the feature request in #22525 would make things better. But at least, let's make thing fail loudly, instead of silently today, with the associated usual wtfs :) Commits ------- 91828ec [DI] Throw useful exception on bad XML argument tags
I still think that the feature request in #22525 would make things better.
But at least, let's make thing fail loudly, instead of silently today, with the associated usual wtfs :)