Skip to content

Preserves absent optional properties during encoding - #71

Closed
NickSdot wants to merge 1 commit into
php-soap:mainfrom
NickSdot:bug/optional-property-presence
Closed

NickSdot wants to merge 1 commit into
php-soap:mainfrom
NickSdot:bug/optional-property-presence

Conversation

@NickSdot

Copy link
Copy Markdown
Contributor
Q A
Type bug
BC Break no
Fixed issues -

Summary

Hey! Distinguishes absent optional properties from explicit null during encoding, while preserving required nullable behaviour and custom encoder lenses. Regression tests for arrays, objects, uninitialised typed properties and nested repeated values.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 76e658c4-5dff-4d0c-a9cd-0bd77d5841c4
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@veewee

veewee commented Oct 15, 2026

Copy link
Copy Markdown
Member

Thanks a lot for this one, @NickSdot. You found a real bug: an optional nillable element was written as xsi:nil when the property was never set, so the server could not tell "not set" apart from "set to null". Your tests made the expected output very clear.

While this was open, the lens layer underneath it changed. The default encoder lens no longer throws on a missing property and returns null instead (veewee/reflecta#39), so tryGet() cannot see the difference anymore. I rebuilt the feature on top of that in #79, with your test file ported and you as co-author on that commit.

For the built-in encoders the result is the same as yours. The presence check only runs for elements that are both minOccurs="0" and nillable, since those are the only ones where null and absent produce different XML, and the check itself now lives in reflecta as property_is_initialized() (veewee/reflecta#41). One choice differs: a custom lens that returns null or throws keeps writing xsi:nil, so third party encoders see no change in output. On the way I also fixed custom lenses behind the optional, repeating and xsi:type wrappers, which were never found.

I'm closing this one in favour of #79, so the discussion continues there.

@veewee veewee closed this Oct 15, 2026
@NickSdot
NickSdot deleted the bug/optional-property-presence branch October 15, 2026 16:15
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