fix(symfony): Symfony 8.1 compatibility#7955
Merged
soyuka merged 7 commits intoapi-platform:4.3from May 7, 2026
Merged
Conversation
…meworkBundle 8.1+ FrameworkBundle 8.1 registers DateTimeValueObjectTransformer itself as .json_streamer.value_object_transformer.date_time and ships DeprecateJsonStreamerValueTransformerTagPass, which appends the json_streamer.property_value_transformer tag to every service still carrying the deprecated json_streamer.value_transformer tag. Our service implements ValueObjectTransformerInterface, not PropertyValueTransformerInterface, so TransformerPass validation rejects the container. Gate the registration on the absence of the deprecation pass so we only register on json-streamer 8.1 + framework-bundle <8.1, and drop the deprecated tag from our own registration. Closes api-platform#7954
56c1cae to
fd4d6f2
Compare
c527b60 to
b815924
Compare
…-streamer) The existing phpunit-symfony-next lane resolves to framework-bundle 8.0.x-dev because behat/* and friends-of-behat/* dev deps cap symfony/console at <8, which excludes framework-bundle 8.1. This means the FB 8.1 + json-streamer 8.1 combination — the one that triggers issue api-platform#7954 — is not exercised in CI today. Add a dedicated phpunit-symfony-edge lane that drops the behat dev deps before resolving and explicitly pins framework-bundle and json-streamer to 8.1.x-dev. Marked continue-on-error since 8.1 is still pre-stable and unrelated upstream breakage shouldn't block PRs.
…ists The Symfony 8.1 PHPUnit lane removes friends-of-behat/symfony-extension from the dev deps to satisfy framework-bundle 8.1 / symfony-console 8 constraints. cache:clear runs outside the phpunit env, so $_ENV[APP_PHPUNIT] is null and the kernel tries to instantiate a class that no longer exists. Mirror the existing class_exists gates on DoctrineMongoDBBundle and McpBundle so the kernel boots cleanly in any environment that doesn't have the bundle installed.
Move config_behat_*.yml imports out of the database-specific config files and load them conditionally from AppKernel only when behat/behat is installed and tests/Behat context classes are available. The DoctrineContext service tweak is gated on the same condition. This unblocks running PHPUnit against the test app on dependency sets that exclude behat — needed to test against Symfony 8.1, where the friends-of-behat ecosystem has not yet shipped a symfony/console 8 compatible release.
* Migrate config_swagger.php from the fluent ConfigBuilder pattern (deprecated in symfony/dependency-injection 7.4, removed in 8.1: PhpFileLoader no longer generates Symfony\Config\* classes) to ContainerConfigurator::extension(). * Gate state/object_mapper.php and mcp/mcp.php loading on ContainerBuilder::willBeAvailable for symfony/object-mapper, mirroring FrameworkBundle's own gate. Without this, an alias to a non-existent "object_mapper" service breaks container compilation when object-mapper is dev-only.
b815924 to
141adc8
Compare
Symfony 8.1 added a "set" property hook on Request::$query that triggers
a deprecation when the property is assigned directly. PHPUnit's stub
generator cannot wrap the hook because its return type "InputBag" is
final, so createStub(Request::class) fails with:
Class "Symfony\Component\HttpFoundation\InputBag" is declared "final"
and cannot be doubled
Use a real anonymous Request subclass that overrides getBaseUrl() instead.
soyuka
commented
May 7, 2026
soyuka
commented
May 7, 2026
| - name: Run Behat tests | ||
| run: vendor/bin/behat --out=std --format=progress --profile=default --no-interaction | ||
|
|
||
| phpunit-symfony-edge: |
Member
Author
There was a problem hiding this comment.
This will get removed once behat (and its dependencies) aligns for the symfony's dependencies
soyuka
commented
May 7, 2026
Co-authored-by: Antoine Bluchet <soyuka@users.noreply.github.com>
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.
Symfony 8.1.0-BETA1 introduces a few removals and behaviour changes that
make API Platform 4.3 fail to compile its container or boot the test app.
This PR brings 4.3 up to compatibility and adds a dedicated CI lane so
the combination is exercised on every PR going forward.
What it changes
JsonStreamer — Skip API Platform's own
DateTimeValueObjectTransformerregistration when FrameworkBundle 8.1+ is detected. FrameworkBundle 8.1
registers the transformer itself and ships a deprecation pass that
upgrades the now-deprecated
json_streamer.value_transformertag, whichfails
TransformerPassvalidation against our service.ConfigBuilder — Fluent
Symfony\Config\*typed-closure config fileswere deprecated in symfony/dependency-injection 7.4 and the fallback
was removed in 8.1. Migrate
tests/Fixtures/app/config/config_swagger.phpto
ContainerConfigurator::extension()(BC across all supportedFrameworkBundle versions).
ObjectMapper — Mirror FrameworkBundle's own
willBeAvailablegatebefore loading our object-mapper wiring (
state/object_mapper.php,mcp/mcp.php). Whensymfony/object-mapperis dev-only,FrameworkBundle skips its
object_mapperservice registration; withoutthis gate, our alias dangles and breaks compilation.
Test app — Move
config_behat_*.ymlimports out of thedatabase-specific configs and load them conditionally from
AppKernelonly when
behat/behatand the local Behat context classes areavailable. Without this, the kernel cannot boot in any environment that
does not have behat installed — including a Symfony 8.1 install,
because
friends-of-behat/*andsoyuka/contextscap behat at 3.x andbehat 3.x caps
symfony/consoleat <8.CI — Add a
phpunit-symfony-edgelane that drops behat dev deps,pins
symfony/framework-bundleandsymfony/json-streamerto8.1.x-dev, and runs PHPUnit.continue-on-error: truesince 8.1 ispre-stable; the lane is informational until Symfony 8.1 ships stable.