Repository navigation
Share one implementation between the QPXML cdata/comment/pi getters - #104
Merged
Merged
Conversation
The three getters were copies of the same loop that had drifted: cdata() used === and returned null explicitly, while comment() and pi() used == and fell off the end. Move the loop into a private firstChildText() helper, keeping pi()'s filter on the processing instruction's target, and give pi() a docblock to match the other two. No behaviour change. Tests pin down the not-found, first-across-matches and child-only cases for all three getters. Fixes #96 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
QPXML::cdata(), comment() and pi() getters
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #104 +/- ##
============================================
+ Coverage 89.84% 90.35% +0.51%
+ Complexity 1430 1425 -5
============================================
Files 26 26
Lines 3189 3184 -5
============================================
+ Hits 2865 2877 +12
+ Misses 324 307 -17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Fixes #96
QPXML::cdata(),comment()andpi()each had their own copy of "the text of the first child node of type X in the match set". The copies had drifted: they mixed==and===, and some returnednullexplicitly while others fell off the end. All three now call one private helper,firstChildText($nodeType, $target = null).pi()gains a full docblock, and "processor instruction" is corrected to "processing instruction".There is no behaviour change, so there is no CHANGELOG entry.
Tests: I wrote these first and ran them green on the old code, then refactored:
testGettersReturnNullWhenNothingFound: no match, an empty set, and nested nodes that aren't direct children;testGettersReturnFirstFoundAcrossMatches, includingpi()with a target.🤖 Generated with Claude Code