Skip to content

Commit 14ac461

Browse files
authored
PHP 8.1 fix deprecated null parameters (#187)
* fix #186 ($string) of type string is deprecated in PHP 8.1 * fix DOMDocument::__construct(): Passing null to parameter #2 ($encoding) of type string is deprecated in vendor/spatie/array-to-xml/src/ArrayToXml.php on line 29 * Update ArrayToXml.php
1 parent 90335a7 commit 14ac461

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ArrayToXml.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(
2626
array $domProperties = [],
2727
?bool $xmlStandalone = null
2828
) {
29-
$this->document = new DOMDocument($xmlVersion, $xmlEncoding);
29+
$this->document = new DOMDocument($xmlVersion, $xmlEncoding ?? '');
3030

3131
if (! is_null($xmlStandalone)) {
3232
$this->document->xmlStandalone = $xmlStandalone;
@@ -141,7 +141,7 @@ protected function convertElement(DOMElement $element, mixed $value): void
141141
$sequential = $this->isArrayAllKeySequential($value);
142142

143143
if (! is_array($value)) {
144-
$value = htmlspecialchars($value);
144+
$value = htmlspecialchars($value ?? '');
145145

146146
$value = $this->removeControlCharacters($value);
147147

0 commit comments

Comments
 (0)