Skip to content

Support Behat 4 and Symfony 8 - #84

Open
stixx wants to merge 1 commit into
Daniel-Marynicz:mainfrom
stixx:support-symfony-8
Open

Support Behat 4 and Symfony 8#84
stixx wants to merge 1 commit into
Daniel-Marynicz:mainfrom
stixx:support-symfony-8

Conversation

@stixx

@stixx stixx commented Sep 5, 2026

Copy link
Copy Markdown

Behat 4 declares Controller::execute(): ?int and Extension::getConfigKey(): string. Four
implementations here lack those return types, which is a fatal error under Behat 4:

Declaration of DMarynicz\BehatParallelExtension\Cli\ParallelController::execute(...)
must be compatible with Behat\Testwork\Cli\Controller::execute(...): ?int

This adds them to ParallelController, RerunController, SigintController and Extension, and
widens the constraints to behat/behat: ^3.9 || ^4.0 plus || ^8.0 on 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:

phpstan no errors
phpunit 78 tests, 189 assertions
behat 18 scenarios, 99 steps

symfony/process, serializer and expression-language resolve to v8.1.6 here. The other four stay
on 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:

serial:        1335ms   (3 scenarios, 3 passed)
--parallel 3:   903ms   (3/3, progress bar, real workers)

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 fixture behat.yml.dist
files 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 workflow scope). A Behat 4 leg would want its own
matrix entry, since the existing symfony key also raises console — which Behat 3 caps at ^7.0.

@stixx
stixx force-pushed the support-symfony-8 branch 2 times, most recently from 7938499 to b8b4798 Compare September 5, 2026 21:15
@stixx stixx changed the title Allow symfony/process ^8.0 Allow symfony ^8.0 Sep 5, 2026
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
stixx force-pushed the support-symfony-8 branch from a0a2749 to 3808578 Compare September 5, 2026 21:48
@stixx stixx changed the title Allow symfony ^8.0 Support Behat 4 and Symfony 8 Sep 5, 2026
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.

1 participant