Skip to content

Commit

Permalink
PHP 8.1 fix deprecated null parameters (spatie#187)
Browse files Browse the repository at this point in the history
* fix spatie#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
  • Loading branch information
gigerIT authored May 8, 2022
1 parent 90335a7 commit 14ac461
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ArrayToXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
array $domProperties = [],
?bool $xmlStandalone = null
) {
$this->document = new DOMDocument($xmlVersion, $xmlEncoding);
$this->document = new DOMDocument($xmlVersion, $xmlEncoding ?? '');

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

if (! is_array($value)) {
$value = htmlspecialchars($value);
$value = htmlspecialchars($value ?? '');

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

Expand Down

0 comments on commit 14ac461

Please sign in to comment.