Skip to content

Commit

Permalink
Fix code for phpstan level 8
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Jun 29, 2023
1 parent ade9d87 commit 0f54dcf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Element/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function xmlSerialize(Xml\Writer $writer): void
{
$writer->text(
resolve(
$writer->contextUri,
$writer->contextUri ?? '',
$this->value
)
);
Expand Down
1 change: 1 addition & 0 deletions lib/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion lib/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ includes:
- phpstan-baseline.neon

parameters:
level: 7
level: 8
phpVersion: 70430 # PHP 7.4.30
paths:
- lib
Expand Down

0 comments on commit 0f54dcf

Please sign in to comment.