Skip to content

ServiceSubscriberTrait is incompatible with AbstractController #33355

@a-menshchikov

Description

@a-menshchikov

Symfony version(s) affected: 4.3.3

Description
On PHP 7.3 fatal error occurs on using Symfony\Contracts\Service\ServiceSubscriberTrait in controller class that extends Symfony\Bundle\FrameworkBundle\Controller\AbstractController:

PHP Fatal error: Symfony\Bundle\FrameworkBundle\Controller\AbstractController and Symfony\Contracts\Service\ServiceSubscriberTrait define the same property ($container) in the composition of App\Controller\Api\v1\Project\DvrChannelController. However, the definition differs and is considered incompatible.

How to reproduce

<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Contracts\Service\ServiceSubscriberTrait;

class TestController extends AbstractController
{
    use ServiceSubscriberTrait;
}

Then run cache:clear command.

Possible Solution
Make $container property protected.

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