Skip to content

Fix 212#10

Merged
startailcoon merged 3 commits intomasterfrom
fix-212
Aug 11, 2025
Merged

Fix 212#10
startailcoon merged 3 commits intomasterfrom
fix-212

Conversation

@startailcoon
Copy link
Copy Markdown
Owner

This pull request introduces ancestor tracking to the JsonMapper class, allowing mapping decisions to be made based on parent and ancestor JSON objects. It also provides memory optimization strategies for handling deeply nested structures, and adds comprehensive tests to ensure correct behavior and backward compatibility.

Ancestor tracking and mapping enhancements:

  • Refactored JsonMapper to support passing an array of ancestor JSON objects through all mapping operations, enabling class mapping decisions based on parent and ancestor data. This includes changes to map, mapWithAncestors, mapArray, and getMappedType, as well as updating all internal calls to propagate the ancestor chain. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Memory optimization:

  • Added a new MemoryOptimizedJsonMapper class that limits ancestor tracking depth and/or filters ancestor fields to reduce memory usage in deeply nested JSON scenarios. This class provides configurable options and a method to retrieve memory usage statistics.

Testing and documentation:

  • Added ClassMapAncestorsTest to verify correct ancestor-aware class mapping, deep ancestor access, and backward compatibility with older classMap functions.
  • Introduced memory_analysis.php to demonstrate the memory impact of ancestor tracking and showcase optimization strategies.
  • Added support classes for tests, such as Contract.

+ Access the value of the ancestors
+ Applies a MemoryOptimizedJsonMapper()
Copilot AI review requested due to automatic review settings August 11, 2025 18:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces ancestor tracking functionality to the JsonMapper class to enable class mapping decisions based on parent and ancestor JSON objects, addressing issue cweiske#212. It also provides memory optimization strategies for handling deeply nested structures.

  • Refactored JsonMapper to support ancestor tracking through all mapping operations
  • Added MemoryOptimizedJsonMapper class with configurable depth limiting and field filtering
  • Comprehensive test coverage for ancestor-aware mapping and memory optimizations

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/JsonMapper.php Core implementation of ancestor tracking through mapWithAncestors method and updated getMappedType signature
src/MemoryOptimizedJsonMapper.php New class extending JsonMapper with memory optimization features for ancestor tracking
tests/ClassMapAncestorsTest.php Test cases verifying ancestor-aware class mapping and backward compatibility
tests/MemoryOptimizedJsonMapperTest.php Comprehensive test suite for memory optimization features
tests/support/*.php Support classes (Contract, ContractBody, ContractVote, etc.) for testing ancestor functionality
usage_example.php Practical usage examples demonstrating memory optimization strategies
memory_analysis.php Analysis script showing memory impact and optimization benefits

@startailcoon startailcoon merged commit 85173cd into master Aug 11, 2025
0 of 18 checks passed
@startailcoon startailcoon deleted the fix-212 branch August 11, 2025 18:31
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