Skip to content
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

[DI] Remove unreachable code #25158

Merged
merged 1 commit into from Nov 26, 2017

Conversation

@GawainLynch
Copy link
Contributor

commented Nov 26, 2017

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

#24033 added the ability to ignore uninitialized references, but the regex above the conditional would lead to an InvalidArgumentException being thrown.

@GawainLynch

This comment has been minimized.

Copy link
Contributor Author

commented Nov 26, 2017

@nicolas-grekas I am scratching my head on all the test fails here, they pass locally under the same PHP versions. Hints welcome 😄

@nicolas-grekas

This comment has been minimized.

Copy link
Member

commented Nov 26, 2017

What's the use case? Can't you use an iterator instead? The downside is that this would be a Symfony specific syntax, whereas I'm aiming at making this function a PSR, so that I'd prefer handling only things that might be accepted by the FIG...

@GawainLynch

This comment has been minimized.

Copy link
Contributor Author

commented Nov 26, 2017

Zero stress, happy to close off.

In that case, doesn't it make this dead code then:

} elseif ($optionalBehavior = '!' === $type[0]) {
$type = substr($type, 1);
$optionalBehavior = ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE;
}

… as the regex will only allow ? or a letter.

@nicolas-grekas

This comment has been minimized.

Copy link
Member

commented Nov 26, 2017

In that case, doesn't it make this dead code then:

correct! let's remove that :)

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Nov 26, 2017

@GawainLynch

This comment has been minimized.

Copy link
Contributor Author

commented Nov 26, 2017

No worries, I'll rebase and change direction 👍

@nicolas-grekas nicolas-grekas changed the title [DI] Add ! to regex check in service subscriber compiler [DI] Remove unreachable code Nov 26, 2017

@@ -68,15 +68,12 @@ protected function processValue($value, $isRoot = false)
$declaringClass = (new \ReflectionMethod($class, 'getSubscribedServices'))->class;
foreach ($class::getSubscribedServices() as $key => $type) {
if (!is_string($type) || !preg_match('/^\??[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)*+$/', $type)) {
if (!is_string($type) || !preg_match('/^[\?!]?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)*+$/', $type)) {

This comment has been minimized.

Copy link
@nicolas-grekas

nicolas-grekas Nov 26, 2017

Member

should be reverted

This comment has been minimized.

Copy link
@GawainLynch

GawainLynch Nov 26, 2017

Author Contributor

🤦‍♂

@xabbuh
xabbuh approved these changes Nov 26, 2017
@fabpot
fabpot approved these changes Nov 26, 2017
@fabpot

This comment has been minimized.

Copy link
Member

commented Nov 26, 2017

Thank you @GawainLynch.

@fabpot fabpot merged commit ced0857 into symfony:3.4 Nov 26, 2017

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
fabbot.io Your code looks good.
Details
fabpot added a commit that referenced this pull request Nov 26, 2017
bug #25158 [DI] Remove unreachable code (GawainLynch)
This PR was merged into the 3.4 branch.

Discussion
----------

[DI] Remove unreachable code

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

#24033 added the ability to ignore uninitialized references, but the regex above the conditional would lead to an `InvalidArgumentException` being thrown.

Commits
-------

ced0857 Remove unreachable code

@GawainLynch GawainLynch deleted the GawainLynch:di-uninit-ref branch Nov 26, 2017

This was referenced Nov 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.