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] Don't skip classes with private constructor when autodiscovering#59712

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

nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedFeb 6, 2025
edited
Loading

QA
Branch?7.3
Bug fix?no
New feature?yes
Deprecations?no
IssuesFix#48392
LicenseMIT

With value objects auto-discovery becoming more mainstream (see#59704), it's time to fix registering classes with private constructors.

Those are skipped today but with support for#[Autoconfigure(constructor: 'createInstance')] as introduced in#49665, this doesn't make sense anymore.

Best reviewedignoring whitespace.

ruudk and GromNaN reacted with heart emoji
@stof
Copy link
Member

stof commentedFeb 6, 2025

Do we still have a compiler pass validating that services are either instantiable classes or have a factory configured, so that we get a clean error at build time for services that miss this configuration ? And if yes, do we need to update its error message to mention the possibility to use#[Autoconfigure(constructor: ...)] for autoconfigured definitions ?

@nicolas-grekas
Copy link
MemberAuthor

We do have a compiler pass but it didn't tell about the attribute. PR updated:

Invalid service "App\Foo": its constructor must be public. Did you miss configuring a factory or a static constructor? Try using the "#[Autoconfigure(constructor: ...)]" attribute for the latter.

OskarStark and chalasr reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas merged commit4d9b7be intosymfony:7.3Feb 10, 2025
8 of 11 checks passed
@nicolas-grekasnicolas-grekas deleted the di-not-instantiables branchFebruary 12, 2025 15:25
@fabpotfabpot mentioned this pull requestMay 2, 2025
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
7.3
Development

Successfully merging this pull request may close these issues.

[DependencyInjection] Allow registering attributes on classes that cannot be instantiated
3 participants
@nicolas-grekas@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp