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] Prevent service:method factory notation in PHP config#24732

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

@vudaltsov
Copy link
Contributor

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

Started working on fixing#24704.

@nicolas-grekas, am I on the right way? If yes I will look at the tests and try to add this case.

@vudaltsov
Copy link
ContributorAuthor

Should I move the string splitting logic to theAbstractConfigurator::processValue?

@ro0NL
Copy link
Contributor

SeeYamlFileLoader::parseCallable; we need to supportconfigurator as well i guess. Also account for:: before splitting by: (seesetFactory).

Im not sure why we dont do this directly inDefinition::setFactory & co; right now XML is missing this feature as well. (e.g.function="service:method").

Otherwise perhaps go withstatic::processValue(static::processCallable()) or so.

@nicolas-grekasnicolas-grekas added this to the3.4 milestoneOct 30, 2017
@nicolas-grekas
Copy link
Member

I know I suggested this one, but I've mixed feelings about it :)
What about throwing instead? Providing a single way to reference services would make teaching easier.
The message should suggest to use[ref('foo'), 'bar'] whenfoo:bar is provided.
WDYT?

vudaltsov and ro0NL reacted with thumbs up emoji

@ogizanagi
Copy link
Contributor

I'd also prefer the exception suggested by@nicolas-grekas instead of this.

@vudaltsov
Copy link
ContributorAuthor

You know, I would also agree :)
When trying to implement it I realized that it looks unnatural.
[ref(), ''] definitely makes much more sense.

@nicolas-grekas
Copy link
Member

@vudaltsov let's throw here then instead?

@vudaltsovvudaltsovforce-pushed thedi-php-string-factory-fix branch fromc83ae1f to81ead82CompareNovember 16, 2017 21:58
@vudaltsov
Copy link
ContributorAuthor

@nicolas-grekas, done

@vudaltsovvudaltsov changed the title[DependencyInjection] Add service:method notation in PHP config[DependencyInjection] Prevent service:method factory notation in PHP configNov 16, 2017
finalpublicfunctionfactory($factory)
{
if (is_string($factory) &&1 ===substr_count($factory,':')) {
thrownewInvalidArgumentException('The short factory notation is not supported by the PHP-based DI configuration.');
Copy link
Contributor

Choose a reason for hiding this comment

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

In addition, it should also suggest to use[ref('service'), 'method'] instead.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I am also considering to replaceshort factory notation withservice:method notation. WDYT

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

So the final exception will look likeThe service:method factory notation is not supported by the PHP-based DI configuration. Use [ref('service'), 'method'] instead.

Choose a reason for hiding this comment

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

LGTM, with double quotes around, and resolved/actual id+method, eg:

Invalid factory "%s:%s": the `service:method` notation is not available when using PHP-based DI configuration. Use "[ref('%s'), '%s']" instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

Static is still allowed usingfactory('class::method')? Or should that notation also be explicit; thusfactory('class', 'method').

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

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.

(could you please squash, and update the commit message meanwhile please)

@vudaltsovvudaltsovforce-pushed thedi-php-string-factory-fix branch frombe6fa70 to49fc677CompareNovember 17, 2017 09:52
@vudaltsov
Copy link
ContributorAuthor

@nicolas-grekas, squashed, reworded and rebased

@nicolas-grekas
Copy link
Member

Thank you@vudaltsov.

@nicolas-grekasnicolas-grekas merged commit49fc677 intosymfony:3.4Nov 17, 2017
nicolas-grekas added a commit that referenced this pull requestNov 17, 2017
…ion in PHP config (vudaltsov)This PR was merged into the 3.4 branch.Discussion----------[DependencyInjection] Prevent service:method factory notation in PHP config| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#24704| License       | MIT| Doc PR        |Started working on fixing#24704.@nicolas-grekas, am I on the right way? If yes I will look at the tests and try to add this case.Commits-------49fc677 Throw on service:method factory notation in PHP-based DI configuration
@vudaltsovvudaltsov deleted the di-php-string-factory-fix branchNovember 17, 2017 10:02
This was referencedNov 21, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

+2 more reviewers

@ro0NLro0NLro0NL left review comments

@ogizanagiogizanagiogizanagi left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

5 participants

@vudaltsov@ro0NL@nicolas-grekas@ogizanagi@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp