diff --git a/src/PhpSpreadsheet/Calculation.php b/src/PhpSpreadsheet/Calculation.php index b755667a..17739346 100644 --- a/src/PhpSpreadsheet/Calculation.php +++ b/src/PhpSpreadsheet/Calculation.php @@ -2037,14 +2037,6 @@ class Calculation return self::$instance; } - /** - * Unset an instance of this class. - */ - public function __destruct() - { - $this->workbook = null; - } - /** * Flush the calculation cache for any existing instance of this class * but only if a Calculation instance exists. diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php index 27fcd616..919eb9e1 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -19,7 +19,7 @@ class Financial * * @return bool */ - private static function isLastDayOfMonth($testDate) + private static function isLastDayOfMonth(\DateTime $testDate) { return $testDate->format('d') == $testDate->format('t'); } diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php index 9e0fe1cb..d49e71eb 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -300,7 +300,7 @@ class Statistical $y = $x; if ($y > 0.0 && $y <= self::LOG_GAMMA_X_MAX_VALUE) { if ($y <= self::EPS) { - $res = -log(y); + $res = -log($y); } elseif ($y <= 1.5) { // --------------------- // EPS .LT. X .LE. 1.5 diff --git a/src/PhpSpreadsheet/Helper/Html.php b/src/PhpSpreadsheet/Helper/Html.php index 528833c3..457b4be8 100644 --- a/src/PhpSpreadsheet/Helper/Html.php +++ b/src/PhpSpreadsheet/Helper/Html.php @@ -581,6 +581,9 @@ class Html protected $stringData = ''; + /** + * @var RichText + */ protected $richTextObject; protected function initialise() diff --git a/src/PhpSpreadsheet/Reader/DefaultReadFilter.php b/src/PhpSpreadsheet/Reader/DefaultReadFilter.php index 347ff39c..e104186a 100644 --- a/src/PhpSpreadsheet/Reader/DefaultReadFilter.php +++ b/src/PhpSpreadsheet/Reader/DefaultReadFilter.php @@ -7,9 +7,9 @@ class DefaultReadFilter implements IReadFilter /** * Should this cell be read? * - * @param $column Column address (as a string value like "A", or "IV") - * @param $row Row number - * @param $worksheetName Optional worksheet name + * @param string $column Column address (as a string value like "A", or "IV") + * @param int $row Row number + * @param string $worksheetName Optional worksheet name * * @return bool */ diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index d1e05ade..a38bb3b7 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -238,7 +238,7 @@ class Html extends BaseReader implements IReader return array_pop($this->nestedColumn); } - protected function flushCell($sheet, $column, $row, &$cellContent) + protected function flushCell(Worksheet $sheet, $column, $row, &$cellContent) { if (is_string($cellContent)) { // Simple String content diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index aa94d739..ea69d29f 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -485,7 +485,7 @@ class Slk extends BaseReader implements IReader * * @param int $pValue Sheet index * - * @return SYLK + * @return Slk */ public function setSheetIndex($pValue) { diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index fbb248da..d876e22d 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -23,7 +23,6 @@ use PhpOffice\PhpSpreadsheet\Style\Font; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Style\Protection; use PhpOffice\PhpSpreadsheet\Worksheet; -use PhpOffice\PhpSpreadsheet\Worksheet\Drawing; use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing; use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; use PhpOffice\PhpSpreadsheet\Worksheet\SheetView; diff --git a/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php index 3e59bddd..e72604f4 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php +++ b/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php @@ -83,7 +83,7 @@ class EigenvalueDecomposition $i_ = $i - 1; // Scale to avoid under/overflow. $h = $scale = 0.0; - $scale += array_sum(array_map(abs, $this->d)); + $scale += array_sum(array_map('abs', $this->d)); if ($scale == 0.0) { $this->e[$i] = $this->d[$i_]; $this->d = array_slice($this->V[$i_], 0, $i_); diff --git a/src/PhpSpreadsheet/Shared/OLE.php b/src/PhpSpreadsheet/Shared/OLE.php index bcec3df7..2f24ba8f 100644 --- a/src/PhpSpreadsheet/Shared/OLE.php +++ b/src/PhpSpreadsheet/Shared/OLE.php @@ -541,7 +541,7 @@ class OLE public static function OLE2LocalDate($string) { if (strlen($string) != 8) { - return new PEAR_Error('Expecting 8 byte string'); + throw new ReaderException('Expecting 8 byte string'); } // factor used for separating numbers into 4 bytes parts diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php index 844a1dbb..a7649d29 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php @@ -47,7 +47,7 @@ class Root extends PPS */ public function __construct($time_1st, $time_2nd, $raChild) { - $this->_tempDir = \PhpOffice\PhpSpreadsheet\Shared\File::sysGetTempDir(); + $this->tempDirectory = \PhpOffice\PhpSpreadsheet\Shared\File::sysGetTempDir(); parent::__construct(null, OLE::ascToUcs('Root Entry'), OLE::OLE_PPS_TYPE_ROOT, null, null, null, $time_1st, $time_2nd, null, $raChild); } diff --git a/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php b/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php index 87d4fa5a..05693b3c 100644 --- a/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php @@ -61,10 +61,10 @@ class ExponentialBestFit extends BestFit public function getSlope($dp = 0) { if ($dp != 0) { - return round(exp($this->_slope), $dp); + return round(exp($this->slope), $dp); } - return exp($this->_slope); + return exp($this->slope); } /** diff --git a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php index cfac30b4..3004930c 100644 --- a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php @@ -101,14 +101,14 @@ class PolynomialBestFit extends BestFit { if ($dp != 0) { $coefficients = []; - foreach ($this->_slope as $coefficient) { + foreach ($this->slope as $coefficient) { $coefficients[] = round($coefficient, $dp); } return $coefficients; } - return $this->_slope; + return $this->slope; } public function getCoefficients($dp = 0) @@ -164,7 +164,7 @@ class PolynomialBestFit extends BestFit } $this->intersect = array_shift($coefficients); - $this->_slope = $coefficients; + $this->slope = $coefficients; $this->calculateGoodnessOfFit($x_sum, $y_sum, $xx_sum, $yy_sum, $xy_sum); foreach ($this->xValues as $xKey => $xValue) { @@ -188,10 +188,10 @@ class PolynomialBestFit extends BestFit $this->order = $order; $this->polynomialRegression($order, $yValues, $xValues); if (($this->getGoodnessOfFit() < 0.0) || ($this->getGoodnessOfFit() > 1.0)) { - $this->_error = true; + $this->error = true; } } else { - $this->_error = true; + $this->error = true; } } } diff --git a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php index 7b7ba007..eeb5ca90 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Cell; use PhpOffice\PhpSpreadsheet\RichText; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Worksheet; use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; class StringTable extends WriterPart @@ -20,45 +21,41 @@ class StringTable extends WriterPart * * @return string[] String table for worksheet */ - public function createStringTable($pSheet = null, $pExistingTable = null) + public function createStringTable(Worksheet $pSheet, $pExistingTable = null) { - if ($pSheet !== null) { - // Create string lookup table - $aStringTable = []; - $cellCollection = null; - $aFlippedStringTable = null; // For faster lookup + // Create string lookup table + $aStringTable = []; + $cellCollection = null; + $aFlippedStringTable = null; // For faster lookup - // Is an existing table given? - if (($pExistingTable !== null) && is_array($pExistingTable)) { - $aStringTable = $pExistingTable; - } - - // Fill index array - $aFlippedStringTable = $this->flipStringTable($aStringTable); - - // Loop through cells - foreach ($pSheet->getCoordinates() as $coordinate) { - $cell = $pSheet->getCell($coordinate); - $cellValue = $cell->getValue(); - if (!is_object($cellValue) && - ($cellValue !== null) && - $cellValue !== '' && - !isset($aFlippedStringTable[$cellValue]) && - ($cell->getDataType() == Cell\DataType::TYPE_STRING || $cell->getDataType() == Cell\DataType::TYPE_STRING2 || $cell->getDataType() == Cell\DataType::TYPE_NULL)) { - $aStringTable[] = $cellValue; - $aFlippedStringTable[$cellValue] = true; - } elseif ($cellValue instanceof RichText && - ($cellValue !== null) && - !isset($aFlippedStringTable[$cellValue->getHashCode()])) { - $aStringTable[] = $cellValue; - $aFlippedStringTable[$cellValue->getHashCode()] = true; - } - } - - return $aStringTable; + // Is an existing table given? + if (($pExistingTable !== null) && is_array($pExistingTable)) { + $aStringTable = $pExistingTable; } - throw new WriterException('Invalid Worksheet object passed.'); + // Fill index array + $aFlippedStringTable = $this->flipStringTable($aStringTable); + + // Loop through cells + foreach ($pSheet->getCoordinates() as $coordinate) { + $cell = $pSheet->getCell($coordinate); + $cellValue = $cell->getValue(); + if (!is_object($cellValue) && + ($cellValue !== null) && + $cellValue !== '' && + !isset($aFlippedStringTable[$cellValue]) && + ($cell->getDataType() == Cell\DataType::TYPE_STRING || $cell->getDataType() == Cell\DataType::TYPE_STRING2 || $cell->getDataType() == Cell\DataType::TYPE_NULL)) { + $aStringTable[] = $cellValue; + $aFlippedStringTable[$cellValue] = true; + } elseif ($cellValue instanceof RichText && + ($cellValue !== null) && + !isset($aFlippedStringTable[$cellValue->getHashCode()])) { + $aStringTable[] = $cellValue; + $aFlippedStringTable[$cellValue->getHashCode()] = true; + } + } + + return $aStringTable; } /** diff --git a/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php index 20e71d81..7698b4c0 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php @@ -10,7 +10,7 @@ use PHPUnit_Framework_TestCase; class ColumnCellIteratorTest extends PHPUnit_Framework_TestCase { public $mockWorksheet; - public $mockColumnCell; + public $mockCell; public function setUp() { diff --git a/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php index 7a040862..2b42138b 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php @@ -10,7 +10,7 @@ use PHPUnit_Framework_TestCase; class RowCellIteratorTest extends PHPUnit_Framework_TestCase { public $mockWorksheet; - public $mockRowCell; + public $mockCell; public function setUp() {