PHP 7.4 compatibility

This commit is contained in:
Adrien Crivelli 2019-11-29 23:41:02 +01:00
parent f734783d82
commit 9fa45f7e48
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
10 changed files with 58 additions and 45 deletions

View File

@ -7,11 +7,6 @@ php:
- 7.3 - 7.3
- 7.4snapshot - 7.4snapshot
matrix:
fast_finish: true
allow_failures:
- php: 7.4snapshot
cache: cache:
directories: directories:
- cache - cache

View File

@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com) The format is based on [Keep a Changelog](https://keepachangelog.com)
and this project adheres to [Semantic Versioning](https://semver.org). and this project adheres to [Semantic Versioning](https://semver.org).
## [Unreleased]
### Changed
- PHP 7.4 compatibility
### Added
- ...
### Fixed
- ...
## [1.10.0] - 2019-11-18 ## [1.10.0] - 2019-11-18
### Changed ### Changed

40
composer.lock generated
View File

@ -578,16 +578,16 @@
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
"version": "v2.16.0", "version": "v2.16.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
"reference": "ceaff36bee1ed3f1bbbedca36d2528c0826c336d" "reference": "c8afb599858876e95e8ebfcd97812d383fa23f02"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/ceaff36bee1ed3f1bbbedca36d2528c0826c336d", "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c8afb599858876e95e8ebfcd97812d383fa23f02",
"reference": "ceaff36bee1ed3f1bbbedca36d2528c0826c336d", "reference": "c8afb599858876e95e8ebfcd97812d383fa23f02",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -598,15 +598,15 @@
"ext-tokenizer": "*", "ext-tokenizer": "*",
"php": "^5.6 || ^7.0", "php": "^5.6 || ^7.0",
"php-cs-fixer/diff": "^1.3", "php-cs-fixer/diff": "^1.3",
"symfony/console": "^3.4.17 || ^4.1.6", "symfony/console": "^3.4.17 || ^4.1.6 || ^5.0",
"symfony/event-dispatcher": "^3.0 || ^4.0", "symfony/event-dispatcher": "^3.0 || ^4.0 || ^5.0",
"symfony/filesystem": "^3.0 || ^4.0", "symfony/filesystem": "^3.0 || ^4.0 || ^5.0",
"symfony/finder": "^3.0 || ^4.0", "symfony/finder": "^3.0 || ^4.0 || ^5.0",
"symfony/options-resolver": "^3.0 || ^4.0", "symfony/options-resolver": "^3.0 || ^4.0 || ^5.0",
"symfony/polyfill-php70": "^1.0", "symfony/polyfill-php70": "^1.0",
"symfony/polyfill-php72": "^1.4", "symfony/polyfill-php72": "^1.4",
"symfony/process": "^3.0 || ^4.0", "symfony/process": "^3.0 || ^4.0 || ^5.0",
"symfony/stopwatch": "^3.0 || ^4.0" "symfony/stopwatch": "^3.0 || ^4.0 || ^5.0"
}, },
"require-dev": { "require-dev": {
"johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0", "johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0",
@ -619,8 +619,8 @@
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1",
"phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1", "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1",
"phpunitgoodpractices/traits": "^1.8", "phpunitgoodpractices/traits": "^1.8",
"symfony/phpunit-bridge": "^4.3", "symfony/phpunit-bridge": "^4.3 || ^5.0",
"symfony/yaml": "^3.0 || ^4.0" "symfony/yaml": "^3.0 || ^4.0 || ^5.0"
}, },
"suggest": { "suggest": {
"ext-mbstring": "For handling non-UTF8 characters in cache signature.", "ext-mbstring": "For handling non-UTF8 characters in cache signature.",
@ -663,7 +663,7 @@
} }
], ],
"description": "A tool to automatically fix PHP code style", "description": "A tool to automatically fix PHP code style",
"time": "2019-11-03T13:31:09+00:00" "time": "2019-11-25T22:10:32+00:00"
}, },
{ {
"name": "jpgraph/jpgraph", "name": "jpgraph/jpgraph",
@ -707,16 +707,16 @@
}, },
{ {
"name": "mpdf/mpdf", "name": "mpdf/mpdf",
"version": "v8.0.3", "version": "v8.0.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/mpdf/mpdf.git", "url": "https://github.com/mpdf/mpdf.git",
"reference": "6dd4285aff21f013554ff752046bb44ab1240f5f" "reference": "d3147a0d790b6d11936fd9c73fa31a7ed45e3f6f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/mpdf/mpdf/zipball/6dd4285aff21f013554ff752046bb44ab1240f5f", "url": "https://api.github.com/repos/mpdf/mpdf/zipball/d3147a0d790b6d11936fd9c73fa31a7ed45e3f6f",
"reference": "6dd4285aff21f013554ff752046bb44ab1240f5f", "reference": "d3147a0d790b6d11936fd9c73fa31a7ed45e3f6f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -724,7 +724,7 @@
"ext-mbstring": "*", "ext-mbstring": "*",
"myclabs/deep-copy": "^1.7", "myclabs/deep-copy": "^1.7",
"paragonie/random_compat": "^1.4|^2.0|9.99.99", "paragonie/random_compat": "^1.4|^2.0|9.99.99",
"php": "^5.6 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0", "php": "^5.6 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0",
"psr/log": "^1.0", "psr/log": "^1.0",
"setasign/fpdi": "^2.1" "setasign/fpdi": "^2.1"
}, },
@ -772,7 +772,7 @@
"php", "php",
"utf-8" "utf-8"
], ],
"time": "2019-10-25T17:54:07+00:00" "time": "2019-11-28T09:39:33+00:00"
}, },
{ {
"name": "myclabs/deep-copy", "name": "myclabs/deep-copy",

View File

@ -3459,7 +3459,7 @@ class Calculation
$parenthesisDepthMap[$pendingStoreKey] -= 1; $parenthesisDepthMap[$pendingStoreKey] -= 1;
} }
if (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $d['value'], $matches)) { // Did this parenthesis just close a function? if (is_array($d) && preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $d['value'], $matches)) { // Did this parenthesis just close a function?
if (!empty($pendingStoreKey) && $parenthesisDepthMap[$pendingStoreKey] == -1) { if (!empty($pendingStoreKey) && $parenthesisDepthMap[$pendingStoreKey] == -1) {
// we are closing an IF( // we are closing an IF(
if ($d['value'] != 'IF(') { if ($d['value'] != 'IF(') {

View File

@ -270,10 +270,12 @@ class Functions
public static function ifCondition($condition) public static function ifCondition($condition)
{ {
$condition = self::flattenSingleValue($condition); $condition = self::flattenSingleValue($condition);
if (!isset($condition[0]) && !is_numeric($condition)) {
if ($condition === '') {
$condition = '=""'; $condition = '=""';
} }
if (!in_array($condition[0], ['>', '<', '='])) {
if (!is_string($condition) || !in_array($condition[0], ['>', '<', '='])) {
if (!is_numeric($condition)) { if (!is_numeric($condition)) {
$condition = Calculation::wrapResult(strtoupper($condition)); $condition = Calculation::wrapResult(strtoupper($condition));
} }

View File

@ -370,7 +370,7 @@ class DataSeriesValues
if ($flatten) { if ($flatten) {
$this->dataValues = Functions::flattenArray($newDataValues); $this->dataValues = Functions::flattenArray($newDataValues);
foreach ($this->dataValues as &$dataValue) { foreach ($this->dataValues as &$dataValue) {
if ((!empty($dataValue)) && ($dataValue[0] == '#')) { if (is_string($dataValue) && !empty($dataValue) && $dataValue[0] == '#') {
$dataValue = 0.0; $dataValue = 0.0;
} }
} }

View File

@ -429,6 +429,7 @@ class Xlsx extends BaseReader
$sharedStrings = []; $sharedStrings = [];
$xpath = self::getArrayItem($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings']")); $xpath = self::getArrayItem($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings']"));
if ($xpath) {
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main" //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
$xmlStrings = simplexml_load_string( $xmlStrings = simplexml_load_string(
$this->securityScanner->scan($this->getFromZipArchive($zip, "$dir/$xpath[Target]")), $this->securityScanner->scan($this->getFromZipArchive($zip, "$dir/$xpath[Target]")),
@ -444,6 +445,7 @@ class Xlsx extends BaseReader
} }
} }
} }
}
$worksheets = []; $worksheets = [];
$macros = $customUI = null; $macros = $customUI = null;
@ -1421,7 +1423,7 @@ class Xlsx extends BaseReader
} }
} }
if ((!$this->readDataOnly) || (!empty($this->loadSheetsOnly))) { if ((!$this->readDataOnly || !empty($this->loadSheetsOnly)) && isset($xmlWorkbook->bookViews->workbookView)) {
$workbookView = $xmlWorkbook->bookViews->workbookView; $workbookView = $xmlWorkbook->bookViews->workbookView;
// active sheet index // active sheet index

View File

@ -1077,7 +1077,7 @@ class Parser
public function parse($formula) public function parse($formula)
{ {
$this->currentCharacter = 0; $this->currentCharacter = 0;
$this->formula = $formula; $this->formula = (string) $formula;
$this->lookAhead = $formula[1] ?? ''; $this->lookAhead = $formula[1] ?? '';
$this->advance(); $this->advance();
$this->parseTree = $this->condition(); $this->parseTree = $this->condition();

View File

@ -138,7 +138,7 @@ class SubTotalTest extends TestCase
protected function cellIsFormula(array $cellValues) protected function cellIsFormula(array $cellValues)
{ {
foreach ($cellValues as $cellValue) { foreach ($cellValues as $cellValue) {
yield $cellValue[0] === '='; yield is_string($cellValue) && $cellValue[0] === '=';
} }
} }

View File

@ -86,7 +86,7 @@ class UnparsedDataTest extends TestCase
$this->assertContains('<mc:AlternateContent', $resultSheet1Raw, 'AlternateContent at sheet1.xml not found!'); $this->assertContains('<mc:AlternateContent', $resultSheet1Raw, 'AlternateContent at sheet1.xml not found!');
$xmlWorksheet = simplexml_load_string($resultSheet1Raw, 'SimpleXMLElement', Settings::getLibXmlLoaderOptions()); $xmlWorksheet = simplexml_load_string($resultSheet1Raw, 'SimpleXMLElement', Settings::getLibXmlLoaderOptions());
$pageSetupAttributes = $xmlWorksheet->pageSetup->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); $pageSetupAttributes = $xmlWorksheet->pageSetup->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships');
$this->assertNotEmpty($pageSetupAttributes['id'], 'sheet1.xml/pageSetup[r:id] not found!'); $this->assertTrue(isset($pageSetupAttributes->id), 'sheet1.xml/pageSetup[r:id] not found!');
if (!$xmlWorksheet->sheetProtection) { if (!$xmlWorksheet->sheetProtection) {
$this->fail('sheet1.xml/sheetProtection not found!'); $this->fail('sheet1.xml/sheetProtection not found!');
} else { } else {