Skip to content

Fix lazy field null handling and clone preservation#89

Merged
dereuromark merged 1 commit intomasterfrom
fix/lazy-clone-and-null-handling
Mar 23, 2026
Merged

Fix lazy field null handling and clone preservation#89
dereuromark merged 1 commit intomasterfrom
fix/lazy-clone-and-null-handling

Conversation

@dereuromark
Copy link
Copy Markdown
Contributor

Summary

  • Use array_key_exists() instead of isset() in method_get.twig template to correctly detect null values in lazy data (isset() returns false for null values, causing lazy null values to be ignored)
  • Copy _lazyData in clone() method to preserve unhydrated lazy data when cloning DTOs
  • Add tests for clone with lazy data and null lazy value handling

Issues Found

1. Getter template uses isset() for lazy data check

// Before (wrong) - isset() returns false for null values
if (isset($this->_lazyData['field'])) {

// After (correct) - array_key_exists detects the key regardless of value
if (array_key_exists('field', $this->_lazyData)) {

2. clone() method doesn't copy _lazyData
When cloning a DTO with unhydrated lazy fields, the lazy data was not preserved in the clone, causing the clone to lose access to that data.

Relates to #83

- Use array_key_exists() instead of isset() in method_get.twig template
  to correctly detect null values in lazy data (isset returns false for null)
- Copy _lazyData in clone() method to preserve unhydrated lazy data
- Add tests for clone with lazy data and null lazy values
@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.47%. Comparing base (7f084c5) to head (fab274a).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master      #89   +/-   ##
=========================================
  Coverage     83.46%   83.47%           
  Complexity     1386     1386           
=========================================
  Files            40       40           
  Lines          3345     3346    +1     
=========================================
+ Hits           2792     2793    +1     
  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 3984da7 into master Mar 23, 2026
12 checks passed
@dereuromark dereuromark deleted the fix/lazy-clone-and-null-handling branch March 23, 2026 02:09
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