Skip to content

[DependencyInjection][WIP] Add more information to the message when passin… #25136

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,14 @@ private function createTypeAlternatives(TypedReference $reference)
if ($message = $this->getAliasesSuggestionForType($type = $reference->getType())) {
return ' '.$message;
}

if (isset($this->ambiguousServiceTypes[$type])) {
$message = sprintf('one of these existing services: "%s"', implode('", "', $this->ambiguousServiceTypes[$type]));
} elseif (isset($this->types[$type])) {
$message = sprintf('the existing "%s" service', $this->types[$type]);
} elseif ($reference->getRequiringClass() && !$reference->canBeAutoregistered()) {
return ' It cannot be auto-registered because it is from a different root namespace.';
} elseif (is_array($this->types) && (null !== $key = array_search(strtolower($type), array_map('strtolower', $this->types)))) {
return sprintf(' Maybe you mean %s instead of %s ?', $key, $type);
Copy link
Contributor

@hhamon hhamon Nov 23, 2017

Choose a reason for hiding this comment

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

Did you mean %s instead of %s?

} else {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ class Foo
{
}

class FooFoo
{
public function __construct(Foo $foo)
{
}
}

class Bar
{
public function __construct(Foo $foo)
Expand Down Expand Up @@ -293,6 +300,17 @@ public function setChildMethodWithoutDocBlock(A $a)
}
}

class ARealClass {

}

class ClassMisMatch {

public function __construct(arealclass $n = null)
{
}
}

class NotWireable
{
public function setNotAutowireable(NotARealClass $n)
Expand Down