You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Test the encoding error of too deeply nested XML - #595
Tests only, no change in src/. Part 3 of 3 of #591, line coverage is 100 % with it. No changelog entry.
The ticket asked whether the JsonException in XmlSerializer::normalize() can be triggered. It can, so the catch stays:
createFromString(xml with 255 nested levels below the root, two same-named elements per level)
libxml parses it # within the limit of libxml 2.9 and 2.15
json_encode(element) # each level adds an object and a list, two comments in the leaf add three more
depth > 512 -> JsonException -> SerializerException
QA on PHP 8.2: PHPUnit OK (869 tests, 4402 assertions), PHPStan [OK] No errors, code style 0 files to fix, Rector dry run exit 0. Behat not run locally, no production code changed.
Merge Danger
Door: two-way
Blast Radius: tests only. The new test sits in a narrow window between two limits: libxml 2.15 parses at most 255 levels below the root, and json_encode() only fails above depth 512, which this input exceeds by one. A libxml version with a lower limit, or a change in how SimpleXML encodes comments, would fail the test. It was run with libxml 2.9.14 and 2.15.4.
Summary by CodeRabbit
Tests
Added coverage for deeply nested XML input that exceeds the parser’s stack-depth limit, verifying that it produces a clear serialization error. No user-facing behavior changes are included in this update.
This PR adds a unit test for the serializer's deep-nesting error path and changes no production code. It is safe to merge.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the change: a new test that checks the encoding error for too deeply nested XML. The raw summary says the PR adds a test that asserts SerializerException with the maximum-stack-depth e…
Linked Issues check
Issue #591 part 3 asks whether the JsonException in XmlSerializer::normalize() can be triggered. If yes, add a test in the existing method test file. The diff adds testCreateFromStringWithTooDeeplyNes…
Out of Scope Changes check
The whole-PR diff (merge base 9de45b7 to head 8bbde63) changes only tests/Unit/Serializer/XmlSerializerTest.php. It adds one test method of 18 lines. The test covers the JsonException catch path in Xm…
Full details: Title check
Explanation
The title names the change: a new test that checks the encoding error for too deeply nested XML. The raw summary says the PR adds a test that asserts SerializerException with the maximum-stack-depth encoding error, and the objectives confirm it tests the JsonException path in XmlSerializer::normalize(). The title is specific and matches the main change. It does not mention the coverage goal, which is acceptable.
Full details: Linked Issues check
Explanation
Issue #591 part 3 asks whether the JsonException in XmlSerializer::normalize() can be triggered. If yes, add a test in the existing method test file. The diff adds testCreateFromStringWithTooDeeplyNestedXmlThrowsException to tests/Unit/Serializer/XmlSerializerTest.php. The test builds XML with 255 levels below the root and two same-named elements per level, plus two comments in the leaf. Its comments explain that json_encode() depth exceeds 512 for this input. It expects SerializerException with the message 'Catched error "Maximum stack depth exceeded" while encoding SimpleXMLElement', which matches the wrapped JsonException path. The PR states the test passed on libxml 2.9.14 and 2.15.4, and reports PHPUnit OK. The reviewer did not execute the test, so the triggerability claim rests on the author's reported run and the code path in the test comments. No production change was made, which matches the issue rule that production changes are allowed only to remove unreachable code. The test is the requested outcome.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff (merge base 9de45b7 to head 8bbde63) changes only tests/Unit/Serializer/XmlSerializerTest.php. It adds one test method of 18 lines. The test covers the JsonException catch path in XmlSerializer::normalize() that issue #591 names. No production code, configuration, coverage thresholds, or other test files changed. The PR does not include the other coverage gaps listed in #591, which the issue assigns to separate PRs. No unrelated change was found.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: e4d33caf-e060-4c32-98f7-b9b077211a43
Commits
Reviewing files that changed from the base of the PR and between 9de45b7 and 8bbde63.
Files selected for processing: 1
tests/Unit/Serializer/XmlSerializerTest.php
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.
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
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
tests/Unit/Serializer/XmlSerializerTest.php +└── testCreateFromStringWithTooDeeplyNestedXmlThrowsExceptionTests only, no change in
src/. Part 3 of 3 of #591, line coverage is 100 % with it. No changelog entry.The ticket asked whether the
JsonExceptioninXmlSerializer::normalize()can be triggered. It can, so thecatchstays:Closes #591
Evidence
XmlSerializer.php107, 108.After:
Classes: 100.00% (31/31),Methods: 100.00% (199/199),Lines: 100.00% (1336/1336).OK (869 tests, 4402 assertions), PHPStan[OK] No errors, code style 0 files to fix, Rector dry run exit 0. Behat not run locally, no production code changed.Merge Danger
Door: two-way
Blast Radius: tests only. The new test sits in a narrow window between two limits: libxml 2.15 parses at most 255 levels below the root, and
json_encode()only fails above depth 512, which this input exceeds by one. A libxml version with a lower limit, or a change in how SimpleXML encodes comments, would fail the test. It was run with libxml 2.9.14 and 2.15.4.Summary by CodeRabbit