Skip to content

lint:container reports "Invalid service XYZ, method Factory:method() does not exist", when it's called via __call #44356

Closed
@chregu

Description

@chregu

Symfony version(s) affected

5.3 / 5.4 (didn't test for others)

Description

With the following service definition:

  Aws\Sdk:
        factory:   ['App\Infrastructure\Aws\SdkFactory', 'createSdk']
        arguments:
            $key: '%aws.credentials.key%'
            $secret: '%aws.credentials.secret%'

    Aws\DynamoDb\DynamoDbClient:
        factory: ['@Aws\Sdk', createDynamoDb]
        arguments:
            -
                version: "%aws.dynamodb.client.version%"
                region: "%aws.dynamodb.client.region%"
                endpoint: "%aws.dynamodb.client.endpoint%"

Symfony during "lint:container" reports

 Invalid service "Aws\DynamoDb\DynamoDbClient": method "Aws\Sdk::createDynamoDb()" does not exist.

The AWS SDK only implements a __call method and does the magic there.

It actually still worked in Symfony 5.3 (and I assume older versions), but reported it with "bin/console lint:container", but now even "composer install" fails in Symfony 5.4 due to that.

How to reproduce

See above

Possible Solution

Symfony should maybe check, if there's a __call method in the factory

(my solution, which also worked but is just manual work, was to extend AWS\Sdk and just the factory method defining the methods I need there)

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