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

[DependencyInjection] Tweaked factories#12065

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

Conversation

@unkind
Copy link
Contributor

QA
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#12008
LicenseMIT
Doc PRn/a

There are some issues with new service factories:

  • ContainerBuilder cannot instantiate service from factory (i.e. currently it works for dumped code only)
  • Dumped code sometimes is invalid (anonymous services as factories, factories without arguments)

@unkindunkind changed the title[DependencyInjection] Tweak factories as callables feature[DependencyInjection] Tweaked factories as callables featureSep 27, 2014
@unkindunkindforce-pushed thebugfix-service-factory-tweaks branch 2 times, most recently from562b870 to4264436CompareSeptember 27, 2014 16:39
Copy link
Member

Choose a reason for hiding this comment

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

Sorry about that but PHP-CS-Fixer is buggy here. The previous code was "better". Can you revert this one and the other one as well. Thanks.

@unkindunkindforce-pushed thebugfix-service-factory-tweaks branch from4264436 tocf905b7CompareSeptember 28, 2014 17:54
@unkind
Copy link
ContributorAuthor

PhpDumper->addService:

if ($definition->isSynthetic()) {$return[] ='@throws RuntimeException always since this service is expected to be injected dynamically';        }elseif ($class =$definition->getClass()) {$return[] =sprintf("@return %s A %s instance.",0 ===strpos($class,'%') ?'object' :"\\".$class,$class);        }elseif ($definition->getFactory()) {$factory =$definition->getFactory();if (is_string($factory)) {$return[] =sprintf('@return object An instance returned by %s().',$factory);            }elseif (is_array($factory) && (is_string($factory[0]) ||$factory[0]instanceof Definition ||$factory[0]instanceof Reference)) {if (is_string($factory[0]) ||$factory[0]instanceof Reference) {$return[] =sprintf('@return object An instance returned by %s::%s().', (string)$factory[0],$factory[1]);                }elseif ($factory[0]instanceof Definition) {$return[] =sprintf('@return object An instance returned by %s::%s().',$factory[0]->getClass(),$factory[1]);                }            }        }elseif ($definition->getFactoryClass()) {$return[] =sprintf('@return object An instance returned by %s::%s().',$definition->getFactoryClass(),$definition->getFactoryMethod());        }elseif ($definition->getFactoryService()) {$return[] =sprintf('@return object An instance returned by %s::%s().',$definition->getFactoryService(),$definition->getFactoryMethod());        }

I thought it is not allowed to define service withoutclass, any real case for this code?

@unkind
Copy link
ContributorAuthor

I'll fix tests later.

@nicolas-grekas
Copy link
Member

👍 once tests are fixed

Copy link
Member

Choose a reason for hiding this comment

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

the factory should win over the factory method, to be consistent with the code generated for dumped containers

@stof
Copy link
Member

Please also add a test instantiating a service with a factory in the ContainerBuilder (well, several to cover the different cases)

@unkindunkindforce-pushed thebugfix-service-factory-tweaks branch 8 times, most recently fromb6ee1f8 tod9f2720CompareOctober 1, 2014 20:25
@unkind
Copy link
ContributorAuthor

Sorry for delay, tests have been updated.

@unkindunkindforce-pushed thebugfix-service-factory-tweaks branch fromd9f2720 toee82392CompareOctober 1, 2014 21:49
@unkindunkind changed the title[DependencyInjection] Tweaked factories as callables feature[DependencyInjection] Tweaked factoriesOct 1, 2014
@unkind
Copy link
ContributorAuthor

@fabpot@stof please, check it, I think it is possible to finish#11968 for 2.6.

@fabpot
Copy link
Member

Looks good to me@unkind. This is merged now. Thanks.

@fabpotfabpot merged commitee82392 intosymfony:masterOct 3, 2014
fabpot added a commit that referenced this pull requestOct 3, 2014
This PR was merged into the 2.6-dev branch.Discussion----------[DependencyInjection] Tweaked factories| Q             | A| ------------- | ---| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#12008| License       | MIT| Doc PR        | n/aThere are some issues with new service factories: * `ContainerBuilder` cannot instantiate service from factory (i.e. currently it works for dumped code only) * Dumped code sometimes is invalid (anonymous services as factories, factories without arguments)Commits-------ee82392 [DependencyInjection] Tweaked factories
@unkindunkind deleted the bugfix-service-factory-tweaks branchOctober 3, 2014 07:48
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@unkind@nicolas-grekas@stof@fabpot@romainneutron

[8]ページ先頭

©2009-2025 Movatter.jp