Skip to content

Commit 1ebf9ca

Browse files
committed
Slight refactor to return an empty string instead of null
1 parent 786aac8 commit 1ebf9ca

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/NullableXMLElement.php renamed to src/TypedXMLElement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use JsonSerializable;
66
use SimpleXMLElement;
77

8-
class NullableXMLElement extends SimpleXMLElement implements JsonSerializable
8+
class TypedXMLElement extends SimpleXMLElement implements JsonSerializable
99
{
1010
/**
1111
* @inheritDoc
@@ -43,7 +43,7 @@ public function jsonSerialize(): mixed
4343

4444
// return empty elements as NULL (self-closing or empty tags)
4545
if ($array === []) {
46-
$array = null;
46+
$array = '';
4747
}
4848

4949
return $array;

src/XmlRequestMiddleware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class XmlRequestMiddleware
1616
public function handle($request, Closure $next)
1717
{
1818
$request->merge($request->xml(true));
19-
19+
2020
return $next($request);
2121
}
22-
}
22+
}

src/XmlRequestServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function register()
2424
return $assoc ? [] : new \stdClass;
2525
}
2626
// Returns the xml input from a request
27-
$xml = simplexml_load_string($content, NullableXMLElement::class, LIBXML_NOCDATA);
27+
$xml = simplexml_load_string($content, TypedXMLElement::class, LIBXML_NOCDATA);
2828
$json = json_encode($xml);
2929

3030
return json_decode($json, $assoc);

0 commit comments

Comments
 (0)