From 858e073063d08574514215c3986561e921d4687e Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 1 Nov 2021 11:40:41 +0900 Subject: [PATCH] Drop PHP 7.2 This is according to our formal, published, policy to only support eol PHP after 6 months. See https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support --- .github/workflows/main.yml | 3 +- CHANGELOG.md | 2 +- composer.json | 4 +- composer.lock | 40 +++++++++---------- docs/index.md | 2 +- samples/index.php | 2 +- .../Reader/Security/XmlScanner.php | 3 +- src/PhpSpreadsheet/Settings.php | 28 ++++--------- 8 files changed, 35 insertions(+), 49 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 32dd510a..b36bf6c8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,6 @@ jobs: experimental: - false php-version: - - '7.2' - '7.3' - '7.4' - '8.0' @@ -150,7 +149,7 @@ jobs: run: composer install --no-progress --prefer-dist --optimize-autoloader - name: Code Version Compatibility check with PHP_CodeSniffer - run: ./vendor/bin/phpcs -q --report-width=200 --report=summary,full src/ --standard=PHPCompatibility --runtime-set testVersion 7.2- + run: ./vendor/bin/phpcs -q --report-width=200 --report=summary,full src/ --standard=PHPCompatibility --runtime-set testVersion 7.3- phpstan: runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index c2828191..8dc363be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Changed -- Nothing +- Drop support for PHP 7.2, according to https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support ### Deprecated diff --git a/composer.json b/composer.json index dff99d7e..ba105c6a 100644 --- a/composer.json +++ b/composer.json @@ -48,11 +48,11 @@ "php-cs-fixer fix --ansi" ], "versions": [ - "phpcs --report-width=200 samples/ src/ tests/ --ignore=samples/Header.php --standard=PHPCompatibility --runtime-set testVersion 7.2- -n" + "phpcs --report-width=200 samples/ src/ tests/ --ignore=samples/Header.php --standard=PHPCompatibility --runtime-set testVersion 7.3- -n" ] }, "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "ext-ctype": "*", "ext-dom": "*", "ext-fileinfo": "*", diff --git a/composer.lock b/composer.lock index f5670fd3..563c5579 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "08bcc40376dc4b219b21d172e40c622d", + "content-hash": "4474427c6ded1acc044ea945792e7fb5", "packages": [ { "name": "ezyang/htmlpurifier", @@ -240,26 +240,26 @@ }, { "name": "myclabs/php-enum", - "version": "1.7.7", + "version": "1.8.3", "source": { "type": "git", "url": "https://github.com/myclabs/php-enum.git", - "reference": "d178027d1e679832db9f38248fcc7200647dc2b7" + "reference": "b942d263c641ddb5190929ff840c68f78713e937" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/php-enum/zipball/d178027d1e679832db9f38248fcc7200647dc2b7", - "reference": "d178027d1e679832db9f38248fcc7200647dc2b7", + "url": "https://api.github.com/repos/myclabs/php-enum/zipball/b942d263c641ddb5190929ff840c68f78713e937", + "reference": "b942d263c641ddb5190929ff840c68f78713e937", "shasum": "" }, "require": { "ext-json": "*", - "php": ">=7.1" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^7", + "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "1.*", - "vimeo/psalm": "^3.8" + "vimeo/psalm": "^4.6.2" }, "type": "library", "autoload": { @@ -284,7 +284,7 @@ ], "support": { "issues": "https://github.com/myclabs/php-enum/issues", - "source": "https://github.com/myclabs/php-enum/tree/1.7.7" + "source": "https://github.com/myclabs/php-enum/tree/1.8.3" }, "funding": [ { @@ -296,7 +296,7 @@ "type": "tidelift" } ], - "time": "2020-11-14T18:14:52+00:00" + "time": "2021-07-05T08:18:36+00:00" }, { "name": "psr/http-client", @@ -2334,29 +2334,29 @@ }, { "name": "phpunit/php-token-stream", - "version": "3.1.3", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "9c1da83261628cb24b6a6df371b6e312b3954768" + "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9c1da83261628cb24b6a6df371b6e312b3954768", - "reference": "9c1da83261628cb24b6a6df371b6e312b3954768", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/a853a0e183b9db7eed023d7933a858fa1c8d25a3", + "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=7.1" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -2381,7 +2381,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", - "source": "https://github.com/sebastianbergmann/php-token-stream/tree/3.1.3" + "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master" }, "funding": [ { @@ -2390,7 +2390,7 @@ } ], "abandoned": true, - "time": "2021-07-26T12:15:06+00:00" + "time": "2020-08-04T08:28:15+00:00" }, { "name": "phpunit/phpunit", @@ -5141,7 +5141,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "ext-ctype": "*", "ext-dom": "*", "ext-fileinfo": "*", diff --git a/docs/index.md b/docs/index.md index 42acedf9..98a2d3d8 100644 --- a/docs/index.md +++ b/docs/index.md @@ -24,7 +24,7 @@ allow you to read and write various spreadsheet file formats such as Excel and L ## Software requirements -PHP version 7.2 or newer to develop using PhpSpreadsheet. Other requirements, such as PHP extensions, are enforced by +PHP version 7.3 or newer to develop using PhpSpreadsheet. Other requirements, such as PHP extensions, are enforced by composer. See the `require` section of [the composer.json file](https://github.com/PHPOffice/PhpSpreadsheet/blob/master/composer.json) for details. diff --git a/samples/index.php b/samples/index.php index b0b75434..d60efd95 100644 --- a/samples/index.php +++ b/samples/index.php @@ -3,7 +3,7 @@ require_once 'Header.php'; $requirements = [ - 'PHP 7.2.0' => version_compare(PHP_VERSION, '7.2.0', '>='), + 'PHP 7.3.0' => version_compare(PHP_VERSION, '7.3.0', '>='), 'PHP extension XML' => extension_loaded('xml'), 'PHP extension xmlwriter' => extension_loaded('xmlwriter'), 'PHP extension mbstring' => extension_loaded('mbstring'), diff --git a/src/PhpSpreadsheet/Reader/Security/XmlScanner.php b/src/PhpSpreadsheet/Reader/Security/XmlScanner.php index c9c3ecc0..8155b838 100644 --- a/src/PhpSpreadsheet/Reader/Security/XmlScanner.php +++ b/src/PhpSpreadsheet/Reader/Security/XmlScanner.php @@ -3,7 +3,6 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Security; use PhpOffice\PhpSpreadsheet\Reader; -use PhpOffice\PhpSpreadsheet\Settings; class XmlScanner { @@ -71,7 +70,7 @@ class XmlScanner private function disableEntityLoaderCheck(): void { - if (Settings::getLibXmlDisableEntityLoader() && \PHP_VERSION_ID < 80000) { + if (\PHP_VERSION_ID < 80000) { $libxmlDisableEntityLoaderValue = libxml_disable_entity_loader(true); if (self::$libxmlDisableEntityLoaderValue === null) { diff --git a/src/PhpSpreadsheet/Settings.php b/src/PhpSpreadsheet/Settings.php index 765ae8c8..5fbbadb6 100644 --- a/src/PhpSpreadsheet/Settings.php +++ b/src/PhpSpreadsheet/Settings.php @@ -26,17 +26,6 @@ class Settings */ private static $libXmlLoaderOptions; - /** - * Allow/disallow libxml_disable_entity_loader() call when not thread safe. - * Default behaviour is to do the check, but if you're running PHP versions - * 7.2 < 7.2.1 - * then you may need to disable this check to prevent unwanted behaviour in other threads - * SECURITY WARNING: Changing this flag is not recommended. - * - * @var bool - */ - private static $libXmlDisableEntityLoader = true; - /** * The cache implementation to be used for cell collection. * @@ -135,28 +124,27 @@ class Settings } /** - * Enable/Disable the entity loader for libxml loader. - * Allow/disallow libxml_disable_entity_loader() call when not thread safe. - * Default behaviour is to do the check, but if you're running PHP versions - * 7.2 < 7.2.1 - * then you may need to disable this check to prevent unwanted behaviour in other threads - * SECURITY WARNING: Changing this flag to false is not recommended. + * Deprecated, has no effect. * * @param bool $state + * + * @deprecated will be removed without replacement as it is no longer necessary on PHP 7.3.0+ */ public static function setLibXmlDisableEntityLoader($state): void { - self::$libXmlDisableEntityLoader = (bool) $state; + // noop } /** - * Return the state of the entity loader (disabled/enabled) for libxml loader. + * Deprecated, has no effect. * * @return bool $state + * + * @deprecated will be removed without replacement as it is no longer necessary on PHP 7.3.0+ */ public static function getLibXmlDisableEntityLoader(): bool { - return self::$libXmlDisableEntityLoader; + return true; } /**