diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index a1e1585d..8a2b74ad 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -2782,7 +2782,7 @@ class Calculation * * @param string $formula Formula to parse * - * @return array + * @return array|bool */ public function parseFormula($formula) { @@ -4278,6 +4278,8 @@ class Calculation throw new Exception($errorMessage); } trigger_error($errorMessage, E_USER_ERROR); + + return false; } /** @@ -4305,6 +4307,8 @@ class Calculation $aReferences = Coordinate::extractAllCellReferencesInRange($pRange); $pRange = $pSheetName . '!' . $pRange; if (!isset($aReferences[1])) { + $currentCol = ''; + $currentRow = 0; // Single cell in range sscanf($aReferences[0], '%[A-Z]%d', $currentCol, $currentRow); if ($pSheet->cellExists($aReferences[0])) { @@ -4315,6 +4319,8 @@ class Calculation } else { // Extract cell data for all cells in the range foreach ($aReferences as $reference) { + $currentCol = ''; + $currentRow = 0; // Extract range sscanf($reference, '%[A-Z]%d', $currentCol, $currentRow); if ($pSheet->cellExists($reference)) { diff --git a/src/PhpSpreadsheet/Cell/Coordinate.php b/src/PhpSpreadsheet/Cell/Coordinate.php index 1bca6f44..12e3b689 100644 --- a/src/PhpSpreadsheet/Cell/Coordinate.php +++ b/src/PhpSpreadsheet/Cell/Coordinate.php @@ -339,6 +339,9 @@ abstract class Coordinate // Sort the result by column and row $sortKeys = []; foreach (array_unique($returnValue) as $coord) { + $column = ''; + $row = 0; + sscanf($coord, '%[A-Z]%d', $column, $row); $sortKeys[sprintf('%3s%09d', $column, $row)] = $coord; } diff --git a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php index 63ea91b2..ec3f6e8a 100644 --- a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php +++ b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php @@ -134,6 +134,7 @@ class JpGraph implements IRenderer private function percentageSumCalculation($groupID, $seriesCount) { + $sumValues = []; // Adjust our values to a percentage value across all series in the group for ($i = 0; $i < $seriesCount; ++$i) { if ($i == 0) { @@ -614,8 +615,9 @@ class JpGraph implements IRenderer for ($groupID = 0; $groupID < $iLimit; ++$groupID) { $grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); $exploded = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); + $datasetLabels = []; if ($groupID == 0) { - $labelCount = count($this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount()); + $labelCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount(); if ($labelCount > 0) { $datasetLabels = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); $datasetLabels = $this->formatDataSetLabels($groupID, $datasetLabels, $labelCount); diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php index ac5faf04..b87b805e 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -153,6 +153,8 @@ class Cells { $sortKeys = []; foreach ($this->getCoordinates() as $coord) { + $column = ''; + $row = 0; sscanf($coord, '%[A-Z]%d', $column, $row); $sortKeys[sprintf('%09d%3s', $row, $column)] = $coord; } @@ -172,15 +174,16 @@ class Cells $col = ['A' => '1A']; $row = [1]; foreach ($this->getCoordinates() as $coord) { + $c = ''; + $r = 0; sscanf($coord, '%[A-Z]%d', $c, $r); $row[$r] = $r; $col[$c] = strlen($c) . $c; } - if (!empty($row)) { - // Determine highest column and row - $highestRow = max($row); - $highestColumn = substr(max($col), 1); - } + + // Determine highest column and row + $highestRow = max($row); + $highestColumn = substr(max($col), 1); return [ 'row' => $highestRow, @@ -205,6 +208,9 @@ class Cells */ public function getCurrentColumn() { + $column = ''; + $row = 0; + sscanf($this->currentCoordinate, '%[A-Z]%d', $column, $row); return $column; @@ -217,6 +223,9 @@ class Cells */ public function getCurrentRow() { + $column = ''; + $row = 0; + sscanf($this->currentCoordinate, '%[A-Z]%d', $column, $row); return (int) $row; @@ -240,6 +249,9 @@ class Cells $columnList = [1]; foreach ($this->getCoordinates() as $coord) { + $c = ''; + $r = 0; + sscanf($coord, '%[A-Z]%d', $c, $r); if ($r != $row) { continue; @@ -268,6 +280,9 @@ class Cells $rowList = [0]; foreach ($this->getCoordinates() as $coord) { + $c = ''; + $r = 0; + sscanf($coord, '%[A-Z]%d', $c, $r); if ($c != $column) { continue; @@ -336,6 +351,9 @@ class Cells public function removeRow($row) { foreach ($this->getCoordinates() as $coord) { + $c = ''; + $r = 0; + sscanf($coord, '%[A-Z]%d', $c, $r); if ($r == $row) { $this->delete($coord); @@ -351,6 +369,9 @@ class Cells public function removeColumn($column) { foreach ($this->getCoordinates() as $coord) { + $c = ''; + $r = 0; + sscanf($coord, '%[A-Z]%d', $c, $r); if ($c == $column) { $this->delete($coord); diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php index 641d6d1c..2b920d70 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php @@ -278,6 +278,7 @@ class Chart break; case 'ser': $marker = null; + $seriesIndex = ''; foreach ($seriesDetails as $seriesKey => $seriesDetail) { switch ($seriesKey) { case 'idx': @@ -433,7 +434,7 @@ class Chart private static function parseRichText(SimpleXMLElement $titleDetailPart) { $value = new RichText(); - + $objText = null; foreach ($titleDetailPart as $titleDetailElementKey => $titleDetailElement) { if (isset($titleDetailElement->t)) { $objText = $value->createTextRun((string) $titleDetailElement->t); diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index c423b840..54bc182a 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -82,6 +82,9 @@ class ReferenceHelper */ public static function cellSort($a, $b) { + $ac = $bc = ''; + $ar = $br = 0; + sscanf($a, '%[A-Z]%d', $ac, $ar); sscanf($b, '%[A-Z]%d', $bc, $br); @@ -103,6 +106,9 @@ class ReferenceHelper */ public static function cellReverseSort($a, $b) { + $ac = $bc = ''; + $ar = $br = 0; + sscanf($a, '%[A-Z]%d', $ac, $ar); sscanf($b, '%[A-Z]%d', $bc, $br); @@ -529,6 +535,8 @@ class ReferenceHelper if ($pNumCols != 0) { $autoFilterColumns = $autoFilter->getColumns(); if (count($autoFilterColumns) > 0) { + $column = ''; + $row = 0; sscanf($pBefore, '%[A-Z]%d', $column, $row); $columnIndex = Coordinate::columnIndexFromString($column); list($rangeStart, $rangeEnd) = Coordinate::rangeBoundaries($autoFilterRange); diff --git a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php index 20219004..b3d82d46 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php +++ b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php @@ -234,7 +234,7 @@ class Matrix $R = new self($m, $n); for ($i = 0; $i < $m; ++$i) { for ($j = 0; $j < $n; ++$j) { - $R->set($i - $i0, $j - $j0, $this->A[$RL[$i]][$CL[$j]]); + $R->set($i, $j, $this->A[$RL[$i]][$CL[$j]]); } } @@ -257,7 +257,7 @@ class Matrix $R = new self($m, $n); for ($i = $i0; $i < $iF; ++$i) { for ($j = 0; $j < $n; ++$j) { - $R->set($i - $i0, $j, $this->A[$RL[$i]][$j]); + $R->set($i - $i0, $j, $this->A[$i][$CL[$j]]); } } @@ -1013,6 +1013,7 @@ class Matrix if ($this->n == $B->m) { $C = new self($this->m, $B->n); for ($j = 0; $j < $B->n; ++$j) { + $Bcolj = []; for ($k = 0; $k < $this->n; ++$k) { $Bcolj[$k] = $B->A[$k][$j]; } diff --git a/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php index a123f48d..e666d74b 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php +++ b/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php @@ -125,6 +125,7 @@ class QRDecomposition */ public function getH() { + $H = []; for ($i = 0; $i < $this->m; ++$i) { for ($j = 0; $j < $this->n; ++$j) { if ($i >= $j) { @@ -147,6 +148,7 @@ class QRDecomposition */ public function getR() { + $R = []; for ($i = 0; $i < $this->n; ++$i) { for ($j = 0; $j < $this->n; ++$j) { if ($i < $j) { @@ -171,6 +173,7 @@ class QRDecomposition */ public function getQ() { + $Q = []; for ($k = $this->n - 1; $k >= 0; --$k) { for ($i = 0; $i < $this->m; ++$i) { $Q[$i][$k] = 0.0; diff --git a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php index 83c9200f..afcf5f47 100644 --- a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php @@ -126,7 +126,7 @@ class PolynomialBestFit extends BestFit // calculate sums $x_sum = array_sum($xValues); $y_sum = array_sum($yValues); - $xx_sum = $xy_sum = 0; + $xx_sum = $xy_sum = $yy_sum = 0; for ($i = 0; $i < $this->valueCount; ++$i) { $xy_sum += $xValues[$i] * $yValues[$i]; $xx_sum += $xValues[$i] * $xValues[$i]; @@ -140,6 +140,8 @@ class PolynomialBestFit extends BestFit * a series of x-y data points using least squares. * */ + $A = []; + $B = []; for ($i = 0; $i < $this->valueCount; ++$i) { for ($j = 0; $j <= $order; ++$j) { $A[$i][$j] = pow($xValues[$i], $j); diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index 333aa1b8..494948a7 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -367,6 +367,8 @@ class AutoFilter } $returnVal = ($join == AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_AND); foreach ($dataSet as $rule) { + $retVal = false; + if (is_numeric($rule['value'])) { // Numeric values are tested using the appropriate operator switch ($rule['operator']) { @@ -747,6 +749,8 @@ class AutoFilter } else { // Date based if ($dynamicRuleType[0] == 'M' || $dynamicRuleType[0] == 'Q') { + $periodType = ''; + $period = 0; // Month or Quarter sscanf($dynamicRuleType, '%[A-Z]%d', $periodType, $period); if ($periodType == 'M') {