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

Appearance settings

list:container reports "Invalid service XYZ, method Factory::method() does not exist" when called via __callStatic. #58614

Copy link
Copy link
Closed
@KevinVanSonsbeek

Description

@KevinVanSonsbeek
Issue body actions

Symfony version(s) affected

5.4 and up

Description

Back in #44356 this issue was reported for factories using the __call magic method.
This behavior was fxed back then in #44710. The same problem is present for the __callStatic logic however.

I ran into this issue, as we have a service definition of a MyCLabs enum, which uses static calls to create instances of the "enums".

I'm aware that the myclabs/enum package has no real use anymore since php 8.1, but due to the scale of the project we have not had the time yet to transition fully to native enums.

And the discrepancy between the two methods feels like it could've been an oversight when implementing said previous fix.

How to reproduce

use MyCLabs\Enum\Enum;

final class FooBar extends Enum
{
    public const FOO = 'foo_value';
    public const BAR = 'bar_value';
}
<service id="foo_instance" class="FooBar">
    <factory class="FooBar" method="FOO"/>
</service>

<service id="bar_instance" class="FooBar">
    <factory class="FooBar" method="BAR"/>
</service>

Possible Solution

A fix similiar to the one in https://github.com/symfony/symfony/pull/44710/files could be applied for the callStatic as well.

Additional Context

No response

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.