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] Ambiguous wording regarding_defaults inservices.yaml; usingwhen@<env> does not use_defaults #21523

Open
@ToshY

Description

@ToshY

Problem

The documentation regarding theautoconfigure option states the following regarding_defaults:

Above, the services.yaml file has autoconfigure: true in the _defaults section so that it applies to all services defined in that file. With this setting, the container will automatically apply certain configuration to your services, based on your service's class. This is mostly used to auto-tag your services.

(this is also denoted insymfony/symfony#28326 (comment) that the defaults are file-based)

With the introduction of usingwhen@<env> tags that can be used within the same file, likeservices.yaml file, this statement has become somewhat ambiguous, as_defaults does not (literally) apply to all services defined in the file. When settingautowire, it does only apply to the currentservices, not to the ones defined under the services ifwhen is used in the same file.

Working example:

services.yaml

services:# default configuration for services in *this* file; (this is the default comment from framework bundle recipe)_defaults:autowire:trueautoconfigure:trueApp\My\Service:# has arbitrary amount of argumentswhen@prod:services:_defaults:autowire:trueautoconfigure:trueApp\My\Service:# autowired arguments passed to service; works

Non-working example:

services.yaml

services:# default configuration for services in *this* file ; (this is the default comment from framework bundle recipe)_defaults:autowire:trueautoconfigure:trueApp\My\Service:# has arbitrary amount of argumentswhen@prod:services:App\My\Service:# no explicit arguments given thus failing with "ArgumentCountError" as not autowired

The wording...that it applies to all services defined in that file or# default configuration for services in *this* file (in theservices.yaml) makes it seems as if the "Non-working example" should have worked as everything is defined in thesame file (but it doesn't).

Suggestion

Add a note/warning to theautoconfigure option section that the_defaults need to be explicitely redefined when usingwhen in the sameservices.yaml.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp