Skip to content

Commit

Permalink
feature #25290 [FrameworkBundle] debug:autowiring: don't list FQCN wh…
Browse files Browse the repository at this point in the history
…en they are aliased (nicolas-grekas)

This PR was merged into the 4.1-dev branch.

Discussion
----------

[FrameworkBundle] debug:autowiring: don't list FQCN when they are aliased

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

In order to favor type-hinting for interfaces, I propose to not list the class as explicitly autowireable when an alias exists for it.

Which means displaying only
```
  App\FooInterface
      alias to App\Foo
```

instead of
```
  App\Foo
  App\FooInterface
      alias to App\Foo
```

ping @weaverryan

Commits
-------

8cbfa1e [FrameworkBundle] debug:autowiring: don't list FQCN when they are aliased
  • Loading branch information
fabpot committed Dec 8, 2017
2 parents 279dc46 + 8cbfa1e commit 7744e8f
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -85,13 +85,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
$io->newLine();
$tableRows = array();
$hasAlias = array();
foreach ($serviceIds as $serviceId) {
$tableRows[] = array(sprintf('<fg=cyan>%s</fg=cyan>', $serviceId));
if ($builder->hasAlias($serviceId)) {
$tableRows[] = array(sprintf('<fg=cyan>%s</fg=cyan>', $serviceId));
$tableRows[] = array(sprintf(' alias to %s', $builder->getAlias($serviceId)));
$hasAlias[(string) $builder->getAlias($serviceId)] = true;
} else {
$tableRows[$serviceId] = array(sprintf('<fg=cyan>%s</fg=cyan>', $serviceId));
}
}

$io->table(array(), $tableRows);
$io->table(array(), array_diff_key($tableRows, $hasAlias));
}
}

0 comments on commit 7744e8f

Please sign in to comment.