Skip to content

False positive with \Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface::get() #191

@alexsakhnov

Description

@alexsakhnov

Symfony ContainerBagInterface implements Psr\Container\ContainerInterface but actually it returns a container parameter, not a service.

However ContainerInterfaceUnknownServiceRule checks for service existence, not parameter. For example this code

/** @var \Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface $params */
$parameterValue = $params->get('parameter_name');

results in the following error

Service "parameter_name" is not registered in the container.

I suggest to ignore subtypes of ContainerBagInterface in the ContainerInterfaceUnknownServiceRule. Is this correct?

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