44
55namespace Soap \Wsdl \Xml \Configurator ;
66
7- use DOMDocument ;
8- use DOMElement ;
7+ use Dom \ Element ;
8+ use Dom \ XMLDocument ;
99use Soap \Wsdl \Exception \UnloadableWsdlException ;
1010use Soap \Wsdl \Loader \Context \FlatteningContext ;
1111use Soap \Wsdl \Uri \IncludePathBuilder ;
1414use VeeWee \Xml \Dom \Configurator \Configurator ;
1515use VeeWee \Xml \Dom \Document ;
1616use VeeWee \Xml \Exception \RuntimeException ;
17+ use function VeeWee \Xml \Dom \Assert \assert_document ;
1718use function VeeWee \Xml \Dom \Locator \document_element ;
1819use function VeeWee \Xml \Dom \Locator \Node \children ;
1920use function VeeWee \Xml \Dom \Manipulator \Element \copy_named_xmlns_attributes ;
@@ -40,13 +41,13 @@ public function __construct(
4041 * @throws RuntimeException
4142 * @throws UnloadableWsdlException
4243 */
43- public function __invoke (DOMDocument $ document ): DOMDocument
44+ public function __invoke (XMLDocument $ document ): XMLDocument
4445 {
4546 $ xml = Document::fromUnsafeDocument ($ document );
4647 $ xpath = $ xml ->xpath (new WsdlPreset ($ xml ));
4748
48- $ imports = $ xpath ->query ('wsdl:import ' )->expectAllOfType (DOMElement ::class);
49- $ imports ->forEach (fn (DOMElement $ import ) => $ this ->importWsdlImportElement ($ import ));
49+ $ imports = $ xpath ->query ('wsdl:import ' )->expectAllOfType (Element ::class);
50+ $ imports ->forEach (fn (Element $ import ) => $ this ->importWsdlImportElement ($ import ));
5051
5152 return $ document ;
5253 }
@@ -55,10 +56,10 @@ public function __invoke(DOMDocument $document): DOMDocument
5556 * @throws RuntimeException
5657 * @throws UnloadableWsdlException
5758 */
58- private function importWsdlImportElement (DOMElement $ import ): void
59+ private function importWsdlImportElement (Element $ import ): void
5960 {
6061 $ location = IncludePathBuilder::build (
61- $ import ->getAttribute ('location ' ),
62+ $ import ->getAttribute ('location ' ) ?? '' ,
6263 $ this ->currentLocation
6364 );
6465
@@ -79,11 +80,15 @@ private function importWsdlImportElement(DOMElement $import): void
7980
8081 /**
8182 * @throws RuntimeException
83+ * @throws \Psl\Type\Exception\AssertException
8284 */
83- private function importWsdlPart (DOMElement $ importElement , Document $ importedDocument ): void
85+ private function importWsdlPart (Element $ importElement , Document $ importedDocument ): void
8486 {
8587 $ definitions = $ importedDocument ->map (document_element ());
86- copy_named_xmlns_attributes ($ importElement ->ownerDocument ->documentElement , $ definitions );
88+ copy_named_xmlns_attributes (
89+ document_element ()(assert_document ($ importElement ->ownerDocument )),
90+ $ definitions
91+ );
8792
8893 replace_by_external_nodes (
8994 $ importElement ,
@@ -94,7 +99,7 @@ private function importWsdlPart(DOMElement $importElement, Document $importedDoc
9499 /**
95100 * @throws RuntimeException
96101 */
97- private function importXsdPart (DOMElement $ importElement , Document $ importedDocument ): void
102+ private function importXsdPart (Element $ importElement , Document $ importedDocument ): void
98103 {
99104 $ types = $ this ->context ->types ();
100105 remove ($ importElement );
0 commit comments