@@ -33,14 +33,11 @@ public function loadMessageXml(string $message_xml_file)
33
33
}
34
34
35
35
$ messageXml = new \SimpleXMLIterator ($ messageXmlString );
36
- unset( $ messageXmlString );
37
- $ message = [
36
+
37
+ return [
38
38
'defaults ' => $ this ->readMessageDefaults ($ messageXml ),
39
39
'segments ' => $ this ->readXmlNodes ($ messageXml ),
40
40
];
41
- unset($ messageXml );
42
-
43
- return $ message ;
44
41
}
45
42
46
43
/**
@@ -58,7 +55,6 @@ public function loadCodesXml(string $codesXml)
58
55
}
59
56
60
57
$ codesXml = new \SimpleXMLIterator ($ codesXmlString );
61
- unset($ codesXmlString );
62
58
$ codes = [];
63
59
foreach ($ codesXml as $ codeCollection ) {
64
60
\assert ($ codeCollection instanceof \SimpleXMLIterator);
@@ -111,12 +107,14 @@ public function loadSegmentsXml(string $segment_xml_file)
111
107
$ segments_xml = null ;
112
108
113
109
foreach ($ xml as $ segmentNode ) {
110
+ \assert ($ segmentNode instanceof \SimpleXMLElement);
114
111
115
- /** @noinspection PhpSillyAssignmentInspection - hack for phpstan */
116
- /* @var \SimpleXMLElement $segmentNode */
117
- $ segmentNode = $ segmentNode ;
112
+ $ segmentNodeAttributes = $ segmentNode ->attributes ();
113
+ if ($ segmentNodeAttributes === null ) {
114
+ continue ;
115
+ }
118
116
119
- $ qualifier = (string ) $ segmentNode -> attributes () ->id ;
117
+ $ qualifier = (string ) $ segmentNodeAttributes ->id ;
120
118
$ segment = [];
121
119
$ segment ['attributes ' ] = $ this ->readAttributesArray ($ segmentNode );
122
120
$ details = $ this ->readXmlNodes ($ segmentNode );
@@ -193,7 +191,7 @@ public function process(array $data, array $rawSegments = null): string
193
191
$ r [] = ' length: ' . $ d_sub_desc_attr ['length ' ];
194
192
}
195
193
196
- //check for skipped data
194
+ // check for skipped data
197
195
unset(
198
196
$ d_sub_desc_attr ['id ' ],
199
197
$ d_sub_desc_attr ['name ' ],
0 commit comments