phoenix icon indicating copy to clipboard operation
phoenix copied to clipboard

Twig 4 compatilibity

Open tacman opened this issue 7 months ago • 6 comments

Is there any downside to adding a return type of array to getFilters()?

Script cache:clear returned with error code 255
!!  PHP Fatal error:  Declaration of Doctrine\Bundle\DoctrineBundle\Twig\DoctrineExtension::getFilters() must be compatible with Twig\Extension\AbstractExtension::getFilters(): array in /home/tac/sites/pokemon/vendor/doctrine/doctrine-bundle/src/Twig/DoctrineExtension.php on line 44
!!  Symfony\Component\ErrorHandler\Error\FatalError {#5861
!!    #message: "Compile Error: Declaration of Doctrine\Bundle\DoctrineBundle\Twig\DoctrineExtension::getFilters() must be compatible with Twig\Extension\AbstractExtension::getFilters(): array"
!!    #code: 0
!!    #file: "./vendor/doctrine/doctrine-bundle/src/Twig/DoctrineExtension.php"
!!    #line: 44
!!    -error: array:4 [
!!      "type" => 64
!!      "message" => "Declaration of Doctrine\Bundle\DoctrineBundle\Twig\DoctrineExtension::getFilters() must be compatible with Twig\Extension\AbstractExtension::getFilters(): array"
!!      "file" => "/home/tac/sites/pokemon/vendor/doctrine/doctrine-bundle/src/Twig/DoctrineExtension.php"
!!      "line" => 44
!!    ]
!!  }
!!  

/vendor/doctrine/doctrine-bundle/src/Twig/DoctrineExtension.php

Or is this something that will need to wait for a point release?

tacman avatar Apr 29 '25 15:04 tacman

We can add it in patch release. However, is that the only change needed for twig 4 support?

ostrolucky avatar Apr 29 '25 15:04 ostrolucky

Any downside to adding it now? I've started to test Symfony 7.3 and twig 4, and got stuck here. I assume there's a solution, but is there a downside to simply adding it now? Like breaking some old version of php?

tacman avatar Apr 29 '25 15:04 tacman

Yes it's potentially BC breaking in case somebody extends that class. Hence it will be added together with Twig 4 support, not separately. If it's the only thing needed for Twig 4 support, I'm fine with having it in patch release, otherwise no.

ostrolucky avatar Apr 29 '25 16:04 ostrolucky

And as expected, it's not the only change required https://github.com/doctrine/DoctrineBundle/blob/4c59dbca6394ef060d0423c429380eb0a4cae391/composer.json#L76

ostrolucky avatar Apr 29 '25 16:04 ostrolucky

@ostrolucky isn't this a conflict rule forbidding old verisons of Twig ?

stof avatar Apr 29 '25 16:04 stof

I stand corrected. So again, is this the only change required? Tests currently can't really coexist with twig 4, because symfony dependencies are blocking twig 4.

ostrolucky avatar Apr 30 '25 08:04 ostrolucky