Skip to content

[DI] Add check of internal type to ContainerBuilder::getReflectionClass #27025

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 24, 2018

Conversation

upyx
Copy link
Contributor

@upyx upyx commented Apr 24, 2018

Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #27018
License MIT
Doc PR no

This PR fixes bug described in #27018 issue.
I think that getReflectionClass should return NULL when internal type was used instead class name but not throws exception. As well as it does when class is empty. If someone have other opinion we can discuss it.

@upyx upyx force-pushed the fix_issue_27018 branch from 9ae116f to 45734b4 Compare April 24, 2018 07:35
@nicolas-grekas nicolas-grekas changed the title Fix issue 27018 [DI] Add check of internal type to ContainerBuilder::getReflectionClass Apr 24, 2018
@@ -321,6 +321,11 @@ public function getReflectionClass(?string $class, bool $throw = true): ?\Reflec
if (!$class = $this->getParameterBag()->resolveValue($class)) {
return null;
}

if ($this->isInternalType($class)) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest to use a private static array instead, and put types as keys in the array, so that checking could be done inline with a simple isset()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, you are right. It would be much better.

'array',
'null',
'callable',
'iterable',
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest to add "mixed" to the list: even if it's not an official one, it's pretty common in phpdoc so might be OK to use it here also

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After some reflections I agree with you :)

@upyx upyx force-pushed the fix_issue_27018 branch 2 times, most recently from 9964403 to 8c3c060 Compare April 24, 2018 08:14
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

(for 3.4)

@stof stof force-pushed the fix_issue_27018 branch from 8c3c060 to 314e881 Compare April 24, 2018 10:28
@stof stof changed the base branch from 4.0 to 3.4 April 24, 2018 10:28
@stof
Copy link
Member

stof commented Apr 24, 2018

Thank you @upyx.

@stof stof merged commit 314e881 into symfony:3.4 Apr 24, 2018
stof added a commit that referenced this pull request Apr 24, 2018
…flectionClass (upyx)

This PR was submitted for the 4.0 branch but it was merged into the 3.4 branch instead (closes #27025).

Discussion
----------

[DI] Add check of internal type to ContainerBuilder::getReflectionClass

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27018
| License       | MIT
| Doc PR        | no

This PR fixes bug described in #27018 issue.
I think that `getReflectionClass` should return `NULL` when internal type was used instead class name but not throws exception. As well as it does when class is empty. If someone have other opinion we can discuss it.

Commits
-------

314e881 [DI] Add check of internal type to ContainerBuilder::getReflectionClass
@upyx
Copy link
Contributor Author

upyx commented Apr 24, 2018

Thank you for your review!

@upyx upyx deleted the fix_issue_27018 branch April 24, 2018 10:31
@chalasr
Copy link
Member

chalasr commented Apr 24, 2018

Congratz for your first contribution to Symfony @upyx :)

This was referenced Apr 30, 2018
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