Skip to content

Commit

Permalink
minor #31304 Made debug:container and debug:autowiring ignore sta…
Browse files Browse the repository at this point in the history
…rting backslash in service id (ruudk)

This PR was merged into the 4.2 branch.

Discussion
----------

Made `debug:container` and `debug:autowiring` ignore starting backslash in service id

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

When you copy a reference to a class from PHPStorm it always start the FQCN with a backslash.

When you now try to search the container for this class using `bin/console debug:container "\My\Class"` it cannot find it.

This PR always removes the starting backslash before searching the container to avoid this issue.

Commits
-------

0945f27 Made `debug:container` and `debug:autowiring` ignore starting backslash in service id
  • Loading branch information
fabpot committed May 1, 2019
2 parents 7c9dffe + 0945f27 commit 0c3c21a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
Expand Up @@ -220,6 +220,8 @@ protected function getContainerBuilder()

private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, string $name, bool $showHidden)
{
$name = ltrim($name, '\\');

if ($builder->has($name) || !$input->isInteractive()) {
return $name;
}
Expand Down
Expand Up @@ -85,6 +85,7 @@ public function provideIgnoreBackslashWhenFindingService()
return [
[BackslashClass::class],
['FixturesBackslashClass'],
['\\'.BackslashClass::class],
];
}
}

0 comments on commit 0c3c21a

Please sign in to comment.