Skip to content

Commit

Permalink
libxml_disable_entity_loader is deprecated on PHP 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Oct 3, 2020
1 parent 5aad0e6 commit 73040ed
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ public function getClark()
*/
public function parse(): array
{
$previousEntityState = libxml_disable_entity_loader(true);
$shouldCallLibxmlDisableEntityLoader = (\PHP_VERSION_ID < 80000);
if ($shouldCallLibxmlDisableEntityLoader) {
$previousEntityState = libxml_disable_entity_loader(true);
}
$previousSetting = libxml_use_internal_errors(true);

try {
Expand All @@ -78,7 +81,9 @@ public function parse(): array
}
} finally {
libxml_use_internal_errors($previousSetting);
libxml_disable_entity_loader($previousEntityState);
if ($shouldCallLibxmlDisableEntityLoader) {
libxml_disable_entity_loader($previousEntityState);
}
}

return $result;
Expand Down

0 comments on commit 73040ed

Please sign in to comment.