From 7faee3d6cc6ff6265886c17d19645bc5849ef41e Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Wed, 24 Jul 2019 23:43:28 -0700 Subject: [PATCH] Take advantage of PHP 7.1 syntax --- .php_cs.dist | 4 +-- .../Calculation/Calculation.php | 34 +++++++++---------- src/PhpSpreadsheet/Calculation/Functions.php | 2 +- src/PhpSpreadsheet/Calculation/LookupRef.php | 28 +++++++-------- src/PhpSpreadsheet/Calculation/MathTrig.php | 4 +-- .../Cell/AdvancedValueBinder.php | 4 +-- src/PhpSpreadsheet/Cell/Cell.php | 4 +-- src/PhpSpreadsheet/Cell/Coordinate.php | 20 +++++------ src/PhpSpreadsheet/Chart/DataSeriesValues.php | 2 +- src/PhpSpreadsheet/Chart/Renderer/JpGraph.php | 2 +- src/PhpSpreadsheet/Reader/Csv.php | 5 ++- src/PhpSpreadsheet/Reader/Gnumeric.php | 4 +-- src/PhpSpreadsheet/Reader/Html.php | 2 +- src/PhpSpreadsheet/Reader/Ods.php | 2 +- src/PhpSpreadsheet/Reader/Slk.php | 2 +- src/PhpSpreadsheet/Reader/Xls.php | 26 +++++++------- src/PhpSpreadsheet/Reader/Xlsx.php | 6 ++-- src/PhpSpreadsheet/Reader/Xlsx/Properties.php | 2 +- src/PhpSpreadsheet/Reader/Xlsx/Styles.php | 2 +- src/PhpSpreadsheet/ReferenceHelper.php | 32 +++++++---------- src/PhpSpreadsheet/Shared/JAMA/Matrix.php | 10 +++--- src/PhpSpreadsheet/Shared/OLE.php | 6 ++-- src/PhpSpreadsheet/Shared/OLE/PPS/Root.php | 4 +-- src/PhpSpreadsheet/Shared/Xls.php | 2 +- src/PhpSpreadsheet/Style/NumberFormat.php | 4 +-- src/PhpSpreadsheet/Style/Style.php | 2 +- src/PhpSpreadsheet/Worksheet/AutoFilter.php | 12 +++---- src/PhpSpreadsheet/Worksheet/Drawing.php | 2 +- src/PhpSpreadsheet/Worksheet/Worksheet.php | 10 +++--- src/PhpSpreadsheet/Writer/Html.php | 6 ++-- src/PhpSpreadsheet/Writer/Ods/Content.php | 2 +- src/PhpSpreadsheet/Writer/Xls.php | 2 +- src/PhpSpreadsheet/Writer/Xls/Escher.php | 4 +-- src/PhpSpreadsheet/Writer/Xls/Parser.php | 30 ++++++++-------- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 32 ++++++++--------- src/PhpSpreadsheet/Writer/Xlsx/Chart.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/Comments.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/Workbook.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 4 +-- 39 files changed, 159 insertions(+), 166 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 88f7f8bb..23216924 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -56,7 +56,7 @@ return PhpCsFixer\Config::create() 'is_null' => ['use_yoda_style' => false], 'linebreak_after_opening_tag' => true, 'line_ending' => true, - 'list_syntax' => ['syntax' => 'long'], // Stay compatiblew with PHP 5.6 + 'list_syntax' => ['syntax' => 'short'], 'lowercase_cast' => true, 'lowercase_constants' => true, 'lowercase_keywords' => true, @@ -172,7 +172,7 @@ return PhpCsFixer\Config::create() 'switch_case_semicolon_to_colon' => true, 'switch_case_space' => true, 'ternary_operator_spaces' => true, - 'ternary_to_null_coalescing' => false, // Cannot use that with PHP 5.6 + 'ternary_to_null_coalescing' => true, 'trailing_comma_in_multiline_array' => true, 'trim_array_spaces' => true, 'unary_operator_spaces' => true, diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index f6385acd..325d132b 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -2416,7 +2416,7 @@ class Calculation // Identify our locale and language $language = $locale = strtolower($locale); if (strpos($locale, '_') !== false) { - list($language) = explode('_', $locale); + [$language] = explode('_', $locale); } if (count(self::$validLocaleLanguages) == 1) { self::loadLocales(); @@ -2441,9 +2441,9 @@ class Calculation // Retrieve the list of locale or language specific function names $localeFunctions = file($functionNamesFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($localeFunctions as $localeFunction) { - list($localeFunction) = explode('##', $localeFunction); // Strip out comments + [$localeFunction] = explode('##', $localeFunction); // Strip out comments if (strpos($localeFunction, '=') !== false) { - list($fName, $lfName) = explode('=', $localeFunction); + [$fName, $lfName] = explode('=', $localeFunction); $fName = trim($fName); $lfName = trim($lfName); if ((isset(self::$phpSpreadsheetFunctions[$fName])) && ($lfName != '') && ($fName != $lfName)) { @@ -2466,9 +2466,9 @@ class Calculation if (file_exists($configFile)) { $localeSettings = file($configFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($localeSettings as $localeSetting) { - list($localeSetting) = explode('##', $localeSetting); // Strip out comments + [$localeSetting] = explode('##', $localeSetting); // Strip out comments if (strpos($localeSetting, '=') !== false) { - list($settingName, $settingValue) = explode('=', $localeSetting); + [$settingName, $settingValue] = explode('=', $localeSetting); $settingName = strtoupper(trim($settingName)); switch ($settingName) { case 'ARGUMENTSEPARATOR': @@ -2977,17 +2977,17 @@ class Calculation // Examine each of the two operands, and turn them into an array if they aren't one already // Note that this function should only be called if one or both of the operand is already an array if (!is_array($operand1)) { - list($matrixRows, $matrixColumns) = self::getMatrixDimensions($operand2); + [$matrixRows, $matrixColumns] = self::getMatrixDimensions($operand2); $operand1 = array_fill(0, $matrixRows, array_fill(0, $matrixColumns, $operand1)); $resize = 0; } elseif (!is_array($operand2)) { - list($matrixRows, $matrixColumns) = self::getMatrixDimensions($operand1); + [$matrixRows, $matrixColumns] = self::getMatrixDimensions($operand1); $operand2 = array_fill(0, $matrixRows, array_fill(0, $matrixColumns, $operand2)); $resize = 0; } - list($matrix1Rows, $matrix1Columns) = self::getMatrixDimensions($operand1); - list($matrix2Rows, $matrix2Columns) = self::getMatrixDimensions($operand2); + [$matrix1Rows, $matrix1Columns] = self::getMatrixDimensions($operand1); + [$matrix2Rows, $matrix2Columns] = self::getMatrixDimensions($operand2); if (($matrix1Rows == $matrix2Columns) && ($matrix2Rows == $matrix1Columns)) { $resize = 1; } @@ -3496,11 +3496,11 @@ class Calculation $testPrevOp = $stack->last(1); if ($testPrevOp['value'] == ':') { $startRowColRef = $output[count($output) - 1]['value']; - list($rangeWS1, $startRowColRef) = Worksheet::extractSheetTitle($startRowColRef, true); + [$rangeWS1, $startRowColRef] = Worksheet::extractSheetTitle($startRowColRef, true); if ($rangeWS1 != '') { $rangeWS1 .= '!'; } - list($rangeWS2, $val) = Worksheet::extractSheetTitle($val, true); + [$rangeWS2, $val] = Worksheet::extractSheetTitle($val, true); if ($rangeWS2 != '') { $rangeWS2 .= '!'; } else { @@ -3678,12 +3678,12 @@ class Calculation // Binary Operators case ':': // Range if (strpos($operand1Data['reference'], '!') !== false) { - list($sheet1, $operand1Data['reference']) = Worksheet::extractSheetTitle($operand1Data['reference'], true); + [$sheet1, $operand1Data['reference']] = Worksheet::extractSheetTitle($operand1Data['reference'], true); } else { $sheet1 = ($pCellParent !== null) ? $pCellWorksheet->getTitle() : ''; } - list($sheet2, $operand2Data['reference']) = Worksheet::extractSheetTitle($operand2Data['reference'], true); + [$sheet2, $operand2Data['reference']] = Worksheet::extractSheetTitle($operand2Data['reference'], true); if (empty($sheet2)) { $sheet2 = $sheet1; } @@ -4312,7 +4312,7 @@ class Calculation if ($pSheet !== null) { $pSheetName = $pSheet->getTitle(); if (strpos($pRange, '!') !== false) { - list($pSheetName, $pRange) = Worksheet::extractSheetTitle($pRange, true); + [$pSheetName, $pRange] = Worksheet::extractSheetTitle($pRange, true); $pSheet = $this->spreadsheet->getSheetByName($pSheetName); } @@ -4365,7 +4365,7 @@ class Calculation if ($pSheet !== null) { $pSheetName = $pSheet->getTitle(); if (strpos($pRange, '!') !== false) { - list($pSheetName, $pRange) = Worksheet::extractSheetTitle($pRange, true); + [$pSheetName, $pRange] = Worksheet::extractSheetTitle($pRange, true); $pSheet = $this->spreadsheet->getSheetByName($pSheetName); } @@ -4389,7 +4389,7 @@ class Calculation $aReferences = Coordinate::extractAllCellReferencesInRange($pRange); if (!isset($aReferences[1])) { // Single cell (or single column or row) in range - list($currentCol, $currentRow) = Coordinate::coordinateFromString($aReferences[0]); + [$currentCol, $currentRow] = Coordinate::coordinateFromString($aReferences[0]); if ($pSheet->cellExists($aReferences[0])) { $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog); } else { @@ -4399,7 +4399,7 @@ class Calculation // Extract cell data for all cells in the range foreach ($aReferences as $reference) { // Extract range - list($currentCol, $currentRow) = Coordinate::coordinateFromString($reference); + [$currentCol, $currentRow] = Coordinate::coordinateFromString($reference); if ($pSheet->cellExists($reference)) { $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog); } else { diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index d2baf4ea..40e7d964 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -281,7 +281,7 @@ class Functions return '=' . $condition; } preg_match('/(=|<[>=]?|>=?)(.*)/', $condition, $matches); - list(, $operator, $operand) = $matches; + [, $operator, $operand] = $matches; if (is_numeric(trim($operand, '"'))) { $operand = trim($operand, '"'); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index f2d22c00..5bc0a435 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -98,9 +98,9 @@ class LookupRef return (int) Coordinate::columnIndexFromString($columnKey); } } else { - list($sheet, $cellAddress) = Worksheet::extractSheetTitle($cellAddress, true); + [$sheet, $cellAddress] = Worksheet::extractSheetTitle($cellAddress, true); if (strpos($cellAddress, ':') !== false) { - list($startAddress, $endAddress) = explode(':', $cellAddress); + [$startAddress, $endAddress] = explode(':', $cellAddress); $startAddress = preg_replace('/[^a-z]/i', '', $startAddress); $endAddress = preg_replace('/[^a-z]/i', '', $endAddress); $returnValue = []; @@ -138,7 +138,7 @@ class LookupRef reset($cellAddress); $isMatrix = (is_numeric(key($cellAddress))); - list($columns, $rows) = Calculation::getMatrixDimensions($cellAddress); + [$columns, $rows] = Calculation::getMatrixDimensions($cellAddress); if ($isMatrix) { return $rows; @@ -175,9 +175,9 @@ class LookupRef } } } else { - list($sheet, $cellAddress) = Worksheet::extractSheetTitle($cellAddress, true); + [$sheet, $cellAddress] = Worksheet::extractSheetTitle($cellAddress, true); if (strpos($cellAddress, ':') !== false) { - list($startAddress, $endAddress) = explode(':', $cellAddress); + [$startAddress, $endAddress] = explode(':', $cellAddress); $startAddress = preg_replace('/\D/', '', $startAddress); $endAddress = preg_replace('/\D/', '', $endAddress); $returnValue = []; @@ -187,7 +187,7 @@ class LookupRef return $returnValue; } - list($cellAddress) = explode(':', $cellAddress); + [$cellAddress] = explode(':', $cellAddress); return (int) preg_replace('/\D/', '', $cellAddress); } @@ -215,7 +215,7 @@ class LookupRef reset($cellAddress); $isMatrix = (is_numeric(key($cellAddress))); - list($columns, $rows) = Calculation::getMatrixDimensions($cellAddress); + [$columns, $rows] = Calculation::getMatrixDimensions($cellAddress); if ($isMatrix) { return $columns; @@ -285,7 +285,7 @@ class LookupRef $cellAddress1 = $cellAddress; $cellAddress2 = null; if (strpos($cellAddress, ':') !== false) { - list($cellAddress1, $cellAddress2) = explode(':', $cellAddress); + [$cellAddress1, $cellAddress2] = explode(':', $cellAddress); } if ((!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress1, $matches)) || @@ -295,7 +295,7 @@ class LookupRef } if (strpos($cellAddress, '!') !== false) { - list($sheetName, $cellAddress) = Worksheet::extractSheetTitle($cellAddress, true); + [$sheetName, $cellAddress] = Worksheet::extractSheetTitle($cellAddress, true); $sheetName = trim($sheetName, "'"); $pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName); } else { @@ -306,7 +306,7 @@ class LookupRef } if (strpos($cellAddress, '!') !== false) { - list($sheetName, $cellAddress) = Worksheet::extractSheetTitle($cellAddress, true); + [$sheetName, $cellAddress] = Worksheet::extractSheetTitle($cellAddress, true); $sheetName = trim($sheetName, "'"); $pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName); } else { @@ -359,16 +359,16 @@ class LookupRef $sheetName = null; if (strpos($cellAddress, '!')) { - list($sheetName, $cellAddress) = Worksheet::extractSheetTitle($cellAddress, true); + [$sheetName, $cellAddress] = Worksheet::extractSheetTitle($cellAddress, true); $sheetName = trim($sheetName, "'"); } if (strpos($cellAddress, ':')) { - list($startCell, $endCell) = explode(':', $cellAddress); + [$startCell, $endCell] = explode(':', $cellAddress); } else { $startCell = $endCell = $cellAddress; } - list($startCellColumn, $startCellRow) = Coordinate::coordinateFromString($startCell); - list($endCellColumn, $endCellRow) = Coordinate::coordinateFromString($endCell); + [$startCellColumn, $startCellRow] = Coordinate::coordinateFromString($startCell); + [$endCellColumn, $endCellRow] = Coordinate::coordinateFromString($endCell); $startCellRow += $rows; $startCellColumn = Coordinate::columnIndexFromString($startCellColumn) - 1; diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index 5afdaf35..4e384ea3 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -1074,7 +1074,7 @@ class MathTrig return array_filter( $args, function ($index) use ($cellReference) { - list(, $row, $column) = explode('.', $index); + [, $row, $column] = explode('.', $index); return $cellReference->getWorksheet()->getRowDimension($row)->getVisible() && $cellReference->getWorksheet()->getColumnDimension($column)->getVisible(); @@ -1088,7 +1088,7 @@ class MathTrig return array_filter( $args, function ($index) use ($cellReference) { - list(, $row, $column) = explode('.', $index); + [, $row, $column] = explode('.', $index); if ($cellReference->getWorksheet()->cellExists($column . $row)) { //take this cell out if it contains the SUBTOTAL or AGGREGATE functions in a formula $isFormula = $cellReference->getWorksheet()->getCell($column . $row)->isFormula(); diff --git a/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php b/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php index 4052c23c..1d28f247 100644 --- a/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php +++ b/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php @@ -118,7 +118,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder // Check for time without seconds e.g. '9:45', '09:45' if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) { // Convert value to number - list($h, $m) = explode(':', $value); + [$h, $m] = explode(':', $value); $days = $h / 24 + $m / 1440; $cell->setValueExplicit($days, DataType::TYPE_NUMERIC); // Set style @@ -131,7 +131,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder // Check for time with seconds '9:45:59', '09:45:59' if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$/', $value)) { // Convert value to number - list($h, $m, $s) = explode(':', $value); + [$h, $m, $s] = explode(':', $value); $days = $h / 24 + $m / 1440 + $s / 86400; // Convert value to number $cell->setValueExplicit($days, DataType::TYPE_NUMERIC); diff --git a/src/PhpSpreadsheet/Cell/Cell.php b/src/PhpSpreadsheet/Cell/Cell.php index 813eee4a..45d1b5ba 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -511,7 +511,7 @@ class Cell { if ($mergeRange = $this->getMergeRange()) { $mergeRange = Coordinate::splitRange($mergeRange); - list($startCell) = $mergeRange[0]; + [$startCell] = $mergeRange[0]; if ($this->getCoordinate() === $startCell) { return true; } @@ -569,7 +569,7 @@ class Cell */ public function isInRange($pRange) { - list($rangeStart, $rangeEnd) = Coordinate::rangeBoundaries($pRange); + [$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($pRange); // Translate properties $myColumn = Coordinate::columnIndexFromString($this->getColumn()); diff --git a/src/PhpSpreadsheet/Cell/Coordinate.php b/src/PhpSpreadsheet/Cell/Coordinate.php index 5e20ec6d..cc0543f6 100644 --- a/src/PhpSpreadsheet/Cell/Coordinate.php +++ b/src/PhpSpreadsheet/Cell/Coordinate.php @@ -71,7 +71,7 @@ abstract class Coordinate } // Split out any worksheet name from the reference - list($worksheet, $pCoordinateString) = Worksheet::extractSheetTitle($pCoordinateString, true); + [$worksheet, $pCoordinateString] = Worksheet::extractSheetTitle($pCoordinateString, true); if ($worksheet > '') { $worksheet .= '!'; } @@ -102,13 +102,13 @@ abstract class Coordinate } // Split out any worksheet name from the coordinate - list($worksheet, $pCoordinateString) = Worksheet::extractSheetTitle($pCoordinateString, true); + [$worksheet, $pCoordinateString] = Worksheet::extractSheetTitle($pCoordinateString, true); if ($worksheet > '') { $worksheet .= '!'; } // Create absolute coordinate - list($column, $row) = self::coordinateFromString($pCoordinateString); + [$column, $row] = self::coordinateFromString($pCoordinateString); $column = ltrim($column, '$'); $row = ltrim($row, '$'); @@ -187,7 +187,7 @@ abstract class Coordinate if (strpos($pRange, ':') === false) { $rangeA = $rangeB = $pRange; } else { - list($rangeA, $rangeB) = explode(':', $pRange); + [$rangeA, $rangeB] = explode(':', $pRange); } // Calculate range outer borders @@ -211,7 +211,7 @@ abstract class Coordinate public static function rangeDimension($pRange) { // Calculate range outer borders - list($rangeStart, $rangeEnd) = self::rangeBoundaries($pRange); + [$rangeStart, $rangeEnd] = self::rangeBoundaries($pRange); return [($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1)]; } @@ -238,7 +238,7 @@ abstract class Coordinate if (strpos($pRange, ':') === false) { $rangeA = $rangeB = $pRange; } else { - list($rangeA, $rangeB) = explode(':', $pRange); + [$rangeA, $rangeB] = explode(':', $pRange); } return [self::coordinateFromString($rangeA), self::coordinateFromString($rangeB)]; @@ -376,9 +376,9 @@ abstract class Coordinate } // Range... - list($rangeStart, $rangeEnd) = $range; - list($startColumn, $startRow) = self::coordinateFromString($rangeStart); - list($endColumn, $endRow) = self::coordinateFromString($rangeEnd); + [$rangeStart, $rangeEnd] = $range; + [$startColumn, $startRow] = self::coordinateFromString($rangeStart); + [$endColumn, $endRow] = self::coordinateFromString($rangeEnd); $startColumnIndex = self::columnIndexFromString($startColumn); $endColumnIndex = self::columnIndexFromString($endColumn); ++$endColumnIndex; @@ -432,7 +432,7 @@ abstract class Coordinate continue; } - list($column, $row) = self::coordinateFromString($coord); + [$column, $row] = self::coordinateFromString($coord); $row = (int) (ltrim($row, '$')); $hashCode = $column . '-' . (is_object($value) ? $value->getHashCode() : $value); diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index e82b7efe..73905d97 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -376,7 +376,7 @@ class DataSeriesValues } unset($dataValue); } else { - list($worksheet, $cellRange) = Worksheet::extractSheetTitle($this->dataSource, true); + [$worksheet, $cellRange] = Worksheet::extractSheetTitle($this->dataSource, true); $dimensions = Coordinate::rangeDimension(str_replace('$', '', $cellRange)); if (($dimensions[0] == 1) || ($dimensions[1] == 1)) { $this->dataValues = Functions::flattenArray($newDataValues); diff --git a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php index c0445d49..9dcab049 100644 --- a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php +++ b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php @@ -442,7 +442,7 @@ class JpGraph implements IRenderer $seriesPlot->link->SetColor(self::$colourSet[self::$plotColour]); } elseif ($scatterStyle == 'smoothMarker') { $spline = new \Spline($dataValuesY, $dataValuesX); - list($splineDataY, $splineDataX) = $spline->Get(count($dataValuesX) * self::$width / 20); + [$splineDataY, $splineDataX] = $spline->Get(count($dataValuesX) * self::$width / 20); $lplot = new \LinePlot($splineDataX, $splineDataY); $lplot->SetColor(self::$colourSet[self::$plotColour]); diff --git a/src/PhpSpreadsheet/Reader/Csv.php b/src/PhpSpreadsheet/Reader/Csv.php index 81ca1a8c..21251913 100644 --- a/src/PhpSpreadsheet/Reader/Csv.php +++ b/src/PhpSpreadsheet/Reader/Csv.php @@ -175,9 +175,8 @@ class Csv extends BaseReader } } foreach ($potentialDelimiters as $delimiter) { - $counts[$delimiter][] = isset($countLine[$delimiter]) - ? $countLine[$delimiter] - : 0; + $counts[$delimiter][] = $countLine[$delimiter] + ?? 0; } } diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index 7445ef1b..44ab701d 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -267,7 +267,7 @@ class Gnumeric extends BaseReader break; case 'user-defined': - list(, $attrName) = explode(':', $attributes['name']); + [, $attrName] = explode(':', $attributes['name']); switch ($attrName) { case 'publisher': $docProps->setCompany(trim($propertyValue)); @@ -879,7 +879,7 @@ class Gnumeric extends BaseReader private static function parseGnumericColour($gnmColour) { - list($gnmR, $gnmG, $gnmB) = explode(':', $gnmColour); + [$gnmR, $gnmG, $gnmB] = explode(':', $gnmColour); $gnmR = substr(str_pad($gnmR, 4, '0', STR_PAD_RIGHT), 0, 2); $gnmG = substr(str_pad($gnmG, 4, '0', STR_PAD_RIGHT), 0, 2); $gnmB = substr(str_pad($gnmB, 4, '0', STR_PAD_RIGHT), 0, 2); diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 75db7591..d599424d 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -920,7 +920,7 @@ class Html extends BaseReader */ private function setBorderStyle(Style $cellStyle, $styleValue, $type) { - list(, $borderStyle, $color) = explode(' ', $styleValue); + [, $borderStyle, $color] = explode(' ', $styleValue); $cellStyle->applyFromArray([ 'borders' => [ diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index 51462c20..5fff07aa 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -490,7 +490,7 @@ class Ods extends BaseReader $dateObj = new DateTime($value, $GMT); $dateObj->setTimeZone($timezoneObj); - list($year, $month, $day, $hour, $minute, $second) = explode( + [$year, $month, $day, $hour, $minute, $second] = explode( ' ', $dateObj->format('Y m d H i s') ); diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index c1013c2e..d73f598c 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -384,7 +384,7 @@ class Slk extends BaseReader break; case 'W': - list($startCol, $endCol, $columnWidth) = explode(' ', substr($rowDatum, 1)); + [$startCol, $endCol, $columnWidth] = explode(' ', substr($rowDatum, 1)); break; case 'S': diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index bd2c9c1d..36b50f0a 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -1089,8 +1089,8 @@ class Xls extends BaseReader } // calculate the width and height of the shape - list($startColumn, $startRow) = Coordinate::coordinateFromString($spContainer->getStartCoordinates()); - list($endColumn, $endRow) = Coordinate::coordinateFromString($spContainer->getEndCoordinates()); + [$startColumn, $startRow] = Coordinate::coordinateFromString($spContainer->getStartCoordinates()); + [$endColumn, $endRow] = Coordinate::coordinateFromString($spContainer->getEndCoordinates()); $startOffsetX = $spContainer->getStartOffsetX(); $startOffsetY = $spContainer->getStartOffsetY(); @@ -1175,7 +1175,7 @@ class Xls extends BaseReader // treat SHAREDFMLA records if ($this->version == self::XLS_BIFF8) { foreach ($this->sharedFormulaParts as $cell => $baseCell) { - list($column, $row) = Coordinate::coordinateFromString($cell); + [$column, $row] = Coordinate::coordinateFromString($cell); if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($column, $row, $this->phpSheet->getTitle())) { $formula = $this->getFormulaFromStructure($this->sharedFormulas[$baseCell], $cell); $this->phpSheet->getCell($cell)->setValueExplicit('=' . $formula, DataType::TYPE_FORMULA); @@ -1251,8 +1251,8 @@ class Xls extends BaseReader $coordinateStrings = explode(':', $extractedRange); if (count($coordinateStrings) == 2) { - list($firstColumn, $firstRow) = Coordinate::coordinateFromString($coordinateStrings[0]); - list($lastColumn, $lastRow) = Coordinate::coordinateFromString($coordinateStrings[1]); + [$firstColumn, $firstRow] = Coordinate::coordinateFromString($coordinateStrings[0]); + [$lastColumn, $lastRow] = Coordinate::coordinateFromString($coordinateStrings[1]); if ($firstColumn == 'A' and $lastColumn == 'IV') { // then we have repeating rows @@ -5355,12 +5355,12 @@ class Xls extends BaseReader $formulaStrings = []; foreach ($tokens as $token) { // initialize spaces - $space0 = isset($space0) ? $space0 : ''; // spaces before next token, not tParen - $space1 = isset($space1) ? $space1 : ''; // carriage returns before next token, not tParen - $space2 = isset($space2) ? $space2 : ''; // spaces before opening parenthesis - $space3 = isset($space3) ? $space3 : ''; // carriage returns before opening parenthesis - $space4 = isset($space4) ? $space4 : ''; // spaces before closing parenthesis - $space5 = isset($space5) ? $space5 : ''; // carriage returns before closing parenthesis + $space0 = $space0 ?? ''; // spaces before next token, not tParen + $space1 = $space1 ?? ''; // carriage returns before next token, not tParen + $space2 = $space2 ?? ''; // spaces before opening parenthesis + $space3 = $space3 ?? ''; // carriage returns before opening parenthesis + $space4 = $space4 ?? ''; // spaces before closing parenthesis + $space5 = $space5 ?? ''; // carriage returns before closing parenthesis switch ($token['name']) { case 'tAdd': // addition @@ -7145,7 +7145,7 @@ class Xls extends BaseReader */ private function readBIFF8CellAddressB($cellAddressStructure, $baseCell = 'A1') { - list($baseCol, $baseRow) = Coordinate::coordinateFromString($baseCell); + [$baseCol, $baseRow] = Coordinate::coordinateFromString($baseCell); $baseCol = Coordinate::columnIndexFromString($baseCol) - 1; // offset: 0; size: 2; index to row (0... 65535) (or offset (-32768... 32767)) @@ -7328,7 +7328,7 @@ class Xls extends BaseReader */ private function readBIFF8CellRangeAddressB($subData, $baseCell = 'A1') { - list($baseCol, $baseRow) = Coordinate::coordinateFromString($baseCell); + [$baseCol, $baseRow] = Coordinate::coordinateFromString($baseCell); $baseCol = Coordinate::columnIndexFromString($baseCol) - 1; // TODO: if cell range is just a single cell, should this funciton diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 5372fef9..1c1351f7 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -1352,7 +1352,7 @@ class Xlsx extends BaseReader $rangeSets = preg_split("/('?(?:.*?)'?(?:![A-Z0-9]+:[A-Z0-9]+)),?/", $extractedRange, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $newRangeSets = []; foreach ($rangeSets as $rangeSet) { - list($sheetName, $rangeSet) = Worksheet::extractSheetTitle($rangeSet, true); + [$sheetName, $rangeSet] = Worksheet::extractSheetTitle($rangeSet, true); if (strpos($rangeSet, ':') === false) { $rangeSet = $rangeSet . ':' . $rangeSet; } @@ -1426,7 +1426,7 @@ class Xlsx extends BaseReader $locatedSheet = $excel->getSheetByName($extractedSheetName); // Modify range - list($worksheetName, $extractedRange) = Worksheet::extractSheetTitle($extractedRange, true); + [$worksheetName, $extractedRange] = Worksheet::extractSheetTitle($extractedRange, true); } if ($locatedSheet !== null) { @@ -1841,7 +1841,7 @@ class Xlsx extends BaseReader private static function getArrayItem($array, $key = 0) { - return isset($array[$key]) ? $array[$key] : null; + return $array[$key] ?? null; } private static function dirAdd($base, $add) diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Properties.php b/src/PhpSpreadsheet/Reader/Xlsx/Properties.php index bc6bba2c..bf8e57d8 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Properties.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Properties.php @@ -86,6 +86,6 @@ class Properties private static function getArrayItem(array $array, $key = 0) { - return isset($array[$key]) ? $array[$key] : null; + return $array[$key] ?? null; } } diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Styles.php b/src/PhpSpreadsheet/Reader/Xlsx/Styles.php index c06564a3..af52a6b2 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Styles.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Styles.php @@ -260,6 +260,6 @@ class Styles extends BaseParserClass private static function getArrayItem($array, $key = 0) { - return isset($array[$key]) ? $array[$key] : null; + return $array[$key] ?? null; } } diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index 13dbe042..143e80d8 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -82,11 +82,8 @@ class ReferenceHelper */ public static function cellSort($a, $b) { - // TODO Scrutinizer doesn't like sscanf($a, '%[A-Z]%d', $ac, $ar), and we can't use short list() syntax - // [$ac, $ar] = sscanf($a, '%[A-Z]%d') while retaining PHP 5.6 support. - // Switch when we drop support for 5.6 - list($ac, $ar) = sscanf($a, '%[A-Z]%d'); - list($bc, $br) = sscanf($b, '%[A-Z]%d'); + [$ac, $ar] = sscanf($a, '%[A-Z]%d'); + [$bc, $br] = sscanf($b, '%[A-Z]%d'); if ($ar === $br) { return strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc); @@ -106,11 +103,8 @@ class ReferenceHelper */ public static function cellReverseSort($a, $b) { - // TODO Scrutinizer doesn't like sscanf($a, '%[A-Z]%d', $ac, $ar), and we can't use short list() syntax - // [$ac, $ar] = sscanf($a, '%[A-Z]%d') while retaining PHP 5.6 support. - // Switch when we drop support for 5.6 - list($ac, $ar) = sscanf($a, '%[A-Z]%d'); - list($bc, $br) = sscanf($b, '%[A-Z]%d'); + [$ac, $ar] = sscanf($a, '%[A-Z]%d'); + [$bc, $br] = sscanf($b, '%[A-Z]%d'); if ($ar === $br) { return 1 - strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc); @@ -132,7 +126,7 @@ class ReferenceHelper */ private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols) { - list($cellColumn, $cellRow) = Coordinate::coordinateFromString($cellAddress); + [$cellColumn, $cellRow] = Coordinate::coordinateFromString($cellAddress); $cellColumnIndex = Coordinate::columnIndexFromString($cellColumn); // Is cell within the range of rows/columns if we're deleting if ($pNumRows < 0 && @@ -319,7 +313,7 @@ class ReferenceHelper if (!empty($aColumnDimensions)) { foreach ($aColumnDimensions as $objColumnDimension) { $newReference = $this->updateCellReference($objColumnDimension->getColumnIndex() . '1', $pBefore, $pNumCols, $pNumRows); - list($newReference) = Coordinate::coordinateFromString($newReference); + [$newReference] = Coordinate::coordinateFromString($newReference); if ($objColumnDimension->getColumnIndex() != $newReference) { $objColumnDimension->setColumnIndex($newReference); } @@ -344,7 +338,7 @@ class ReferenceHelper if (!empty($aRowDimensions)) { foreach ($aRowDimensions as $objRowDimension) { $newReference = $this->updateCellReference('A' . $objRowDimension->getRowIndex(), $pBefore, $pNumCols, $pNumRows); - list(, $newReference) = Coordinate::coordinateFromString($newReference); + [, $newReference] = Coordinate::coordinateFromString($newReference); if ($objRowDimension->getRowIndex() != $newReference) { $objRowDimension->setRowIndex($newReference); } @@ -378,7 +372,7 @@ class ReferenceHelper $allCoordinates = $pSheet->getCoordinates(); // Get coordinate of $pBefore - list($beforeColumn, $beforeRow) = Coordinate::coordinateFromString($pBefore); + [$beforeColumn, $beforeRow] = Coordinate::coordinateFromString($pBefore); $beforeColumnIndex = Coordinate::columnIndexFromString($beforeColumn); // Clear cells if we are removing columns or rows @@ -539,7 +533,7 @@ class ReferenceHelper $row = 0; sscanf($pBefore, '%[A-Z]%d', $column, $row); $columnIndex = Coordinate::columnIndexFromString($column); - list($rangeStart, $rangeEnd) = Coordinate::rangeBoundaries($autoFilterRange); + [$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($autoFilterRange); if ($columnIndex <= $rangeEnd[0]) { if ($pNumCols < 0) { // If we're actually deleting any columns that fall within the autofilter range, @@ -707,7 +701,7 @@ class ReferenceHelper if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) { $toString = ($match[2] > '') ? $match[2] . '!' : ''; $toString .= $modified3 . ':' . $modified4; - list($column, $row) = Coordinate::coordinateFromString($match[3]); + [$column, $row] = Coordinate::coordinateFromString($match[3]); // Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more $column = Coordinate::columnIndexFromString(trim($column, '$')) + 100000; $row = trim($row, '$') + 10000000; @@ -733,7 +727,7 @@ class ReferenceHelper if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) { $toString = ($match[2] > '') ? $match[2] . '!' : ''; $toString .= $modified3; - list($column, $row) = Coordinate::coordinateFromString($match[3]); + [$column, $row] = Coordinate::coordinateFromString($match[3]); // Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more $column = Coordinate::columnIndexFromString(trim($column, '$')) + 100000; $row = trim($row, '$') + 10000000; @@ -881,10 +875,10 @@ class ReferenceHelper } // Get coordinate of $pBefore - list($beforeColumn, $beforeRow) = Coordinate::coordinateFromString($pBefore); + [$beforeColumn, $beforeRow] = Coordinate::coordinateFromString($pBefore); // Get coordinate of $pCellReference - list($newColumn, $newRow) = Coordinate::coordinateFromString($pCellReference); + [$newColumn, $newRow] = Coordinate::coordinateFromString($pCellReference); // Verify which parts should be updated $updateColumn = (($newColumn[0] != '$') && ($beforeColumn[0] != '$') && (Coordinate::columnIndexFromString($newColumn) >= Coordinate::columnIndexFromString($beforeColumn))); diff --git a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php index b3d82d46..17f32107 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php +++ b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php @@ -174,7 +174,7 @@ class Matrix switch ($match) { //A($i0...; $j0...) case 'integer,integer': - list($i0, $j0) = $args; + [$i0, $j0] = $args; if ($i0 >= 0) { $m = $this->m - $i0; } else { @@ -197,7 +197,7 @@ class Matrix break; //A($i0...$iF; $j0...$jF) case 'integer,integer,integer,integer': - list($i0, $iF, $j0, $jF) = $args; + [$i0, $iF, $j0, $jF] = $args; if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { @@ -220,7 +220,7 @@ class Matrix break; //$R = array of row indices; $C = array of column indices case 'array,array': - list($RL, $CL) = $args; + [$RL, $CL] = $args; if (count($RL) > 0) { $m = count($RL); } else { @@ -243,7 +243,7 @@ class Matrix break; //A($i0...$iF); $CL = array of column indices case 'integer,integer,array': - list($i0, $iF, $CL) = $args; + [$i0, $iF, $CL] = $args; if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { @@ -266,7 +266,7 @@ class Matrix break; //$RL = array of row indices case 'array,integer,integer': - list($RL, $j0, $jF) = $args; + [$RL, $j0, $jF] = $args; if (count($RL) > 0) { $m = count($RL); } else { diff --git a/src/PhpSpreadsheet/Shared/OLE.php b/src/PhpSpreadsheet/Shared/OLE.php index f09fbc92..efa7522f 100644 --- a/src/PhpSpreadsheet/Shared/OLE.php +++ b/src/PhpSpreadsheet/Shared/OLE.php @@ -253,7 +253,7 @@ class OLE */ private static function _readInt1($fh) { - list(, $tmp) = unpack('c', fread($fh, 1)); + [, $tmp] = unpack('c', fread($fh, 1)); return $tmp; } @@ -267,7 +267,7 @@ class OLE */ private static function _readInt2($fh) { - list(, $tmp) = unpack('v', fread($fh, 2)); + [, $tmp] = unpack('v', fread($fh, 2)); return $tmp; } @@ -281,7 +281,7 @@ class OLE */ private static function _readInt4($fh) { - list(, $tmp) = unpack('V', fread($fh, 4)); + [, $tmp] = unpack('V', fread($fh, 4)); return $tmp; } diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php index 578e08fa..c52cea23 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php @@ -118,7 +118,7 @@ class Root extends PPS $aList = []; PPS::_savePpsSetPnt($aList, [$this]); // calculate values for header - list($iSBDcnt, $iBBcnt, $iPPScnt) = $this->_calcSize($aList); //, $rhInfo); + [$iSBDcnt, $iBBcnt, $iPPScnt] = $this->_calcSize($aList); //, $rhInfo); // Save Header $this->_saveHeader($iSBDcnt, $iBBcnt, $iPPScnt); @@ -149,7 +149,7 @@ class Root extends PPS public function _calcSize(&$raList) { // Calculate Basic Setting - list($iSBDcnt, $iBBcnt, $iPPScnt) = [0, 0, 0]; + [$iSBDcnt, $iBBcnt, $iPPScnt] = [0, 0, 0]; $iSmallLen = 0; $iSBcnt = 0; $iCount = count($raList); diff --git a/src/PhpSpreadsheet/Shared/Xls.php b/src/PhpSpreadsheet/Shared/Xls.php index 177779f8..51407ade 100644 --- a/src/PhpSpreadsheet/Shared/Xls.php +++ b/src/PhpSpreadsheet/Shared/Xls.php @@ -211,7 +211,7 @@ class Xls */ public static function oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height) { - list($column, $row) = Coordinate::coordinateFromString($coordinates); + [$column, $row] = Coordinate::coordinateFromString($coordinates); $col_start = Coordinate::columnIndexFromString($column); $row_start = $row - 1; diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index 785c1f0c..ac64b20e 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -706,7 +706,7 @@ class NumberFormat extends Supervisor if (preg_match('/\[\$(.*)\]/u', $format, $m)) { // Currency or Accounting $currencyCode = $m[1]; - list($currencyCode) = explode('-', $currencyCode); + [$currencyCode] = explode('-', $currencyCode); if ($currencyCode == '') { $currencyCode = StringHelper::getCurrencyCode(); } @@ -807,7 +807,7 @@ class NumberFormat extends Supervisor // Additional formatting provided by callback function if ($callBack !== null) { - list($writerInstance, $function) = $callBack; + [$writerInstance, $function] = $callBack; $value = $writerInstance->$function($value, $formatColor); } diff --git a/src/PhpSpreadsheet/Style/Style.php b/src/PhpSpreadsheet/Style/Style.php index fbe07c2c..9cdfc1b1 100644 --- a/src/PhpSpreadsheet/Style/Style.php +++ b/src/PhpSpreadsheet/Style/Style.php @@ -204,7 +204,7 @@ class Style extends Supervisor $rangeA = $pRange; $rangeB = $pRange; } else { - list($rangeA, $rangeB) = explode(':', $pRange); + [$rangeA, $rangeB] = explode(':', $pRange); } // Calculate range outer borders diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index 494948a7..b4449254 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -90,7 +90,7 @@ class AutoFilter public function setRange($pRange) { // extract coordinate - list($worksheet, $pRange) = Worksheet::extractSheetTitle($pRange, true); + [$worksheet, $pRange] = Worksheet::extractSheetTitle($pRange, true); if (strpos($pRange, ':') !== false) { $this->range = $pRange; @@ -105,7 +105,7 @@ class AutoFilter $this->columns = []; } else { // Discard any column rules that are no longer valid within this range - list($rangeStart, $rangeEnd) = Coordinate::rangeBoundaries($this->range); + [$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($this->range); foreach ($this->columns as $key => $value) { $colIndex = Coordinate::columnIndexFromString($key); if (($rangeStart[0] > $colIndex) || ($rangeEnd[0] < $colIndex)) { @@ -143,7 +143,7 @@ class AutoFilter } $columnIndex = Coordinate::columnIndexFromString($column); - list($rangeStart, $rangeEnd) = Coordinate::rangeBoundaries($this->range); + [$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($this->range); if (($rangeStart[0] > $columnIndex) || ($rangeEnd[0] < $columnIndex)) { throw new PhpSpreadsheetException('Column is outside of current autofilter range.'); } @@ -196,7 +196,7 @@ class AutoFilter */ public function getColumnByOffset($pColumnOffset) { - list($rangeStart, $rangeEnd) = Coordinate::rangeBoundaries($this->range); + [$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($this->range); $pColumn = Coordinate::stringFromColumnIndex($rangeStart[0] + $pColumnOffset); return $this->getColumn($pColumn); @@ -357,7 +357,7 @@ class AutoFilter { $dataSet = $ruleSet['filterRules']; $join = $ruleSet['join']; - $customRuleForBlanks = isset($ruleSet['customRuleForBlanks']) ? $ruleSet['customRuleForBlanks'] : false; + $customRuleForBlanks = $ruleSet['customRuleForBlanks'] ?? false; if (!$customRuleForBlanks) { // Blank cells are always ignored, so return a FALSE @@ -621,7 +621,7 @@ class AutoFilter */ public function showHideRows() { - list($rangeStart, $rangeEnd) = Coordinate::rangeBoundaries($this->range); + [$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($this->range); // The heading row should always be visible $this->workSheet->getRowDimension($rangeStart[1])->setVisible(true); diff --git a/src/PhpSpreadsheet/Worksheet/Drawing.php b/src/PhpSpreadsheet/Worksheet/Drawing.php index ed26006c..8194da31 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing.php @@ -88,7 +88,7 @@ class Drawing extends BaseDrawing if ($this->width == 0 && $this->height == 0) { // Get width/height - list($this->width, $this->height) = getimagesize($pValue); + [$this->width, $this->height] = getimagesize($pValue); } } else { throw new PhpSpreadsheetException("File $pValue not found!"); diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index 1e525a3f..689c547e 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -1561,7 +1561,7 @@ class Worksheet implements IComparable } // Calculate range outer borders - list($rangeStart, $rangeEnd) = Coordinate::rangeBoundaries($pRange . ':' . $pRange); + [$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($pRange . ':' . $pRange); // Make sure we can loop upwards on rows and columns if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { @@ -1601,7 +1601,7 @@ class Worksheet implements IComparable } // Calculate range outer borders - list($rangeStart, $rangeEnd) = Coordinate::rangeBoundaries($pRange . ':' . $pRange); + [$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($pRange . ':' . $pRange); // Make sure we can loop upwards on rows and columns if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { @@ -2424,7 +2424,7 @@ class Worksheet implements IComparable $pCoordinate = preg_replace('/^(\d+):(\d+)$/', 'A${1}:XFD${2}', $pCoordinate); if (Coordinate::coordinateIsRange($pCoordinate)) { - list($first) = Coordinate::splitRange($pCoordinate); + [$first] = Coordinate::splitRange($pCoordinate); $this->activeCell = $first[0]; } else { $this->activeCell = $pCoordinate; @@ -2493,7 +2493,7 @@ class Worksheet implements IComparable } // start coordinate - list($startColumn, $startRow) = Coordinate::coordinateFromString($startCell); + [$startColumn, $startRow] = Coordinate::coordinateFromString($startCell); // Loop through $source foreach ($source as $rowData) { @@ -2535,7 +2535,7 @@ class Worksheet implements IComparable // Returnvalue $returnValue = []; // Identify the range that we need to extract from the worksheet - list($rangeStart, $rangeEnd) = Coordinate::rangeBoundaries($pRange); + [$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($pRange); $minCol = Coordinate::stringFromColumnIndex($rangeStart[0]); $minRow = $rangeStart[1]; $maxCol = Coordinate::stringFromColumnIndex($rangeEnd[0]); diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 6ab08a96..ebda5c33 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -1541,14 +1541,14 @@ class Html extends BaseWriter // loop through all Excel merged cells foreach ($sheet->getMergeCells() as $cells) { - list($cells) = Coordinate::splitRange($cells); + [$cells] = Coordinate::splitRange($cells); $first = $cells[0]; $last = $cells[1]; - list($fc, $fr) = Coordinate::coordinateFromString($first); + [$fc, $fr] = Coordinate::coordinateFromString($first); $fc = Coordinate::columnIndexFromString($fc) - 1; - list($lc, $lr) = Coordinate::coordinateFromString($last); + [$lc, $lr] = Coordinate::coordinateFromString($last); $lc = Coordinate::columnIndexFromString($lc) - 1; // loop through the individual cells in the individual merge diff --git a/src/PhpSpreadsheet/Writer/Ods/Content.php b/src/PhpSpreadsheet/Writer/Ods/Content.php index 11de0fd3..962f8fff 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Content.php +++ b/src/PhpSpreadsheet/Writer/Ods/Content.php @@ -383,7 +383,7 @@ class Content extends WriterPart } $mergeRange = Coordinate::splitRange($cell->getMergeRange()); - list($startCell, $endCell) = $mergeRange[0]; + [$startCell, $endCell] = $mergeRange[0]; $start = Coordinate::coordinateFromString($startCell); $end = Coordinate::coordinateFromString($endCell); $columnSpan = Coordinate::columnIndexFromString($end[0]) - Coordinate::columnIndexFromString($start[0]) + 1; diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index 6dff1342..6932eb1a 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -459,7 +459,7 @@ class Xls extends BaseWriter if ($drawing instanceof Drawing) { $filename = $drawing->getPath(); - list($imagesx, $imagesy, $imageFormat) = getimagesize($filename); + [$imagesx, $imagesy, $imageFormat] = getimagesize($filename); switch ($imageFormat) { case 1: // GIF, not supported by BIFF8, we convert to PNG diff --git a/src/PhpSpreadsheet/Writer/Xls/Escher.php b/src/PhpSpreadsheet/Writer/Xls/Escher.php index 1dcef807..1ee2e904 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Escher.php +++ b/src/PhpSpreadsheet/Writer/Xls/Escher.php @@ -420,7 +420,7 @@ class Escher $recType = 0xF010; // start coordinates - list($column, $row) = Coordinate::coordinateFromString($this->object->getStartCoordinates()); + [$column, $row] = Coordinate::coordinateFromString($this->object->getStartCoordinates()); $c1 = Coordinate::columnIndexFromString($column) - 1; $r1 = $row - 1; @@ -431,7 +431,7 @@ class Escher $startOffsetY = $this->object->getStartOffsetY(); // end coordinates - list($column, $row) = Coordinate::coordinateFromString($this->object->getEndCoordinates()); + [$column, $row] = Coordinate::coordinateFromString($this->object->getEndCoordinates()); $c2 = Coordinate::columnIndexFromString($column) - 1; $r2 = $row - 1; diff --git a/src/PhpSpreadsheet/Writer/Xls/Parser.php b/src/PhpSpreadsheet/Writer/Xls/Parser.php index 6049e328..625a243d 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Parser.php +++ b/src/PhpSpreadsheet/Writer/Xls/Parser.php @@ -608,15 +608,15 @@ class Parser // TODO: possible class value 0,1,2 check Formula.pm // Split the range into 2 cell refs if (preg_match('/^(\$)?([A-Ia-i]?[A-Za-z])(\$)?(\d+)\:(\$)?([A-Ia-i]?[A-Za-z])(\$)?(\d+)$/', $range)) { - list($cell1, $cell2) = explode(':', $range); + [$cell1, $cell2] = explode(':', $range); } else { // TODO: use real error codes throw new WriterException('Unknown range separator'); } // Convert the cell references - list($row1, $col1) = $this->cellToPackedRowcol($cell1); - list($row2, $col2) = $this->cellToPackedRowcol($cell2); + [$row1, $col1] = $this->cellToPackedRowcol($cell1); + [$row2, $col2] = $this->cellToPackedRowcol($cell2); // The ptg value depends on the class of the ptg. if ($class == 0) { @@ -644,20 +644,20 @@ class Parser private function convertRange3d($token) { // Split the ref at the ! symbol - list($ext_ref, $range) = PhpspreadsheetWorksheet::extractSheetTitle($token, true); + [$ext_ref, $range] = PhpspreadsheetWorksheet::extractSheetTitle($token, true); // Convert the external reference part (different for BIFF8) $ext_ref = $this->getRefIndex($ext_ref); // Split the range into 2 cell refs - list($cell1, $cell2) = explode(':', $range); + [$cell1, $cell2] = explode(':', $range); // Convert the cell references if (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\\d+)$/', $cell1)) { - list($row1, $col1) = $this->cellToPackedRowcol($cell1); - list($row2, $col2) = $this->cellToPackedRowcol($cell2); + [$row1, $col1] = $this->cellToPackedRowcol($cell1); + [$row2, $col2] = $this->cellToPackedRowcol($cell2); } else { // It's a rows range (like 26:27) - list($row1, $col1, $row2, $col2) = $this->rangeToPackedRange($cell1 . ':' . $cell2); + [$row1, $col1, $row2, $col2] = $this->rangeToPackedRange($cell1 . ':' . $cell2); } // The ptg value depends on the class of the ptg. @@ -677,7 +677,7 @@ class Parser { // Convert the cell reference $cell_array = $this->cellToPackedRowcol($cell); - list($row, $col) = $cell_array; + [$row, $col] = $cell_array; // The ptg value depends on the class of the ptg. $ptgRef = pack('C', $this->ptg['ptgRefA']); @@ -696,13 +696,13 @@ class Parser private function convertRef3d($cell) { // Split the ref at the ! symbol - list($ext_ref, $cell) = PhpspreadsheetWorksheet::extractSheetTitle($cell, true); + [$ext_ref, $cell] = PhpspreadsheetWorksheet::extractSheetTitle($cell, true); // Convert the external reference part (different for BIFF8) $ext_ref = $this->getRefIndex($ext_ref); // Convert the cell reference part - list($row, $col) = $this->cellToPackedRowcol($cell); + [$row, $col] = $this->cellToPackedRowcol($cell); // The ptg value depends on the class of the ptg. $ptgRef = pack('C', $this->ptg['ptgRef3dA']); @@ -756,7 +756,7 @@ class Parser // Check if there is a sheet range eg., Sheet1:Sheet2. if (preg_match('/:/', $ext_ref)) { - list($sheet_name1, $sheet_name2) = explode(':', $ext_ref); + [$sheet_name1, $sheet_name2] = explode(':', $ext_ref); $sheet1 = $this->getSheetIndex($sheet_name1); if ($sheet1 == -1) { @@ -769,7 +769,7 @@ class Parser // Reverse max and min sheet numbers if necessary if ($sheet1 > $sheet2) { - list($sheet1, $sheet2) = [$sheet2, $sheet1]; + [$sheet1, $sheet2] = [$sheet2, $sheet1]; } } else { // Single sheet name only. $sheet1 = $this->getSheetIndex($ext_ref); @@ -843,7 +843,7 @@ class Parser private function cellToPackedRowcol($cell) { $cell = strtoupper($cell); - list($row, $col, $row_rel, $col_rel) = $this->cellToRowcol($cell); + [$row, $col, $row_rel, $col_rel] = $this->cellToRowcol($cell); if ($col >= 256) { throw new WriterException("Column in: $cell greater than 255"); } @@ -1078,7 +1078,7 @@ class Parser { $this->currentCharacter = 0; $this->formula = $formula; - $this->lookAhead = isset($formula[1]) ? $formula[1] : ''; + $this->lookAhead = $formula[1] ?? ''; $this->advance(); $this->parseTree = $this->condition(); diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index db63fa34..d8822d80 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -479,7 +479,7 @@ class Worksheet extends BIFFwriter // Hyperlinks foreach ($phpSheet->getHyperLinkCollection() as $coordinate => $hyperlink) { - list($column, $row) = Coordinate::coordinateFromString($coordinate); + [$column, $row] = Coordinate::coordinateFromString($coordinate); $url = $hyperlink->getUrl(); @@ -1355,17 +1355,17 @@ class Worksheet extends BIFFwriter $selectedCells = Coordinate::splitRange($this->phpSheet->getSelectedCells()); $selectedCells = $selectedCells[0]; if (count($selectedCells) == 2) { - list($first, $last) = $selectedCells; + [$first, $last] = $selectedCells; } else { $first = $selectedCells[0]; $last = $selectedCells[0]; } - list($colFirst, $rwFirst) = Coordinate::coordinateFromString($first); + [$colFirst, $rwFirst] = Coordinate::coordinateFromString($first); $colFirst = Coordinate::columnIndexFromString($colFirst) - 1; // base 0 column index --$rwFirst; // base 0 row index - list($colLast, $rwLast) = Coordinate::coordinateFromString($last); + [$colLast, $rwLast] = Coordinate::coordinateFromString($last); $colLast = Coordinate::columnIndexFromString($colLast) - 1; // base 0 column index --$rwLast; // base 0 row index @@ -1394,11 +1394,11 @@ class Worksheet extends BIFFwriter // Swap last row/col for first row/col as necessary if ($rwFirst > $rwLast) { - list($rwFirst, $rwLast) = [$rwLast, $rwFirst]; + [$rwFirst, $rwLast] = [$rwLast, $rwFirst]; } if ($colFirst > $colLast) { - list($colFirst, $colLast) = [$colLast, $colFirst]; + [$colFirst, $colLast] = [$colLast, $colFirst]; } $header = pack('vv', $record, $length); @@ -1440,9 +1440,9 @@ class Worksheet extends BIFFwriter // extract the row and column indexes $range = Coordinate::splitRange($mergeCell); - list($first, $last) = $range[0]; - list($firstColumn, $firstRow) = Coordinate::coordinateFromString($first); - list($lastColumn, $lastRow) = Coordinate::coordinateFromString($last); + [$first, $last] = $range[0]; + [$firstColumn, $firstRow] = Coordinate::coordinateFromString($first); + [$lastColumn, $lastRow] = Coordinate::coordinateFromString($last); $recordData .= pack('vvvv', $firstRow - 1, $lastRow - 1, Coordinate::columnIndexFromString($firstColumn) - 1, Coordinate::columnIndexFromString($lastColumn) - 1); @@ -1589,11 +1589,11 @@ class Worksheet extends BIFFwriter { $panes = []; if ($this->phpSheet->getFreezePane()) { - list($column, $row) = Coordinate::coordinateFromString($this->phpSheet->getFreezePane()); + [$column, $row] = Coordinate::coordinateFromString($this->phpSheet->getFreezePane()); $panes[0] = Coordinate::columnIndexFromString($column) - 1; $panes[1] = $row - 1; - list($leftMostColumn, $topRow) = Coordinate::coordinateFromString($this->phpSheet->getTopLeftCell()); + [$leftMostColumn, $topRow] = Coordinate::coordinateFromString($this->phpSheet->getTopLeftCell()); //Coordinates are zero-based in xls files $panes[2] = $topRow - 1; $panes[3] = Coordinate::columnIndexFromString($leftMostColumn) - 1; @@ -1602,10 +1602,10 @@ class Worksheet extends BIFFwriter return; } - $x = isset($panes[0]) ? $panes[0] : null; - $y = isset($panes[1]) ? $panes[1] : null; - $rwTop = isset($panes[2]) ? $panes[2] : null; - $colLeft = isset($panes[3]) ? $panes[3] : null; + $x = $panes[0] ?? null; + $y = $panes[1] ?? null; + $rwTop = $panes[2] ?? null; + $colLeft = $panes[3] ?? null; if (count($panes) > 4) { // if Active pane was received $pnnAct = $panes[4]; } else { @@ -2215,7 +2215,7 @@ class Worksheet extends BIFFwriter public function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1) { $bitmap_array = (is_resource($bitmap) ? $this->processBitmapGd($bitmap) : $this->processBitmap($bitmap)); - list($width, $height, $size, $data) = $bitmap_array; + [$width, $height, $size, $data] = $bitmap_array; // Scale the frame of the image. $width *= $scale_x; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php index 625fd16d..3241d403 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php @@ -1136,7 +1136,7 @@ class Chart extends WriterPart $fillColorValues = $plotSeriesValues->getFillColor(); if ($fillColorValues !== null && is_array($fillColorValues)) { foreach ($plotSeriesValues->getDataValues() as $dataKey => $dataValue) { - $this->writePlotSeriesValuesElement($objWriter, $dataKey, (isset($fillColorValues[$dataKey]) ? $fillColorValues[$dataKey] : 'FF9900')); + $this->writePlotSeriesValuesElement($objWriter, $dataKey, ($fillColorValues[$dataKey] ?? 'FF9900')); } } else { $this->writePlotSeriesValuesElement($objWriter); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php index 8b08f31f..a95298af 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php @@ -175,7 +175,7 @@ class Comments extends WriterPart private function writeVMLComment(XMLWriter $objWriter, $pCellReference, Comment $pComment) { // Metadata - list($column, $row) = Coordinate::coordinateFromString($pCellReference); + [$column, $row] = Coordinate::coordinateFromString($pCellReference); $column = Coordinate::columnIndexFromString($column); $id = 1024 + $column + $row; $id = substr($id, 0, 4); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php index b9f8f99b..fd936748 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php @@ -339,7 +339,7 @@ class Workbook extends WriterPart $range = Coordinate::splitRange($autoFilterRange); $range = $range[0]; // Strip any worksheet ref so we can make the cell ref absolute - list($ws, $range[0]) = Worksheet::extractSheetTitle($range[0], true); + [$ws, $range[0]] = Worksheet::extractSheetTitle($range[0], true); $range[0] = Coordinate::absoluteCoordinate($range[0]); $range[1] = Coordinate::absoluteCoordinate($range[1]); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 065eaaf1..07bf39bf 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -251,7 +251,7 @@ class Worksheet extends WriterPart // Pane $pane = ''; if ($pSheet->getFreezePane()) { - list($xSplit, $ySplit) = Coordinate::coordinateFromString($pSheet->getFreezePane()); + [$xSplit, $ySplit] = Coordinate::coordinateFromString($pSheet->getFreezePane()); $xSplit = Coordinate::columnIndexFromString($xSplit); --$xSplit; --$ySplit; @@ -752,7 +752,7 @@ class Worksheet extends WriterPart $range = Coordinate::splitRange($autoFilterRange); $range = $range[0]; // Strip any worksheet ref - list($ws, $range[0]) = PhpspreadsheetWorksheet::extractSheetTitle($range[0], true); + [$ws, $range[0]] = PhpspreadsheetWorksheet::extractSheetTitle($range[0], true); $range = implode(':', $range); $objWriter->writeAttribute('ref', str_replace('$', '', $range));