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] Factorize compiler passes around new AbstractRecursivePass#21327

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
fabpot merged 1 commit intosymfony:masterfromnicolas-grekas:di-recursive
Jan 23, 2017

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedJan 17, 2017
edited
Loading

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

This PR introduces an AbstractRecursivePass that is able to visit the definition tree recursively everywhere a Definition or a Reference can be nested.

All existing compiler passes that need recursivity are updated to leverage this new class.
This remove a bunch of boilerplate that was previously repeated all over.
It also fixes compiler passes that eg missed looking at configurators for no reason (this "fix" is a new feature really).
It then applies recursivity to AutowirePass, that does not handle it today, but should.

I'm happy that the net result is a loss of 153 lines :)

}else {
$arguments[$k] =clone$definition;
}
if ($definition->isShared()) {

Choose a reason for hiding this comment

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

Can this be turned into a 1-liner?

$value =$definition->isShared() ?$definition :clone$definition;

Copy link
Member

Choose a reason for hiding this comment

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

no. Shared definitions are returned directly, while non-shared ones are passed to the parent processing

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Indeed now - I changed that after@javiereguiluz's comment :)

}
$this->lazy =false;

foreach ($container->getAliases()as$id =>$alias) {
Copy link
Member

Choose a reason for hiding this comment

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

this is moved before the processing of definitions instead of after. Is it expected ? And does it make any difference ?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

given that this pass is ready-only, that doesn't make any difference yes

}else {
$arguments[$k] =clone$definition;
}
if ($definition->isShared()) {
Copy link
Member

Choose a reason for hiding this comment

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

no. Shared definitions are returned directly, while non-shared ones are passed to the parent processing

$definition->setFactory($this->updateFactoryReference($replacements,$definition->getFactory()));
}
parent::process($container);
$this->replacements =array();
Copy link
Member

Choose a reason for hiding this comment

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

should be in a finally block to ensure it is still reset on exceptions

Copy link
MemberAuthor

@nicolas-grekasnicolas-grekasJan 18, 2017
edited
Loading

Choose a reason for hiding this comment

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

I decided not, to remove one level of indentation: on exception, there would be no circular refs to cleanup - thus no need.

}

/**
* Process a value found in a definition tree.
Copy link
Member

Choose a reason for hiding this comment

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

Processes

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

fixed

* @param mixed $value
* @param bool $isRoot
*
* @return mixed The processed value
Copy link
Member

Choose a reason for hiding this comment

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

Can be removed as mixed does not really help :)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I fear that people won't notice that the return value is here at all.

HeahDude reacted with thumbs up emoji
abstractclass AbstractRecursivePassimplements CompilerPassInterface
{
protected$container;
protected$currentId;
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be "better" to create getters for those?

Copy link
MemberAuthor

@nicolas-grekasnicolas-grekasJan 18, 2017
edited
Loading

Choose a reason for hiding this comment

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

Some passes set the value also. They are "local vars passed as properties". Cleaned after use. Just saves boilerplates this way. I'd prefer keep them asis.

@fabpotfabpot merged commit6acb80f intosymfony:masterJan 23, 2017
fabpot added a commit that referenced this pull requestJan 23, 2017
…rsivePass (nicolas-grekas)This PR was merged into the 3.3-dev branch.Discussion----------[DI] Factorize compiler passes around new AbstractRecursivePass| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -This PR introduces an AbstractRecursivePass that is able to visit the definition tree recursively everywhere a Definition or a Reference can be nested.All existing compiler passes that need recursivity are updated to leverage this new class.This remove a bunch of boilerplate that was previously repeated all over.It also fixes compiler passes that eg missed looking at configurators for no reason (this "fix" is a new feature really).It then applies recursivity to AutowirePass, that does not handle it today, but should.I'm happy that the net result is a loss of 153 lines :)Commits-------6acb80f [DI] Factorize compiler passes around new AbstractRecursivePass
@nicolas-grekasnicolas-grekas deleted the di-recursive branchJanuary 23, 2017 21:12
fabpot added a commit that referenced this pull requestJan 24, 2017
This PR was merged into the 3.3-dev branch.Discussion----------[DependencyInjection] Remove an unused docblock| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aThe removal of this doc block was forgotten in#21327.Commits-------9e33434 [DependencyInjection] Remove an unused docblock
@fabpotfabpot mentioned this pull requestMay 1, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot left review comments

@javiereguiluzjaviereguiluzjaviereguiluz left review comments

@stofstofstof left review comments

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

5 participants

@nicolas-grekas@fabpot@javiereguiluz@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp