Skip to content

Commit

Permalink
Merge pull request #190 from phil-davis/test-with-php-8.0
Browse files Browse the repository at this point in the history
Test with PHP8.0
  • Loading branch information
phil-davis authored Oct 3, 2020
2 parents 41c6ba1 + 446ded7 commit cb378d8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
15 changes: 13 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,26 @@ php:

env:
global:
- RUN_PHPCSFIXER="TRUE"
- RUN_PHPUNIT="TRUE"
- RUN_PHPSTAN="FALSE"
matrix:
- PREFER_LOWEST="" REPORT_COVERAGE="TRUE" WITH_COVERAGE="--coverage-clover=coverage.xml"
- PREFER_LOWEST="--prefer-lowest" REPORT_COVERAGE="FALSE" WITH_COVERAGE=""

matrix:
include:
- name: 'PHP8'
dist: focal
php: nightly
env:
- RUN_PHPCSFIXER="FALSE"
- REPORT_COVERAGE="FALSE"
- name: 'PHPStan'
php: 7.4
env:
- RUN_PHPCSFIXER="FALSE"
- RUN_PHPUNIT="FALSE"
- RUN_PHPSTAN="TRUE"
- REPORT_COVERAGE="FALSE"
fast_finish: true
Expand All @@ -27,11 +37,12 @@ cache:
- $HOME/.composer/cache

before_script:
- if [ $RUN_PHPCSFIXER == "FALSE" ]; then composer remove --dev friendsofphp/php-cs-fixer; fi
- composer update $PREFER_LOWEST

script:
- if [ $RUN_PHPSTAN == "FALSE" ]; then php vendor/bin/php-cs-fixer fix --dry-run --diff; fi
- if [ $RUN_PHPSTAN == "FALSE" ]; then php vendor/bin/phpunit --configuration tests/phpunit.xml $WITH_COVERAGE; fi
- if [ $RUN_PHPCSFIXER == "TRUE" ]; then php vendor/bin/php-cs-fixer fix --dry-run --diff; fi
- if [ $RUN_PHPUNIT == "TRUE" ]; then php vendor/bin/phpunit --configuration tests/phpunit.xml $WITH_COVERAGE; fi
- if [ $RUN_PHPSTAN == "TRUE" ]; then composer phpstan; fi

after_success:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"homepage" : "https://sabre.io/xml/",
"license" : "BSD-3-Clause",
"require" : {
"php" : "^7.1",
"php" : "^7.1 || ^8.0",
"ext-xmlwriter" : "*",
"ext-xmlreader" : "*",
"ext-dom" : "*",
Expand Down
10 changes: 8 additions & 2 deletions lib/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ public function getClark()
*/
public function parse(): array
{
$previousEntityState = libxml_disable_entity_loader(true);
$previousEntityState = null;
$shouldCallLibxmlDisableEntityLoader = (\PHP_VERSION_ID < 80000);
if ($shouldCallLibxmlDisableEntityLoader) {
$previousEntityState = libxml_disable_entity_loader(true);
}
$previousSetting = libxml_use_internal_errors(true);

try {
Expand All @@ -78,7 +82,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 cb378d8

Please sign in to comment.