Skip to content

Fix lazy data handling in serialization, toArray, and validation#90

Merged
dereuromark merged 1 commit intomasterfrom
fix/lazy-serialization-and-validation
Mar 23, 2026
Merged

Fix lazy data handling in serialization, toArray, and validation#90
dereuromark merged 1 commit intomasterfrom
fix/lazy-serialization-and-validation

Conversation

@dereuromark
Copy link
Copy Markdown
Contributor

@dereuromark dereuromark commented Mar 23, 2026

Summary

Comprehensive fixes for lazy field handling across the codebase.

Serialization & toArray fixes:

  • Fix _toArrayInternal to check _lazyData before reading property values
  • Ensures touchedToArray(), __serialize(), and toArray() with parameters preserve unhydrated lazy data

Template fixes:

  • Fix setFromArrayFast to use array_key_exists() for lazy fields
  • Fix setDefaults template to check _lazyData for lazy fields with defaults
  • Fix validate() template to check _lazyData for required lazy fields
  • Fix method_get_or_fail.twig to call getter (handles hydration)
  • Fix method_set_or_fail.twig to clear _lazyData
  • Fix method_with_or_fail.twig to clear _lazyData

Base class fixes:

  • Fix base validate() to check _lazyData for required lazy fields
  • Fix base setDefaults() to not overwrite lazy field data

Tests:

  • Add 7 code generation tests for lazy field handling
  • Add 4 runtime tests for serialization and toArray edge cases

Relates to #83

- Fix _toArrayInternal to check _lazyData before reading property values,
  ensuring touchedToArray(), __serialize(), and toArray() with parameters
  correctly preserve unhydrated lazy data
- Fix setFromArrayFast template to use array_key_exists() instead of isset()
  for lazy fields (consistent with method_get.twig fix)
- Fix validate() template to check _lazyData for required lazy fields
- Add tests for serialization, touchedToArray, and toArray with parameters
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.48%. Comparing base (3984da7) to head (8452837).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master      #90   +/-   ##
=========================================
  Coverage     83.47%   83.48%           
- Complexity     1386     1388    +2     
=========================================
  Files            40       40           
  Lines          3346     3348    +2     
=========================================
+ Hits           2793     2795    +2     
  Misses          553      553           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dereuromark dereuromark merged commit 2bc0c90 into master Mar 23, 2026
12 checks passed
@dereuromark dereuromark deleted the fix/lazy-serialization-and-validation branch March 23, 2026 02:16
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.

1 participant