Skip to content

Conversation

@mpdude
Copy link

@mpdude mpdude commented Dec 2, 2025

Symfony 8 added return types to all interfaces and classes. This leaks through the Behat API in places where Behat used classes from Symfony, for example the Event Dispatcher implementation or the \Behat\Testwork\ServiceContainer\Extension interface which extends \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface.

The Behat maintainers work on creating a new Behat release supporting Symfony 8, but it will also affect extensions like this one (Behat/Behat#1687).

Technically, this may be a BC break for people that extend the classes provided here (they're not final), but on the other hand, these classes were never meant to be an extension point in the first place.

@aik099
Copy link

aik099 commented Dec 3, 2025

This change is a BC break, because older Symfony versions could not be used anymore.

Have you checked, that with these changes you can use older Symfony versions?

@mpdude
Copy link
Author

mpdude commented Dec 3, 2025

Great to see you're responsive 😄

This is how PHP type variance works – return types can be added "bottom up", even if the interfaces do not (yet) require it. See https://onlinephp.io/c/dba0d for an example – this is valid code.

You can add the return types right now, and it will not affect compatibility with Symfony versions. But, unless you add this, the code won't work with Symfony 8.

@aik099
Copy link

aik099 commented Dec 3, 2025

That's good to know. Thank you. I've approved the PR. Hopefully somebody will merge it.

@mpdude mpdude force-pushed the prepare-behat-4 branch 3 times, most recently from 4ca3441 to d835c78 Compare December 17, 2025 09:11
@mpdude mpdude changed the title Prepare for Behat 4.x / Symfomy 8.x compatibility Prepare for Symfomy 8.x compatibility Dec 17, 2025
mpdude added a commit to mpdude/MinkExtension that referenced this pull request Dec 17, 2025
… Symfony 8.x

Squash-merge of FriendsOfBehat#37

commit f428dd9
Author: Matthias Pigulla <mp@webfactory.de>
Date:   Wed Dec 17 12:41:48 2025 +0100

    Declare dependencies for Symfony components that we are actually (and unconditionally) using

commit d835c78
Author: Matthias Pigulla <mp@webfactory.de>
Date:   Tue Dec 2 18:38:41 2025 +0100

    Prepare for Behat 4.x / Symfomy 8.x compatibility
mpdude added a commit to mpdude/MinkExtension that referenced this pull request Dec 17, 2025
… Symfony 8.x

Squash-merge of FriendsOfBehat#37

commit f428dd9
Author: Matthias Pigulla <mp@webfactory.de>
Date:   Wed Dec 17 12:41:48 2025 +0100

    Declare dependencies for Symfony components that we are actually (and unconditionally) using

commit d835c78
Author: Matthias Pigulla <mp@webfactory.de>
Date:   Tue Dec 2 18:38:41 2025 +0100

    Prepare for Behat 4.x / Symfomy 8.x compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants