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] Allow auto-configured method calls.#24996

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

Closed
GaryPEGEOT wants to merge9 commits intosymfony:masterfromGaryPEGEOT:feature/autoconfigured-calls
Closed

[DI] Allow auto-configured method calls.#24996

GaryPEGEOT wants to merge9 commits intosymfony:masterfromGaryPEGEOT:feature/autoconfigured-calls

Conversation

@GaryPEGEOT
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets
LicenseMIT
Doc PR

Allow to auto-configure method calls like:

$container->registerForAutoconfiguration(LoggerAwareInterface::class)->addMethodCall('setLogger',array(newReference(LoggerInterface::class)));

dmaicher, Koc, and enleur reacted with thumbs up emoji
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

thanks for starting this work

$definition->setInstanceofConditionals(array());
$parent =$shared =null;
$instanceofTags =array();
$instanceof =array(

Choose a reason for hiding this comment

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

another variable instead of an array would be better I think

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed inb61d981

$instanceofDef =clone$instanceofDef;
$instanceofDef->setAbstract(true)->setParent($parent ?:'abstract.instanceof.'.$id);
$parent ='instanceof.'.$interface.'.'.$key.'.'.$id;
$instanceofDef->setAbstract(true)->setParent($parent ?:"abstract.instanceof.$id");
Copy link
Member

@nicolas-grekasnicolas-grekasNov 16, 2017
edited
Loading

Choose a reason for hiding this comment

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

please revert these changes, they are unrelated (did fabbot suggest them? if yes, please ignore it :) )

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Not fabbot, just did it because string interpolation run faster in PHP7, but I can revert it.

Choose a reason for hiding this comment

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

yes please do, that's unrelated

if ($parent) {
$bindings =$definition->getBindings();
$abstract =$container->setDefinition('abstract.instanceof.'.$id,$definition);
$abstract =$container->setDefinition("abstract.instanceof.$id",$definition);

Choose a reason for hiding this comment

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

same as above

(newResolveChildDefinitionsPass())->process($container);

$expected =array(
array('foo',array('bar')),

Choose a reason for hiding this comment

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

changing an existing test case is always suspicious,
is this really legitimate? won't it introduce BC breaks?
we need to answer these questions carefully

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

This change came from the fact that if a definition has already a method call (line 125:if (!$definition->hasMethodCall($call[0])) {), I do not add it again to avoid call a setter multiple times. Hard to say if we should deduplicate or not method calls...

Choose a reason for hiding this comment

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

Hard to say if we should deduplicate or not method calls
we should not:

$twig->addExtension($ext1);$twig->addExtension($ext1);...

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I removed method filtering. Method order has changed, but seems normal since we now allow calls inheritance and they are added at the end of the process.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Test order fixed inda6d7e4

# calls from instanceof are kept, but this comes later
calls:
# first call is from instanceof
-[setSunshine, [bright]]

Choose a reason for hiding this comment

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

same as above: changing an existing test case needs to be doubly confirmed

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@nicolas-grekas fixed inda6d7e4

#
-[enableSummer, [true]]
-[setSunshine, [warm]]
# Call from instanceof
Copy link
Member

Choose a reason for hiding this comment

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

if the order of calls changes, that means a BC break

@GaryPEGEOT
Copy link
ContributorAuthor

Methods calls are now in the right order, error on Travis is unrelated (error with RedisAdapter).

@GaryPEGEOTGaryPEGEOT deleted the feature/autoconfigured-calls branchApril 3, 2018 12:41
@xabbuh
Copy link
Member

@GaryPEGEOT Why did you close here?

@nicolas-grekas
Copy link
Member

Continued in#26768

@GaryPEGEOT
Copy link
ContributorAuthor

Lost some of my commits, so openned a new one

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@xabbuhxabbuhxabbuh left review comments

Assignees

No one assigned

Projects

None yet

Milestone

4.1

Development

Successfully merging this pull request may close these issues.

4 participants

@GaryPEGEOT@xabbuh@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp