feat: Complex pattern streaming for JSONPath expressions#1
Merged
Conversation
Extended streaming support to handle property extraction after wildcards, filters, and array operations. Added shouldExtractFromValue() and walkValue() methods to PathEvaluator for partial path matching and nested value extraction. Updated canUseSimpleStreaming() to recognize patterns like $.users[*].name, $.items[0].name, and filter expressions as streamable. Implemented sequential result indexing to maintain correct key ordering across all streamed results. All 568 tests pass with 21,621 assertions passing. Code is PSR-12 compliant and passes PHPStan analysis.
Added Phase 12 (Advanced Streaming Features) to task index with Task 56 for nested wildcard streaming. Updated total task count to 55 and adjusted completion metrics. Created detailed task file for nested wildcard patterns like $.users[*].posts[*]. Cleaned up 100% coverage analysis document.
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
This pull request implements Task 25 - Complex Pattern Streaming, extending the JSONPath streaming capability to handle sophisticated patterns that previously required buffering the entire JSON in memory.
Key Features
$.users[*].namenow stream individual property values without buffering the entire array$.items[0].nameextract nested properties from array elements with streaming$.items[?price > 100].nameleverage streaming when possibleTechnical Changes
Core Implementation
shouldExtractFromValue()andwalkValue()methods for partial path matching and nested value extractioncanUseSimpleStreaming()to recognize complex streamable patternsCompatibility
Files Changed
src/Internal/JsonPath/PathEvaluator.php- Core streaming logic (191 lines added)src/Internal/JsonPath/PathExpression.php- Pattern recognition (53 lines updated)src/Internal/JsonPath/PropertySegment.php- Property extraction (8 lines added)src/Internal/Parser.php- Pattern detection (32 lines updated)tests/Unit/JsonPath/PathExpressionTest.php- Test coverage (21 lines updated)tasks/00-INDEX.md- Task tracking (30 lines updated)tasks/25-complex-pattern-streaming.md- Task completiontasks/56-nested-wildcard-streaming.md- New task for future nested wildcard optimizationcomposer.json- Version bumpcoverage-analysis-100-percent.mdTesting & Quality
✅ Unit Tests: All PathExpression streaming logic tests pass
✅ Integration Tests: Complex pattern streaming validated against real JSON data
✅ Static Analysis: PHPStan level 9 compliance verified
✅ Code Style: PSR-12 formatting enforced
Performance Impact
Migration Guide
No changes required for existing code. New streaming capability is automatically used for eligible patterns.
Future Work
Task 56 (Nested Wildcard Streaming) deferred as low-priority optimization for patterns with multiple
[*]operators (e.g.,$.users[*].posts[*].title). These currently fall back to PathFilter buffering but could be optimized in the future.Related Issues/Tasks: Task 25 - Complex Pattern Streaming | Task 24 - Streaming JSONPath Memory Optimization
Branch: feature/phase-5-complex-patterns
Base: main