fix(serializer): bump api-platform/serializer to ^4.3.8 and cover Hal in CI#8242
Merged
soyuka merged 2 commits intoJun 4, 2026
Merged
Conversation
… in CI
The cache-key gate `isCacheKeySafe()` moved into
`Serializer/AbstractItemNormalizer` after `api-platform/serializer v4.3.7`
was tagged, so `^4.3.7` resolves to a release that still lacks the
method. The api-platform/json-api lowest CI job blew up with
"Call to undefined method ItemNormalizer::isCacheKeySafe()". Bump the
constraint to `^4.3.8` in JsonApi, Hal and GraphQl so lowest installs
pick up the published release that exposes the method.
api-platform/hal was missing from the phpunit components matrix, so the
same lowest-deps regression silently passed for it. Add it to the matrix
and migrate `ItemNormalizerTest.php` to local Hal fixtures so the suite
runs standalone:
- Add missing `phpspec/prophecy-phpunit` dev dep used by the suite.
- Enrich `Tests/Fixtures/Dummy` with alias/description and make
`relatedDummy` nullable so the legacy assertions still hold.
- Make `Tests/Fixtures/MaxDepthDummy::\$child` nullable to avoid the
"must not be accessed before initialization" error.
- Correct the stale `getSupportedTypes` assertion that was never
executed in CI.
- Skip two pre-existing `SchemaFactoryTest` cases whose assertions
drifted from the current factory output; tracked for follow-up.
0058ff5 to
49c622b
Compare
Hal SchemaFactory ctor takes (schemaFactory, definitionNameFactory,
resourceMetadataFactory). setUp() omitted the third argument, so
Hal's ResourceMetadataTrait::isResourceClass(Dummy) returned false,
causing Hal to bypass its own wrap and delegate straight to the base
factory with format='jsonhal'. The base factory then wrote
Dummy.jsonhal={type:object}, never producing the allOf wrap the
tests assert on.
Hal was added to the CI matrix in 49c622b, exposing this for the
first time. Pass the existing $resourceMetadataFactory mock so
isResourceClass() resolves true and the wrap fires.
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.
Summary
The
api-platform/json-apilowest CI job started failing on 4.3 withCall to undefined method ApiPlatform\JsonApi\Serializer\ItemNormalizer::isCacheKeySafe()(see run #26951513731).The
isCacheKeySafe()helper moved intoSerializer/AbstractItemNormalizerafterapi-platform/serializer v4.3.7was tagged, so the^4.3.7constraint introduced infd2518695still resolves to a release that does not expose the method.v4.3.8was tagged with the helper but the constraint was never bumped.Changes
api-platform/serializerconstraint to^4.3.8inJsonApi,HalandGraphQlcomposer.json so--prefer-lowestpulls the released package that exposesisCacheKeySafe().api-platform/halto thephpunit-componentsmatrix — the same regression silently passed for Hal because no CI job ever ran its standalone test suite.src/Hal/Tests/Serializer/ItemNormalizerTest.phprunnable standalone (it previously imported root-tree fixtures that aren't shipped with the Hal subtree):phpspec/prophecy-phpunitdev dep (suite already usesProphecyTrait).Tests/Fixtures/Dummywithalias/descriptionaccessors and nullablerelatedDummyso existing assertions still hold.Tests/Fixtures/MaxDepthDummy::$childnullable (prevents the "must not be accessed before initialization" error intestMaxDepth).getSupportedTypesassertion ('object' => true→false) that had drifted since 2023 because the test never ran in CI.SchemaFactoryTestcases (testHasRootDefinitionKeyBuildSchema,testCollection) whose assertions drifted from the currentSchemaFactoryoutput — unrelated to this fix, worth a follow-up. The 18 other Hal tests pass on both lowest and latest.Test plan
cd src/Hal && composer update --prefer-lowest --prefer-source && ./vendor/bin/phpunit→ 20 tests, 18 pass, 2 skipped, 0 failcd src/JsonApi && composer update --prefer-lowest --prefer-source && ./vendor/bin/phpunit→ 59 tests pass (was 6 errors + 1 fail on 4.3 HEAD)cd src/GraphQl && composer update --prefer-lowest --prefer-source && ./vendor/bin/phpunit→ 242 tests passapi-platform/serializer v4.3.8resolves on lowest with bumped constraintFollow-up: rewrite the
SchemaFactoryTestassertions against current factory output, and consider porting HalItemNormalizerTestfrom Prophecy to PHPUnit mocks.