Repository navigation
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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. Comment |
|
@NickSdot, you caught a nasty one here. Attributes and child elements ended up in one array keyed by local name, so The decode side changed underneath this PR in the meantime, so I rebuilt it in #80. Your tests are ported there, and you are co-author on the commits that carry them. I went with a different shape than the While testing namespaces I also ran into attributes declared through Thanks for pushing this. I'm closing this one in favour of #80, so the discussion continues there. |
…ildren DocumentToLookupArrayReader puts child elements and attributes in one flat array keyed by local name, so an attribute overwrites or stands in for a child with the same name, xsi:type and xmlns declarations included. ElementLookup keeps them apart: element() only returns child elements, attribute() reads by namespace and local name, text() follows the existing '_' rule, and toArray() builds the legacy array with the child winning on a collision and protocol attributes left out. attribute() falls back to the only other attribute with that local name when the exact namespace is absent. That keeps xml:lang, other ref attributes and servers that qualify attributes differently from their WSDL decoding, while id next to a:id still resolves to the right one. The child wins rule, the protocol attribute filter and two of the tests come from php-soap#72. Nothing uses it yet. Co-authored-by: NickSdot <catch.github.com.nicksdot@nicksdot.dev>
The built-in decoder lenses read child elements, attributes and the '_' text from ElementLookup instead of the flat lookup array. An attribute no longer overwrites or stands in for a child element with the same name, xsi:type and namespace declarations included, and an attribute property only reads the attribute in its own namespace, with the single namesake fallback of ElementLookup::attribute(). ObjectEncoder::from builds one lookup per element. DocumentToLookupArrayReader now returns ElementLookup::toArray(), so its callers get the same fix: the child wins on a collision and xsi, soap-enc and xmlns attributes are left out. Custom decoder lenses still receive that array through an adapter that ObjectAccess builds once per property. The next commit hands them the lookup itself. Because the adapter is the innermost frame in src/ now, the allowed throw of the throwing lens fixture moves from ObjectEncoder to ObjectAccess. The tests port php-soap#72. Its two lookup array tests are in ElementLookupTest since the previous commit, asserting attribute() where php-soap#72 asserted '@{ns}name' keys, which this design does not have. Co-authored-by: NickSdot <catch.github.com.nicksdot@nicksdot.dev>
Summary
Hey! Prevenst XML attributes from overwriting or being mistaken for child elements. Resolves schema attributes by namespace while preserving non conflicting legacy lookup keys for custom decoder lenses. Regression tests for collisions, absent children, qualified and unqualified attributes, repeated children and simple text content.