Skip to content

Commit 6c60082

Browse files
committed
PHP 8 compat
1 parent edb2a69 commit 6c60082

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

api.include.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8746,7 +8746,11 @@ private function json2xml($json, $types = 'null,boolean,number,string,object,arr
87468746

87478747
private function xml2json($xml)
87488748
{
8749-
$a = @dom_import_simplexml(simplexml_load_string($xml));
8749+
$o = @simplexml_load_string($xml);
8750+
if ($o===false) {
8751+
return null;
8752+
}
8753+
$a = @dom_import_simplexml($o);
87508754
if (!$a) {
87518755
return null;
87528756
}

api.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8746,7 +8746,11 @@ private function json2xml($json, $types = 'null,boolean,number,string,object,arr
87468746

87478747
private function xml2json($xml)
87488748
{
8749-
$a = @dom_import_simplexml(simplexml_load_string($xml));
8749+
$o = @simplexml_load_string($xml);
8750+
if ($o===false) {
8751+
return null;
8752+
}
8753+
$a = @dom_import_simplexml($o);
87508754
if (!$a) {
87518755
return null;
87528756
}

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ services:
2929
- "8080:80"
3030
depends_on:
3131
- database
32+
volumes:
33+
- .:/php-crud-api:ro

src/Tqdev/PhpCrudApi/Middleware/XmlMiddleware.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ private function json2xml($json, $types = 'null,boolean,number,string,object,arr
8383

8484
private function xml2json($xml)
8585
{
86-
$a = @dom_import_simplexml(simplexml_load_string($xml));
86+
$o = @simplexml_load_string($xml);
87+
if ($o===false) {
88+
return null;
89+
}
90+
$a = @dom_import_simplexml($o);
8791
if (!$a) {
8892
return null;
8993
}

0 commit comments

Comments
 (0)