File tree Expand file tree Collapse file tree 3 files changed +104
-2
lines changed Expand file tree Collapse file tree 3 files changed +104
-2
lines changed Original file line number Diff line number Diff line change 7
7
use DOMNode ;
8
8
use Soap \Encoding \Xml \Node \Element ;
9
9
use Soap \Encoding \Xml \Node \ElementList ;
10
+ use VeeWee \Xml \Xmlns \Xmlns ;
10
11
use function VeeWee \Xml \Dom \Predicate \is_element ;
11
12
12
13
/**
@@ -50,8 +51,11 @@ public function __invoke(Element $xml): array
50
51
51
52
// It might be possible that the child is a regular textNode.
52
53
// In that case, we use '_' as the key and the value of the textNode as value.
53
- if (!$ nodes && $ content = trim ($ root ->textContent )) {
54
- $ nodes ['_ ' ] = $ content ;
54
+ if (!$ nodes ) {
55
+ $ nodes ['_ ' ] = match (true ) {
56
+ $ root ->getAttributeNS (Xmlns::xsi ()->value (), 'nil ' ) === 'true ' => null ,
57
+ default => $ root ->textContent ,
58
+ };
55
59
}
56
60
57
61
// All attributes also need to be added as key => value pairs.
Original file line number Diff line number Diff line change
1
+ <?php
2
+ declare (strict_types=1 );
3
+
4
+ namespace Soap \Encoding \Test \PhpCompatibility ;
5
+
6
+ use PHPUnit \Framework \Attributes \CoversClass ;
7
+ use Soap \Encoding \Decoder ;
8
+ use Soap \Encoding \Driver ;
9
+ use Soap \Encoding \Encoder ;
10
+
11
+ #[CoversClass(Driver::class)]
12
+ #[CoversClass(Encoder::class)]
13
+ #[CoversClass(Decoder::class)]
14
+ final class Schema062Variant1Test extends AbstractCompatibilityTests
15
+ {
16
+ protected string $ schema = <<<EOXML
17
+ <complexType name="testType">
18
+ <simpleContent>
19
+ <restriction base="string">
20
+ <attribute name="int" type="int"/>
21
+ </restriction>
22
+ </simpleContent>
23
+ </complexType>
24
+ EOXML ;
25
+ protected string $ type = 'type="testType" ' ;
26
+
27
+ protected function calculateParam (): mixed
28
+ {
29
+ return (object )[
30
+ '_ ' => '' ,
31
+ 'int ' => 123
32
+ ];
33
+ }
34
+
35
+ protected function expectXml (): string
36
+ {
37
+ return <<<XML
38
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://test-uri/"
39
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
40
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
41
+ <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
42
+ <tns:test>
43
+ <testParam int="123" xsi:type="tns:testType"/>
44
+ </tns:test>
45
+ </SOAP-ENV:Body>
46
+ </SOAP-ENV:Envelope>
47
+ XML ;
48
+ }
49
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ declare (strict_types=1 );
3
+
4
+ namespace Soap \Encoding \Test \PhpCompatibility ;
5
+
6
+ use PHPUnit \Framework \Attributes \CoversClass ;
7
+ use Soap \Encoding \Decoder ;
8
+ use Soap \Encoding \Driver ;
9
+ use Soap \Encoding \Encoder ;
10
+
11
+ #[CoversClass(Driver::class)]
12
+ #[CoversClass(Encoder::class)]
13
+ #[CoversClass(Decoder::class)]
14
+ final class Schema062Variant2Test extends AbstractCompatibilityTests
15
+ {
16
+ protected string $ schema = <<<EOXML
17
+ <complexType name="testType">
18
+ <simpleContent>
19
+ <restriction base="string">
20
+ <attribute name="int" type="int"/>
21
+ </restriction>
22
+ </simpleContent>
23
+ </complexType>
24
+ EOXML ;
25
+ protected string $ type = 'type="testType" ' ;
26
+
27
+ protected function calculateParam (): mixed
28
+ {
29
+ return (object )[
30
+ '_ ' => null ,
31
+ 'int ' => 123
32
+ ];
33
+ }
34
+
35
+ protected function expectXml (): string
36
+ {
37
+ return <<<XML
38
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://test-uri/"
39
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
40
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
41
+ <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
42
+ <tns:test>
43
+ <testParam xsi:nil="true" int="123" xsi:type="tns:testType"/>
44
+ </tns:test>
45
+ </SOAP-ENV:Body>
46
+ </SOAP-ENV:Envelope>
47
+ XML ;
48
+ }
49
+ }
You can’t perform that action at this time.
0 commit comments