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