From 124b4247e68ef16a17c7a0fcef48ea3c7f0a70af Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Sat, 17 Mar 2018 12:44:45 +0100 Subject: [PATCH] find default ns fixes https://github.com/goetas-webservices/xsd2php/issues/58 --- src/SchemaReader.php | 5 ++++- tests/SchemaTest.php | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/SchemaReader.php b/src/SchemaReader.php index 57de8edd..e385c1b4 100644 --- a/src/SchemaReader.php +++ b/src/SchemaReader.php @@ -861,7 +861,10 @@ private static function splitParts(DOMElement $node, string $typeName): array list($prefix, $name) = explode(':', $typeName); } - $namespace = $node->lookupNamespaceUri($prefix ?: ''); + /** + * @psalm-suppress PossiblyNullArgument + */ + $namespace = $node->lookupNamespaceUri($prefix); return array( $name, diff --git a/tests/SchemaTest.php b/tests/SchemaTest.php index 15920d9b..9c8a4826 100644 --- a/tests/SchemaTest.php +++ b/tests/SchemaTest.php @@ -6,9 +6,34 @@ use GoetasWebservices\XML\XSDReader\Schema\Element\ElementDef; use GoetasWebservices\XML\XSDReader\Schema\Type\ComplexType; +use GoetasWebservices\XML\XSDReader\Schema\Type\SimpleType; class SchemaTest extends BaseTest { + public function testWithXSDAsDefaultNamespace() + { + $xml = ' + + + + + + + + + '; + $schema = $this->reader->readString($xml); + + $crypto = $schema->findType('CryptoBinary', 'http://www.example.com'); + $this->assertInstanceOf(SimpleType::class, $crypto); + + $localCrypto = $schema->findType('LocalCryptoBinary', 'http://www.example.com'); + $this->assertInstanceOf(SimpleType::class, $localCrypto); + } + /** * @expectedException \GoetasWebservices\XML\XSDReader\Exception\IOException * @expectedExceptionMessage Can't load the schema