Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Merged
merged 1 commit into from
Apr 29, 2017

Conversation

nicolas-grekas
Copy link
Member

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 :)

@nicolas-grekas
Copy link
Member Author

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')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasAttribute?

Copy link
Member Author

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

Copy link
Contributor

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong type

Copy link
Member Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong type

@nicolas-grekas nicolas-grekas force-pushed the di-strict-xml branch 2 times, most recently from ae21520 to cdc24ba Compare April 26, 2017 14:24
@nicolas-grekas
Copy link
Member Author

rebased

@@ -474,6 +476,9 @@ private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true,

switch ($arg->getAttribute('type')) {
case 'service':
if (!$arg->getAttribute('id')) {
Copy link
Contributor

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

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@fabpot
Copy link
Member

fabpot commented Apr 29, 2017

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 91828ec into symfony:master Apr 29, 2017
fabpot added a commit that referenced this pull request Apr 29, 2017
…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
@nicolas-grekas nicolas-grekas deleted the di-strict-xml branch April 29, 2017 16:39
@fabpot fabpot mentioned this pull request May 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants