Repository navigation
test: accept the native jsonSerialize call count on newer PHP patch releases - #329
Merged
Merged
Conversation
marandaneto
marked this pull request as ready for review
November 20, 2026 08:30
marandaneto
enabled auto-merge (squash)
November 20, 2026 08:30
PR overviewNo security issues were found in this pull request. Reviews
|
Contributor
posthog-php-lib_curl Compliance ReportDate: 2026-11-20T08:32:40.829500+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
Contributor
posthog-php-fork_curl Compliance ReportDate: 2026-11-20T08:32:47.312078+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
Contributor
posthog-php-socket Compliance ReportDate: 2026-11-20T08:32:49.498440+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
6 tasks done
ioannisj
approved these changes
Nov 20, 2026
ioannisj
left a comment
Contributor
There was a problem hiding this comment.
🤖 An AI agent wrote this on behalf of @ioannisj.
No findings. JsonEncoder::encode() sends a malformed-key array straight to native json_encode(), so matching the native jsonSerialize() count holds both on versions that call it once and on 8.4.28 / 8.5.13 that skip it.
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.
💡 Motivation and Context
JsonEncoderTest::testMalformedKeysRetainErrorsAndNativeCallbackOrderingnow fails on CI for every PR, inphpunit (8.4)andphpunit (8.5). CI picked up PHP 8.4.28 and 8.5.13. In those patch releases, nativejson_encode()rejects an array with a malformed UTF-8 key without calling the value'sjsonSerialize()first. The test asserted that nativejson_encode()calls it exactly once, so it reports "Failed asserting that 0 is identical to 1." The SDK'sJsonEncoderbehaves the same as before. Only PHP's own call count changed.The test now records how many times native
json_encode()calledjsonSerialize(), either 0 or 1, and checks thatJsonEncoder::encode()makes the same number of calls. It still checks that both returnfalsewithJSON_ERROR_UTF8, and that the error resets afterwards.💚 How did you test it?
Ran the single test in Docker on each PHP version (
php:<version>-cli,vendor/bin/phpunit --filter testMalformedKeysRetainErrorsAndNativeCallbackOrdering):The full suite on local PHP 8.5.10 has one failure,
EmailsClientTest::testAnOversizedReplyIsNotReadOrRetried, and it fails the same way without this change. In Docker,PackageArchiveTestalso fails because the container has nogit. Neither is related to this change. Autoreview found nothing to fix.📝 Checklist
If releasing new changes
pnpm changeto generate a change intent fileTest-only change, so there is no change intent.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Found while updating #328, whose CI failed on this test even though it doesn't touch JSON encoding. A probe script in the official PHP Docker images showed that 8.4.27 and 8.5.12 call
jsonSerialize()once for a malformed-key array, and 8.4.28 and 8.5.13 don't call it at all. I chose to accept both counts rather than pin the CI PHP version, because the test's point is thatJsonEncodermatches native behavior on whichever PHP runs it.