Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fatal error during upgrading to Symfony 7.3 and rebuilding container: Uncaught Error: First array member is not a valid class name or object #60585

Closed as not planned
@robiningelbrecht

Description

@robiningelbrecht

Symfony version(s) affected

7.3.0

Description

When running composer update symfony/* to upgrade from 7.2 to 7.3, all packages are downloaded and installed. When composer tries to clear the Symfony cache and the container is rebuilt, the following error is thrown:

Image

Line 799 contains:

 return $container->privates['App\\Infrastructure\\ValueObject\\Measurement\\UnitSystem'] = [NULL, 'from']($container->get("app.config")->get("appearance.unit_system", ));

The error is thrown due to the first value in the array NULL. The reason for NULL being there is that my service is defined as:

    App\Infrastructure\ValueObject\Measurement\UnitSystem:
        factory: [ null, from ]
        arguments: ['@=app_config("appearance.unit_system")']

How to reproduce

  • Add an entry in services.yaml with a factory method on the class itself:
    App\Namespace\To\Class
        factory: [ null, yourFactoryMethod ]
        arguments: ['your-argument']
  • update composer.json and edit all Symfony packages from 7.2.* to 7.3.*
  • Run composer update symfony/*

Possible Solution

No response

Additional Context

The Symfony docs state that this approach should be possible: https://symfony.com/doc/current/service_container/factories.html#using-the-class-as-factory-itself

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