From 670eebf89dd98a8532752d6cd539408a7d9d44f0 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sat, 3 Oct 2020 13:06:45 +0545 Subject: [PATCH 1/4] Adjust boolean vars in .travis.yml to prepare for PHP8.0 --- .travis.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ebca5e8..5c7f0b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,8 @@ php: env: global: + - RUN_PHPCSFIXER="TRUE" + - RUN_PHPUNIT="TRUE" - RUN_PHPSTAN="FALSE" matrix: - PREFER_LOWEST="" REPORT_COVERAGE="TRUE" WITH_COVERAGE="--coverage-clover=coverage.xml" @@ -18,6 +20,8 @@ matrix: - name: 'PHPStan' php: 7.4 env: + - RUN_PHPCSFIXER="FALSE" + - RUN_PHPUNIT="FALSE" - RUN_PHPSTAN="TRUE" - REPORT_COVERAGE="FALSE" fast_finish: true @@ -27,11 +31,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: From 5aad0e67f0d2825cc9bccb36abe720816eb40525 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sat, 3 Oct 2020 13:09:08 +0545 Subject: [PATCH 2/4] Run unit tests on PHP8 --- .travis.yml | 6 ++++++ composer.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5c7f0b2..fc4a98d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,12 @@ env: matrix: include: + - name: 'PHP8' + dist: focal + php: nightly + env: + - RUN_PHPCSFIXER="FALSE" + - REPORT_COVERAGE="FALSE" - name: 'PHPStan' php: 7.4 env: diff --git a/composer.json b/composer.json index 40abe14..b54cf19 100644 --- a/composer.json +++ b/composer.json @@ -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" : "*", From 73040eda220955a9ab3721c25483da1192c36242 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sat, 3 Oct 2020 13:22:03 +0545 Subject: [PATCH 3/4] libxml_disable_entity_loader is deprecated on PHP 8.0 --- lib/Reader.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Reader.php b/lib/Reader.php index a28cf8c..385f608 100644 --- a/lib/Reader.php +++ b/lib/Reader.php @@ -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 { @@ -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; From 446ded78b07618ea2c437b891c4eb1b08e44ca05 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 3 Oct 2020 10:07:46 +0200 Subject: [PATCH 4/4] Update lib/Reader.php --- lib/Reader.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Reader.php b/lib/Reader.php index 385f608..368e8ff 100644 --- a/lib/Reader.php +++ b/lib/Reader.php @@ -55,6 +55,7 @@ public function getClark() */ public function parse(): array { + $previousEntityState = null; $shouldCallLibxmlDisableEntityLoader = (\PHP_VERSION_ID < 80000); if ($shouldCallLibxmlDisableEntityLoader) { $previousEntityState = libxml_disable_entity_loader(true);