Support Behat 4 and Symfony 8 - #84
Open
stixx wants to merge 1 commit into
Open
Conversation
stixx
force-pushed
the
support-symfony-8
branch
2 times, most recently
from
September 5, 2026 21:15
7938499 to
b8b4798
Compare
Adds the return types Behat 4 requires on implementations of its interfaces,
and widens the version constraints so both major versions are permitted.
Behat 4 declares `Controller::execute(): ?int` and `Extension::getConfigKey():
string`. Four implementations lacked those types, which is a fatal error under
Behat 4 — ParallelController, RerunController, SigintController and Extension.
Adding a return type where the parent declares none is allowed, so these remain
compatible with Behat 3.
Constraints are widened rather than moved: `behat/behat ^3.9 || ^4.0` and
`|| ^8.0` on the symfony components. Nothing is forced to upgrade — Behat 3 and
Symfony 7 users are unaffected.
Verified on two stacks, both PHP 8.5:
Behat 3.32.0 (default resolution)
phpstan no errors
phpunit 78 tests, 189 assertions
behat 18 scenarios, 99 steps
symfony/process, serializer and expression-language resolve to v8.1.6
Behat 4.0.0-alpha1, all seven symfony components at v8
phpstan no errors
parallel execution verified in a separate consumer project:
3 scenarios serial 1335ms vs 903ms with --parallel 3
The extension's own Behat suite is not ported to Behat 4 and still runs under
Behat 3. Behat 4 removed both docblock annotations and YAML configuration, so
porting it means converting every context to attributes and all seven fixture
configs to PHP — which cannot serve Behat 3 at the same time. That is a
decision about dropping Behat 3 support, so it is left out of this change.
stixx
force-pushed
the
support-symfony-8
branch
from
September 5, 2026 21:48
a0a2749 to
3808578
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Behat 4 declares
Controller::execute(): ?intandExtension::getConfigKey(): string. Fourimplementations here lack those return types, which is a fatal error under Behat 4:
This adds them to
ParallelController,RerunController,SigintControllerandExtension, andwidens the constraints to
behat/behat: ^3.9 || ^4.0plus|| ^8.0on the symfony components.Adding a return type where the parent declares none is allowed, so Behat 3 keeps working. Constraints
are widened rather than moved — nothing is forced to upgrade.
Verified on both stacks, PHP 8.5
Behat 3.32.0, default resolution — the existing-user path:
symfony/process,serializerandexpression-languageresolve to v8.1.6 here. The other four stayon 7.x because Behat 3 caps them.
Behat 4.0.0-alpha1, all seven symfony components on v8 — phpstan clean. Since the suite below can't
run on Behat 4 yet, parallel execution was verified in a separate consumer project:
Not included: porting this project's own Behat suite
It still runs under Behat 3. Behat 4 removed both docblock annotations and YAML configuration, so
porting means converting every context to
#[Given]attributes and all seven fixturebehat.yml.distfiles to PHP — and those can't serve Behat 3 at the same time.
That makes it a decision about whether to drop Behat 3, which seemed yours to make rather than
something to slip into this PR. Happy to do that work separately if you'd like it, in either direction.
CI
Couldn't commit a workflow change (token lacks
workflowscope). A Behat 4 leg would want its ownmatrix entry, since the existing
symfonykey also raisesconsole— which Behat 3 caps at^7.0.