Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow installing and build on PHP 8 #1267

Merged
merged 7 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ matrix:

- php: 7.4
env: VERY_LATEST=1
- php: 8.0snapshot
env: COMPOSER_FLAGS='--ignore-platform-req=php'
fast_finish: true

install:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": "^7.2",
"php": "^7.2||^8.0",
"doctrine/annotations": "^1.0",
"doctrine/instantiator": "^1.0.3",
"doctrine/lexer": "^1.1",
Expand Down
9 changes: 7 additions & 2 deletions src/XmlDeserializationVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public function prepare($data)
$previous = libxml_use_internal_errors(true);
libxml_clear_errors();

$previousEntityLoaderState = libxml_disable_entity_loader($this->disableExternalEntities);
if (\LIBXML_VERSION < 20900) {
$previousEntityLoaderState = libxml_disable_entity_loader($this->disableExternalEntities);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as of libxml 2.9.0 entity substitution is disabled by default, so there is no need to disable the loading of external entities.

https://www.php.net/manual/en/function.libxml-disable-entity-loader.php


if (false !== stripos($data, '<!doctype')) {
$internalSubset = $this->getDomDocumentTypeEntitySubset($data);
Expand All @@ -92,7 +94,10 @@ public function prepare($data)
$doc = simplexml_load_string($data, 'SimpleXMLElement', $this->options);

libxml_use_internal_errors($previous);
libxml_disable_entity_loader($previousEntityLoaderState);

if (\LIBXML_VERSION < 20900) {
libxml_disable_entity_loader($previousEntityLoaderState);
}

if (false === $doc) {
throw new XmlErrorException(libxml_get_last_error());
Expand Down