Skip to content

[DI] Cannot instantiate abstract class #22345

@pierredup

Description

@pierredup
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.3.0-dev

When defining a service without the class config, and that has an abstract parent, I'm getting the error Cannot instantiate abstract class ...

Class definitions:

abstract class AbstractTestService {}

class TestService extends AbstractTestService { }

This is the service definition:

AppBundle\AbstractTestService:
    abstract: true

AppBundle\TestService:
    parent: AppBundle\AbstractTestService

Whenever I try to use the AppBundle\TestService service, I'm getting the above mentioned error.

This config however works, when I add the class option to the TestService definition

AppBundle\AbstractTestService:
    abstract: true

AppBundle\TestService:
    class: AppBundle\TestService
    parent: AppBundle\AbstractTestService

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