minor #31304 Made `debug:container` and `debug:autowiring` ignore starting 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
-------

0945f27e81 Made `debug:container` and `debug:autowiring` ignore starting backslash in service id
This commit is contained in:
Fabien Potencier 2019-05-01 08:35:18 +02:00
commit 0c3c21ac8d
2 changed files with 3 additions and 0 deletions

View File

@ -220,6 +220,8 @@ EOF
private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, string $name, bool $showHidden)
{
$name = ltrim($name, '\\');
if ($builder->has($name) || !$input->isInteractive()) {
return $name;
}

View File

@ -85,6 +85,7 @@ class ContainerDebugCommandTest extends WebTestCase
return [
[BackslashClass::class],
['FixturesBackslashClass'],
['\\'.BackslashClass::class],
];
}
}