Skip to content

Make the serializer tests independent of the PHP 8.6 JSON error text - #176

Merged
tomaj merged 1 commit into
masterfrom
fix/php86-json-error-text
Oct 25, 2026
Merged

tomaj merged 1 commit into
masterfrom
fix/php86-json-error-text

Conversation

@tomaj

@tomaj tomaj commented Oct 25, 2026

Copy link
Copy Markdown
Owner

PHP 8.6 appends the position to JSON error messages: Syntax error became Syntax error near location 1:12. Two MessageSerializerTest tests compared the exact text, so the PHP 8.6 job failed.

Audit

  • src/ does not depend on the text. MessageSerializer only passes JsonException::getMessage() through into the SerializeException message and sets the JSON_ERROR_* code as the exception code. No logic compares messages.
  • Full test suite on PHP 8.6.0RC4 (php:8.6-rc-cli, failOnDeprecation/failOnNotice, error_reporting=-1): after this change the only failures came from extensions missing in the local image (redis, pcntl). There were no deprecations, notices or other 8.6 failures. The full run with every extension and broker is the CI PHP 8.6 job.
  • composer.json php constraint does not block 8.6.

Changes

  • Tests: the expected JSON error text comes from the running PHP (jsonError() helper), and the exact assertions stay in place. testInvalidJsonKeepsTheJsonExceptionAsPrevious also asserts the invalid JSON (Syntax error prefix next to the JSON_ERROR_SYNTAX code.
  • UPGRADE-6.0.md: notes that the text in parentheses after invalid JSON depends on the PHP version, and that code should match the JSON_ERROR_* code instead. The EN and SK docs only show <error>, so they need no change.
  • CHANGELOG 6.0.0 Fixed entry.
  • The PHP 8.6 job stays continue-on-error because 8.6 is not GA yet.

Review log

  1. Round 1: assertions inside the static data-provider helper were moved out. The helper now only returns the text, and the prefix and code assertions live in a test.
  2. Round 2: checked docs for quoted error text (only UPGRADE-6.0.md has it, EN/SK docs use <error>), the CHANGELOG placement and the commit metadata. Found nothing.
  3. Round 3: full diff again on 8.4 and 8.6. Found nothing.

Verification

  • MessageSerializerTest passes on PHP 8.4.26 and 8.6.0RC4 (it failed on 8.6 before this change)
  • PHPStan, php-cs-fixer and Rector are clean
  • No src/ changes, so Infection has no changed lines to mutate (CI Infection job)
  • CI is green, including PHP 8.6

PHP 8.6 appends the position to JSON error messages ("Syntax error near
location 1:12"). The library only passes that text through and uses the
JSON_ERROR_* code; the tests now take the expected text from the running
PHP. UPGRADE-6.0.md notes that the text depends on the PHP version.
@tomaj tomaj added this to the 6.0.0 milestone Oct 25, 2026
@tomaj tomaj self-assigned this Oct 25, 2026
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 40215322223

Coverage remained the same at 99.283%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 697
Covered Lines: 692
Line Coverage: 99.28%
Coverage Strength: 23.4 hits per line

💛 - Coveralls

@tomaj
tomaj merged commit 7d9823f into master Oct 25, 2026
29 checks passed
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.

2 participants