Content-Length: 221747 | pFad | http://github.com/symfony/symfony/issues/60593

A4 [DependencyInjection] Invalid service "Foo\Bar": its constructor must be public · Issue #60593 · symfony/symfony · GitHub
Skip to content

[DependencyInjection] Invalid service "Foo\Bar": its constructor must be public #60593

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
derrabus opened this issue May 30, 2025 · 0 comments

Comments

@derrabus
Copy link
Member

Symfony version(s) affected

7.3.0

Description

I tried to upgrade a codebase to Symfony 7.3 that contains classes that serve merely as a namespace for utility functions, e.g.:

final readonly class MyUtils
{
    public static function doSomething()
    {
        // some logic
    }

    private function __construct() {}
}

Those classes are not meant to be instantiated and they're not wired anywhere. However, wen I try to perform a service autodiscovery on a namespace that hat classes like that, I now get an error:

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

Excluding each and every of these classes from the discovery solves this issue, but I would've expected that this error is not raised unless I actually try to wire one of those classes as a service.

How to reproduce

I'll try to come up with a reproducer soon.

Possible Solution

No response

Additional Context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/symfony/symfony/issues/60593

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy