Skip to content

build(ContainerBuilder $container) incompatibility (Symfony 8, php 8.4) #4719

@tacman

Description

@tacman

Running php 8.4 and Symfony 8 (include symfony/twig-bundle) I'm getting this error.

The issue is with

Did something change in Symfony 8 so that this if statement needs to change?

if (!method_exists(ContainerBuilder::class, 'getAutoconfiguredAttributes')) {
    class TwigExtraBundle extends Bundle
    {
        public function build(ContainerBuilder $container): void
        {
            parent::build($container);

            $container->addCompilerPass(new MissingExtensionSuggestorPass());
        }
    }
} else {
    class TwigExtraBundle extends Bundle
    {
        /** @return void */
        public function build(ContainerBuilder $container)
        {

m var/cache/ -rf
~/g/sites/md$ bin/console c:cl
PHP Fatal error: Declaration of Twig\Extra\TwigExtraBundle\TwigExtraBundle::build(Symfony\Component\DependencyInjection\ContainerBuilder $container) must be compatible with Symfony\Component\HttpKernel\Bundle\Bundle::build(Symfony\Component\DependencyInjection\ContainerBuilder $container): void in /home/tac/g/sites/md/vendor/twig/extra-bundle/TwigExtraBundle.php on line 32
Symfony\Component\ErrorHandler\Error\FatalError^ {#90
#message: "Compile Error: Declaration of Twig\Extra\TwigExtraBundle\TwigExtraBundle::build(Symfony\Component\DependencyInjection\ContainerBuilder $container) must be compatible with Symfony\Component\HttpKernel\Bundle\Bundle::build(Symfony\Component\DependencyInjection\ContainerBuilder $container): void"
#code: 0
#file: "./vendor/twig/extra-bundle/TwigExtraBundle.php"
#line: 32
-error: array:4 [
"type" => 64
"message" => "Declaration of Twig\Extra\TwigExtraBundle\TwigExtraBundle::build(Symfony\Component\DependencyInjection\ContainerBuilder $container) must be compatible with Symfony\Component\HttpKernel\Bundle\Bundle::build(Symfony\Component\DependencyInjection\ContainerBuilder $container): void"
"file" => "/home/tac/g/sites/md/vendor/twig/extra-bundle/TwigExtraBundle.php"
"line" => 32
]
}

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