diff --git a/lib/Element/Uri.php b/lib/Element/Uri.php index 259dfa0..3f9308e 100644 --- a/lib/Element/Uri.php +++ b/lib/Element/Uri.php @@ -59,7 +59,7 @@ public function xmlSerialize(Xml\Writer $writer): void { $writer->text( resolve( - $writer->contextUri, + $writer->contextUri ?? '', $this->value ) ); diff --git a/lib/Service.php b/lib/Service.php index ba1c443..1dd3427 100644 --- a/lib/Service.php +++ b/lib/Service.php @@ -241,6 +241,7 @@ public function write(string $rootElementName, $value, string $contextUri = null public function mapValueObject(string $elementName, string $className): void { list($namespace) = self::parseClarkNotation($elementName); + $namespace = $namespace ?? ''; $this->elementMap[$elementName] = function (Reader $reader) use ($className, $namespace) { return \Sabre\Xml\Deserializer\valueObject($reader, $className, $namespace); diff --git a/lib/Writer.php b/lib/Writer.php index 9cc0001..88a298b 100644 --- a/lib/Writer.php +++ b/lib/Writer.php @@ -124,6 +124,7 @@ public function startElement($name): bool if ('{' === $name[0]) { list($namespace, $localName) = Service::parseClarkNotation($name); + $namespace = $namespace ?? ''; if (array_key_exists($namespace, $this->namespaceMap)) { $result = $this->startElementNS( @@ -134,7 +135,7 @@ public function startElement($name): bool } else { // An empty namespace means it's the global namespace. This is // allowed, but it mustn't get a prefix. - if ('' === $namespace || null === $namespace) { + if ('' === $namespace) { $result = $this->startElement($localName); $this->writeAttribute('xmlns', ''); } else { @@ -238,6 +239,7 @@ public function writeAttribute($name, $value): bool $localName ) = Service::parseClarkNotation($name); + $namespace = $namespace ?? ''; if (array_key_exists($namespace, $this->namespaceMap)) { // It's an attribute with a namespace we know return $this->writeAttribute( diff --git a/phpstan.neon b/phpstan.neon index 67b1aee..bb0d913 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,7 +2,7 @@ includes: - phpstan-baseline.neon parameters: - level: 7 + level: 8 phpVersion: 70430 # PHP 7.4.30 paths: - lib