Skip to content

Support for DI config in PHP file format #303

Open
@Wirone

Description

@Wirone

Symfony supports PHP format for configuration (it's even default one now), so it would be great if this plugin could help with verifying DI configs. Assume we have:

class Foo
{
    public function __construct(Bar $bar, Baz $baz)
    {
    }
}
return static function (ContainerConfigurator $containerConfigurator): void {
    $services = $containerConfigurator->services();

    $services->set(Foo::class)
        ->public()
        ->args([Bar::class]);
});

Plugin should warn that Baz $baz argument is missing in the Foo service definition.

Similarly it should support:

  • factories like ->factory([service(FooFactory::class), 'create'])
    • if factory's service exists
    • if factory's class has such method
  • fetching parameters (like ->args(['%foo%']))
  • named args (like ->arg('$bar', service(Bar::class))
  • expressions (using expr())

That would really help with keeping quality in DI definitions with PHP format 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions