Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DI] Do not suggest writing an implementation when multiple exist#26595

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:3.4fromchalasr:autowiring-suggest
Mar 29, 2018

Conversation

@chalasr
Copy link
Member

QA
Branch?3.4
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRn/a

Before:

Cannot autowire service "App\Decorator2": argument "$inner" of method "__construct()" references interface "App\SomeInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "App\Decorator1", "App\Decorator2", "App\Original". Did you create a class that implements this interface?

After:

Cannot autowire service "App\Decorator2": argument "$inner" of method "__construct()" references interface "App\SomeInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "App\Decorator1", "App\Decorator2", "App\Original".

@javiereguiluz
Copy link
Member

javiereguiluz commentedMar 19, 2018
edited
Loading

@chalasr much better! If I may, I'd like to propose another tweak to your latest proposal:

Cannot autowire service "_____": argument "_____" of method "_____" is ambiguousbecause it references interface "_____" which is implemented by multipleservices. You should alias this interface to one of these services: "_____","_____", "_____".
teohhanhui reacted with thumbs up emoji

}else {
$alternatives =$this->createTypeAlternatives($reference);
$message =$this->container->has($type) ?'this service is abstract' :'no such service exists';
$message =sprintf('references %s "%s" but %s.%s',$r->isInterface() ?'interface' :'class',$type,$message,$this->createTypeAlternatives($reference));

Choose a reason for hiding this comment

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

$alternatives to be used on this line, no need to call createTypeAlternatives twice

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

}

$this->assertNotNull($e);
$this->assertSame('Cannot autowire service "setter_injection_collision": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\SetterInjectionCollision::setMultipleInstancesForOneArg()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "c1", "c2".',$e->getMessage());
Copy link
Member

@nicolas-grekasnicolas-grekasMar 19, 2018
edited
Loading

Choose a reason for hiding this comment

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

What's the difference with the previous way this test was written?
This one doesn't tell aboutDid you create...

Copy link
Member

Choose a reason for hiding this comment

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

@expectedExceptionMessage usesassertContains IIRC

chalasr and medinae reacted with thumbs up emoji
@chalasr
Copy link
MemberAuthor

chalasr commentedMar 29, 2018
edited
Loading

@javiereguiluz Not that I dislike your suggestion, but it applies for interfaces only whereas this code deals with classes as well and I'm just not in the mood for adding more conditions into it. This PR removes a bad suggestion, please feel free to improve the correct one in another :)

Ready on my side.

javiereguiluz and teohhanhui reacted with thumbs up emoji

@nicolas-grekas
Copy link
Member

Thank you@chalasr.

@nicolas-grekasnicolas-grekas merged commit1ffdb50 intosymfony:3.4Mar 29, 2018
nicolas-grekas added a commit that referenced this pull requestMar 29, 2018
…e exist (chalasr)This PR was merged into the 3.4 branch.Discussion----------[DI] Do not suggest writing an implementation when multiple exist| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aBefore:> Cannot autowire service "App\Decorator2": argument "$inner" of method "__construct()" references interface "App\SomeInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "App\Decorator1", "App\Decorator2", "App\Original". Did you create a class that implements this interface?After:> Cannot autowire service "App\Decorator2": argument "$inner" of method "__construct()" references interface "App\SomeInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "App\Decorator1", "App\Decorator2", "App\Original".Commits-------1ffdb50 [DI] Do not suggest writing an implementation when multiple exist
@chalasrchalasr deleted the autowiring-suggest branchMarch 30, 2018 00:27
This was referencedApr 3, 2018
nicolas-grekas added a commit that referenced this pull requestApr 3, 2018
…bbuh)This PR was merged into the 4.1-dev branch.Discussion----------[DependencyInjection] fix expected exception message| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |Updates a test that was introduced in#25631 to match the changes made in#26595.Commits-------042eb4f fix expected exception message
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof left review comments

@javiereguiluzjaviereguiluzjaviereguiluz approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

5 participants

@chalasr@javiereguiluz@nicolas-grekas@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp