From 57c36e01d5c1a26f22e58f0c96dae02c834f9a54 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 5 Apr 2020 17:46:03 +0900 Subject: [PATCH 001/659] Replace Sami with phpDocumentor 3 Because Sami is deprecated and now raise errors. We lose API docs for multiple versions but we still have latest version with low maintenance cost. --- .sami.php | 24 ---------------------- .travis.yml | 15 ++++++-------- README.md | 2 +- docs/index.md | 2 +- docs/topics/recipes.md | 6 +++--- src/PhpSpreadsheet/Worksheet/PageSetup.php | 12 +++++------ 6 files changed, 17 insertions(+), 44 deletions(-) delete mode 100644 .sami.php diff --git a/.sami.php b/.sami.php deleted file mode 100644 index 9a2fca3534..0000000000 --- a/.sami.php +++ /dev/null @@ -1,24 +0,0 @@ -files() - ->name('*.php') - ->in($dir = __DIR__ . '/src'); -$versions = GitVersionCollection::create($dir) - ->addFromTags(function ($version) { - return preg_match('~^\d+\.\d+\.\d+$~', $version); - }) - ->add('master'); - -return new Sami($iterator, [ - 'title' => 'PhpSpreadsheet', - 'versions' => $versions, - 'build_dir' => __DIR__ . '/build/%version%', - 'cache_dir' => __DIR__ . '/cache/%version%', - 'remote_repository' => new GitHubRemoteRepository('PHPOffice/PhpSpreadsheet', dirname($dir)), -]); diff --git a/.travis.yml b/.travis.yml index 45d67ef894..82e25cee1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ php: cache: directories: - - cache - vendor - $HOME/.composer/cache @@ -41,19 +40,17 @@ jobs: - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover tests/coverage-clover.xml - - stage: API documentation - php: 7.2 + - stage: API documentations + if: tag is present + php: 7.4 before_script: - - curl -O https://get.sensiolabs.org/sami.phar + - curl -O https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.0.0-rc/phpDocumentor.phar script: - - git fetch origin master:master - - git fetch origin --tags - - php sami.phar update .sami.php - - echo '

If you are not automatically redirected, please go to the latest stable API documentation.

' > build/index.html + - php phpDocumentor.phar --directory src/ --target docs/api deploy: provider: pages skip-cleanup: true - local-dir: build + local-dir: docs/api github-token: $GITHUB_TOKEN on: all_branches: true diff --git a/README.md b/README.md index 71721220df..df683a1e1b 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ PhpSpreadsheet is a library written in pure PHP and providing a set of classes t ## Documentation -Read more about it, including install instructions, in the [official documentation](https://phpspreadsheet.readthedocs.io). Or check out the [API documentation](https://phpoffice.github.io/PhpSpreadsheet/master). +Read more about it, including install instructions, in the [official documentation](https://phpspreadsheet.readthedocs.io). Or check out the [API documentation](https://phpoffice.github.io/PhpSpreadsheet). Please ask your support questions on [StackOverflow](https://stackoverflow.com/questions/tagged/phpspreadsheet), or have a quick chat on [Gitter](https://gitter.im/PHPOffice/PhpSpreadsheet). diff --git a/docs/index.md b/docs/index.md index 7c2767922c..e7bb466004 100644 --- a/docs/index.md +++ b/docs/index.md @@ -89,7 +89,7 @@ architecture](./topics/architecture.md), [accessing cells](./topics/accessing-cells.md) and [reading and writing to files](./topics/reading-and-writing-to-file.md). -Or browse the [API documentation](https://phpoffice.github.io/PhpSpreadsheet/master). +Or browse the [API documentation](https://phpoffice.github.io/PhpSpreadsheet). # Credits diff --git a/docs/topics/recipes.md b/docs/topics/recipes.md index 712691086d..b0956b6e42 100644 --- a/docs/topics/recipes.md +++ b/docs/topics/recipes.md @@ -3,12 +3,12 @@ The following pages offer you some widely-used PhpSpreadsheet recipes. Please note that these do NOT offer complete documentation on specific PhpSpreadsheet API functions, but just a bump to get you started. If you -need specific API functions, please refer to the [API documentation](https://phpoffice.github.io/PhpSpreadsheet/master). +need specific API functions, please refer to the [API documentation](https://phpoffice.github.io/PhpSpreadsheet). For example, [setting a worksheet's page orientation and size ](#setting-a-worksheets-page-orientation-and-size) covers setting a page orientation to A4. Other paper formats, like US Letter, are not covered -in this document, but in the PhpSpreadsheet [API documentation](https://phpoffice.github.io/PhpSpreadsheet/master). +in this document, but in the PhpSpreadsheet [API documentation](https://phpoffice.github.io/PhpSpreadsheet). ## Setting a spreadsheet's metadata @@ -301,7 +301,7 @@ $spreadsheet->getActiveSheet()->getPageSetup() ``` Note that there are additional page settings available. Please refer to -the [API documentation](https://phpoffice.github.io/PhpSpreadsheet/master) for all possible options. +the [API documentation](https://phpoffice.github.io/PhpSpreadsheet) for all possible options. ### Page Setup: Scaling options diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index fa1810f3bd..38a0973639 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -180,7 +180,7 @@ class PageSetup * Print scaling. Valid values range from 10 to 400 * This setting is overridden when fitToWidth and/or fitToHeight are in use * - * @var int? + * @var null|int */ private $scale = 100; @@ -196,7 +196,7 @@ class PageSetup * Fit To Height * Number of vertical pages to fit on. * - * @var int? + * @var null|int */ private $fitToHeight = 1; @@ -204,7 +204,7 @@ class PageSetup * Fit To Width * Number of horizontal pages to fit on. * - * @var int? + * @var null|int */ private $fitToWidth = 1; @@ -308,7 +308,7 @@ public function setOrientation($pValue) /** * Get Scale. * - * @return int? + * @return null|int */ public function getScale() { @@ -370,7 +370,7 @@ public function setFitToPage($pValue) /** * Get Fit To Height. * - * @return int? + * @return null|int */ public function getFitToHeight() { @@ -398,7 +398,7 @@ public function setFitToHeight($pValue, $pUpdate = true) /** * Get Fit To Width. * - * @return int? + * @return null|int */ public function getFitToWidth() { From 87f71e1930b497b36e3b9b1522117dfa87096d2b Mon Sep 17 00:00:00 2001 From: Matthijs Alles Date: Tue, 4 Feb 2020 13:19:23 +0100 Subject: [PATCH 002/659] Support whitespaces in CSS style in Xlsx Indentation in the xml leaves spaces in style string even after replacing newlines. Replacing the spaces ensures no spaces in keys of the resulting style-array Fixes #1347 --- CHANGELOG.md | 15 +---------- src/PhpSpreadsheet/Reader/Xlsx.php | 7 +++++- tests/PhpSpreadsheetTests/Reader/XlsxTest.php | 25 +++++++++++++++++++ 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca24d6f0e5..593700a4b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,20 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org). ## [Unreleased] -### Added - -- Improved the ARABIC function to also hande short-hand roman numerals - -### Fixed - -- Fix ROUNDUP and ROUNDDOWN for floating-point rounding error [#1404](https://github.com/PHPOffice/PhpSpreadsheet/pull/1404) - -## [1.11.0] - 2020-03-02 - -### Added - -- Added support for the BASE function -- Added support for the ARABIC function - Conditionals - Extend Support for (NOT)CONTAINSBLANKS [#1278](https://github.com/PHPOffice/PhpSpreadsheet/pull/1278) ### Fixed @@ -33,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Fix active cell when freeze pane is used [#1323](https://github.com/PHPOffice/PhpSpreadsheet/pull/1323) - Fix XLSX file loading with autofilter containing '$' [#1326](https://github.com/PHPOffice/PhpSpreadsheet/pull/1326) - PHPDoc - Use `@return $this` for fluent methods [#1362](https://github.com/PHPOffice/PhpSpreadsheet/pull/1362) +- Fix loading styles from vmlDrawings when containing whitespace [#1347](https://github.com/PHPOffice/PhpSpreadsheet/issues/1347) ## [1.10.1] - 2019-12-02 diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 9b5b7db42d..428014c369 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -1828,7 +1828,7 @@ private static function dirAdd($base, $add) private static function toCSSArray($style) { - $style = trim(str_replace(["\r", "\n"], '', $style), ';'); + $style = self::stripWhiteSpaceFromStyleString($style); $temp = explode(';', $style); $style = []; @@ -1857,6 +1857,11 @@ private static function toCSSArray($style) return $style; } + public static function stripWhiteSpaceFromStyleString($string) + { + return trim(str_replace(["\r", "\n", ' '], '', $string), ';'); + } + private static function boolean($value) { if (is_object($value)) { diff --git a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php index 1180aacc33..f178e851bb 100644 --- a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php @@ -228,4 +228,29 @@ public function testLoadSaveWithEmptyDrawings() // Fake assert. The only thing we need is to ensure the file is loaded without exception $this->assertNotNull($excel); } + + /** + * Test if all whitespace is removed from a style definition string. + * This is needed to parse it into properties with the correct keys. + * + * @param $string + * @dataProvider providerStripsWhiteSpaceFromStyleString + */ + public function testStripsWhiteSpaceFromStyleString($string) + { + $string = Xlsx::stripWhiteSpaceFromStyleString($string); + $this->assertEquals(preg_match('/\s/', $string), 0); + } + + public function providerStripsWhiteSpaceFromStyleString() + { + return [ + ['position:absolute;margin-left:424.5pt;margin-top:169.5pt;width:67.5pt; + height:13.5pt;z-index:5;mso-wrap-style:tight'], + ['position:absolute;margin-left:424.5pt;margin-top:169.5pt;width:67.5pt; +height:13.5pt;z-index:5;mso-wrap-style:tight'], + ['position:absolute; margin-left:424.5pt; margin-top:169.5pt; width:67.5pt; + height:13.5pt;z-index:5;mso-wrap-style:tight'], + ]; + } } From 6e76d4e8b52b229f72fe0b7ee299628bfb8ed1af Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 26 Apr 2020 10:24:14 +0900 Subject: [PATCH 003/659] Cleanup CHANGELOG accidental changes --- CHANGELOG.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 593700a4b4..3e65a1a88c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org). ## [Unreleased] +### Added + +- Improved the ARABIC function to also hande short-hand roman numerals + +### Fixed + +- Fix ROUNDUP and ROUNDDOWN for floating-point rounding error [#1404](https://github.com/PHPOffice/PhpSpreadsheet/pull/1404) +- Fix loading styles from vmlDrawings when containing whitespace [#1347](https://github.com/PHPOffice/PhpSpreadsheet/issues/1347) + +## [1.11.0] - 2020-03-02 + +### Added + +- Added support for the BASE function +- Added support for the ARABIC function - Conditionals - Extend Support for (NOT)CONTAINSBLANKS [#1278](https://github.com/PHPOffice/PhpSpreadsheet/pull/1278) ### Fixed @@ -19,7 +34,6 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Fix active cell when freeze pane is used [#1323](https://github.com/PHPOffice/PhpSpreadsheet/pull/1323) - Fix XLSX file loading with autofilter containing '$' [#1326](https://github.com/PHPOffice/PhpSpreadsheet/pull/1326) - PHPDoc - Use `@return $this` for fluent methods [#1362](https://github.com/PHPOffice/PhpSpreadsheet/pull/1362) -- Fix loading styles from vmlDrawings when containing whitespace [#1347](https://github.com/PHPOffice/PhpSpreadsheet/issues/1347) ## [1.10.1] - 2019-12-02 From 3dcc5ca7533180cba95ede7d2db5f9ce008ad082 Mon Sep 17 00:00:00 2001 From: Tim Gavryutenko <35343569+TimGa@users.noreply.github.com> Date: Sun, 26 Apr 2020 05:00:43 +0300 Subject: [PATCH 004/659] Fix removing last row incorrect behavior `$highestRow = $this->getHighestDataRow();` was calculated after `$this->getCellCollection()->removeRow($pRow + $r);` - this is the root reason for incorrect rows removal because removing last row will change '$this->getHighestDataRow()' value, but removing row from the middle will not change it. So, removing last row causes incorrect `$highestRow` value that is used for wiping out empty rows from the bottom of the table: ```php for ($r = 0; $r < $pNumRows; ++$r) { $this->getCellCollection()->removeRow($highestRow); --$highestRow; } ``` To prevent this incorrect behavior I've moved highest row calculation before row removal. But this still doesn't solve another problem when trying remove non existing rows: in this case the code above will remove `$pNumRows` rows from below of the table, e.g. if `$highestRow=4` and `$pNumRows=6`, than rows 4, 3, 2, 1, 0, -1 will be deleted. Obviously, this is not good, that is why I've added `$removedRowsCounter` to fix this issue. And finally, moved Exception to early if statement to get away from unnecessary 'if-else'. Fixes #1364 Closes #1365 --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Worksheet/Worksheet.php | 27 ++-- .../Worksheet/WorksheetTest.php | 132 ++++++++++++++++++ 3 files changed, 149 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e65a1a88c..391115a6c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Fix ROUNDUP and ROUNDDOWN for floating-point rounding error [#1404](https://github.com/PHPOffice/PhpSpreadsheet/pull/1404) - Fix loading styles from vmlDrawings when containing whitespace [#1347](https://github.com/PHPOffice/PhpSpreadsheet/issues/1347) +- Fix incorrect behavior when removing last row [#1365](https://github.com/PHPOffice/PhpSpreadsheet/pull/1365) ## [1.11.0] - 2020-03-02 diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index f3a5b4da78..9a3f96471d 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -2114,20 +2114,25 @@ public function insertNewColumnBeforeByIndex($beforeColumnIndex, $pNumCols = 1) */ public function removeRow($pRow, $pNumRows = 1) { - if ($pRow >= 1) { - for ($r = 0; $r < $pNumRows; ++$r) { + if ($pRow < 1) { + throw new Exception('Rows to be deleted should at least start from row 1.'); + } + + $highestRow = $this->getHighestDataRow(); + $removedRowsCounter = 0; + + for ($r = 0; $r < $pNumRows; ++$r) { + if ($pRow + $r <= $highestRow) { $this->getCellCollection()->removeRow($pRow + $r); + ++$removedRowsCounter; } + } - $highestRow = $this->getHighestDataRow(); - $objReferenceHelper = ReferenceHelper::getInstance(); - $objReferenceHelper->insertNewBefore('A' . ($pRow + $pNumRows), 0, -$pNumRows, $this); - for ($r = 0; $r < $pNumRows; ++$r) { - $this->getCellCollection()->removeRow($highestRow); - --$highestRow; - } - } else { - throw new Exception('Rows to be deleted should at least start from row 1.'); + $objReferenceHelper = ReferenceHelper::getInstance(); + $objReferenceHelper->insertNewBefore('A' . ($pRow + $pNumRows), 0, -$pNumRows, $this); + for ($r = 0; $r < $removedRowsCounter; ++$r) { + $this->getCellCollection()->removeRow($highestRow); + --$highestRow; } return $this; diff --git a/tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php b/tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php index e1b4738b81..d1e19df429 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php @@ -272,4 +272,136 @@ public function testRemoveColumn( self::assertSame($expectedHighestColumn, $worksheet->getHighestColumn()); self::assertSame($expectedData, $worksheet->toArray()); } + + public function removeRowsProvider() + { + return [ + 'Remove all rows except first one' => [ + [ + ['A1', 'B1', 'C1'], + ['A2', 'B2', 'C2'], + ['A3', 'B3', 'C3'], + ['A4', 'B4', 'C4'], + ], + 2, + 3, + [ + ['A1', 'B1', 'C1'], + ], + 1, + ], + 'Remove all rows except last one' => [ + [ + ['A1', 'B1', 'C1'], + ['A2', 'B2', 'C2'], + ['A3', 'B3', 'C3'], + ['A4', 'B4', 'C4'], + ], + 1, + 3, + [ + ['A4', 'B4', 'C4'], + ], + 1, + ], + 'Remove last row' => [ + [ + ['A1', 'B1', 'C1'], + ['A2', 'B2', 'C2'], + ['A3', 'B3', 'C3'], + ['A4', 'B4', 'C4'], + ], + 4, + 1, + [ + ['A1', 'B1', 'C1'], + ['A2', 'B2', 'C2'], + ['A3', 'B3', 'C3'], + ], + 3, + ], + 'Remove first row' => [ + [ + ['A1', 'B1', 'C1'], + ['A2', 'B2', 'C2'], + ['A3', 'B3', 'C3'], + ['A4', 'B4', 'C4'], + ], + 1, + 1, + [ + ['A2', 'B2', 'C2'], + ['A3', 'B3', 'C3'], + ['A4', 'B4', 'C4'], + ], + 3, + ], + 'Remove all rows except first and last' => [ + [ + ['A1', 'B1', 'C1'], + ['A2', 'B2', 'C2'], + ['A3', 'B3', 'C3'], + ['A4', 'B4', 'C4'], + ], + 2, + 2, + [ + ['A1', 'B1', 'C1'], + ['A4', 'B4', 'C4'], + ], + 2, + ], + 'Remove non existing rows' => [ + [ + ['A1', 'B1', 'C1'], + ['A2', 'B2', 'C2'], + ['A3', 'B3', 'C3'], + ['A4', 'B4', 'C4'], + ], + 2, + 10, + [ + ['A1', 'B1', 'C1'], + ], + 1, + ], + 'Remove only non existing rows' => [ + [ + ['A1', 'B1', 'C1'], + ['A2', 'B2', 'C2'], + ['A3', 'B3', 'C3'], + ['A4', 'B4', 'C4'], + ], + 5, + 10, + [ + ['A1', 'B1', 'C1'], + ['A2', 'B2', 'C2'], + ['A3', 'B3', 'C3'], + ['A4', 'B4', 'C4'], + ], + 4, + ], + ]; + } + + /** + * @dataProvider removeRowsProvider + */ + public function testRemoveRows( + array $initialData, + int $rowToRemove, + int $rowsQtyToRemove, + array $expectedData, + int $expectedHighestRow + ) { + $workbook = new Spreadsheet(); + $worksheet = $workbook->getActiveSheet(); + $worksheet->fromArray($initialData); + + $worksheet->removeRow($rowToRemove, $rowsQtyToRemove); + + self::assertSame($expectedData, $worksheet->toArray()); + self::assertSame($expectedHighestRow, $worksheet->getHighestRow()); + } } From 6788869a409735a8d057c24e280ddba0d0d27f32 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 26 Apr 2020 05:09:56 -0700 Subject: [PATCH 005/659] =?UTF-8?q?Fix=20typo:=20occured=20=E2=86=92=20occ?= =?UTF-8?q?urred=20(#1435)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/PhpSpreadsheet/Calculation/Calculation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 344bc32316..f428c9b4cb 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -3737,7 +3737,7 @@ private function _parseFormula($formula, Cell $pCell = null) } elseif (isset(self::$operators[$opCharacter]) && !$expectingOperator) { return $this->raiseFormulaError("Formula Error: Unexpected operator '$opCharacter'"); } else { // I don't even want to know what you did to get here - return $this->raiseFormulaError('Formula Error: An unexpected error occured'); + return $this->raiseFormulaError('Formula Error: An unexpected error occurred'); } // Test for end of formula string if ($index == strlen($formula)) { From c4895b94687cd79b91a7d026ea1aed1b061385fe Mon Sep 17 00:00:00 2001 From: Owen Leibman Date: Fri, 17 Jan 2020 17:52:16 -0800 Subject: [PATCH 006/659] MATCH with a static array should return the position of the found value based on the values submitted. Returns #N/A, unless the element searched for is at the end of the array. The problem is in Calculation.php line 4231: if (!is_array($functionCall)) { foreach ($args as &$arg) { $arg = Functions::flattenSingleValue($arg); } unset($arg); } I believe this code is intended to handle functions where PhpSpreadsheet just passes the call on to PHP without implementing the code on its own, e.g. for atan or acos. In the bug report, the following code fails: $flat_rate = "=MATCH(6,{4,5,6,2}, 0)"; $sheet->getCell('A1')->setValue($flat_rate); The expected value is 3, but the actual result is "#N/A". The reason for this result is that the parser replaces the braces with calls to the MKMATRIX internal function, whose value for functioncall was: 'self::MKMATRIX'. Since this isn't an array, the flattening code is executed, and the unintended result occurs. The fix is to change the definition for functioncall in that case to [__CLASS__, 'mkMatrix'], avoiding the flattening. However, there is also another part to this bug. The flattening should be returning the first entry in the array, but is in fact returning the last. This explains why the bug report specified "unless ... end of the array". I confirmed that Excel does use the first item in the array rather than the last, e.g. =atan({1,2,3}) entered into a cell will return atan(1), not atan(3). The problem here is that flattenSingleValue, which says in its comments that it is supposed to be returning the first item, uses array_pop rather than array_shift. I have changed that as well. The same mistake was also present in Cell.php function getCalculatedValue. The correct behavior can be verified by entering =minverse({-2.5,1.5;2,-1}) into an Excel cell' Excel flattens the result ({2,3;4,5}) to 2, and so should PhpSpreadsheet. Fixes #1271 Closes #1332 --- CHANGELOG.md | 1 + .../Calculation/Calculation.php | 2 +- src/PhpSpreadsheet/Calculation/Functions.php | 2 +- src/PhpSpreadsheet/Cell/Cell.php | 2 +- .../Calculation/FormulaAsStringTest.php | 46 +++++++++++++++++++ tests/data/Calculation/FunctionsAsString.php | 24 ++++++++++ 6 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/Calculation/FormulaAsStringTest.php create mode 100644 tests/data/Calculation/FunctionsAsString.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 391115a6c0..d4fae5c43e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Fix ROUNDUP and ROUNDDOWN for floating-point rounding error [#1404](https://github.com/PHPOffice/PhpSpreadsheet/pull/1404) - Fix loading styles from vmlDrawings when containing whitespace [#1347](https://github.com/PHPOffice/PhpSpreadsheet/issues/1347) - Fix incorrect behavior when removing last row [#1365](https://github.com/PHPOffice/PhpSpreadsheet/pull/1365) +- MATCH with a static array should return the position of the found value based on the values submitted [#1332](https://github.com/PHPOffice/PhpSpreadsheet/pull/1332) ## [1.11.0] - 2020-03-02 diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index f428c9b4cb..ae86a963a0 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -2235,7 +2235,7 @@ class Calculation private static $controlFunctions = [ 'MKMATRIX' => [ 'argumentCount' => '*', - 'functionCall' => 'self::mkMatrix', + 'functionCall' => [__CLASS__, 'mkMatrix'], ], ]; diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index bb2170be1f..1862b008a1 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -646,7 +646,7 @@ public static function flattenArrayIndexed($array) public static function flattenSingleValue($value = '') { while (is_array($value)) { - $value = array_pop($value); + $value = array_shift($value); } return $value; diff --git a/src/PhpSpreadsheet/Cell/Cell.php b/src/PhpSpreadsheet/Cell/Cell.php index bae8261ef2..e618436ed2 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -266,7 +266,7 @@ public function getCalculatedValue($resetLog = true) // We don't yet handle array returns if (is_array($result)) { while (is_array($result)) { - $result = array_pop($result); + $result = array_shift($result); } } } catch (Exception $ex) { diff --git a/tests/PhpSpreadsheetTests/Calculation/FormulaAsStringTest.php b/tests/PhpSpreadsheetTests/Calculation/FormulaAsStringTest.php new file mode 100644 index 0000000000..c51e520a95 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/FormulaAsStringTest.php @@ -0,0 +1,46 @@ +getActiveSheet(); + $workSheet->setCellValue('A1', 10); + $workSheet->setCellValue('A2', 20); + $workSheet->setCellValue('A3', 30); + $workSheet->setCellValue('A4', 40); + $spreadsheet->addNamedRange(new \PhpOffice\PhpSpreadsheet\NamedRange('namedCell', $workSheet, 'A4')); + $workSheet->setCellValue('B1', 'uPPER'); + $workSheet->setCellValue('B2', '=TRUE()'); + $workSheet->setCellValue('B3', '=FALSE()'); + + $ws2 = $spreadsheet->createSheet(); + $ws2->setCellValue('A1', 100); + $ws2->setCellValue('A2', 200); + $ws2->setTitle('Sheet2'); + $spreadsheet->addNamedRange(new \PhpOffice\PhpSpreadsheet\NamedRange('A2B', $ws2, 'A2')); + + $spreadsheet->setActiveSheetIndex(0); + $cell2 = $workSheet->getCell('D1'); + $cell2->setValue($formula); + $result = $cell2->getCalculatedValue(); + self::assertEquals($expectedResult, $result); + } + + public function providerFunctionsAsString() + { + return require 'data/Calculation/FunctionsAsString.php'; + } +} diff --git a/tests/data/Calculation/FunctionsAsString.php b/tests/data/Calculation/FunctionsAsString.php new file mode 100644 index 0000000000..8595347239 --- /dev/null +++ b/tests/data/Calculation/FunctionsAsString.php @@ -0,0 +1,24 @@ + Date: Thu, 6 Feb 2020 08:53:25 +0100 Subject: [PATCH 007/659] Added support for the FLOOR.MATH and FLOOR.PRECISE functions --- CHANGELOG.md | 1 + .../Calculation/Calculation.php | 10 +++ src/PhpSpreadsheet/Calculation/MathTrig.php | 74 +++++++++++++++ .../Calculation/functionlist.txt | 2 + .../Functions/MathTrig/FloorMathTest.php | 31 +++++++ .../Functions/MathTrig/FloorPreciseTest.php | 31 +++++++ tests/data/Calculation/MathTrig/FLOORMATH.php | 89 +++++++++++++++++++ .../Calculation/MathTrig/FLOORPRECISE.php | 57 ++++++++++++ 8 files changed, 295 insertions(+) create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php create mode 100644 tests/data/Calculation/MathTrig/FLOORMATH.php create mode 100644 tests/data/Calculation/MathTrig/FLOORPRECISE.php diff --git a/CHANGELOG.md b/CHANGELOG.md index d4fae5c43e..6f4bae1ab2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Added - Improved the ARABIC function to also hande short-hand roman numerals +- Added support for the FLOOR.MATH and FLOOR.PRECISE functions [#1351](https://github.com/PHPOffice/PhpSpreadsheet/pull/1351) ### Fixed diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index ae86a963a0..69f72033a3 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -914,6 +914,16 @@ class Calculation 'functionCall' => [MathTrig::class, 'FLOOR'], 'argumentCount' => '2', ], + 'FLOOR.MATH' => [ + 'category' => Category::CATEGORY_MATH_AND_TRIG, + 'functionCall' => [MathTrig::class, 'FLOORMATH'], + 'argumentCount' => '3', + ], + 'FLOOR.PRECISE' => [ + 'category' => Category::CATEGORY_MATH_AND_TRIG, + 'functionCall' => [MathTrig::class, 'FLOORPRECISE'], + 'argumentCount' => '2', + ], 'FORECAST' => [ 'category' => Category::CATEGORY_STATISTICAL, 'functionCall' => [Statistical::class, 'FORECAST'], diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index 73403686b2..590ad99b86 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -438,6 +438,80 @@ public static function FLOOR($number, $significance = null) return Functions::VALUE(); } + /** + * FLOOR.MATH. + * + * Round a number down to the nearest integer or to the nearest multiple of significance. + * + * Excel Function: + * FLOOR.MATH(number[,significance[,mode]]) + * + * @category Mathematical and Trigonometric Functions + * + * @param float $number Number to round + * @param float $significance Significance + * @param int $mode direction to round negative numbers + * + * @return float|string Rounded Number, or a string containing an error + */ + public static function FLOORMATH($number, $significance = null, $mode = 0) + { + $number = Functions::flattenSingleValue($number); + $significance = Functions::flattenSingleValue($significance); + $mode = Functions::flattenSingleValue($mode); + + if (is_numeric($number) && $significance === null) { + $significance = $number / abs($number); + } + + if (is_numeric($number) && is_numeric($significance) && is_numeric($mode)) { + if ($significance == 0.0) { + return Functions::DIV0(); + } elseif ($number == 0.0) { + return 0.0; + } elseif (self::SIGN($significance) == -1 || (self::SIGN($number) == -1 && !empty($mode))) { + return ceil($number / $significance) * $significance; + } + + return floor($number / $significance) * $significance; + } + + return Functions::VALUE(); + } + + /** + * FLOOR.PRECISE. + * + * Rounds number down, toward zero, to the nearest multiple of significance. + * + * Excel Function: + * FLOOR.PRECISE(number[,significance]) + * + * @category Mathematical and Trigonometric Functions + * + * @param float $number Number to round + * @param float $significance Significance + * + * @return float|string Rounded Number, or a string containing an error + */ + public static function FLOORPRECISE($number, $significance = 1) + { + $number = Functions::flattenSingleValue($number); + $significance = Functions::flattenSingleValue($significance); + + if ((is_numeric($number)) && (is_numeric($significance))) { + if ($significance == 0.0) { + return Functions::DIV0(); + } elseif ($number == 0.0) { + return 0.0; + } + + return floor($number / abs($significance)) * abs($significance); + } + + return Functions::VALUE(); + } + private static function evaluateGCD($a, $b) { return $b ? self::evaluateGCD($b, $a % $b) : $a; diff --git a/src/PhpSpreadsheet/Calculation/functionlist.txt b/src/PhpSpreadsheet/Calculation/functionlist.txt index 7776e6ead4..77fd4ee0e4 100644 --- a/src/PhpSpreadsheet/Calculation/functionlist.txt +++ b/src/PhpSpreadsheet/Calculation/functionlist.txt @@ -139,6 +139,8 @@ FISHER FISHERINV FIXED FLOOR +FLOOR.MATH +FLOOR.PRECISE FORECAST FREQUENCY FTEST diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php new file mode 100644 index 0000000000..0e693e80e9 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php @@ -0,0 +1,31 @@ +assertEquals($expectedResult, $result, '', 1E-12); + } + + public function providerFLOORMATH() + { + return require 'data/Calculation/MathTrig/FLOORMATH.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php new file mode 100644 index 0000000000..616cb43bb3 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php @@ -0,0 +1,31 @@ +assertEquals($expectedResult, $result, '', 1E-12); + } + + public function providerFLOORPRECISE() + { + return require 'data/Calculation/MathTrig/FLOORPRECISE.php'; + } +} diff --git a/tests/data/Calculation/MathTrig/FLOORMATH.php b/tests/data/Calculation/MathTrig/FLOORMATH.php new file mode 100644 index 0000000000..691b5245b8 --- /dev/null +++ b/tests/data/Calculation/MathTrig/FLOORMATH.php @@ -0,0 +1,89 @@ + Date: Fri, 14 Feb 2020 14:32:41 +0100 Subject: [PATCH 008/659] Load with styles should not default to black fill color Fixes #1353 Closes #1361 --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Reader/Xlsx.php | 2 -- tests/PhpSpreadsheetTests/Reader/XlsxTest.php | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f4bae1ab2..a25c9c519f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Fix loading styles from vmlDrawings when containing whitespace [#1347](https://github.com/PHPOffice/PhpSpreadsheet/issues/1347) - Fix incorrect behavior when removing last row [#1365](https://github.com/PHPOffice/PhpSpreadsheet/pull/1365) - MATCH with a static array should return the position of the found value based on the values submitted [#1332](https://github.com/PHPOffice/PhpSpreadsheet/pull/1332) +- Fix Xlsx Reader's handling of undefined fill color [#1353](https://github.com/PHPOffice/PhpSpreadsheet/pull/1353) ## [1.11.0] - 2020-03-02 diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 428014c369..566e9fbbf0 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -1620,8 +1620,6 @@ private static function readStyle(Style $docStyle, $style) $docStyle->getFill()->setFillType($patternType); if ($style->fill->patternFill->fgColor) { $docStyle->getFill()->getStartColor()->setARGB(self::readColor($style->fill->patternFill->fgColor, true)); - } else { - $docStyle->getFill()->getStartColor()->setARGB('FF000000'); } if ($style->fill->patternFill->bgColor) { $docStyle->getFill()->getEndColor()->setARGB(self::readColor($style->fill->patternFill->bgColor, true)); diff --git a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php index f178e851bb..246b5a4733 100644 --- a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php @@ -83,8 +83,8 @@ public function testLoadXlsxWithStyles() { $expectedColours = [ 1 => ['A' => 'C00000', 'C' => 'FF0000', 'E' => 'FFC000'], - 3 => ['A' => '7030A0', 'C' => '000000', 'E' => 'FFFF00'], - 5 => ['A' => '002060', 'C' => '000000', 'E' => '92D050'], + 3 => ['A' => '7030A0', 'C' => 'FFFFFF', 'E' => 'FFFF00'], + 5 => ['A' => '002060', 'C' => 'FFFFFF', 'E' => '92D050'], 7 => ['A' => '0070C0', 'C' => '00B0F0', 'E' => '00B050'], ]; From f9f9f4cacfe1398f3ab0f1b709e71bbea044b6d2 Mon Sep 17 00:00:00 2001 From: n-longcape Date: Thu, 12 Mar 2020 12:37:07 +0900 Subject: [PATCH 009/659] Fix ROUNDUP and ROUNDDOWN for negative number Closes #1417 --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Calculation/MathTrig.php | 8 ++------ tests/data/Calculation/MathTrig/ROUNDDOWN.php | 10 ++++++++++ tests/data/Calculation/MathTrig/ROUNDUP.php | 10 ++++++++++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a25c9c519f..1fa12b3d15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Fixed - Fix ROUNDUP and ROUNDDOWN for floating-point rounding error [#1404](https://github.com/PHPOffice/PhpSpreadsheet/pull/1404) +- Fix ROUNDUP and ROUNDDOWN for negative number [#1417](https://github.com/PHPOffice/PhpSpreadsheet/pull/1417) - Fix loading styles from vmlDrawings when containing whitespace [#1347](https://github.com/PHPOffice/PhpSpreadsheet/issues/1347) - Fix incorrect behavior when removing last row [#1365](https://github.com/PHPOffice/PhpSpreadsheet/pull/1365) - MATCH with a static array should return the position of the found value based on the values submitted [#1332](https://github.com/PHPOffice/PhpSpreadsheet/pull/1332) diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index 590ad99b86..f94c8fcc5e 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -1139,9 +1139,7 @@ public static function ROUNDUP($number, $digits) if ((is_numeric($number)) && (is_numeric($digits))) { if ($number < 0.0) { - $significance = pow(10, (int) $digits); - - return floor($number * $significance) / $significance; + return round($number - 0.5 * pow(0.1, $digits), $digits, PHP_ROUND_HALF_DOWN); } return round($number + 0.5 * pow(0.1, $digits), $digits, PHP_ROUND_HALF_DOWN); @@ -1167,9 +1165,7 @@ public static function ROUNDDOWN($number, $digits) if ((is_numeric($number)) && (is_numeric($digits))) { if ($number < 0.0) { - $significance = pow(10, (int) $digits); - - return ceil($number * $significance) / $significance; + return round($number + 0.5 * pow(0.1, $digits), $digits, PHP_ROUND_HALF_UP); } return round($number - 0.5 * pow(0.1, $digits), $digits, PHP_ROUND_HALF_UP); diff --git a/tests/data/Calculation/MathTrig/ROUNDDOWN.php b/tests/data/Calculation/MathTrig/ROUNDDOWN.php index 499c5a5bdb..b1b3ac71f8 100644 --- a/tests/data/Calculation/MathTrig/ROUNDDOWN.php +++ b/tests/data/Calculation/MathTrig/ROUNDDOWN.php @@ -71,6 +71,16 @@ 2.26 + 2.94, 2, ], + [ + -4.44, + -4.4400, + 2, + ], + [ + -5.20, + -2.26 - 2.94, + 2, + ], [ '#VALUE!', 'ABC', diff --git a/tests/data/Calculation/MathTrig/ROUNDUP.php b/tests/data/Calculation/MathTrig/ROUNDUP.php index c1782b2b07..f522e83f6f 100644 --- a/tests/data/Calculation/MathTrig/ROUNDUP.php +++ b/tests/data/Calculation/MathTrig/ROUNDUP.php @@ -66,11 +66,21 @@ 4.4400, 2, ], + [ + -4.44, + -4.4400, + 2, + ], [ 5.20, 2.26 + 2.94, 2, ], + [ + -5.20, + -2.26 - 2.94, + 2, + ], [ '#VALUE!', 'ABC', From f79611d6dc1f6b7e8e30b738fc371b392001dbfd Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 27 Apr 2020 17:12:48 +0900 Subject: [PATCH 010/659] 1.12.0 --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fa12b3d15..897a8e5133 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com) and this project adheres to [Semantic Versioning](https://semver.org). -## [Unreleased] +## [1.12.0] - 2020-04-27 ### Added -- Improved the ARABIC function to also hande short-hand roman numerals +- Improved the ARABIC function to also handle short-hand roman numerals - Added support for the FLOOR.MATH and FLOOR.PRECISE functions [#1351](https://github.com/PHPOffice/PhpSpreadsheet/pull/1351) ### Fixed From b1a78634856516a6b92f3387479b2b4bc519da15 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 27 Apr 2020 18:26:51 +0900 Subject: [PATCH 011/659] Force doc deploy just for this once --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 82e25cee1a..2a0d7cf686 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,6 @@ jobs: - php ocular.phar code-coverage:upload --format=php-clover tests/coverage-clover.xml - stage: API documentations - if: tag is present php: 7.4 before_script: - curl -O https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.0.0-rc/phpDocumentor.phar @@ -52,6 +51,3 @@ jobs: skip-cleanup: true local-dir: docs/api github-token: $GITHUB_TOKEN - on: - all_branches: true - condition: $TRAVIS_BRANCH =~ ^master$ From 4e6d6838e02bf0f5e8253ec53ea06d7431411ad4 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 27 Apr 2020 18:29:05 +0900 Subject: [PATCH 012/659] Deploy doc only when tags on master --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2a0d7cf686..a9b8c84aff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,6 +41,7 @@ jobs: - php ocular.phar code-coverage:upload --format=php-clover tests/coverage-clover.xml - stage: API documentations + if: tag is present AND branch = master php: 7.4 before_script: - curl -O https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.0.0-rc/phpDocumentor.phar From 8ea48ecb40eb70bff9e771b1a1ced72299f3de14 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 27 Apr 2020 18:33:44 +0900 Subject: [PATCH 013/659] Run code style and coverage with PHP 7.4 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a9b8c84aff..d357904a1f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,13 +24,13 @@ jobs: include: - stage: Code style - php: 7.2 + php: 7.4 script: - ./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run - ./vendor/bin/phpcs --report-width=200 samples/ src/ tests/ --ignore=samples/Header.php --standard=PSR2 -n - stage: Coverage - php: 7.2 + php: 7.4 script: - pecl install pcov - composer require pcov/clobber --dev From 03c587fe0b3164ffeb850e82936fad78ebbb980a Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 27 Apr 2020 18:42:32 +0900 Subject: [PATCH 014/659] Drop PHP 7.1 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 --- .travis.yml | 1 - CHANGELOG.md | 6 ++++++ composer.json | 4 ++-- composer.lock | 4 ++-- docs/index.md | 5 +++-- samples/index.php | 2 +- src/PhpSpreadsheet/Settings.php | 4 ---- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index d357904a1f..f4abffd1e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: php dist: bionic php: - - 7.1 - 7.2 - 7.3 - 7.4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 897a8e5133..0f5c002c31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com) and this project adheres to [Semantic Versioning](https://semver.org). +## [Unreleased] + +### Changed + +- Drop support for PHP 7.1, according to https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support + ## [1.12.0] - 2020-04-27 ### Added diff --git a/composer.json b/composer.json index cfff1cb1ab..52a6466ce7 100644 --- a/composer.json +++ b/composer.json @@ -35,11 +35,11 @@ "php-cs-fixer fix --ansi" ], "versions": [ - "phpcs --report-width=200 samples/ src/ tests/ --ignore=samples/Header.php --standard=PHPCompatibility --runtime-set testVersion 7.1- -n" + "phpcs --report-width=200 samples/ src/ tests/ --ignore=samples/Header.php --standard=PHPCompatibility --runtime-set testVersion 7.2- -n" ] }, "require": { - "php": "^7.1", + "php": "^7.2", "ext-ctype": "*", "ext-dom": "*", "ext-gd": "*", diff --git a/composer.lock b/composer.lock index 9299919f5d..182d58322a 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": "0fd32acfbb0d21f168f495840ffc8d7e", + "content-hash": "83ef345a065e12287e792d660b49619b", "packages": [ { "name": "markbaker/complex", @@ -3484,7 +3484,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.1", + "php": "^7.2", "ext-ctype": "*", "ext-dom": "*", "ext-gd": "*", diff --git a/docs/index.md b/docs/index.md index e7bb466004..808fb75957 100644 --- a/docs/index.md +++ b/docs/index.md @@ -25,13 +25,14 @@ spreadsheet file formats, like Excel and LibreOffice Calc. ## Software requirements -PHP version 7.1 or newer to develop using PhpSpreadsheet. Other requirements, such as PHP extensions, are enforced by +PHP version 7.2 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. ### PHP version support -Support for PHP versions will only be maintained for a period of six months beyond the end-of-life of that PHP version +Support for PHP versions will only be maintained for a period of six months beyond the +[end of life of that PHP version](https://www.php.net/eol.php). ## Installation diff --git a/samples/index.php b/samples/index.php index 598caef43d..b0b7543482 100644 --- a/samples/index.php +++ b/samples/index.php @@ -3,7 +3,7 @@ require_once 'Header.php'; $requirements = [ - 'PHP 7.1.0' => version_compare(PHP_VERSION, '7.1.0', '>='), + 'PHP 7.2.0' => version_compare(PHP_VERSION, '7.2.0', '>='), 'PHP extension XML' => extension_loaded('xml'), 'PHP extension xmlwriter' => extension_loaded('xmlwriter'), 'PHP extension mbstring' => extension_loaded('mbstring'), diff --git a/src/PhpSpreadsheet/Settings.php b/src/PhpSpreadsheet/Settings.php index 03fa6ac2cb..d9d74cb06c 100644 --- a/src/PhpSpreadsheet/Settings.php +++ b/src/PhpSpreadsheet/Settings.php @@ -28,8 +28,6 @@ class Settings * 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 - * 7.1 < 7.1.13 - * 7.0 < 7.0.27 * then you may need to disable this check to prevent unwanted behaviour in other threads * SECURITY WARNING: Changing this flag is not recommended. * @@ -119,8 +117,6 @@ public static function getLibXmlLoaderOptions() * 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 - * 7.1 < 7.1.13 - * 7.0 < 7.0.27 * 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. * From 973011921d63c2a004cd355a4999937443d169c4 Mon Sep 17 00:00:00 2001 From: Collie-IT <40590185+Collie-IT@users.noreply.github.com> Date: Mon, 27 Apr 2020 12:01:36 +0200 Subject: [PATCH 015/659] Add Missing Operator NOTBETWEEN (#1390) --- src/PhpSpreadsheet/Style/Conditional.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PhpSpreadsheet/Style/Conditional.php b/src/PhpSpreadsheet/Style/Conditional.php index ec8c858b03..2b096a34aa 100644 --- a/src/PhpSpreadsheet/Style/Conditional.php +++ b/src/PhpSpreadsheet/Style/Conditional.php @@ -27,6 +27,7 @@ class Conditional implements IComparable const OPERATOR_CONTAINSTEXT = 'containsText'; const OPERATOR_NOTCONTAINS = 'notContains'; const OPERATOR_BETWEEN = 'between'; + const OPERATOR_NOTBETWEEN = 'notBetween'; /** * Condition type. From a7986520f999c4e4dad17c59ae07b8549079456a Mon Sep 17 00:00:00 2001 From: Gennadiy Litvinyuk Date: Mon, 27 Apr 2020 12:02:49 +0200 Subject: [PATCH 016/659] Removed unnecessary object creation. (#1430) --- samples/Basic/01_Simple.php | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/Basic/01_Simple.php b/samples/Basic/01_Simple.php index 89aca6d056..69309794c0 100644 --- a/samples/Basic/01_Simple.php +++ b/samples/Basic/01_Simple.php @@ -4,7 +4,6 @@ require __DIR__ . '/../Header.php'; -$spreadsheet = new Spreadsheet(); $helper->log('Create new Spreadsheet object'); $spreadsheet = new Spreadsheet(); From f1a019e49281891752f07d950e230678094bfea2 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 27 Apr 2020 19:28:36 +0900 Subject: [PATCH 017/659] Upgrad PHP deps --- composer.json | 4 +- composer.lock | 741 ++++++++++-------- .../Calculation/CalculationTest.php | 4 +- .../Calculation/FinancialTest.php | 72 +- .../Functions/DateTime/DateDifTest.php | 4 +- .../Functions/DateTime/DateTest.php | 7 +- .../Functions/DateTime/DateValueTest.php | 7 +- .../Functions/DateTime/DayTest.php | 6 +- .../Functions/DateTime/Days360Test.php | 4 +- .../Functions/DateTime/DaysTest.php | 4 +- .../Functions/DateTime/EDateTest.php | 7 +- .../Functions/DateTime/EoMonthTest.php | 7 +- .../Functions/DateTime/HourTest.php | 4 +- .../Functions/DateTime/IsoWeekNumTest.php | 4 +- .../Functions/DateTime/MinuteTest.php | 4 +- .../Functions/DateTime/MonthTest.php | 4 +- .../Functions/DateTime/NetworkDaysTest.php | 4 +- .../Functions/DateTime/SecondTest.php | 4 +- .../Functions/DateTime/TimeTest.php | 6 +- .../Functions/DateTime/TimeValueTest.php | 7 +- .../Functions/DateTime/WeekDayTest.php | 4 +- .../Functions/DateTime/WeekNumTest.php | 4 +- .../Functions/DateTime/WorkDayTest.php | 4 +- .../Functions/DateTime/YearFracTest.php | 4 +- .../Functions/DateTime/YearTest.php | 4 +- .../Functions/Engineering/BesselITest.php | 4 +- .../Functions/Engineering/BesselJTest.php | 4 +- .../Functions/Engineering/BesselKTest.php | 4 +- .../Functions/Engineering/BesselYTest.php | 4 +- .../Functions/Engineering/Bin2DecTest.php | 2 +- .../Functions/Engineering/Bin2HexTest.php | 2 +- .../Functions/Engineering/Bin2OctTest.php | 2 +- .../Functions/Engineering/BitAndTest.php | 2 +- .../Functions/Engineering/BitLShiftTest.php | 2 +- .../Functions/Engineering/BitOrTest.php | 2 +- .../Functions/Engineering/BitRShiftTest.php | 2 +- .../Functions/Engineering/BitXorTest.php | 2 +- .../Functions/Engineering/ComplexTest.php | 2 +- .../Functions/Engineering/ConvertUoMTest.php | 2 +- .../Functions/Engineering/Dec2BinTest.php | 2 +- .../Functions/Engineering/Dec2HexTest.php | 2 +- .../Functions/Engineering/Dec2OctTest.php | 2 +- .../Functions/Engineering/DeltaTest.php | 2 +- .../Functions/Engineering/ErfCTest.php | 5 +- .../Functions/Engineering/ErfPreciseTest.php | 5 +- .../Functions/Engineering/ErfTest.php | 5 +- .../Functions/Engineering/GeStepTest.php | 2 +- .../Functions/Engineering/Hex2BinTest.php | 2 +- .../Functions/Engineering/Hex2DecTest.php | 2 +- .../Functions/Engineering/Hex2OctTest.php | 2 +- .../Functions/Engineering/ImAbsTest.php | 4 +- .../Functions/Engineering/ImArgumentTest.php | 4 +- .../Functions/Engineering/ImConjugateTest.php | 4 +- .../Functions/Engineering/ImCosTest.php | 4 +- .../Functions/Engineering/ImCoshTest.php | 4 +- .../Functions/Engineering/ImCotTest.php | 4 +- .../Functions/Engineering/ImCscTest.php | 4 +- .../Functions/Engineering/ImCschTest.php | 4 +- .../Functions/Engineering/ImDivTest.php | 4 +- .../Functions/Engineering/ImExpTest.php | 4 +- .../Functions/Engineering/ImLnTest.php | 4 +- .../Functions/Engineering/ImLog10Test.php | 4 +- .../Functions/Engineering/ImLog2Test.php | 4 +- .../Functions/Engineering/ImPowerTest.php | 4 +- .../Functions/Engineering/ImProductTest.php | 4 +- .../Functions/Engineering/ImRealTest.php | 4 +- .../Functions/Engineering/ImSecTest.php | 4 +- .../Functions/Engineering/ImSechTest.php | 4 +- .../Functions/Engineering/ImSinTest.php | 4 +- .../Functions/Engineering/ImSinhTest.php | 4 +- .../Functions/Engineering/ImSqrtTest.php | 4 +- .../Functions/Engineering/ImSubTest.php | 4 +- .../Functions/Engineering/ImSumTest.php | 4 +- .../Functions/Engineering/ImTanTest.php | 4 +- .../Functions/Engineering/ImaginaryTest.php | 4 +- .../Functions/Engineering/Oct2BinTest.php | 2 +- .../Functions/Engineering/Oct2DecTest.php | 2 +- .../Functions/Engineering/Oct2HexTest.php | 2 +- .../Engineering/ParseComplexTest.php | 2 +- .../Functions/Financial/AccrintMTest.php | 4 +- .../Functions/Financial/AccrintTest.php | 4 +- .../Calculation/Functions/Logical/AndTest.php | 2 +- .../Functions/Logical/FalseTest.php | 2 +- .../Functions/Logical/IfErrorTest.php | 2 +- .../Functions/Logical/IfNaTest.php | 2 +- .../Calculation/Functions/Logical/IfTest.php | 2 +- .../Calculation/Functions/Logical/NotTest.php | 2 +- .../Calculation/Functions/Logical/OrTest.php | 2 +- .../Functions/Logical/SwitchTest.php | 2 +- .../Functions/Logical/TrueTest.php | 2 +- .../Calculation/Functions/Logical/XorTest.php | 2 +- .../Functions/LookupRef/ChooseTest.php | 2 +- .../Functions/LookupRef/ColumnsTest.php | 2 +- .../Functions/LookupRef/HLookupTest.php | 2 +- .../Functions/LookupRef/IndexTest.php | 2 +- .../Functions/LookupRef/LookupTest.php | 2 +- .../Functions/LookupRef/MatchTest.php | 2 +- .../Functions/LookupRef/RowsTest.php | 2 +- .../Functions/LookupRef/VLookupTest.php | 2 +- .../Functions/MathTrig/AcotTest.php | 4 +- .../Functions/MathTrig/AcothTest.php | 4 +- .../Functions/MathTrig/ArabicTest.php | 2 +- .../Functions/MathTrig/Atan2Test.php | 4 +- .../Functions/MathTrig/BaseTest.php | 2 +- .../Functions/MathTrig/CeilingTest.php | 4 +- .../Functions/MathTrig/CombinTest.php | 4 +- .../Functions/MathTrig/CotTest.php | 4 +- .../Functions/MathTrig/CothTest.php | 4 +- .../Functions/MathTrig/CscTest.php | 4 +- .../Functions/MathTrig/CschTest.php | 4 +- .../Functions/MathTrig/EvenTest.php | 4 +- .../Functions/MathTrig/FactDoubleTest.php | 4 +- .../Functions/MathTrig/FactTest.php | 4 +- .../Functions/MathTrig/FloorMathTest.php | 4 +- .../Functions/MathTrig/FloorPreciseTest.php | 4 +- .../Functions/MathTrig/FloorTest.php | 4 +- .../Functions/MathTrig/GcdTest.php | 4 +- .../Functions/MathTrig/IntTest.php | 2 +- .../Functions/MathTrig/LcmTest.php | 4 +- .../Functions/MathTrig/LogTest.php | 4 +- .../Functions/MathTrig/MInverseTest.php | 4 +- .../Functions/MathTrig/MMultTest.php | 4 +- .../Functions/MathTrig/MRoundTest.php | 4 +- .../Functions/MathTrig/MdeTermTest.php | 4 +- .../Functions/MathTrig/ModTest.php | 4 +- .../Functions/MathTrig/MultinomialTest.php | 4 +- .../Functions/MathTrig/OddTest.php | 4 +- .../Functions/MathTrig/PowerTest.php | 4 +- .../Functions/MathTrig/ProductTest.php | 4 +- .../Functions/MathTrig/QuotientTest.php | 4 +- .../Functions/MathTrig/RomanTest.php | 2 +- .../Functions/MathTrig/RoundDownTest.php | 4 +- .../Functions/MathTrig/RoundUpTest.php | 4 +- .../Functions/MathTrig/SecTest.php | 4 +- .../Functions/MathTrig/SechTest.php | 4 +- .../Functions/MathTrig/SeriesSumTest.php | 4 +- .../Functions/MathTrig/SignTest.php | 4 +- .../Functions/MathTrig/SqrtPiTest.php | 4 +- .../Functions/MathTrig/SubTotalTest.php | 8 +- .../Functions/MathTrig/SumIfTest.php | 4 +- .../Functions/MathTrig/SumIfsTest.php | 4 +- .../Functions/MathTrig/SumProductTest.php | 4 +- .../Functions/MathTrig/SumSqTest.php | 4 +- .../Functions/MathTrig/SumX2MY2Test.php | 4 +- .../Functions/MathTrig/SumX2PY2Test.php | 4 +- .../Functions/MathTrig/SumXMY2Test.php | 4 +- .../Functions/MathTrig/TruncTest.php | 4 +- .../Functions/Statistical/AveDevTest.php | 4 +- .../Functions/Statistical/AverageATest.php | 4 +- .../Functions/Statistical/AverageIfTest.php | 4 +- .../Functions/Statistical/AverageTest.php | 4 +- .../Functions/Statistical/BetaDistTest.php | 4 +- .../Functions/Statistical/BetaInvTest.php | 4 +- .../Functions/Statistical/BinomDistTest.php | 4 +- .../Functions/Statistical/ChiDistTest.php | 4 +- .../Functions/Statistical/ChiInvTest.php | 4 +- .../Functions/Statistical/ConfidenceTest.php | 4 +- .../Functions/Statistical/CorrelTest.php | 4 +- .../Functions/Statistical/CountATest.php | 4 +- .../Functions/Statistical/CountBlankTest.php | 4 +- .../Functions/Statistical/CountIfTest.php | 4 +- .../Functions/Statistical/CountIfsTest.php | 4 +- .../Functions/Statistical/CountTest.php | 10 +- .../Functions/Statistical/CovarTest.php | 4 +- .../Functions/Statistical/ExponDistTest.php | 4 +- .../Functions/Statistical/FisherInvTest.php | 4 +- .../Functions/Statistical/FisherTest.php | 4 +- .../Functions/Statistical/ForecastTest.php | 4 +- .../Functions/Statistical/GammaDistTest.php | 4 +- .../Functions/Statistical/GammaInvTest.php | 4 +- .../Functions/Statistical/GammaLnTest.php | 4 +- .../Functions/Statistical/GeoMeanTest.php | 4 +- .../Functions/Statistical/HarMeanTest.php | 4 +- .../Functions/Statistical/InterceptTest.php | 4 +- .../Functions/Statistical/MaxIfsTest.php | 4 +- .../Functions/Statistical/MedianTest.php | 4 +- .../Functions/Statistical/MinIfsTest.php | 4 +- .../Functions/Statistical/PermutTest.php | 4 +- .../Functions/Statistical/RsqTest.php | 4 +- .../Functions/Statistical/SlopeTest.php | 4 +- .../Functions/Statistical/SteyxTest.php | 4 +- .../Functions/TextData/CharTest.php | 4 +- .../Functions/TextData/CleanTest.php | 4 +- .../Functions/TextData/CodeTest.php | 4 +- .../Functions/TextData/ConcatenateTest.php | 4 +- .../Functions/TextData/DollarTest.php | 4 +- .../Functions/TextData/ExactTest.php | 4 +- .../Functions/TextData/FindTest.php | 4 +- .../Functions/TextData/FixedTest.php | 4 +- .../Functions/TextData/LeftTest.php | 4 +- .../Functions/TextData/LenTest.php | 4 +- .../Functions/TextData/LowerTest.php | 4 +- .../Functions/TextData/MidTest.php | 4 +- .../Functions/TextData/NumberValueTest.php | 4 +- .../Functions/TextData/ProperTest.php | 4 +- .../Functions/TextData/ReplaceTest.php | 4 +- .../Functions/TextData/RightTest.php | 4 +- .../Functions/TextData/SearchTest.php | 4 +- .../Functions/TextData/SubstituteTest.php | 4 +- .../Calculation/Functions/TextData/TTest.php | 4 +- .../Functions/TextData/TextJoinTest.php | 4 +- .../Functions/TextData/TextTest.php | 4 +- .../Functions/TextData/TrimTest.php | 4 +- .../Functions/TextData/UpperTest.php | 4 +- .../Functions/TextData/ValueTest.php | 6 +- .../Calculation/FunctionsTest.php | 32 +- .../Calculation/LookupRefTest.php | 4 +- .../PhpSpreadsheetTests/Helper/SampleTest.php | 12 - tests/PhpSpreadsheetTests/Reader/HtmlTest.php | 12 +- .../Reader/Security/XmlScannerTest.php | 2 +- .../PhpSpreadsheetTests/Reader/Xlsx2Test.php | 2 +- tests/PhpSpreadsheetTests/Reader/XlsxTest.php | 3 - .../ReferenceHelperTest.php | 2 +- tests/PhpSpreadsheetTests/SettingsTest.php | 4 +- tests/PhpSpreadsheetTests/Shared/DateTest.php | 8 +- .../Shared/StringHelperTest.php | 2 +- tests/PhpSpreadsheetTests/SpreadsheetTest.php | 2 +- .../Style/NumberFormatTest.php | 2 +- .../Worksheet/AutoFilter/Column/RuleTest.php | 2 +- .../Worksheet/AutoFilter/ColumnTest.php | 2 +- .../Worksheet/AutoFilterTest.php | 2 +- .../Worksheet/ColumnCellIteratorTest.php | 2 +- .../Worksheet/ColumnIteratorTest.php | 2 +- .../Worksheet/ColumnTest.php | 2 +- .../Worksheet/RowCellIteratorTest.php | 2 +- .../Worksheet/RowIteratorTest.php | 2 +- .../PhpSpreadsheetTests/Worksheet/RowTest.php | 2 +- .../Writer/Ods/ContentTest.php | 6 +- .../Writer/Xls/FormulaErrTest.php | 4 +- .../Writer/Xls/WorkbookTest.php | 4 +- .../Writer/Xlsx/LocaleFloatsTest.php | 4 +- .../Writer/Xlsx/UnparsedDataTest.php | 16 +- 232 files changed, 899 insertions(+), 811 deletions(-) diff --git a/composer.json b/composer.json index 52a6466ce7..b3be69b0cd 100644 --- a/composer.json +++ b/composer.json @@ -58,12 +58,12 @@ "psr/simple-cache": "^1.0" }, "require-dev": { - "dompdf/dompdf": "^0.8.3", + "dompdf/dompdf": "^0.8.5", "friendsofphp/php-cs-fixer": "^2.16", "jpgraph/jpgraph": "^4.0", "mpdf/mpdf": "^8.0", "phpcompatibility/php-compatibility": "^9.3", - "phpunit/phpunit": "^7.5", + "phpunit/phpunit": "^8.5", "squizlabs/php_codesniffer": "^3.5", "tecnickcom/tcpdf": "^6.3" }, diff --git a/composer.lock b/composer.lock index 182d58322a..0575eefed2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,34 +4,34 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "83ef345a065e12287e792d660b49619b", + "content-hash": "9c60146d8c78c13d2610a2cec23339a2", "packages": [ { "name": "markbaker/complex", - "version": "1.4.7", + "version": "1.4.8", "source": { "type": "git", "url": "https://github.com/MarkBaker/PHPComplex.git", - "reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000" + "reference": "8eaa40cceec7bf0518187530b2e63871be661b72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/1ea674a8308baf547cbcbd30c5fcd6d301b7c000", - "reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000", + "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/8eaa40cceec7bf0518187530b2e63871be661b72", + "reference": "8eaa40cceec7bf0518187530b2e63871be661b72", "shasum": "" }, "require": { "php": "^5.6.0|^7.0.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3", - "phpcompatibility/php-compatibility": "^8.0", + "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", + "phpcompatibility/php-compatibility": "^9.0", "phpdocumentor/phpdocumentor": "2.*", "phploc/phploc": "2.*", "phpmd/phpmd": "2.*", "phpunit/phpunit": "^4.8.35|^5.4.0", "sebastian/phpcpd": "2.*", - "squizlabs/php_codesniffer": "^3.3.0" + "squizlabs/php_codesniffer": "^3.4.0" }, "type": "library", "autoload": { @@ -99,7 +99,7 @@ "complex", "mathematics" ], - "time": "2018-10-13T23:28:42+00:00" + "time": "2020-03-11T20:15:49+00:00" }, { "name": "markbaker/matrix", @@ -222,24 +222,23 @@ "packages-dev": [ { "name": "composer/semver", - "version": "1.5.0", + "version": "1.5.1", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "46d9139568ccb8d9e7cdd4539cab7347568a5e2e" + "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/46d9139568ccb8d9e7cdd4539cab7347568a5e2e", - "reference": "46d9139568ccb8d9e7cdd4539cab7347568a5e2e", + "url": "https://api.github.com/repos/composer/semver/zipball/c6bea70230ef4dd483e6bbcab6005f682ed3a8de", + "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de", "shasum": "" }, "require": { "php": "^5.3.2 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^4.5 || ^5.0.5", - "phpunit/phpunit-mock-objects": "2.3.0 || ^3.0" + "phpunit/phpunit": "^4.5 || ^5.0.5" }, "type": "library", "extra": { @@ -280,20 +279,20 @@ "validation", "versioning" ], - "time": "2019-03-19T17:25:45+00:00" + "time": "2020-01-13T12:06:48+00:00" }, { "name": "composer/xdebug-handler", - "version": "1.4.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "cbe23383749496fe0f373345208b79568e4bc248" + "reference": "1ab9842d69e64fb3a01be6b656501032d1b78cb7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/cbe23383749496fe0f373345208b79568e4bc248", - "reference": "cbe23383749496fe0f373345208b79568e4bc248", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/1ab9842d69e64fb3a01be6b656501032d1b78cb7", + "reference": "1ab9842d69e64fb3a01be6b656501032d1b78cb7", "shasum": "" }, "require": { @@ -324,24 +323,25 @@ "Xdebug", "performance" ], - "time": "2019-11-06T16:40:04+00:00" + "time": "2020-03-01T12:26:26+00:00" }, { "name": "doctrine/annotations", - "version": "v1.8.0", + "version": "1.10.2", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc" + "reference": "b9d758e831c70751155c698c2f7df4665314a1cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/904dca4eb10715b92569fbcd79e201d5c349b6bc", - "reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/b9d758e831c70751155c698c2f7df4665314a1cb", + "reference": "b9d758e831c70751155c698c2f7df4665314a1cb", "shasum": "" }, "require": { "doctrine/lexer": "1.*", + "ext-tokenizer": "*", "php": "^7.1" }, "require-dev": { @@ -351,7 +351,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7.x-dev" + "dev-master": "1.9.x-dev" } }, "autoload": { @@ -392,20 +392,20 @@ "docblock", "parser" ], - "time": "2019-10-01T18:55:10+00:00" + "time": "2020-04-20T09:18:32+00:00" }, { "name": "doctrine/instantiator", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "a2c590166b2133a4633738648b6b064edae0814a" + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a", - "reference": "a2c590166b2133a4633738648b6b064edae0814a", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", "shasum": "" }, "require": { @@ -448,32 +448,34 @@ "constructor", "instantiate" ], - "time": "2019-03-17T17:37:11+00:00" + "time": "2019-10-21T16:45:58+00:00" }, { "name": "doctrine/lexer", - "version": "1.0.2", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/lexer.git", - "reference": "1febd6c3ef84253d7c815bed85fc622ad207a9f8" + "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/1febd6c3ef84253d7c815bed85fc622ad207a9f8", - "reference": "1febd6c3ef84253d7c815bed85fc622ad207a9f8", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", + "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", "shasum": "" }, "require": { - "php": ">=5.3.2" + "php": "^7.2" }, "require-dev": { - "phpunit/phpunit": "^4.5" + "doctrine/coding-standard": "^6.0", + "phpstan/phpstan": "^0.11.8", + "phpunit/phpunit": "^8.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -486,14 +488,14 @@ "MIT" ], "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, { "name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com" }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, { "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com" @@ -508,32 +510,32 @@ "parser", "php" ], - "time": "2019-06-08T11:03:04+00:00" + "time": "2019-10-30T14:39:59+00:00" }, { "name": "dompdf/dompdf", - "version": "v0.8.3", + "version": "v0.8.5", "source": { "type": "git", "url": "https://github.com/dompdf/dompdf.git", - "reference": "75f13c700009be21a1965dc2c5b68a8708c22ba2" + "reference": "6782abfc090b132134cd6cea0ec6d76f0fce2c56" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dompdf/dompdf/zipball/75f13c700009be21a1965dc2c5b68a8708c22ba2", - "reference": "75f13c700009be21a1965dc2c5b68a8708c22ba2", + "url": "https://api.github.com/repos/dompdf/dompdf/zipball/6782abfc090b132134cd6cea0ec6d76f0fce2c56", + "reference": "6782abfc090b132134cd6cea0ec6d76f0fce2c56", "shasum": "" }, "require": { "ext-dom": "*", "ext-mbstring": "*", - "phenx/php-font-lib": "0.5.*", - "phenx/php-svg-lib": "0.3.*", - "php": ">=5.4.0" + "phenx/php-font-lib": "^0.5.1", + "phenx/php-svg-lib": "^0.3.3", + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^4.8|^5.5|^6.5", - "squizlabs/php_codesniffer": "2.*" + "phpunit/phpunit": "^7.5", + "squizlabs/php_codesniffer": "^3.5" }, "suggest": { "ext-gd": "Needed to process images", @@ -574,20 +576,20 @@ ], "description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter", "homepage": "https://github.com/dompdf/dompdf", - "time": "2018-12-14T02:40:31+00:00" + "time": "2020-02-20T03:52:51+00:00" }, { "name": "friendsofphp/php-cs-fixer", - "version": "v2.16.1", + "version": "v2.16.3", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "c8afb599858876e95e8ebfcd97812d383fa23f02" + "reference": "83baf823a33a1cbd5416c8626935cf3f843c10b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c8afb599858876e95e8ebfcd97812d383fa23f02", - "reference": "c8afb599858876e95e8ebfcd97812d383fa23f02", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/83baf823a33a1cbd5416c8626935cf3f843c10b0", + "reference": "83baf823a33a1cbd5416c8626935cf3f843c10b0", "shasum": "" }, "require": { @@ -623,6 +625,7 @@ "symfony/yaml": "^3.0 || ^4.0 || ^5.0" }, "suggest": { + "ext-dom": "For handling output formats in XML", "ext-mbstring": "For handling non-UTF8 characters in cache signature.", "php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.", @@ -645,6 +648,7 @@ "tests/Test/IntegrationCaseFactory.php", "tests/Test/IntegrationCaseFactoryInterface.php", "tests/Test/InternalIntegrationCaseFactory.php", + "tests/Test/IsIdenticalConstraint.php", "tests/TestCase.php" ] }, @@ -663,7 +667,7 @@ } ], "description": "A tool to automatically fix PHP code style", - "time": "2019-11-25T22:10:32+00:00" + "time": "2020-04-15T18:51:10+00:00" }, { "name": "jpgraph/jpgraph", @@ -707,16 +711,16 @@ }, { "name": "mpdf/mpdf", - "version": "v8.0.4", + "version": "v8.0.5", "source": { "type": "git", "url": "https://github.com/mpdf/mpdf.git", - "reference": "d3147a0d790b6d11936fd9c73fa31a7ed45e3f6f" + "reference": "bad32aa9cd5958175aef185c02e032ddbadc56ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mpdf/mpdf/zipball/d3147a0d790b6d11936fd9c73fa31a7ed45e3f6f", - "reference": "d3147a0d790b6d11936fd9c73fa31a7ed45e3f6f", + "url": "https://api.github.com/repos/mpdf/mpdf/zipball/bad32aa9cd5958175aef185c02e032ddbadc56ea", + "reference": "bad32aa9cd5958175aef185c02e032ddbadc56ea", "shasum": "" }, "require": { @@ -772,20 +776,20 @@ "php", "utf-8" ], - "time": "2019-11-28T09:39:33+00:00" + "time": "2020-02-05T08:43:46+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.9.3", + "version": "1.9.5", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea" + "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/007c053ae6f31bba39dfa19a7726f56e9763bbea", - "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef", + "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef", "shasum": "" }, "require": { @@ -820,7 +824,7 @@ "object", "object graph" ], - "time": "2019-08-09T12:45:53+00:00" + "time": "2020-01-17T21:11:47+00:00" }, { "name": "paragonie/random_compat", @@ -971,20 +975,20 @@ }, { "name": "phenx/php-font-lib", - "version": "0.5.1", + "version": "0.5.2", "source": { "type": "git", "url": "https://github.com/PhenX/php-font-lib.git", - "reference": "760148820110a1ae0936e5cc35851e25a938bc97" + "reference": "ca6ad461f032145fff5971b5985e5af9e7fa88d8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PhenX/php-font-lib/zipball/760148820110a1ae0936e5cc35851e25a938bc97", - "reference": "760148820110a1ae0936e5cc35851e25a938bc97", + "url": "https://api.github.com/repos/PhenX/php-font-lib/zipball/ca6ad461f032145fff5971b5985e5af9e7fa88d8", + "reference": "ca6ad461f032145fff5971b5985e5af9e7fa88d8", "shasum": "" }, "require-dev": { - "phpunit/phpunit": "^4.8" + "phpunit/phpunit": "^4.8.35 || ^5 || ^6 || ^7" }, "type": "library", "autoload": { @@ -1004,7 +1008,7 @@ ], "description": "A library to read, parse, export and make subsets of different types of font files.", "homepage": "https://github.com/PhenX/php-font-lib", - "time": "2017-09-13T16:14:37+00:00" + "time": "2020-03-08T15:31:32+00:00" }, { "name": "phenx/php-svg-lib", @@ -1099,16 +1103,16 @@ }, { "name": "phpcompatibility/php-compatibility", - "version": "9.3.2", + "version": "9.3.5", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", - "reference": "bfca2be3992f40e92206e5a7ebe5eaee37280b58" + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/bfca2be3992f40e92206e5a7ebe5eaee37280b58", - "reference": "bfca2be3992f40e92206e5a7ebe5eaee37280b58", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", "shasum": "" }, "require": { @@ -1153,28 +1157,25 @@ "phpcs", "standards" ], - "time": "2019-10-16T21:24:24+00:00" + "time": "2019-12-27T09:44:58+00:00" }, { "name": "phpdocumentor/reflection-common", - "version": "2.0.0", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/6568f4687e5b41b054365f9ae03fcb1ed5f2069b", + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b", "shasum": "" }, "require": { "php": ">=7.1" }, - "require-dev": { - "phpunit/phpunit": "~6" - }, "type": "library", "extra": { "branch-alias": { @@ -1205,44 +1206,42 @@ "reflection", "static analysis" ], - "time": "2018-08-07T13:53:10+00:00" + "time": "2020-04-27T09:25:28+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.2", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e" + "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", + "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", "shasum": "" }, "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", - "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", - "webmozart/assert": "^1.0" + "ext-filter": "^7.1", + "php": "^7.2", + "phpdocumentor/reflection-common": "^2.0", + "phpdocumentor/type-resolver": "^1.0", + "webmozart/assert": "^1" }, "require-dev": { - "doctrine/instantiator": "^1.0.5", - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^6.4" + "doctrine/instantiator": "^1", + "mockery/mockery": "^1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.x-dev" + "dev-master": "5.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -1253,33 +1252,36 @@ { "name": "Mike van Riel", "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-09-12T14:27:41+00:00" + "time": "2020-02-22T12:28:44+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.0.1", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" + "reference": "7462d5f123dfc080dfdf26897032a6513644fc95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", - "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/7462d5f123dfc080dfdf26897032a6513644fc95", + "reference": "7462d5f123dfc080dfdf26897032a6513644fc95", "shasum": "" }, "require": { - "php": "^7.1", + "php": "^7.2", "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "ext-tokenizer": "^7.1", - "mockery/mockery": "~1", - "phpunit/phpunit": "^7.0" + "ext-tokenizer": "^7.2", + "mockery/mockery": "~1" }, "type": "library", "extra": { @@ -1303,37 +1305,37 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2019-08-22T18:11:29+00:00" + "time": "2020-02-18T18:59:58+00:00" }, { "name": "phpspec/prophecy", - "version": "1.9.0", + "version": "v1.10.3", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203" + "reference": "451c3cd1418cf640de218914901e51b064abb093" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203", - "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", + "reference": "451c3cd1418cf640de218914901e51b064abb093", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.1|^2.0|^3.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" + "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", + "phpspec/phpspec": "^2.5 || ^3.2", "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.10.x-dev" } }, "autoload": { @@ -1366,44 +1368,44 @@ "spy", "stub" ], - "time": "2019-10-03T11:07:50+00:00" + "time": "2020-03-05T15:02:03+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "6.1.4", + "version": "7.0.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d" + "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", - "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f1884187926fbb755a9aaf0b3836ad3165b478bf", + "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", - "php": "^7.1", - "phpunit/php-file-iterator": "^2.0", + "php": "^7.2", + "phpunit/php-file-iterator": "^2.0.2", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.0", + "phpunit/php-token-stream": "^3.1.1", "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.1 || ^4.0", + "sebastian/environment": "^4.2.2", "sebastian/version": "^2.0.1", - "theseer/tokenizer": "^1.1" + "theseer/tokenizer": "^1.1.3" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^8.2.2" }, "suggest": { - "ext-xdebug": "^2.6.0" + "ext-xdebug": "^2.7.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "6.1-dev" + "dev-master": "7.0-dev" } }, "autoload": { @@ -1429,7 +1431,7 @@ "testing", "xunit" ], - "time": "2018-10-31T16:06:48+00:00" + "time": "2019-11-20T13:55:58+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1622,53 +1624,52 @@ }, { "name": "phpunit/phpunit", - "version": "7.5.17", + "version": "8.5.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "4c92a15296e58191a4cd74cff3b34fc8e374174a" + "reference": "8474e22d7d642f665084ba5ec780626cbd1efd23" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4c92a15296e58191a4cd74cff3b34fc8e374174a", - "reference": "4c92a15296e58191a4cd74cff3b34fc8e374174a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8474e22d7d642f665084ba5ec780626cbd1efd23", + "reference": "8474e22d7d642f665084ba5ec780626cbd1efd23", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.1", + "doctrine/instantiator": "^1.2.0", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", - "myclabs/deep-copy": "^1.7", - "phar-io/manifest": "^1.0.2", - "phar-io/version": "^2.0", - "php": "^7.1", - "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^6.0.7", - "phpunit/php-file-iterator": "^2.0.1", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.9.1", + "phar-io/manifest": "^1.0.3", + "phar-io/version": "^2.0.1", + "php": "^7.2", + "phpspec/prophecy": "^1.8.1", + "phpunit/php-code-coverage": "^7.0.7", + "phpunit/php-file-iterator": "^2.0.2", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^2.1", - "sebastian/comparator": "^3.0", - "sebastian/diff": "^3.0", - "sebastian/environment": "^4.0", - "sebastian/exporter": "^3.1", - "sebastian/global-state": "^2.0", + "phpunit/php-timer": "^2.1.2", + "sebastian/comparator": "^3.0.2", + "sebastian/diff": "^3.0.2", + "sebastian/environment": "^4.2.2", + "sebastian/exporter": "^3.1.1", + "sebastian/global-state": "^3.0.0", "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^2.0", + "sebastian/resource-operations": "^2.0.1", + "sebastian/type": "^1.1.3", "sebastian/version": "^2.0.1" }, - "conflict": { - "phpunit/phpunit-mock-objects": "*" - }, "require-dev": { "ext-pdo": "*" }, "suggest": { "ext-soap": "*", "ext-xdebug": "*", - "phpunit/php-invoker": "^2.0" + "phpunit/php-invoker": "^2.0.0" }, "bin": [ "phpunit" @@ -1676,7 +1677,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.5-dev" + "dev-master": "8.5-dev" } }, "autoload": { @@ -1702,7 +1703,7 @@ "testing", "xunit" ], - "time": "2019-10-28T10:37:36+00:00" + "time": "2020-04-23T04:39:42+00:00" }, { "name": "psr/container", @@ -1753,18 +1754,64 @@ ], "time": "2017-02-14T16:28:37+00:00" }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "time": "2019-01-08T18:20:26+00:00" + }, { "name": "psr/log", - "version": "1.1.2", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801" + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", - "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", + "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", "shasum": "" }, "require": { @@ -1798,7 +1845,7 @@ "psr", "psr-3" ], - "time": "2019-11-01T11:05:21+00:00" + "time": "2020-03-23T09:12:05+00:00" }, { "name": "sabberworm/php-css-parser", @@ -2012,16 +2059,16 @@ }, { "name": "sebastian/environment", - "version": "4.2.2", + "version": "4.2.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404" + "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/f2a2c8e1c97c11ace607a7a667d73d47c19fe404", - "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/464c90d7bdf5ad4e8a6aea15c091fec0603d4368", + "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368", "shasum": "" }, "require": { @@ -2061,7 +2108,7 @@ "environment", "hhvm" ], - "time": "2019-05-05T09:05:15+00:00" + "time": "2019-11-20T08:46:58+00:00" }, { "name": "sebastian/exporter", @@ -2132,23 +2179,26 @@ }, { "name": "sebastian/global-state", - "version": "2.0.0", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.2", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "ext-dom": "*", + "phpunit/phpunit": "^8.0" }, "suggest": { "ext-uopz": "*" @@ -2156,7 +2206,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -2179,7 +2229,7 @@ "keywords": [ "global state" ], - "time": "2017-04-27T15:39:26+00:00" + "time": "2019-02-01T05:30:01+00:00" }, { "name": "sebastian/object-enumerator", @@ -2368,6 +2418,52 @@ "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "time": "2018-10-04T04:07:39+00:00" }, + { + "name": "sebastian/type", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/3aaaa15fa71d27650d62a948be022fe3b48541a3", + "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3", + "shasum": "" + }, + "require": { + "php": "^7.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "time": "2019-07-02T08:10:15+00:00" + }, { "name": "sebastian/version", "version": "2.0.1", @@ -2413,33 +2509,33 @@ }, { "name": "setasign/fpdi", - "version": "v2.2.0", + "version": "v2.3.2", "source": { "type": "git", "url": "https://github.com/Setasign/FPDI.git", - "reference": "3c266002f8044f61b17329f7cd702d44d73f0f7f" + "reference": "527761458f504882ab844f15754523825647f291" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Setasign/FPDI/zipball/3c266002f8044f61b17329f7cd702d44d73f0f7f", - "reference": "3c266002f8044f61b17329f7cd702d44d73f0f7f", + "url": "https://api.github.com/repos/Setasign/FPDI/zipball/527761458f504882ab844f15754523825647f291", + "reference": "527761458f504882ab844f15754523825647f291", "shasum": "" }, "require": { "ext-zlib": "*", "php": "^5.6 || ^7.0" }, + "conflict": { + "setasign/tfpdf": "<1.31" + }, "require-dev": { "phpunit/phpunit": "~5.7", "setasign/fpdf": "~1.8", - "setasign/tfpdf": "1.25", + "setasign/tfpdf": "1.31", "tecnickcom/tcpdf": "~6.2" }, "suggest": { - "setasign/fpdf": "FPDI will extend this class but as it is also possible to use TCPDF or tFPDF as an alternative. There's no fixed dependency configured.", - "setasign/fpdi-fpdf": "Use this package to automatically evaluate dependencies to FPDF.", - "setasign/fpdi-tcpdf": "Use this package to automatically evaluate dependencies to TCPDF.", - "setasign/fpdi-tfpdf": "Use this package to automatically evaluate dependencies to tFPDF." + "setasign/fpdf": "FPDI will extend this class but as it is also possible to use TCPDF or tFPDF as an alternative. There's no fixed dependency configured." }, "type": "library", "autoload": { @@ -2470,20 +2566,20 @@ "fpdi", "pdf" ], - "time": "2019-01-30T14:11:19+00:00" + "time": "2020-03-23T15:53:59+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.5.2", + "version": "3.5.5", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "65b12cdeaaa6cd276d4c3033a95b9b88b12701e7" + "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/65b12cdeaaa6cd276d4c3033a95b9b88b12701e7", - "reference": "65b12cdeaaa6cd276d4c3033a95b9b88b12701e7", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/73e2e7f57d958e7228fce50dc0c61f58f017f9f6", + "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6", "shasum": "" }, "require": { @@ -2521,44 +2617,45 @@ "phpcs", "standards" ], - "time": "2019-10-28T04:36:32+00:00" + "time": "2020-04-17T01:09:41+00:00" }, { "name": "symfony/console", - "version": "v4.3.6", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "136c4bd62ea871d00843d1bc0316de4c4a84bb78" + "reference": "5fa1caadc8cdaa17bcfb25219f3b53fe294a9935" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/136c4bd62ea871d00843d1bc0316de4c4a84bb78", - "reference": "136c4bd62ea871d00843d1bc0316de4c4a84bb78", + "url": "https://api.github.com/repos/symfony/console/zipball/5fa1caadc8cdaa17bcfb25219f3b53fe294a9935", + "reference": "5fa1caadc8cdaa17bcfb25219f3b53fe294a9935", "shasum": "" }, "require": { - "php": "^7.1.3", + "php": "^7.2.5", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php73": "^1.8", - "symfony/service-contracts": "^1.1" + "symfony/service-contracts": "^1.1|^2" }, "conflict": { - "symfony/dependency-injection": "<3.4", - "symfony/event-dispatcher": "<4.3", - "symfony/process": "<3.3" + "symfony/dependency-injection": "<4.4", + "symfony/event-dispatcher": "<4.4", + "symfony/lock": "<4.4", + "symfony/process": "<4.4" }, "provide": { "psr/log-implementation": "1.0" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.4|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/event-dispatcher": "^4.3", - "symfony/lock": "~3.4|~4.0", - "symfony/process": "~3.4|~4.0", - "symfony/var-dumper": "^4.3" + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/event-dispatcher": "^4.4|^5.0", + "symfony/lock": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0" }, "suggest": { "psr/log": "For using the console logger", @@ -2569,7 +2666,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -2596,41 +2693,41 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2019-10-30T12:58:49+00:00" + "time": "2020-03-30T11:42:42+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.3.6", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "6229f58993e5a157f6096fc7145c0717d0be8807" + "reference": "24f40d95385774ed5c71dbf014edd047e2f2f3dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/6229f58993e5a157f6096fc7145c0717d0be8807", - "reference": "6229f58993e5a157f6096fc7145c0717d0be8807", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/24f40d95385774ed5c71dbf014edd047e2f2f3dc", + "reference": "24f40d95385774ed5c71dbf014edd047e2f2f3dc", "shasum": "" }, "require": { - "php": "^7.1.3", - "symfony/event-dispatcher-contracts": "^1.1" + "php": "^7.2.5", + "symfony/event-dispatcher-contracts": "^2" }, "conflict": { - "symfony/dependency-injection": "<3.4" + "symfony/dependency-injection": "<4.4" }, "provide": { "psr/event-dispatcher-implementation": "1.0", - "symfony/event-dispatcher-implementation": "1.1" + "symfony/event-dispatcher-implementation": "2.0" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.4|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/expression-language": "~3.4|~4.0", - "symfony/http-foundation": "^3.4|^4.0", - "symfony/service-contracts": "^1.1", - "symfony/stopwatch": "~3.4|~4.0" + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/service-contracts": "^1.1|^2", + "symfony/stopwatch": "^4.4|^5.0" }, "suggest": { "symfony/dependency-injection": "", @@ -2639,7 +2736,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -2666,33 +2763,33 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2019-10-01T16:40:32+00:00" + "time": "2020-03-27T16:56:45+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v1.1.7", + "version": "v2.0.1", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "c43ab685673fb6c8d84220c77897b1d6cdbe1d18" + "reference": "af23c2584d4577d54661c434446fb8fbed6025dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/c43ab685673fb6c8d84220c77897b1d6cdbe1d18", - "reference": "c43ab685673fb6c8d84220c77897b1d6cdbe1d18", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/af23c2584d4577d54661c434446fb8fbed6025dd", + "reference": "af23c2584d4577d54661c434446fb8fbed6025dd", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": "^7.2.5", + "psr/event-dispatcher": "^1" }, "suggest": { - "psr/event-dispatcher": "", "symfony/event-dispatcher-implementation": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -2724,30 +2821,30 @@ "interoperability", "standards" ], - "time": "2019-09-17T09:54:03+00:00" + "time": "2019-11-18T17:27:11+00:00" }, { "name": "symfony/filesystem", - "version": "v4.3.6", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "9abbb7ef96a51f4d7e69627bc6f63307994e4263" + "reference": "ca3b87dd09fff9b771731637f5379965fbfab420" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/9abbb7ef96a51f4d7e69627bc6f63307994e4263", - "reference": "9abbb7ef96a51f4d7e69627bc6f63307994e4263", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/ca3b87dd09fff9b771731637f5379965fbfab420", + "reference": "ca3b87dd09fff9b771731637f5379965fbfab420", "shasum": "" }, "require": { - "php": "^7.1.3", + "php": "^7.2.5", "symfony/polyfill-ctype": "~1.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -2774,29 +2871,29 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2019-08-20T14:07:54+00:00" + "time": "2020-03-27T16:56:45+00:00" }, { "name": "symfony/finder", - "version": "v4.3.6", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "72a068f77e317ae77c0a0495236ad292cfb5ce6f" + "reference": "600a52c29afc0d1caa74acbec8d3095ca7e9910d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/72a068f77e317ae77c0a0495236ad292cfb5ce6f", - "reference": "72a068f77e317ae77c0a0495236ad292cfb5ce6f", + "url": "https://api.github.com/repos/symfony/finder/zipball/600a52c29afc0d1caa74acbec8d3095ca7e9910d", + "reference": "600a52c29afc0d1caa74acbec8d3095ca7e9910d", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": "^7.2.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -2823,29 +2920,29 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2019-10-30T12:53:54+00:00" + "time": "2020-03-27T16:56:45+00:00" }, { "name": "symfony/options-resolver", - "version": "v4.3.6", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "f46c7fc8e207bd8a2188f54f8738f232533765a4" + "reference": "09dccfffd24b311df7f184aa80ee7b61ad61ed8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/f46c7fc8e207bd8a2188f54f8738f232533765a4", - "reference": "f46c7fc8e207bd8a2188f54f8738f232533765a4", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/09dccfffd24b311df7f184aa80ee7b61ad61ed8d", + "reference": "09dccfffd24b311df7f184aa80ee7b61ad61ed8d", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": "^7.2.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -2877,20 +2974,20 @@ "configuration", "options" ], - "time": "2019-10-28T20:59:01+00:00" + "time": "2020-03-27T16:56:45+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.12.0", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "550ebaac289296ce228a706d0867afc34687e3f4" + "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/550ebaac289296ce228a706d0867afc34687e3f4", - "reference": "550ebaac289296ce228a706d0867afc34687e3f4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/4719fa9c18b0464d399f1a63bf624b42b6fa8d14", + "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14", "shasum": "" }, "require": { @@ -2902,7 +2999,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -2935,20 +3032,20 @@ "polyfill", "portable" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2020-02-27T09:26:54+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.12.0", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17" + "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b42a2f66e8f1b15ccf25652c3424265923eb4f17", - "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/81ffd3a9c6d707be22e3012b827de1c9775fc5ac", + "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac", "shasum": "" }, "require": { @@ -2960,7 +3057,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -2994,20 +3091,20 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2020-03-09T19:04:49+00:00" }, { "name": "symfony/polyfill-php70", - "version": "v1.12.0", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "54b4c428a0054e254223797d2713c31e08610831" + "reference": "2a18e37a489803559284416df58c71ccebe50bf0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/54b4c428a0054e254223797d2713c31e08610831", - "reference": "54b4c428a0054e254223797d2713c31e08610831", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/2a18e37a489803559284416df58c71ccebe50bf0", + "reference": "2a18e37a489803559284416df58c71ccebe50bf0", "shasum": "" }, "require": { @@ -3017,7 +3114,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -3053,20 +3150,20 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2020-02-27T09:26:54+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.12.0", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "04ce3335667451138df4307d6a9b61565560199e" + "reference": "37b0976c78b94856543260ce09b460a7bc852747" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/04ce3335667451138df4307d6a9b61565560199e", - "reference": "04ce3335667451138df4307d6a9b61565560199e", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/37b0976c78b94856543260ce09b460a7bc852747", + "reference": "37b0976c78b94856543260ce09b460a7bc852747", "shasum": "" }, "require": { @@ -3075,7 +3172,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -3108,20 +3205,20 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2020-02-27T09:26:54+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.12.0", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188" + "reference": "0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/2ceb49eaccb9352bff54d22570276bb75ba4a188", - "reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7", + "reference": "0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7", "shasum": "" }, "require": { @@ -3130,7 +3227,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.15-dev" } }, "autoload": { @@ -3166,29 +3263,29 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" + "time": "2020-02-27T09:26:54+00:00" }, { "name": "symfony/process", - "version": "v4.3.6", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "3b2e0cb029afbb0395034509291f21191d1a4db0" + "reference": "c5ca4a0fc16a0c888067d43fbcfe1f8a53d8e70e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/3b2e0cb029afbb0395034509291f21191d1a4db0", - "reference": "3b2e0cb029afbb0395034509291f21191d1a4db0", + "url": "https://api.github.com/repos/symfony/process/zipball/c5ca4a0fc16a0c888067d43fbcfe1f8a53d8e70e", + "reference": "c5ca4a0fc16a0c888067d43fbcfe1f8a53d8e70e", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": "^7.2.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -3215,24 +3312,24 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2019-10-28T17:07:32+00:00" + "time": "2020-03-27T16:56:45+00:00" }, { "name": "symfony/service-contracts", - "version": "v1.1.8", + "version": "v2.0.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf" + "reference": "144c5e51266b281231e947b51223ba14acf1a749" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ffc7f5692092df31515df2a5ecf3b7302b3ddacf", - "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/144c5e51266b281231e947b51223ba14acf1a749", + "reference": "144c5e51266b281231e947b51223ba14acf1a749", "shasum": "" }, "require": { - "php": "^7.1.3", + "php": "^7.2.5", "psr/container": "^1.0" }, "suggest": { @@ -3241,7 +3338,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -3273,30 +3370,30 @@ "interoperability", "standards" ], - "time": "2019-10-14T12:27:06+00:00" + "time": "2019-11-18T17:27:11+00:00" }, { "name": "symfony/stopwatch", - "version": "v4.3.6", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "1e4ff456bd625be5032fac9be4294e60442e9b71" + "reference": "a1d86d30d4522423afc998f32404efa34fcf5a73" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/1e4ff456bd625be5032fac9be4294e60442e9b71", - "reference": "1e4ff456bd625be5032fac9be4294e60442e9b71", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/a1d86d30d4522423afc998f32404efa34fcf5a73", + "reference": "a1d86d30d4522423afc998f32404efa34fcf5a73", "shasum": "" }, "require": { - "php": "^7.1.3", - "symfony/service-contracts": "^1.0" + "php": "^7.2.5", + "symfony/service-contracts": "^1.0|^2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -3323,20 +3420,20 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2019-08-07T11:52:19+00:00" + "time": "2020-03-27T16:56:45+00:00" }, { "name": "tecnickcom/tcpdf", - "version": "6.3.2", + "version": "6.3.5", "source": { "type": "git", "url": "https://github.com/tecnickcom/TCPDF.git", - "reference": "9fde7bb9b404b945e7ea88fb7eccd23d9a4e324b" + "reference": "19a535eaa7fb1c1cac499109deeb1a7a201b4549" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/9fde7bb9b404b945e7ea88fb7eccd23d9a4e324b", - "reference": "9fde7bb9b404b945e7ea88fb7eccd23d9a4e324b", + "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/19a535eaa7fb1c1cac499109deeb1a7a201b4549", + "reference": "19a535eaa7fb1c1cac499109deeb1a7a201b4549", "shasum": "" }, "require": { @@ -3365,7 +3462,7 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL-3.0" + "LGPL-3.0-only" ], "authors": [ { @@ -3385,7 +3482,7 @@ "pdf417", "qrcode" ], - "time": "2019-09-20T09:35:01+00:00" + "time": "2020-02-14T14:20:12+00:00" }, { "name": "theseer/tokenizer", @@ -3429,31 +3526,29 @@ }, { "name": "webmozart/assert", - "version": "1.5.0", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4" + "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/88e6d84706d09a236046d686bbea96f07b3a34f4", - "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4", + "url": "https://api.github.com/repos/webmozart/assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6", + "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6", "shasum": "" }, "require": { "php": "^5.3.3 || ^7.0", "symfony/polyfill-ctype": "^1.8" }, + "conflict": { + "vimeo/psalm": "<3.9.1" + }, "require-dev": { "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, "autoload": { "psr-4": { "Webmozart\\Assert\\": "src/" @@ -3475,7 +3570,7 @@ "check", "validate" ], - "time": "2019-08-24T08:43:50+00:00" + "time": "2020-04-18T12:12:48+00:00" } ], "aliases": [], diff --git a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php index 59b8cd0e0f..14cd993a35 100644 --- a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php @@ -9,12 +9,12 @@ class CalculationTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } - public function tearDown() + protected function tearDown(): void { $calculation = Calculation::getInstance(); $calculation->setLocale('en_us'); diff --git a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php index e941845498..27eb3d61b5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php @@ -8,7 +8,7 @@ class FinancialTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testAMORDEGRC($expectedResult, ...$args) { $result = Financial::AMORDEGRC(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerAMORDEGRC() @@ -37,7 +37,7 @@ public function providerAMORDEGRC() public function testAMORLINC($expectedResult, ...$args) { $result = Financial::AMORLINC(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerAMORLINC() @@ -53,7 +53,7 @@ public function providerAMORLINC() public function testCOUPDAYBS($expectedResult, ...$args) { $result = Financial::COUPDAYBS(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerCOUPDAYBS() @@ -69,7 +69,7 @@ public function providerCOUPDAYBS() public function testCOUPDAYS($expectedResult, ...$args) { $result = Financial::COUPDAYS(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerCOUPDAYS() @@ -85,7 +85,7 @@ public function providerCOUPDAYS() public function testCOUPDAYSNC($expectedResult, ...$args) { $result = Financial::COUPDAYSNC(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerCOUPDAYSNC() @@ -101,7 +101,7 @@ public function providerCOUPDAYSNC() public function testCOUPNCD($expectedResult, ...$args) { $result = Financial::COUPNCD(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerCOUPNCD() @@ -117,7 +117,7 @@ public function providerCOUPNCD() public function testCOUPNUM($expectedResult, ...$args) { $result = Financial::COUPNUM(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerCOUPNUM() @@ -133,7 +133,7 @@ public function providerCOUPNUM() public function testCOUPPCD($expectedResult, ...$args) { $result = Financial::COUPPCD(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerCOUPPCD() @@ -149,7 +149,7 @@ public function providerCOUPPCD() public function testCUMIPMT($expectedResult, ...$args) { $result = Financial::CUMIPMT(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerCUMIPMT() @@ -165,7 +165,7 @@ public function providerCUMIPMT() public function testCUMPRINC($expectedResult, ...$args) { $result = Financial::CUMPRINC(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerCUMPRINC() @@ -181,7 +181,7 @@ public function providerCUMPRINC() public function testDB($expectedResult, ...$args) { $result = Financial::DB(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerDB() @@ -197,7 +197,7 @@ public function providerDB() public function testDDB($expectedResult, ...$args) { $result = Financial::DDB(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerDDB() @@ -213,7 +213,7 @@ public function providerDDB() public function testDISC($expectedResult, ...$args) { $result = Financial::DISC(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerDISC() @@ -229,7 +229,7 @@ public function providerDISC() public function testDOLLARDE($expectedResult, ...$args) { $result = Financial::DOLLARDE(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerDOLLARDE() @@ -245,7 +245,7 @@ public function providerDOLLARDE() public function testDOLLARFR($expectedResult, ...$args) { $result = Financial::DOLLARFR(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerDOLLARFR() @@ -261,7 +261,7 @@ public function providerDOLLARFR() public function testEFFECT($expectedResult, ...$args) { $result = Financial::EFFECT(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerEFFECT() @@ -277,7 +277,7 @@ public function providerEFFECT() public function testFV($expectedResult, ...$args) { $result = Financial::FV(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerFV() @@ -293,7 +293,7 @@ public function providerFV() public function testFVSCHEDULE($expectedResult, ...$args) { $result = Financial::FVSCHEDULE(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerFVSCHEDULE() @@ -309,7 +309,7 @@ public function providerFVSCHEDULE() public function testINTRATE($expectedResult, ...$args) { $result = Financial::INTRATE(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerINTRATE() @@ -325,7 +325,7 @@ public function providerINTRATE() public function testIPMT($expectedResult, ...$args) { $result = Financial::IPMT(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerIPMT() @@ -341,7 +341,7 @@ public function providerIPMT() public function testIRR($expectedResult, ...$args) { $result = Financial::IRR(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerIRR() @@ -357,7 +357,7 @@ public function providerIRR() public function testISPMT($expectedResult, ...$args) { $result = Financial::ISPMT(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerISPMT() @@ -373,7 +373,7 @@ public function providerISPMT() public function testMIRR($expectedResult, ...$args) { $result = Financial::MIRR(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerMIRR() @@ -389,7 +389,7 @@ public function providerMIRR() public function testNOMINAL($expectedResult, ...$args) { $result = Financial::NOMINAL(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerNOMINAL() @@ -405,7 +405,7 @@ public function providerNOMINAL() public function testNPER($expectedResult, ...$args) { $result = Financial::NPER(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerNPER() @@ -421,7 +421,7 @@ public function providerNPER() public function testNPV($expectedResult, ...$args) { $result = Financial::NPV(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerNPV() @@ -439,7 +439,7 @@ public function testPRICE($expectedResult, ...$args) $this->markTestIncomplete('TODO: This test should be fixed'); $result = Financial::PRICE(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerPRICE() @@ -455,7 +455,7 @@ public function providerPRICE() public function testPRICEDISC($expectedResult, array $args) { $result = Financial::PRICEDISC(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerPRICEDISC() @@ -471,7 +471,7 @@ public function providerPRICEDISC() public function testPV($expectedResult, array $args) { $result = Financial::PV(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerPV() @@ -489,7 +489,7 @@ public function testRATE($expectedResult, ...$args) $this->markTestIncomplete('TODO: This test should be fixed'); $result = Financial::RATE(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerRATE() @@ -506,7 +506,7 @@ public function providerRATE() public function testXIRR($expectedResult, $message, ...$args) { $result = Financial::XIRR(...$args); - self::assertEquals($expectedResult, $result, $message, Financial::FINANCIAL_PRECISION); + self::assertEqualsWithDelta($expectedResult, $result, Financial::FINANCIAL_PRECISION, $message); } public function providerXIRR() @@ -522,7 +522,7 @@ public function providerXIRR() public function testPDURATION($expectedResult, array $args) { $result = Financial::PDURATION(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerPDURATION() @@ -538,7 +538,7 @@ public function providerPDURATION() public function testRRI($expectedResult, array $args) { $result = Financial::RRI(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerRRI() @@ -554,7 +554,7 @@ public function providerRRI() public function testSLN($expectedResult, array $args) { $result = Financial::SLN(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerSLN() @@ -570,7 +570,7 @@ public function providerSLN() public function testSYD($expectedResult, array $args) { $result = Financial::SYD(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerSYD() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php index 9c61dcc9f9..adbc52218c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php @@ -9,7 +9,7 @@ class DateDifTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -27,7 +27,7 @@ public function setUp() public function testDATEDIF($expectedResult, $startDate, $endDate, $unit) { $result = DateTime::DATEDIF($startDate, $endDate, $unit); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerDATEDIF() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php index 447e504e95..ef3d60eeb4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php @@ -9,7 +9,7 @@ class DateTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -27,7 +27,7 @@ public function setUp() public function testDATE($expectedResult, $year, $month, $day) { $result = DateTime::DATE($year, $month, $day); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerDATE() @@ -40,7 +40,8 @@ public function testDATEtoUnixTimestamp() Functions::setReturnDateType(Functions::RETURNDATE_UNIX_TIMESTAMP); $result = DateTime::DATE(2012, 1, 31); - $this->assertEquals(1327968000, $result, '', 1E-8); + $this->assertEquals(1327968000, $result); + $this->assertEqualsWithDelta(1327968000, $result, 1E-8); } public function testDATEtoDateTimeObject() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php index 236da6c766..3c5d7a56a8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php @@ -10,7 +10,7 @@ class DateValueTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -26,7 +26,7 @@ public function setUp() public function testDATEVALUE($expectedResult, $dateValue) { $result = DateTime::DATEVALUE($dateValue); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerDATEVALUE() @@ -39,7 +39,8 @@ public function testDATEVALUEtoUnixTimestamp() Functions::setReturnDateType(Functions::RETURNDATE_UNIX_TIMESTAMP); $result = DateTime::DATEVALUE('2012-1-31'); - $this->assertEquals(1327968000, $result, '', 1E-8); + $this->assertEquals(1327968000, $result); + $this->assertEqualsWithDelta(1327968000, $result, 1E-8); } public function testDATEVALUEtoDateTimeObject() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php index 6bd5ba712e..1b2bf43034 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php @@ -9,7 +9,7 @@ class DayTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -26,12 +26,12 @@ public function setUp() public function testDAY($expectedResultExcel, $expectedResultOpenOffice, $dateTimeValue) { $resultExcel = DateTime::DAYOFMONTH($dateTimeValue); - $this->assertEquals($expectedResultExcel, $resultExcel, '', 1E-8); + $this->assertEqualsWithDelta($expectedResultExcel, $resultExcel, 1E-8); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); $resultOpenOffice = DateTime::DAYOFMONTH($dateTimeValue); - $this->assertEquals($expectedResultOpenOffice, $resultOpenOffice, '', 1E-8); + $this->assertEqualsWithDelta($expectedResultOpenOffice, $resultOpenOffice, 1E-8); } public function providerDAY() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php index ec067acaa8..aa1da8236b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php @@ -9,7 +9,7 @@ class Days360Test extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -27,7 +27,7 @@ public function setUp() public function testDAYS360($expectedResult, $startDate, $endDate, $method) { $result = DateTime::DAYS360($startDate, $endDate, $method); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerDAYS360() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php index 6e63b1db2b..0d805245d2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php @@ -9,7 +9,7 @@ class DaysTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -26,7 +26,7 @@ public function setUp() public function testDAYS($expectedResult, $endDate, $startDate) { $result = DateTime::DAYS($endDate, $startDate); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerDAYS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php index eead74417d..fbd4dee476 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php @@ -9,7 +9,7 @@ class EDateTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -26,7 +26,7 @@ public function setUp() public function testEDATE($expectedResult, $dateValue, $adjustmentMonths) { $result = DateTime::EDATE($dateValue, $adjustmentMonths); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerEDATE() @@ -39,7 +39,8 @@ public function testEDATEtoUnixTimestamp() Functions::setReturnDateType(Functions::RETURNDATE_UNIX_TIMESTAMP); $result = DateTime::EDATE('2012-1-26', -1); - $this->assertEquals(1324857600, $result, '', 1E-8); + $this->assertEquals(1324857600, $result); + $this->assertEqualsWithDelta(1324857600, $result, 1E-8); } public function testEDATEtoDateTimeObject() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php index 5e1c52a13d..deb679929a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php @@ -9,7 +9,7 @@ class EoMonthTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -26,7 +26,7 @@ public function setUp() public function testEOMONTH($expectedResult, $dateValue, $adjustmentMonths) { $result = DateTime::EOMONTH($dateValue, $adjustmentMonths); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerEOMONTH() @@ -39,7 +39,8 @@ public function testEOMONTHtoUnixTimestamp() Functions::setReturnDateType(Functions::RETURNDATE_UNIX_TIMESTAMP); $result = DateTime::EOMONTH('2012-1-26', -1); - $this->assertEquals(1325289600, $result, '', 1E-8); + $this->assertEquals(1325289600, $result); + $this->assertEqualsWithDelta(1325289600, $result, 1E-8); } public function testEOMONTHtoDateTimeObject() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php index a7a4d0fa13..dc6931010c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php @@ -9,7 +9,7 @@ class HourTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -25,7 +25,7 @@ public function setUp() public function testHOUR($expectedResult, $dateTimeValue) { $result = DateTime::HOUROFDAY($dateTimeValue); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerHOUR() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php index 39c9f036dd..61a8427a10 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php @@ -9,7 +9,7 @@ class IsoWeekNumTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -25,7 +25,7 @@ public function setUp() public function testISOWEEKNUM($expectedResult, $dateValue) { $result = DateTime::ISOWEEKNUM($dateValue); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerISOWEEKNUM() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php index c432707966..986ce48049 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php @@ -9,7 +9,7 @@ class MinuteTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -25,7 +25,7 @@ public function setUp() public function testMINUTE($expectedResult, $dateTimeValue) { $result = DateTime::MINUTE($dateTimeValue); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerMINUTE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php index 2bec0557b3..d0060af19c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php @@ -9,7 +9,7 @@ class MonthTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -25,7 +25,7 @@ public function setUp() public function testMONTH($expectedResult, $dateTimeValue) { $result = DateTime::MONTHOFYEAR($dateTimeValue); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerMONTH() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php index e1aa446f29..f4340d9cda 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php @@ -9,7 +9,7 @@ class NetworkDaysTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -24,7 +24,7 @@ public function setUp() public function testNETWORKDAYS($expectedResult, ...$args) { $result = DateTime::NETWORKDAYS(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerNETWORKDAYS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php index 40418706f0..aa1dba7ea6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php @@ -9,7 +9,7 @@ class SecondTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -25,7 +25,7 @@ public function setUp() public function testSECOND($expectedResult, $dateTimeValue) { $result = DateTime::SECOND($dateTimeValue); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerSECOND() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php index 8debe7a1a1..3be2678672 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php @@ -9,7 +9,7 @@ class TimeTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -24,7 +24,7 @@ public function setUp() public function testTIME($expectedResult, ...$args) { $result = DateTime::TIME(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerTIME() @@ -37,7 +37,7 @@ public function testTIMEtoUnixTimestamp() Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC); $result = DateTime::TIME(7, 30, 20); - $this->assertEquals(27020, $result, '', 1E-8); + $this->assertEqualsWithDelta(27020, $result, 1E-8); } public function testTIMEtoDateTimeObject() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php index 52fe18f6ad..263e665e56 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php @@ -9,7 +9,7 @@ class TimeValueTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -25,7 +25,7 @@ public function setUp() public function testTIMEVALUE($expectedResult, $timeValue) { $result = DateTime::TIMEVALUE($timeValue); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerTIMEVALUE() @@ -38,7 +38,8 @@ public function testTIMEVALUEtoUnixTimestamp() Functions::setReturnDateType(Functions::RETURNDATE_UNIX_TIMESTAMP); $result = DateTime::TIMEVALUE('7:30:20'); - $this->assertEquals(23420, $result, '', 1E-8); + $this->assertEquals(23420, $result); + $this->assertEqualsWithDelta(23420, $result, 1E-8); } public function testTIMEVALUEtoDateTimeObject() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php index 9636e7e764..72c8ac232a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php @@ -9,7 +9,7 @@ class WeekDayTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -24,7 +24,7 @@ public function setUp() public function testWEEKDAY($expectedResult, ...$args) { $result = DateTime::WEEKDAY(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerWEEKDAY() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php index f310aa1814..a7c3260dad 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php @@ -9,7 +9,7 @@ class WeekNumTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -24,7 +24,7 @@ public function setUp() public function testWEEKNUM($expectedResult, ...$args) { $result = DateTime::WEEKNUM(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerWEEKNUM() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php index d735203cc3..2edc8609cc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php @@ -9,7 +9,7 @@ class WorkDayTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -24,7 +24,7 @@ public function setUp() public function testWORKDAY($expectedResult, ...$args) { $result = DateTime::WORKDAY(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerWORKDAY() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php index 60c3581912..2d87c53263 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php @@ -9,7 +9,7 @@ class YearFracTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -24,7 +24,7 @@ public function setUp() public function testYEARFRAC($expectedResult, ...$args) { $result = DateTime::YEARFRAC(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerYEARFRAC() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php index 8b59e0aa56..3545140f19 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php @@ -9,7 +9,7 @@ class YearTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -25,7 +25,7 @@ public function setUp() public function testYEAR($expectedResult, $dateTimeValue) { $result = DateTime::YEAR($dateTimeValue); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerYEAR() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php index adaddd6e19..e6fa29245c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php @@ -10,7 +10,7 @@ class BesselITest extends TestCase { const BESSEL_PRECISION = 1E-8; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -23,7 +23,7 @@ public function setUp() public function testBESSELI($expectedResult, ...$args) { $result = Engineering::BESSELI(...$args); - $this->assertEquals($expectedResult, $result, '', self::BESSEL_PRECISION); + $this->assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); } public function providerBESSELI() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php index 4787fa1a84..1458ece94a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php @@ -10,7 +10,7 @@ class BesselJTest extends TestCase { const BESSEL_PRECISION = 1E-8; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -23,7 +23,7 @@ public function setUp() public function testBESSELJ($expectedResult, ...$args) { $result = Engineering::BESSELJ(...$args); - $this->assertEquals($expectedResult, $result, '', self::BESSEL_PRECISION); + $this->assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); } public function providerBESSEJ() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php index 865244af52..f2ab0529be 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php @@ -10,7 +10,7 @@ class BesselKTest extends TestCase { const BESSEL_PRECISION = 1E-8; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -23,7 +23,7 @@ public function setUp() public function testBESSELK($expectedResult, ...$args) { $result = Engineering::BESSELK(...$args); - $this->assertEquals($expectedResult, $result, '', self::BESSEL_PRECISION); + $this->assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); } public function providerBESSELK() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php index e79b9871b8..66af44c94d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php @@ -10,7 +10,7 @@ class BesselYTest extends TestCase { const BESSEL_PRECISION = 1E-8; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -23,7 +23,7 @@ public function setUp() public function testBESSELY($expectedResult, ...$args) { $result = Engineering::BESSELY(...$args); - $this->assertEquals($expectedResult, $result, '', self::BESSEL_PRECISION); + $this->assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); } public function providerBESSELY() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php index 917493eb19..61fe3423b2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php @@ -8,7 +8,7 @@ class Bin2DecTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php index 1366a7a998..77e9722d4b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php @@ -8,7 +8,7 @@ class Bin2HexTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php index acec8843d2..a8f7095ee7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php @@ -8,7 +8,7 @@ class Bin2OctTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php index 7e2d6ae7cf..e60aa79b07 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php @@ -8,7 +8,7 @@ class BitAndTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php index 8ae9db687d..47703c51bf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php @@ -8,7 +8,7 @@ class BitLShiftTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php index 4719d1baa8..19a5a6b1ee 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php @@ -8,7 +8,7 @@ class BitOrTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php index 07b6b542e4..597fa33388 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php @@ -8,7 +8,7 @@ class BitRShiftTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php index ca29c064f9..fc3df89378 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php @@ -8,7 +8,7 @@ class BitXorTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php index d7686fb01f..dbdd825796 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php @@ -8,7 +8,7 @@ class ComplexTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php index f09479ade2..593bfc65b0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php @@ -8,7 +8,7 @@ class ConvertUoMTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php index 3856c21393..f5c8f089f1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php @@ -8,7 +8,7 @@ class Dec2BinTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php index bc9781dc2b..2bdeff25fa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php @@ -8,7 +8,7 @@ class Dec2HexTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php index 4b225b7f0b..93fa46c7d9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php @@ -8,7 +8,7 @@ class Dec2OctTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php index daf30e7105..241530ac91 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php @@ -8,7 +8,7 @@ class DeltaTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php index 36d89f2ea3..7dbb415869 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php @@ -10,7 +10,7 @@ class ErfCTest extends TestCase { const ERF_PRECISION = 1E-12; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -23,7 +23,8 @@ public function setUp() public function testERFC($expectedResult, ...$args) { $result = Engineering::ERFC(...$args); - $this->assertEquals($expectedResult, $result, '', self::ERF_PRECISION); + $this->assertEquals($expectedResult, $result); + $this->assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION); } public function providerERFC() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php index 6511b5d5de..f42ebde116 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php @@ -10,7 +10,7 @@ class ErfPreciseTest extends TestCase { const ERF_PRECISION = 1E-12; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -23,7 +23,8 @@ public function setUp() public function testERFPRECISE($expectedResult, ...$args) { $result = Engineering::ERFPRECISE(...$args); - $this->assertEquals($expectedResult, $result, '', self::ERF_PRECISION); + $this->assertEquals($expectedResult, $result); + $this->assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION); } public function providerERFPRECISE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php index 709131fa21..fbc004fad3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php @@ -10,7 +10,7 @@ class ErfTest extends TestCase { const ERF_PRECISION = 1E-12; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -23,7 +23,8 @@ public function setUp() public function testERF($expectedResult, ...$args) { $result = Engineering::ERF(...$args); - $this->assertEquals($expectedResult, $result, '', self::ERF_PRECISION); + $this->assertEquals($expectedResult, $result); + $this->assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION); } public function providerERF() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php index 1a6b63b62e..b96dbcec04 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php @@ -8,7 +8,7 @@ class GeStepTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php index bb7b62bd77..4e779fbace 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php @@ -8,7 +8,7 @@ class Hex2BinTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php index 38f2a28a0d..acefad656a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php @@ -8,7 +8,7 @@ class Hex2DecTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php index 0ae0f44d98..2db814d68f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php @@ -8,7 +8,7 @@ class Hex2OctTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php index e52d32b2b1..fb68d58073 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php @@ -10,7 +10,7 @@ class ImAbsTest extends TestCase { const COMPLEX_PRECISION = 1E-8; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -24,7 +24,7 @@ public function setUp() public function testIMABS($expectedResult, $value) { $result = Engineering::IMABS($value); - $this->assertEquals($expectedResult, $result, '', self::COMPLEX_PRECISION); + $this->assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } public function providerIMABS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php index 85e613527a..ffc051ef2d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php @@ -10,7 +10,7 @@ class ImArgumentTest extends TestCase { const COMPLEX_PRECISION = 1E-8; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -24,7 +24,7 @@ public function setUp() public function testIMARGUMENT($expectedResult, $value) { $result = Engineering::IMARGUMENT($value); - $this->assertEquals($expectedResult, $result, '', self::COMPLEX_PRECISION); + $this->assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } public function providerIMARGUMENT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php index 189cc593fa..d431429a3e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php @@ -16,13 +16,13 @@ class ImConjugateTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php index d8dc223290..1e7a0ac008 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php @@ -16,13 +16,13 @@ class ImCosTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php index baa7e94a6d..ada76b6250 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php @@ -16,13 +16,13 @@ class ImCoshTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php index 9e5e6dd644..91089820a9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php @@ -16,13 +16,13 @@ class ImCotTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php index c7e11bad18..151216db47 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php @@ -16,13 +16,13 @@ class ImCscTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php index 14bdd30ae9..5ce9d6bc5f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php @@ -16,13 +16,13 @@ class ImCschTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php index c3e4fb6071..ee75c99670 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php @@ -16,13 +16,13 @@ class ImDivTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php index cfc7d4fe3d..8d38fe5722 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php @@ -16,13 +16,13 @@ class ImExpTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php index d9d446603c..54bf5db00d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php @@ -16,13 +16,13 @@ class ImLnTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php index c748ed4157..69930da5a0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php @@ -16,13 +16,13 @@ class ImLog10Test extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php index fceda8fd15..aee9f4427e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php @@ -16,13 +16,13 @@ class ImLog2Test extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php index f9dd03806b..6321143986 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php @@ -16,13 +16,13 @@ class ImPowerTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php index b95c600257..d13d1a6c85 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php @@ -16,13 +16,13 @@ class ImProductTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php index 317745a9ed..013e6d934c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php @@ -10,7 +10,7 @@ class ImRealTest extends TestCase { const COMPLEX_PRECISION = 1E-8; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -24,7 +24,7 @@ public function setUp() public function testIMREAL($expectedResult, $value) { $result = Engineering::IMREAL($value); - $this->assertEquals($expectedResult, $result, '', self::COMPLEX_PRECISION); + $this->assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } public function providerIMREAL() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php index 852e4acbb2..4f2957fa1a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php @@ -16,13 +16,13 @@ class ImSecTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php index 63a87e0421..6b842566b4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php @@ -16,13 +16,13 @@ class ImSechTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php index 4bb0aaeba6..ca3ceb228d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php @@ -16,13 +16,13 @@ class ImSinTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php index 7640e9b485..b30d8280f9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php @@ -16,13 +16,13 @@ class ImSinhTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php index ae4c445285..0bff1eef3a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php @@ -16,13 +16,13 @@ class ImSqrtTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php index 902be21370..0daa18276e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php @@ -16,13 +16,13 @@ class ImSubTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php index 07f7e11d3c..c4fbc3e72c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php @@ -16,13 +16,13 @@ class ImSumTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php index cb8b961fb7..c3e5eb1c71 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php @@ -16,13 +16,13 @@ class ImTanTest extends TestCase */ protected $complexAssert; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $this->complexAssert = new ComplexAssert(); } - public function tearDown() + protected function tearDown(): void { $this->complexAssert = null; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php index b2e8596816..6f9e67cf9e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php @@ -10,7 +10,7 @@ class ImaginaryTest extends TestCase { const COMPLEX_PRECISION = 1E-8; - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -24,7 +24,7 @@ public function setUp() public function testIMAGINARY($expectedResult, $value) { $result = Engineering::IMAGINARY($value); - $this->assertEquals($expectedResult, $result, '', self::COMPLEX_PRECISION); + $this->assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } public function providerIMAGINARY() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php index e737b12079..97558b6523 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php @@ -8,7 +8,7 @@ class Oct2BinTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php index 6d14e546f6..ed51ab486d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php @@ -8,7 +8,7 @@ class Oct2DecTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php index 5a2252f07e..35764d2be9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php @@ -8,7 +8,7 @@ class Oct2HexTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php index e438ec393d..bc1437a362 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php @@ -8,7 +8,7 @@ class ParseComplexTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php index a89d74f1b9..84f459629a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php @@ -8,7 +8,7 @@ class AccrintMTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testACCRINTM($expectedResult, ...$args) { $result = Financial::ACCRINTM(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerACCRINTM() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php index 31bc3cc577..55ee6747c8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php @@ -8,7 +8,7 @@ class AccrintTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testACCRINT($expectedResult, ...$args) { $result = Financial::ACCRINT(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerACCRINT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php index 69ae43afb8..74c426ea63 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php @@ -8,7 +8,7 @@ class AndTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/FalseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/FalseTest.php index cbd2a8f483..c546554efe 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/FalseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/FalseTest.php @@ -8,7 +8,7 @@ class FalseTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php index 678dcc6ed5..20d71025b8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php @@ -8,7 +8,7 @@ class IfErrorTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php index 16f0314f17..02181b64e8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php @@ -8,7 +8,7 @@ class IfNaTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php index d3a7623f99..6f0b408735 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php @@ -8,7 +8,7 @@ class IfTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php index 1aab0cd163..5dd40fdc30 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php @@ -8,7 +8,7 @@ class NotTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php index a47b83bce0..a91fc5b0cf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php @@ -8,7 +8,7 @@ class OrTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php index aa3b752585..d85ca4f319 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php @@ -8,7 +8,7 @@ class SwitchTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php index 075820a988..77166db09b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php @@ -8,7 +8,7 @@ class TrueTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php index 8a41f0d047..dc264f527f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php @@ -8,7 +8,7 @@ class XorTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php index c1e043e0c2..9e72056658 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php @@ -8,7 +8,7 @@ class ChooseTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php index 06872eec60..f34a3f64ba 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php @@ -8,7 +8,7 @@ class ColumnsTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php index cb1f08fa2b..2baaa4f83d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php @@ -8,7 +8,7 @@ class HLookupTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php index 0da7de1bc3..972e7511ef 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php @@ -8,7 +8,7 @@ class IndexTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php index 0c5e610e1f..f643783d90 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php @@ -8,7 +8,7 @@ class LookupTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php index 42c7b3bb79..3c956b663d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php @@ -8,7 +8,7 @@ class MatchTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php index 46dd985108..0a97382ffe 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php @@ -8,7 +8,7 @@ class RowsTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php index ea9afa20b4..cf4b3059e9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php @@ -8,7 +8,7 @@ class VLookupTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php index 898c1939ac..e77c4ffbbb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php @@ -8,7 +8,7 @@ class AcotTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testACOT($expectedResult, $number) { $result = MathTrig::ACOT($number); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerACOT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php index abc899b316..695df0108f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php @@ -8,7 +8,7 @@ class AcothTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testACOTH($expectedResult, $number) { $result = MathTrig::ACOTH($number); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerACOTH() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php index f3f5c9652f..10135e115e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php @@ -8,7 +8,7 @@ class ArabicTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php index db11c89c8d..dc96530573 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php @@ -8,7 +8,7 @@ class Atan2Test extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -23,7 +23,7 @@ public function setUp() public function testATAN2($expectedResult, $x, $y) { $result = MathTrig::ATAN2($x, $y); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerATAN2() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php index 3aaf68b5bf..1368df190a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php @@ -8,7 +8,7 @@ class BaseTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php index ec0b32e049..f60fae7265 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php @@ -8,7 +8,7 @@ class CeilingTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testCEILING($expectedResult, ...$args) { $result = MathTrig::CEILING(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCEILING() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php index 7d1002a21d..d3a4ee4430 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php @@ -8,7 +8,7 @@ class CombinTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testCOMBIN($expectedResult, ...$args) { $result = MathTrig::COMBIN(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOMBIN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php index cd52472517..6263c9fd88 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php @@ -8,7 +8,7 @@ class CotTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testCOT($expectedResult, $angle) { $result = MathTrig::COT($angle); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php index 2ed5515da7..2dfa57a59c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php @@ -8,7 +8,7 @@ class CothTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testCOTH($expectedResult, $angle) { $result = MathTrig::COTH($angle); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOTH() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php index f84415a3dd..1b0cdbf7e3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php @@ -8,7 +8,7 @@ class CscTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testCSC($expectedResult, $angle) { $result = MathTrig::CSC($angle); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCSC() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php index 98b02f3ab8..82e286da09 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php @@ -8,7 +8,7 @@ class CschTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testCSCH($expectedResult, $angle) { $result = MathTrig::CSCH($angle); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCSCH() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php index 65ed5f54e6..3bd84ddd0d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php @@ -8,7 +8,7 @@ class EvenTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testEVEN($expectedResult, $value) { $result = MathTrig::EVEN($value); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerEVEN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php index 5605e40c26..2dfe8fad25 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php @@ -8,7 +8,7 @@ class FactDoubleTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testFACTDOUBLE($expectedResult, $value) { $result = MathTrig::FACTDOUBLE($value); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFACTDOUBLE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php index 38c95ab1f7..0f3294e343 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php @@ -8,7 +8,7 @@ class FactTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testFACT($expectedResult, $value) { $result = MathTrig::FACT($value); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFACT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php index 0e693e80e9..63b694f3c1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php @@ -8,7 +8,7 @@ class FloorMathTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testFLOORMATH($expectedResult, ...$args) { $result = MathTrig::FLOORMATH(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFLOORMATH() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php index 616cb43bb3..e84e596a69 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php @@ -8,7 +8,7 @@ class FloorPreciseTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testFLOOR($expectedResult, ...$args) { $result = MathTrig::FLOORPRECISE(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFLOORPRECISE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php index e43ba3d1ec..60ff5bb7f1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php @@ -8,7 +8,7 @@ class FloorTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testFLOOR($expectedResult, ...$args) { $result = MathTrig::FLOOR(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFLOOR() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php index d066f405c9..d6f588d1a2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php @@ -8,7 +8,7 @@ class GcdTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testGCD($expectedResult, ...$args) { $result = MathTrig::GCD(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerGCD() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php index 58ba3e4443..3a287aa3ee 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php @@ -8,7 +8,7 @@ class IntTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php index 6be79feb30..a5cc2312ef 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php @@ -8,7 +8,7 @@ class LcmTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testLCM($expectedResult, ...$args) { $result = MathTrig::LCM(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerLCM() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php index eccec454c1..2e54654ea8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php @@ -8,7 +8,7 @@ class LogTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testLOG($expectedResult, ...$args) { $result = MathTrig::logBase(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerLOG() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php index d61ceaf808..2a4f1af04d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php @@ -8,7 +8,7 @@ class MInverseTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testMINVERSE($expectedResult, ...$args) { $result = MathTrig::MINVERSE(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerMINVERSE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php index 1e2d65b7b8..337abbea86 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php @@ -8,7 +8,7 @@ class MMultTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testMMULT($expectedResult, ...$args) { $result = MathTrig::MMULT(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerMMULT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php index c02e70ba03..ca14bc1c0e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php @@ -8,7 +8,7 @@ class MRoundTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testMROUND($expectedResult, ...$args) { $result = MathTrig::MROUND(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerMROUND() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php index 4b2d3279a0..84911aafa5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php @@ -8,7 +8,7 @@ class MdeTermTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testMDETERM($expectedResult, ...$args) { $result = MathTrig::MDETERM(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerMDETERM() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php index fa60000e27..8d1666187b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php @@ -8,7 +8,7 @@ class ModTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testMOD($expectedResult, ...$args) { $result = MathTrig::MOD(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerMOD() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php index 3c8d19161b..1f751351af 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php @@ -8,7 +8,7 @@ class MultinomialTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testMULTINOMIAL($expectedResult, ...$args) { $result = MathTrig::MULTINOMIAL(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerMULTINOMIAL() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php index 1183dd5783..8ba4beaf71 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php @@ -8,7 +8,7 @@ class OddTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testODD($expectedResult, $value) { $result = MathTrig::ODD($value); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerODD() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php index 7d86ebf8fb..9df08b5f55 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php @@ -8,7 +8,7 @@ class PowerTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testPOWER($expectedResult, ...$args) { $result = MathTrig::POWER(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerPOWER() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php index bd99fd0e11..fecc806a20 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php @@ -8,7 +8,7 @@ class ProductTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testPRODUCT($expectedResult, ...$args) { $result = MathTrig::PRODUCT(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerPRODUCT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php index ac96f07910..e81414fee9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php @@ -8,7 +8,7 @@ class QuotientTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testQUOTIENT($expectedResult, ...$args) { $result = MathTrig::QUOTIENT(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerQUOTIENT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php index 6a09e458aa..edc7228930 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php @@ -8,7 +8,7 @@ class RomanTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php index a3368827f5..4d95dac7f0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php @@ -8,7 +8,7 @@ class RoundDownTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testROUNDDOWN($expectedResult, ...$args) { $result = MathTrig::ROUNDDOWN(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerROUNDDOWN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php index ba36c77696..143aa65319 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php @@ -8,7 +8,7 @@ class RoundUpTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testROUNDUP($expectedResult, ...$args) { $result = MathTrig::ROUNDUP(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerROUNDUP() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php index c27423461e..944c3e376e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php @@ -8,7 +8,7 @@ class SecTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testSEC($expectedResult, $angle) { $result = MathTrig::SEC($angle); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSEC() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php index c9ff29bf87..42fecb0b0f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php @@ -8,7 +8,7 @@ class SechTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testSECH($expectedResult, $angle) { $result = MathTrig::SECH($angle); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSECH() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php index ef8ee62e60..7923fbc1d7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php @@ -8,7 +8,7 @@ class SeriesSumTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testSERIESSUM($expectedResult, ...$args) { $result = MathTrig::SERIESSUM(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSERIESSUM() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php index e6f7becd3f..c0ff7b5ec2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php @@ -8,7 +8,7 @@ class SignTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testSIGN($expectedResult, $value) { $result = MathTrig::SIGN($value); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSIGN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php index 58b2a3dc61..19a182c540 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php @@ -8,7 +8,7 @@ class SqrtPiTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testSQRTPI($expectedResult, $value) { $result = MathTrig::SQRTPI($value); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSQRTPI() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php index 91f662634d..2711c657da 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php @@ -12,7 +12,7 @@ class SubTotalTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -49,7 +49,7 @@ public function testSUBTOTAL($expectedResult, ...$args) array_push($args, $cellReference); $result = MathTrig::SUBTOTAL(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUBTOTAL() @@ -120,7 +120,7 @@ public function testHiddenSUBTOTAL($expectedResult, ...$args) array_push($args, $cellReference); $result = MathTrig::SUBTOTAL(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerHiddenSUBTOTAL() @@ -188,7 +188,7 @@ public function testNestedSUBTOTAL($expectedResult, ...$args) array_push($args, $cellReference); $result = MathTrig::SUBTOTAL(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerNestedSUBTOTAL() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php index 51755dc8c0..359fef443f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php @@ -8,7 +8,7 @@ class SumIfTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testSUMIF($expectedResult, ...$args) { $result = MathTrig::SUMIF(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUMIF() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php index 9336cec822..9127705a4d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php @@ -8,7 +8,7 @@ class SumIfsTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testSUMIFS($expectedResult, ...$args) { $result = MathTrig::SUMIFS(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUMIFS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php index 13558661ad..c409ee184c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php @@ -8,7 +8,7 @@ class SumProductTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testSUMPRODUCT($expectedResult, ...$args) { $result = MathTrig::SUMPRODUCT(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUMPRODUCT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php index 91c6ec1506..bfd2d87490 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php @@ -8,7 +8,7 @@ class SumSqTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testSUMSQ($expectedResult, ...$args) { $result = MathTrig::SUMSQ(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUMSQ() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php index b890461214..937043ee5d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php @@ -8,7 +8,7 @@ class SumX2MY2Test extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testSUMX2MY2($expectedResult, ...$args) { $result = MathTrig::SUMX2MY2(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUMX2MY2() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php index ce016e6fb7..c58f28a29d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php @@ -8,7 +8,7 @@ class SumX2PY2Test extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testSUMX2PY2($expectedResult, ...$args) { $result = MathTrig::SUMX2PY2(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUMX2PY2() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php index 67e3c80dee..a4a6e8a1bc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php @@ -8,7 +8,7 @@ class SumXMY2Test extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testSUMXMY2($expectedResult, ...$args) { $result = MathTrig::SUMXMY2(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUMXMY2() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php index fec384286e..b5bb6e43fb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php @@ -8,7 +8,7 @@ class TruncTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testTRUNC($expectedResult, ...$args) { $result = MathTrig::TRUNC(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerTRUNC() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php index 9866082fd6..94f214a3ab 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php @@ -8,7 +8,7 @@ class AveDevTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testAVEDEV($expectedResult, ...$args) { $result = Statistical::AVEDEV(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerAVEDEV() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php index b0c6ff8125..526875f3e7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php @@ -8,7 +8,7 @@ class AverageATest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testAVERAGEA($expectedResult, ...$args) { $result = Statistical::AVERAGEA(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerAVERAGEA() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php index 25462c7fa0..0d7863bf94 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php @@ -8,7 +8,7 @@ class AverageIfTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testAVERAGEIF($expectedResult, ...$args) { $result = Statistical::AVERAGEIF(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerAVERAGEIF() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php index 87d7bed8d1..30503a3a2f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php @@ -8,7 +8,7 @@ class AverageTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testAVERAGE($expectedResult, ...$args) { $result = Statistical::AVERAGE(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerAVERAGE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php index d40d0c3aec..6b1aed8235 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php @@ -8,7 +8,7 @@ class BetaDistTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testBETADIST($expectedResult, ...$args) { $result = Statistical::BETADIST(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerBETADIST() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php index 3721c50d05..b0fc38d7ca 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php @@ -8,7 +8,7 @@ class BetaInvTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testBETAINV($expectedResult, ...$args) { $result = Statistical::BETAINV(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerBETAINV() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php index c9cfcf8ed4..c16ff6c27a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php @@ -8,7 +8,7 @@ class BinomDistTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testBINOMDIST($expectedResult, ...$args) { $result = Statistical::BINOMDIST(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerBINOMDIST() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php index 1e2eb13af3..3d027c2343 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php @@ -8,7 +8,7 @@ class ChiDistTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testCHIDIST($expectedResult, ...$args) { $result = Statistical::CHIDIST(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCHIDIST() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php index c99c8f9c5e..d176ee78e9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php @@ -8,7 +8,7 @@ class ChiInvTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testCHIINV($expectedResult, ...$args) { $result = Statistical::CHIINV(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCHIINV() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php index 5f6bb2e86a..5d4472d4e9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php @@ -8,7 +8,7 @@ class ConfidenceTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testCONFIDENCE($expectedResult, ...$args) { $result = Statistical::CONFIDENCE(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCONFIDENCE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php index cefdff7b80..c489d4c80c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php @@ -8,7 +8,7 @@ class CorrelTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testCORREL($expectedResult, array $xargs, array $yargs) { $result = Statistical::CORREL($xargs, $yargs); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCORREL() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php index 51538a2c11..4edb187464 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php @@ -8,7 +8,7 @@ class CountATest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testCOUNTA($expectedResult, ...$args) { $result = Statistical::COUNTA(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOUNTA() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php index 86979d87ab..5bd008e85a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php @@ -8,7 +8,7 @@ class CountBlankTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testCOUNTBLANK($expectedResult, ...$args) { $result = Statistical::COUNTBLANK(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOUNTBLANK() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php index 92c398659f..ec3a25b36c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php @@ -8,7 +8,7 @@ class CountIfTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testCOUNTIF($expectedResult, ...$args) { $result = Statistical::COUNTIF(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOUNTIF() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php index 472d9d61b8..0170c277c0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php @@ -8,7 +8,7 @@ class CountIfsTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testCOUNTIFS($expectedResult, ...$args) { $result = Statistical::COUNTIFS(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOUNTIFS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php index 73c20d25cd..798bcbd995 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php @@ -8,7 +8,7 @@ class CountTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testBasicCOUNT($expectedResult, ...$args) { $result = Statistical::COUNT(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerBasicCOUNT() @@ -37,7 +37,7 @@ public function providerBasicCOUNT() public function testExcelCOUNT($expectedResult, ...$args) { $result = Statistical::COUNT(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerExcelCOUNT() @@ -55,7 +55,7 @@ public function testOpenOfficeCOUNT($expectedResult, ...$args) Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); $result = Statistical::COUNT(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerOpenOfficeCOUNT() @@ -73,7 +73,7 @@ public function testGnumericCOUNT($expectedResult, ...$args) Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); $result = Statistical::COUNT(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerGnumericCOUNT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php index 7d70283a4c..7658d44554 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php @@ -8,7 +8,7 @@ class CovarTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testCOVAR($expectedResult, ...$args) { $result = Statistical::COVAR(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOVAR() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php index 9d61356f28..a9184eddbe 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php @@ -8,7 +8,7 @@ class ExponDistTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testEXPONDIST($expectedResult, ...$args) { $result = Statistical::EXPONDIST(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerEXPONDIST() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php index a6c2f695c0..0488d50400 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php @@ -8,7 +8,7 @@ class FisherInvTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testFISHERINV($expectedResult, $value) { $result = Statistical::FISHERINV($value); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFISHERINV() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php index ec5d928c99..25ca6b481b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php @@ -8,7 +8,7 @@ class FisherTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testFISHER($expectedResult, $value) { $result = Statistical::FISHER($value); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFISHER() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php index 2fcb1e5491..e0227ad795 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php @@ -8,7 +8,7 @@ class ForecastTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testFORECAST($expectedResult, ...$args) { $result = Statistical::FORECAST(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFORECAST() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php index 51235f9041..325f662dd3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php @@ -8,7 +8,7 @@ class GammaDistTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testGAMMADIST($expectedResult, ...$args) { $result = Statistical::GAMMADIST(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerGAMMADIST() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php index 2cb243fc64..76f5e30c3c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php @@ -8,7 +8,7 @@ class GammaInvTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testGAMMAINV($expectedResult, ...$args) { $result = Statistical::GAMMAINV(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerGAMMAINV() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php index 436996ba02..11363b1f23 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php @@ -8,7 +8,7 @@ class GammaLnTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -22,7 +22,7 @@ public function setUp() public function testGAMMALN($expectedResult, $value) { $result = Statistical::GAMMALN($value); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerGAMMALN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php index b927bdacf1..cbb7b33d14 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php @@ -8,7 +8,7 @@ class GeoMeanTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testGEOMEAN($expectedResult, ...$args) { $result = Statistical::GEOMEAN(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerGEOMEAN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php index 5b57ee3858..5777204dbe 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php @@ -8,7 +8,7 @@ class HarMeanTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testHARMEAN($expectedResult, ...$args) { $result = Statistical::HARMEAN(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerHARMEAN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php index b66bd76678..9362e692e5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php @@ -8,7 +8,7 @@ class InterceptTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testINTERCEPT($expectedResult, array $xargs, array $yargs) { $result = Statistical::INTERCEPT($xargs, $yargs); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerINTERCEPT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php index 5e4ae37699..06fc226313 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php @@ -8,7 +8,7 @@ class MaxIfsTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testMAXIFS($expectedResult, ...$args) { $result = Statistical::MAXIFS(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerMAXIFS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php index bc6139ced9..29497689ca 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php @@ -8,7 +8,7 @@ class MedianTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testMEDIAN($expectedResult, ...$args) { $result = Statistical::MEDIAN(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerMEDIAN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php index b0ab4088f5..4721043f0b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php @@ -8,7 +8,7 @@ class MinIfsTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testMINIFS($expectedResult, ...$args) { $result = Statistical::MINIFS(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerMINIFS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php index 8f4eeb6977..4e0c9da949 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php @@ -8,7 +8,7 @@ class PermutTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testPERMUT($expectedResult, ...$args) { $result = Statistical::PERMUT(...$args); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerPERMUT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php index cf91b3142b..229c221fcd 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php @@ -8,7 +8,7 @@ class RsqTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testRSQ($expectedResult, array $xargs, array $yargs) { $result = Statistical::RSQ($xargs, $yargs); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerRSQ() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php index b62fede30d..4bdaef025b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php @@ -8,7 +8,7 @@ class SlopeTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testSLOPE($expectedResult, array $xargs, array $yargs) { $result = Statistical::SLOPE($xargs, $yargs); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSLOPE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php index fe8d2ae543..271c2175ba 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php @@ -8,7 +8,7 @@ class SteyxTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -21,7 +21,7 @@ public function setUp() public function testSTEYX($expectedResult, array $xargs, array $yargs) { $result = Statistical::STEYX($xargs, $yargs); - $this->assertEquals($expectedResult, $result, '', 1E-12); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSTEYX() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php index 7ae50fa764..66bbdc20eb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php @@ -9,7 +9,7 @@ class CharTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php index 3286e6fd3c..0f0e391af4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php @@ -9,7 +9,7 @@ class CleanTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php index a22c140168..99f7dcf5b9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php @@ -9,7 +9,7 @@ class CodeTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php index 46ea0cb799..7b93f56eb4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php @@ -9,7 +9,7 @@ class ConcatenateTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php index af49a7d03e..827860bc0b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php @@ -9,7 +9,7 @@ class DollarTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php index 8c47be4707..ddf685c4b2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php @@ -9,7 +9,7 @@ class ExactTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php index 86ae5e77fd..495339ab9c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php @@ -9,7 +9,7 @@ class FindTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php index d46f0e4861..af9b02ca26 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php @@ -9,7 +9,7 @@ class FixedTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php index 18d6c2584b..b42a4ac33d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php @@ -9,7 +9,7 @@ class LeftTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php index ad3dc00c87..ad5bffb695 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php @@ -9,7 +9,7 @@ class LenTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php index 52fd3afe52..5651e7ae7a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php @@ -9,7 +9,7 @@ class LowerTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php index d0db50e061..cda1dc015a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php @@ -9,7 +9,7 @@ class MidTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php index 9de91f7eb7..3ffd147d3f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php @@ -9,7 +9,7 @@ class NumberValueTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php index 4e1b0b76cf..0aaf968f10 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php @@ -9,7 +9,7 @@ class ProperTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php index dd4411a0c4..e7592a1f6b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php @@ -9,7 +9,7 @@ class ReplaceTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php index 64fb0e5b6f..3ec883f4d3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php @@ -9,7 +9,7 @@ class RightTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php index c77742b611..c8b3040b61 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php @@ -9,7 +9,7 @@ class SearchTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php index 2fdb109136..a88ee81dc9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php @@ -9,7 +9,7 @@ class SubstituteTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php index 90104a178d..4cdf3fb406 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php @@ -9,7 +9,7 @@ class TTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php index 690db3463d..c4c929db5b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php @@ -9,7 +9,7 @@ class TextJoinTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php index dbcd0900a7..306530a558 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php @@ -9,7 +9,7 @@ class TextTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php index 2a9fe94e85..aa89642775 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php @@ -9,7 +9,7 @@ class TrimTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php index 60c894d673..cdfdb49f48 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php @@ -9,7 +9,7 @@ class UpperTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php index b6c29f3d45..f60a12a92d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php @@ -9,7 +9,7 @@ class ValueTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -17,7 +17,7 @@ public function setUp() StringHelper::setCurrencyCode('$'); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); StringHelper::setDecimalSeparator('.'); @@ -38,7 +38,7 @@ public function testVALUE($expectedResult, $value) StringHelper::setCurrencyCode('$'); $result = TextData::VALUE($value); - $this->assertEquals($expectedResult, $result, '', 1E-8); + $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerVALUE() diff --git a/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php index 2e8e7e9d17..b0c8eb870c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php @@ -10,13 +10,13 @@ class FunctionsTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); } - public function tearDown() + protected function tearDown(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -114,7 +114,7 @@ public function testVALUE() public function testIsBlank($expectedResult, ...$args) { $result = Functions::isBlank(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerIsBlank() @@ -130,7 +130,7 @@ public function providerIsBlank() public function testIsErr($expectedResult, ...$args) { $result = Functions::isErr(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerIsErr() @@ -146,7 +146,7 @@ public function providerIsErr() public function testIsError($expectedResult, ...$args) { $result = Functions::isError(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerIsError() @@ -162,7 +162,7 @@ public function providerIsError() public function testErrorType($expectedResult, ...$args) { $result = Functions::errorType(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerErrorType() @@ -178,7 +178,7 @@ public function providerErrorType() public function testIsLogical($expectedResult, ...$args) { $result = Functions::isLogical(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerIsLogical() @@ -194,7 +194,7 @@ public function providerIsLogical() public function testIsNa($expectedResult, ...$args) { $result = Functions::isNa(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerIsNa() @@ -210,7 +210,7 @@ public function providerIsNa() public function testIsNumber($expectedResult, ...$args) { $result = Functions::isNumber(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerIsNumber() @@ -226,7 +226,7 @@ public function providerIsNumber() public function testIsText($expectedResult, ...$args) { $result = Functions::isText(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerIsText() @@ -242,7 +242,7 @@ public function providerIsText() public function testIsNonText($expectedResult, ...$args) { $result = Functions::isNonText(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerIsNonText() @@ -258,7 +258,7 @@ public function providerIsNonText() public function testIsEven($expectedResult, ...$args) { $result = Functions::isEven(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerIsEven() @@ -274,7 +274,7 @@ public function providerIsEven() public function testIsOdd($expectedResult, ...$args) { $result = Functions::isOdd(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerIsOdd() @@ -290,7 +290,7 @@ public function providerIsOdd() public function testTYPE($expectedResult, ...$args) { $result = Functions::TYPE(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerTYPE() @@ -306,7 +306,7 @@ public function providerTYPE() public function testN($expectedResult, ...$args) { $result = Functions::n(...$args); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerN() @@ -359,7 +359,7 @@ public function testIsFormula($expectedResult, $reference, $value = 'undefined') } $result = Functions::isFormula($reference, $ourCell); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerIsFormula() diff --git a/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php b/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php index 9d7da8ddae..5694d85984 100644 --- a/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php @@ -14,7 +14,7 @@ */ class LookupRefTest extends TestCase { - public function setUp() + protected function setUp(): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } @@ -66,7 +66,7 @@ public function testFormulaText($expectedResult, $reference, $value = 'undefined } $result = LookupRef::FORMULATEXT($reference, $ourCell); - self::assertEquals($expectedResult, $result, '', 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerFormulaText() diff --git a/tests/PhpSpreadsheetTests/Helper/SampleTest.php b/tests/PhpSpreadsheetTests/Helper/SampleTest.php index 121ec14808..e97941f766 100644 --- a/tests/PhpSpreadsheetTests/Helper/SampleTest.php +++ b/tests/PhpSpreadsheetTests/Helper/SampleTest.php @@ -32,18 +32,6 @@ public function providerSample() 'Chart/32_Chart_read_write_HTML.php', // idem ]; - // TCPDF does not support PHP 7.2 - if (version_compare(PHP_VERSION, '7.2.0') >= 0) { - $skipped[] = 'Pdf/21_Pdf_TCPDF.php'; - } - - // DomPDF does not support PHP 7.3 - if (version_compare(PHP_VERSION, '7.2.99') >= 0) { - $skipped[] = 'Basic/26_Utf8.php'; - $skipped[] = 'Pdf/21_Pdf_Domdf.php'; - $skipped[] = 'Pdf/21_Pdf_mPDF.php'; - } - // Unfortunately some tests are too long be ran with code-coverage // analysis on Travis, so we need to exclude them global $argv; diff --git a/tests/PhpSpreadsheetTests/Reader/HtmlTest.php b/tests/PhpSpreadsheetTests/Reader/HtmlTest.php index c692e537d8..a91fe73dc2 100644 --- a/tests/PhpSpreadsheetTests/Reader/HtmlTest.php +++ b/tests/PhpSpreadsheetTests/Reader/HtmlTest.php @@ -289,12 +289,12 @@ public function testCanApplyCellWrapping() $cellStyle = $firstSheet->getStyle('A2'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A2')->getValue(); - $this->assertContains("\n", $cellValue); + $this->assertStringContainsString("\n", $cellValue); $cellStyle = $firstSheet->getStyle('A3'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A3')->getValue(); - $this->assertContains("\n", $cellValue); + $this->assertStringContainsString("\n", $cellValue); unlink($filename); } @@ -321,12 +321,12 @@ public function testCanLoadFromString() $cellStyle = $firstSheet->getStyle('A2'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A2')->getValue(); - $this->assertContains("\n", $cellValue); + $this->assertStringContainsString("\n", $cellValue); $cellStyle = $firstSheet->getStyle('A3'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A3')->getValue(); - $this->assertContains("\n", $cellValue); + $this->assertStringContainsString("\n", $cellValue); } public function testCanLoadFromStringIntoExistingSpreadsheet() @@ -352,12 +352,12 @@ public function testCanLoadFromStringIntoExistingSpreadsheet() $cellStyle = $firstSheet->getStyle('A2'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A2')->getValue(); - $this->assertContains("\n", $cellValue); + $this->assertStringContainsString("\n", $cellValue); $cellStyle = $firstSheet->getStyle('A3'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A3')->getValue(); - $this->assertContains("\n", $cellValue); + $this->assertStringContainsString("\n", $cellValue); $reader->setSheetIndex(1); $html = ' diff --git a/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php b/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php index 0d9fc13ff2..6bb1f02127 100644 --- a/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php @@ -9,7 +9,7 @@ class XmlScannerTest extends TestCase { - protected function setUp() + protected function setUp(): void { libxml_disable_entity_loader(false); } diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php index 0544d74af2..54908bc2b6 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php @@ -11,7 +11,7 @@ class Xlsx2Test extends TestCase { - public function tearDown() + protected function tearDown(): void { $outfile = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); if (file_exists($outfile)) { diff --git a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php index 246b5a4733..7c5b08d95b 100644 --- a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php @@ -204,9 +204,6 @@ public function testLoadWithReadFilter() */ public function testLoadXlsxWithDoubleAttrDrawing() { - if (version_compare(PHP_VERSION, '7.0.0', '<')) { - $this->markTestSkipped('Only handled in PHP version >= 7.0.0'); - } $filename = './data/Reader/XLSX/double_attr_drawing.xlsx'; $reader = new Xlsx(); $reader->load($filename); diff --git a/tests/PhpSpreadsheetTests/ReferenceHelperTest.php b/tests/PhpSpreadsheetTests/ReferenceHelperTest.php index c1f13a731e..6de3d79209 100644 --- a/tests/PhpSpreadsheetTests/ReferenceHelperTest.php +++ b/tests/PhpSpreadsheetTests/ReferenceHelperTest.php @@ -7,7 +7,7 @@ class ReferenceHelperTest extends TestCase { - public function setUp() + protected function setUp(): void { } diff --git a/tests/PhpSpreadsheetTests/SettingsTest.php b/tests/PhpSpreadsheetTests/SettingsTest.php index 6878986a4b..1a1d24e76b 100644 --- a/tests/PhpSpreadsheetTests/SettingsTest.php +++ b/tests/PhpSpreadsheetTests/SettingsTest.php @@ -12,13 +12,13 @@ class SettingsTest extends TestCase */ protected $prevValue; - public function setUp() + protected function setUp(): void { $this->prevValue = libxml_disable_entity_loader(); libxml_disable_entity_loader(false); // Enable entity loader } - protected function tearDown() + protected function tearDown(): void { libxml_disable_entity_loader($this->prevValue); } diff --git a/tests/PhpSpreadsheetTests/Shared/DateTest.php b/tests/PhpSpreadsheetTests/Shared/DateTest.php index 5de3470243..8d844cba33 100644 --- a/tests/PhpSpreadsheetTests/Shared/DateTest.php +++ b/tests/PhpSpreadsheetTests/Shared/DateTest.php @@ -55,7 +55,7 @@ public function testDateTimeTimestampToExcel1900($expectedResult, ...$args) Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); $result = Date::timestampToExcel(...$args); - self::assertEquals($expectedResult, $result, '', 1E-5); + self::assertEqualsWithDelta($expectedResult, $result, 1E-5); } public function providerDateTimeTimestampToExcel1900() @@ -73,7 +73,7 @@ public function testDateTimeDateTimeToExcel($expectedResult, ...$args) Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); $result = Date::dateTimeToExcel(...$args); - self::assertEquals($expectedResult, $result, '', 1E-5); + self::assertEqualsWithDelta($expectedResult, $result, 1E-5); } public function providerDateTimeDateTimeToExcel() @@ -91,7 +91,7 @@ public function testDateTimeFormattedPHPToExcel1900($expectedResult, ...$args) Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); $result = Date::formattedPHPToExcel(...$args); - self::assertEquals($expectedResult, $result, '', 1E-5); + self::assertEqualsWithDelta($expectedResult, $result, 1E-5); } public function providerDateTimeFormattedPHPToExcel1900() @@ -127,7 +127,7 @@ public function testDateTimeTimestampToExcel1904($expectedResult, ...$args) Date::setExcelCalendar(Date::CALENDAR_MAC_1904); $result = Date::timestampToExcel(...$args); - self::assertEquals($expectedResult, $result, '', 1E-5); + self::assertEqualsWithDelta($expectedResult, $result, 1E-5); } public function providerDateTimeTimestampToExcel1904() diff --git a/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php b/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php index 61021030a5..fd1ec153d9 100644 --- a/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php +++ b/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php @@ -7,7 +7,7 @@ class StringHelperTest extends TestCase { - public function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/PhpSpreadsheetTests/SpreadsheetTest.php b/tests/PhpSpreadsheetTests/SpreadsheetTest.php index 5173bf22fd..498ce27b94 100644 --- a/tests/PhpSpreadsheetTests/SpreadsheetTest.php +++ b/tests/PhpSpreadsheetTests/SpreadsheetTest.php @@ -11,7 +11,7 @@ class SpreadsheetTest extends TestCase /** @var Spreadsheet */ private $object; - public function setUp() + protected function setUp(): void { parent::setUp(); $this->object = new Spreadsheet(); diff --git a/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php b/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php index fe40361b1e..e0ab660e6a 100644 --- a/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php +++ b/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php @@ -8,7 +8,7 @@ class NumberFormatTest extends TestCase { - public function setUp() + protected function setUp(): void { StringHelper::setDecimalSeparator('.'); StringHelper::setThousandsSeparator(','); diff --git a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/Column/RuleTest.php b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/Column/RuleTest.php index b1da9b3a2a..4a0e5c2c88 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/Column/RuleTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/Column/RuleTest.php @@ -11,7 +11,7 @@ class RuleTest extends TestCase private $mockAutoFilterColumnObject; - public function setUp() + protected function setUp(): void { $this->mockAutoFilterColumnObject = $this->getMockBuilder(Column::class) ->disableOriginalConstructor() diff --git a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php index 855de2bcc5..fd462b43a9 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php @@ -13,7 +13,7 @@ class ColumnTest extends TestCase private $mockAutoFilterObject; - public function setUp() + protected function setUp(): void { $this->mockAutoFilterObject = $this->getMockBuilder(AutoFilter::class) ->disableOriginalConstructor() diff --git a/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php b/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php index aa66eb8e94..c2c7f6fc98 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php @@ -21,7 +21,7 @@ class AutoFilterTest extends TestCase private $cellCollection; - public function setUp() + protected function setUp(): void { $this->mockWorksheetObject = $this->getMockBuilder(Worksheet::class) ->disableOriginalConstructor() diff --git a/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php index 397567407e..5d4706dc99 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php @@ -13,7 +13,7 @@ class ColumnCellIteratorTest extends TestCase public $mockCell; - public function setUp() + protected function setUp(): void { $this->mockCell = $this->getMockBuilder(Cell::class) ->disableOriginalConstructor() diff --git a/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php index 04c626d172..eb0b1e0f04 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php @@ -13,7 +13,7 @@ class ColumnIteratorTest extends TestCase public $mockColumn; - public function setUp() + protected function setUp(): void { $this->mockColumn = $this->getMockBuilder(Column::class) ->disableOriginalConstructor() diff --git a/tests/PhpSpreadsheetTests/Worksheet/ColumnTest.php b/tests/PhpSpreadsheetTests/Worksheet/ColumnTest.php index b1e7b47474..d8c5c9972c 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ColumnTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ColumnTest.php @@ -13,7 +13,7 @@ class ColumnTest extends TestCase public $mockColumn; - public function setUp() + protected function setUp(): void { $this->mockWorksheet = $this->getMockBuilder(Worksheet::class) ->disableOriginalConstructor() diff --git a/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php index a10c7aa536..786a0d1a1d 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php @@ -13,7 +13,7 @@ class RowCellIteratorTest extends TestCase public $mockCell; - public function setUp() + protected function setUp(): void { $this->mockCell = $this->getMockBuilder(Cell::class) ->disableOriginalConstructor() diff --git a/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php index cb0b12d1dc..ea2fe351d4 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php @@ -13,7 +13,7 @@ class RowIteratorTest extends TestCase public $mockRow; - public function setUp() + protected function setUp(): void { $this->mockRow = $this->getMockBuilder(Row::class) ->disableOriginalConstructor() diff --git a/tests/PhpSpreadsheetTests/Worksheet/RowTest.php b/tests/PhpSpreadsheetTests/Worksheet/RowTest.php index 0b2822c3db..ee2dcffb1b 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/RowTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/RowTest.php @@ -13,7 +13,7 @@ class RowTest extends TestCase public $mockRow; - public function setUp() + protected function setUp(): void { $this->mockWorksheet = $this->getMockBuilder(Worksheet::class) ->disableOriginalConstructor() diff --git a/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php b/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php index 0c9995af75..3caaba7c9a 100644 --- a/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php @@ -1,6 +1,6 @@ compatibilityMode); diff --git a/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php b/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php index 2c615b72ce..affb917f0d 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php @@ -1,6 +1,6 @@ currentLocale = setlocale(LC_ALL, '0'); @@ -23,7 +23,7 @@ public function setUp() $this->localeAdjusted = true; } - public function tearDown() + protected function tearDown(): void { if ($this->localeAdjusted) { setlocale(LC_ALL, $this->currentLocale); diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php index 0717fa827b..8e0d654fdf 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php @@ -45,15 +45,15 @@ public function testLoadSaveXlsxWithUnparsedData() unlink($resultFilename); // [Content_Types].xml - $this->assertContains('application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings', $resultContentTypesRaw, 'Content type for printerSettings not found!'); - $this->assertContains('application/vnd.ms-office.vbaProject', $resultContentTypesRaw, 'Content type for VbaProject not found!'); - $this->assertContains('application/vnd.ms-excel.controlproperties+xml', $resultContentTypesRaw, 'Content type for ctrlProp not found!'); + $this->assertStringContainsString('application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings', $resultContentTypesRaw, 'Content type for printerSettings not found!'); + $this->assertStringContainsString('application/vnd.ms-office.vbaProject', $resultContentTypesRaw, 'Content type for VbaProject not found!'); + $this->assertStringContainsString('application/vnd.ms-excel.controlproperties+xml', $resultContentTypesRaw, 'Content type for ctrlProp not found!'); // xl/ctrlProps/ctrlProp1.xml $this->assertNotEmpty($resultControlPropRaw, 'ctrlProp not found!'); // xl/drawings/drawing1.xml - $this->assertContains('assertStringContainsString('assertNotEmpty($resultVmlDrawingRaw, 'vmlDrawing not found!'); @@ -78,12 +78,12 @@ public function testLoadSaveXlsxWithUnparsedData() unset($xmlWorkbook); // xl/worksheets/_rels/sheet1.xml.rels - $this->assertContains('http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings', $resultSheet1RelsRaw, 'Sheet relation with printerSettings not found!'); - $this->assertContains('http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing', $resultSheet1RelsRaw, 'Sheet relation with vmlDrawing not found!'); - $this->assertContains('http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp', $resultSheet1RelsRaw, 'Sheet relation with ctrlProp not found!'); + $this->assertStringContainsString('http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings', $resultSheet1RelsRaw, 'Sheet relation with printerSettings not found!'); + $this->assertStringContainsString('http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing', $resultSheet1RelsRaw, 'Sheet relation with vmlDrawing not found!'); + $this->assertStringContainsString('http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp', $resultSheet1RelsRaw, 'Sheet relation with ctrlProp not found!'); // xl/worksheets/sheet1.xml - $this->assertContains('assertStringContainsString('pageSetup->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); $this->assertTrue(isset($pageSetupAttributes->id), 'sheet1.xml/pageSetup[r:id] not found!'); From b07cd2028dd2454cbcfeff9a70d41761bc77f054 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 27 Apr 2020 20:21:07 +0900 Subject: [PATCH 018/659] Don't patch PHPUnit for phpcov --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f4abffd1e3..2e51c7a4a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,8 +32,6 @@ jobs: php: 7.4 script: - pecl install pcov - - composer require pcov/clobber --dev - - ./vendor/bin/pcov clobber - ./vendor/bin/phpunit --coverage-clover coverage-clover.xml after_script: - wget https://scrutinizer-ci.com/ocular.phar From 385b83362f845f5758ce2933adf8edb6a59b8887 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 27 Apr 2020 21:16:53 +0900 Subject: [PATCH 019/659] Keep PHPUnit result out of project --- phpunit.xml.dist | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index be3643d8a4..90b66acda1 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,7 +4,9 @@ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd" bootstrap="./tests/bootstrap.php" backupGlobals="true" - colors="true"> + colors="true" + cacheResultFile="/tmp/.phpspreadsheet.phpunit.result.cache" +> From 1bcdf15533a5b286e67b81b7e79402eb859044bd Mon Sep 17 00:00:00 2001 From: basbl Date: Fri, 13 Dec 2019 15:59:30 +0100 Subject: [PATCH 020/659] Add maennchen/zipstream-php dependency The built-in ZipArchive class does not have the ability to accept streams. This means that we would always have to write the zip to disk. The ZipStream library does offer support for writing to streams. --- composer.json | 3 +- composer.lock | 344 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 344 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index b3be69b0cd..6ce3a72830 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,8 @@ "ext-zlib": "*", "markbaker/complex": "^1.4", "markbaker/matrix": "^1.2", - "psr/simple-cache": "^1.0" + "psr/simple-cache": "^1.0", + "maennchen/zipstream-php": "^2.0" }, "require-dev": { "dompdf/dompdf": "^0.8.5", diff --git a/composer.lock b/composer.lock index 0575eefed2..41ec1b9b75 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,69 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9c60146d8c78c13d2610a2cec23339a2", + "content-hash": "ab06908c3ff8187971def16c578f1ced", "packages": [ + { + "name": "maennchen/zipstream-php", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/maennchen/ZipStream-PHP.git", + "reference": "9ceee828f9620b2e5c075e551ec7ed8a7035ac95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/9ceee828f9620b2e5c075e551ec7ed8a7035ac95", + "reference": "9ceee828f9620b2e5c075e551ec7ed8a7035ac95", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "myclabs/php-enum": "^1.5", + "php": ">= 7.1", + "psr/http-message": "^1.0" + }, + "require-dev": { + "ext-zip": "*", + "guzzlehttp/guzzle": ">= 6.3", + "mikey179/vfsstream": "^1.6", + "phpunit/phpunit": ">= 7.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "ZipStream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paul Duncan", + "email": "pabs@pablotron.org" + }, + { + "name": "Jonatan Männchen", + "email": "jonatan@maennchen.ch" + }, + { + "name": "Jesse Donat", + "email": "donatj@gmail.com" + }, + { + "name": "András Kolesár", + "email": "kolesar@kolesar.hu" + } + ], + "description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.", + "keywords": [ + "stream", + "zip" + ], + "time": "2020-02-23T01:48:39+00:00" + }, { "name": "markbaker/complex", "version": "1.4.8", @@ -170,6 +231,102 @@ ], "time": "2019-10-06T11:29:25+00:00" }, + { + "name": "myclabs/php-enum", + "version": "1.7.6", + "source": { + "type": "git", + "url": "https://github.com/myclabs/php-enum.git", + "reference": "5f36467c7a87e20fbdc51e524fd8f9d1de80187c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/php-enum/zipball/5f36467c7a87e20fbdc51e524fd8f9d1de80187c", + "reference": "5f36467c7a87e20fbdc51e524fd8f9d1de80187c", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7", + "squizlabs/php_codesniffer": "1.*", + "vimeo/psalm": "^3.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "MyCLabs\\Enum\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP Enum contributors", + "homepage": "https://github.com/myclabs/php-enum/graphs/contributors" + } + ], + "description": "PHP Enum implementation", + "homepage": "http://github.com/myclabs/php-enum", + "keywords": [ + "enum" + ], + "time": "2020-02-14T08:15:52+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" + }, { "name": "psr/simple-cache", "version": "1.0.1", @@ -323,6 +480,12 @@ "Xdebug", "performance" ], + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + } + ], "time": "2020-03-01T12:26:26+00:00" }, { @@ -667,6 +830,12 @@ } ], "description": "A tool to automatically fix PHP code style", + "funding": [ + { + "url": "https://github.com/keradus", + "type": "github" + } + ], "time": "2020-04-15T18:51:10+00:00" }, { @@ -1703,6 +1872,16 @@ "testing", "xunit" ], + "funding": [ + { + "url": "https://phpunit.de/donate.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], "time": "2020-04-23T04:39:42+00:00" }, { @@ -2566,6 +2745,12 @@ "fpdi", "pdf" ], + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/setasign/fpdi", + "type": "tidelift" + } + ], "time": "2020-03-23T15:53:59+00:00" }, { @@ -2693,6 +2878,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-03-30T11:42:42+00:00" }, { @@ -2763,6 +2962,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-03-27T16:56:45+00:00" }, { @@ -2871,6 +3084,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-03-27T16:56:45+00:00" }, { @@ -2920,6 +3147,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-03-27T16:56:45+00:00" }, { @@ -2974,6 +3215,20 @@ "configuration", "options" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-03-27T16:56:45+00:00" }, { @@ -3032,6 +3287,20 @@ "polyfill", "portable" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-02-27T09:26:54+00:00" }, { @@ -3091,6 +3360,20 @@ "portable", "shim" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-03-09T19:04:49+00:00" }, { @@ -3205,6 +3488,20 @@ "portable", "shim" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-02-27T09:26:54+00:00" }, { @@ -3263,6 +3560,20 @@ "portable", "shim" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-02-27T09:26:54+00:00" }, { @@ -3312,6 +3623,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-03-27T16:56:45+00:00" }, { @@ -3420,6 +3745,20 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-03-27T16:56:45+00:00" }, { @@ -3594,5 +3933,6 @@ "ext-zip": "*", "ext-zlib": "*" }, - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "1.1.0" } From ccb49de301d0b1eb932b70c393b6f3bfc461461f Mon Sep 17 00:00:00 2001 From: basbl Date: Fri, 13 Dec 2019 15:59:55 +0100 Subject: [PATCH 021/659] Add support for streaming zip files in the xlsx and ods writers --- src/PhpSpreadsheet/Writer/IWriter.php | 2 +- src/PhpSpreadsheet/Writer/Ods.php | 70 +++++++++------- src/PhpSpreadsheet/Writer/Xlsx.php | 115 +++++++++++++++----------- 3 files changed, 108 insertions(+), 79 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/IWriter.php b/src/PhpSpreadsheet/Writer/IWriter.php index 448b532fc2..97b14bef7c 100644 --- a/src/PhpSpreadsheet/Writer/IWriter.php +++ b/src/PhpSpreadsheet/Writer/IWriter.php @@ -59,7 +59,7 @@ public function setPreCalculateFormulas($pValue); /** * Save PhpSpreadsheet to file. * - * @param string $pFilename Name of the file to save + * @param resource|string $pFilename Name of the file to save * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ diff --git a/src/PhpSpreadsheet/Writer/Ods.php b/src/PhpSpreadsheet/Writer/Ods.php index 43659fa08e..2a1dba02eb 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -12,7 +12,9 @@ use PhpOffice\PhpSpreadsheet\Writer\Ods\Settings; use PhpOffice\PhpSpreadsheet\Writer\Ods\Styles; use PhpOffice\PhpSpreadsheet\Writer\Ods\Thumbnails; -use ZipArchive; +use ZipStream\Exception\OverflowException; +use ZipStream\Option\Archive; +use ZipStream\ZipStream; class Ods extends BaseWriter { @@ -30,6 +32,11 @@ class Ods extends BaseWriter */ private $spreadSheet; + /** + * @var bool|resource + */ + private $fileHandle; + /** * Create a new Ods. * @@ -73,7 +80,7 @@ public function getWriterPart($pPartName) /** * Save PhpSpreadsheet to file. * - * @param string $pFilename + * @param resource|string $pFilename * * @throws WriterException */ @@ -88,31 +95,41 @@ public function save($pFilename) // If $pFilename is php://output or php://stdout, make it a temporary file... $originalFilename = $pFilename; - if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { + if (is_resource($pFilename)) { + $this->fileHandle = $pFilename; + } elseif (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { + // If $pFilename is php://output or php://stdout, make it a temporary file... $pFilename = @tempnam(File::sysGetTempDir(), 'phpxltmp'); if ($pFilename == '') { $pFilename = $originalFilename; } + $this->fileHandle = fopen($pFilename, 'wb+'); + } else { + $this->fileHandle = fopen($pFilename, 'wb+'); } - $zip = $this->createZip($pFilename); + $zip = $this->createZip(); - $zip->addFromString('META-INF/manifest.xml', $this->getWriterPart('meta_inf')->writeManifest()); - $zip->addFromString('Thumbnails/thumbnail.png', $this->getWriterPart('thumbnails')->writeThumbnail()); - $zip->addFromString('content.xml', $this->getWriterPart('content')->write()); - $zip->addFromString('meta.xml', $this->getWriterPart('meta')->write()); - $zip->addFromString('mimetype', $this->getWriterPart('mimetype')->write()); - $zip->addFromString('settings.xml', $this->getWriterPart('settings')->write()); - $zip->addFromString('styles.xml', $this->getWriterPart('styles')->write()); + $zip->addFile('META-INF/manifest.xml', $this->getWriterPart('meta_inf')->writeManifest()); + $zip->addFile('Thumbnails/thumbnail.png', $this->getWriterPart('thumbnails')->writeThumbnail()); + $zip->addFile('content.xml', $this->getWriterPart('content')->write()); + $zip->addFile('meta.xml', $this->getWriterPart('meta')->write()); + $zip->addFile('mimetype', $this->getWriterPart('mimetype')->write()); + $zip->addFile('settings.xml', $this->getWriterPart('settings')->write()); + $zip->addFile('styles.xml', $this->getWriterPart('styles')->write()); // Close file - if ($zip->close() === false) { - throw new WriterException("Could not close zip file $pFilename."); + try { + $zip->finish(); + } catch (OverflowException $e) { + throw new WriterException('Could not close resource.'); } + rewind($this->fileHandle); + // If a temporary file was used, copy it to the correct file stream if ($originalFilename != $pFilename) { - if (copy($pFilename, $originalFilename) === false) { + if (stream_copy_to_stream($this->fileHandle, fopen($originalFilename, 'wb+')) === false) { throw new WriterException("Could not copy temporary zip file $pFilename to $originalFilename."); } @unlink($pFilename); @@ -122,28 +139,23 @@ public function save($pFilename) /** * Create zip object. * - * @param string $pFilename - * * @throws WriterException * - * @return ZipArchive + * @return ZipStream */ - private function createZip($pFilename) + private function createZip() { - // Create new ZIP file and open it for writing - $zip = new ZipArchive(); - - if (file_exists($pFilename)) { - unlink($pFilename); - } // Try opening the ZIP file - if ($zip->open($pFilename, ZipArchive::OVERWRITE) !== true) { - if ($zip->open($pFilename, ZipArchive::CREATE) !== true) { - throw new WriterException("Could not open $pFilename for writing."); - } + if ($this->fileHandle === false) { + throw new WriterException('Could not open resource for writing.'); } - return $zip; + // Create new ZIP stream + $options = new Archive(); + $options->setEnableZip64(false); + $options->setOutputStream($this->fileHandle); + + return new ZipStream(null, $options); } /** diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index 1fa59e51c7..2297002bb5 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -24,6 +24,9 @@ use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Workbook; use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet; use ZipArchive; +use ZipStream\Exception\OverflowException; +use ZipStream\Option\Archive; +use ZipStream\ZipStream; class Xlsx extends BaseWriter { @@ -104,6 +107,11 @@ class Xlsx extends BaseWriter */ private $drawingHashTable; + /** + * @var bool|resource + */ + private $fileHandle; + /** * Create a new Xlsx Writer. * @@ -166,7 +174,7 @@ public function getWriterPart($pPartName) /** * Save PhpSpreadsheet to file. * - * @param string $pFilename + * @param resource|string $pFilename * * @throws WriterException */ @@ -176,13 +184,24 @@ public function save($pFilename) // garbage collect $this->spreadSheet->garbageCollect(); - // If $pFilename is php://output or php://stdout, make it a temporary file... $originalFilename = $pFilename; - if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { + + if (is_resource($pFilename)) { + $this->fileHandle = $pFilename; + } elseif (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { + // If $pFilename is php://output or php://stdout, make it a temporary file... $pFilename = @tempnam(File::sysGetTempDir(), 'phpxltmp'); if ($pFilename == '') { $pFilename = $originalFilename; } + $this->fileHandle = fopen($pFilename, 'wb+'); + } else { + $this->fileHandle = fopen($pFilename, 'wb+'); + } + + // Try opening the ZIP file + if ($this->fileHandle === false) { + throw new WriterException('Could not open resource for writing.'); } $saveDebugLog = Calculation::getInstance($this->spreadSheet)->getDebugLog()->getWriteDebugLog(); @@ -207,83 +226,77 @@ public function save($pFilename) // Create drawing dictionary $this->drawingHashTable->addFromSource($this->getWriterPart('Drawing')->allDrawings($this->spreadSheet)); - $zip = new ZipArchive(); + $options = new Archive(); + $options->setEnableZip64(false); + $options->setOutputStream($this->fileHandle); - if (file_exists($pFilename)) { - unlink($pFilename); - } - // Try opening the ZIP file - if ($zip->open($pFilename, ZipArchive::OVERWRITE) !== true) { - if ($zip->open($pFilename, ZipArchive::CREATE) !== true) { - throw new WriterException('Could not open ' . $pFilename . ' for writing.'); - } - } + $zip = new ZipStream(null, $options); // Add [Content_Types].xml to ZIP file - $zip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->spreadSheet, $this->includeCharts)); + $zip->addFile('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->spreadSheet, $this->includeCharts)); //if hasMacros, add the vbaProject.bin file, Certificate file(if exists) if ($this->spreadSheet->hasMacros()) { $macrosCode = $this->spreadSheet->getMacrosCode(); if ($macrosCode !== null) { // we have the code ? - $zip->addFromString('xl/vbaProject.bin', $macrosCode); //allways in 'xl', allways named vbaProject.bin + $zip->addFile('xl/vbaProject.bin', $macrosCode); //allways in 'xl', allways named vbaProject.bin if ($this->spreadSheet->hasMacrosCertificate()) { //signed macros ? // Yes : add the certificate file and the related rels file - $zip->addFromString('xl/vbaProjectSignature.bin', $this->spreadSheet->getMacrosCertificate()); - $zip->addFromString('xl/_rels/vbaProject.bin.rels', $this->getWriterPart('RelsVBA')->writeVBARelationships($this->spreadSheet)); + $zip->addFile('xl/vbaProjectSignature.bin', $this->spreadSheet->getMacrosCertificate()); + $zip->addFile('xl/_rels/vbaProject.bin.rels', $this->getWriterPart('RelsVBA')->writeVBARelationships($this->spreadSheet)); } } } //a custom UI in this workbook ? add it ("base" xml and additional objects (pictures) and rels) if ($this->spreadSheet->hasRibbon()) { $tmpRibbonTarget = $this->spreadSheet->getRibbonXMLData('target'); - $zip->addFromString($tmpRibbonTarget, $this->spreadSheet->getRibbonXMLData('data')); + $zip->addFile($tmpRibbonTarget, $this->spreadSheet->getRibbonXMLData('data')); if ($this->spreadSheet->hasRibbonBinObjects()) { $tmpRootPath = dirname($tmpRibbonTarget) . '/'; $ribbonBinObjects = $this->spreadSheet->getRibbonBinObjects('data'); //the files to write foreach ($ribbonBinObjects as $aPath => $aContent) { - $zip->addFromString($tmpRootPath . $aPath, $aContent); + $zip->addFile($tmpRootPath . $aPath, $aContent); } //the rels for files - $zip->addFromString($tmpRootPath . '_rels/' . basename($tmpRibbonTarget) . '.rels', $this->getWriterPart('RelsRibbonObjects')->writeRibbonRelationships($this->spreadSheet)); + $zip->addFile($tmpRootPath . '_rels/' . basename($tmpRibbonTarget) . '.rels', $this->getWriterPart('RelsRibbonObjects')->writeRibbonRelationships($this->spreadSheet)); } } // Add relationships to ZIP file - $zip->addFromString('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->spreadSheet)); - $zip->addFromString('xl/_rels/workbook.xml.rels', $this->getWriterPart('Rels')->writeWorkbookRelationships($this->spreadSheet)); + $zip->addFile('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->spreadSheet)); + $zip->addFile('xl/_rels/workbook.xml.rels', $this->getWriterPart('Rels')->writeWorkbookRelationships($this->spreadSheet)); // Add document properties to ZIP file - $zip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->spreadSheet)); - $zip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->spreadSheet)); + $zip->addFile('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->spreadSheet)); + $zip->addFile('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->spreadSheet)); $customPropertiesPart = $this->getWriterPart('DocProps')->writeDocPropsCustom($this->spreadSheet); if ($customPropertiesPart !== null) { - $zip->addFromString('docProps/custom.xml', $customPropertiesPart); + $zip->addFile('docProps/custom.xml', $customPropertiesPart); } // Add theme to ZIP file - $zip->addFromString('xl/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->spreadSheet)); + $zip->addFile('xl/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->spreadSheet)); // Add string table to ZIP file - $zip->addFromString('xl/sharedStrings.xml', $this->getWriterPart('StringTable')->writeStringTable($this->stringTable)); + $zip->addFile('xl/sharedStrings.xml', $this->getWriterPart('StringTable')->writeStringTable($this->stringTable)); // Add styles to ZIP file - $zip->addFromString('xl/styles.xml', $this->getWriterPart('Style')->writeStyles($this->spreadSheet)); + $zip->addFile('xl/styles.xml', $this->getWriterPart('Style')->writeStyles($this->spreadSheet)); // Add workbook to ZIP file - $zip->addFromString('xl/workbook.xml', $this->getWriterPart('Workbook')->writeWorkbook($this->spreadSheet, $this->preCalculateFormulas)); + $zip->addFile('xl/workbook.xml', $this->getWriterPart('Workbook')->writeWorkbook($this->spreadSheet, $this->preCalculateFormulas)); $chartCount = 0; // Add worksheets for ($i = 0; $i < $this->spreadSheet->getSheetCount(); ++$i) { - $zip->addFromString('xl/worksheets/sheet' . ($i + 1) . '.xml', $this->getWriterPart('Worksheet')->writeWorksheet($this->spreadSheet->getSheet($i), $this->stringTable, $this->includeCharts)); + $zip->addFile('xl/worksheets/sheet' . ($i + 1) . '.xml', $this->getWriterPart('Worksheet')->writeWorksheet($this->spreadSheet->getSheet($i), $this->stringTable, $this->includeCharts)); if ($this->includeCharts) { $charts = $this->spreadSheet->getSheet($i)->getChartCollection(); if (count($charts) > 0) { foreach ($charts as $chart) { - $zip->addFromString('xl/charts/chart' . ($chartCount + 1) . '.xml', $this->getWriterPart('Chart')->writeChart($chart, $this->preCalculateFormulas)); + $zip->addFile('xl/charts/chart' . ($chartCount + 1) . '.xml', $this->getWriterPart('Chart')->writeChart($chart, $this->preCalculateFormulas)); ++$chartCount; } } @@ -294,19 +307,19 @@ public function save($pFilename) // Add worksheet relationships (drawings, ...) for ($i = 0; $i < $this->spreadSheet->getSheetCount(); ++$i) { // Add relationships - $zip->addFromString('xl/worksheets/_rels/sheet' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeWorksheetRelationships($this->spreadSheet->getSheet($i), ($i + 1), $this->includeCharts)); + $zip->addFile('xl/worksheets/_rels/sheet' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeWorksheetRelationships($this->spreadSheet->getSheet($i), ($i + 1), $this->includeCharts)); // Add unparsedLoadedData $sheetCodeName = $this->spreadSheet->getSheet($i)->getCodeName(); $unparsedLoadedData = $this->spreadSheet->getUnparsedLoadedData(); if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['ctrlProps'])) { foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['ctrlProps'] as $ctrlProp) { - $zip->addFromString($ctrlProp['filePath'], $ctrlProp['content']); + $zip->addFile($ctrlProp['filePath'], $ctrlProp['content']); } } if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['printerSettings'])) { foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['printerSettings'] as $ctrlProp) { - $zip->addFromString($ctrlProp['filePath'], $ctrlProp['content']); + $zip->addFile($ctrlProp['filePath'], $ctrlProp['content']); } } @@ -319,13 +332,13 @@ public function save($pFilename) // Add drawing and image relationship parts if (($drawingCount > 0) || ($chartCount > 0)) { // Drawing relationships - $zip->addFromString('xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeDrawingRelationships($this->spreadSheet->getSheet($i), $chartRef1, $this->includeCharts)); + $zip->addFile('xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeDrawingRelationships($this->spreadSheet->getSheet($i), $chartRef1, $this->includeCharts)); // Drawings - $zip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts)); + $zip->addFile('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts)); } elseif (isset($unparsedLoadedData['sheets'][$sheetCodeName]['drawingAlternateContents'])) { // Drawings - $zip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts)); + $zip->addFile('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts)); } // Add unparsed drawings @@ -334,7 +347,7 @@ public function save($pFilename) $drawingFile = array_search($relId, $unparsedLoadedData['sheets'][$sheetCodeName]['drawingOriginalIds']); if ($drawingFile !== false) { $drawingFile = ltrim($drawingFile, '.'); - $zip->addFromString('xl' . $drawingFile, $drawingXml); + $zip->addFile('xl' . $drawingFile, $drawingXml); } } } @@ -342,30 +355,30 @@ public function save($pFilename) // Add comment relationship parts if (count($this->spreadSheet->getSheet($i)->getComments()) > 0) { // VML Comments - $zip->addFromString('xl/drawings/vmlDrawing' . ($i + 1) . '.vml', $this->getWriterPart('Comments')->writeVMLComments($this->spreadSheet->getSheet($i))); + $zip->addFile('xl/drawings/vmlDrawing' . ($i + 1) . '.vml', $this->getWriterPart('Comments')->writeVMLComments($this->spreadSheet->getSheet($i))); // Comments - $zip->addFromString('xl/comments' . ($i + 1) . '.xml', $this->getWriterPart('Comments')->writeComments($this->spreadSheet->getSheet($i))); + $zip->addFile('xl/comments' . ($i + 1) . '.xml', $this->getWriterPart('Comments')->writeComments($this->spreadSheet->getSheet($i))); } // Add unparsed relationship parts if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['vmlDrawings'])) { foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['vmlDrawings'] as $vmlDrawing) { - $zip->addFromString($vmlDrawing['filePath'], $vmlDrawing['content']); + $zip->addFile($vmlDrawing['filePath'], $vmlDrawing['content']); } } // Add header/footer relationship parts if (count($this->spreadSheet->getSheet($i)->getHeaderFooter()->getImages()) > 0) { // VML Drawings - $zip->addFromString('xl/drawings/vmlDrawingHF' . ($i + 1) . '.vml', $this->getWriterPart('Drawing')->writeVMLHeaderFooterImages($this->spreadSheet->getSheet($i))); + $zip->addFile('xl/drawings/vmlDrawingHF' . ($i + 1) . '.vml', $this->getWriterPart('Drawing')->writeVMLHeaderFooterImages($this->spreadSheet->getSheet($i))); // VML Drawing relationships - $zip->addFromString('xl/drawings/_rels/vmlDrawingHF' . ($i + 1) . '.vml.rels', $this->getWriterPart('Rels')->writeHeaderFooterDrawingRelationships($this->spreadSheet->getSheet($i))); + $zip->addFile('xl/drawings/_rels/vmlDrawingHF' . ($i + 1) . '.vml.rels', $this->getWriterPart('Rels')->writeHeaderFooterDrawingRelationships($this->spreadSheet->getSheet($i))); // Media foreach ($this->spreadSheet->getSheet($i)->getHeaderFooter()->getImages() as $image) { - $zip->addFromString('xl/media/' . $image->getIndexedFilename(), file_get_contents($image->getPath())); + $zip->addFile('xl/media/' . $image->getIndexedFilename(), file_get_contents($image->getPath())); } } } @@ -388,7 +401,7 @@ public function save($pFilename) $imageContents = file_get_contents($imagePath); } - $zip->addFromString('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); + $zip->addFile('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); } elseif ($this->getDrawingHashTable()->getByIndex($i) instanceof MemoryDrawing) { ob_start(); call_user_func( @@ -398,7 +411,7 @@ public function save($pFilename) $imageContents = ob_get_contents(); ob_end_clean(); - $zip->addFromString('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); + $zip->addFile('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); } } @@ -406,13 +419,17 @@ public function save($pFilename) Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); // Close file - if ($zip->close() === false) { - throw new WriterException("Could not close zip file $pFilename."); + try { + $zip->finish(); + } catch (OverflowException $e) { + throw new WriterException('Could not close resource.'); } + rewind($this->fileHandle); + // If a temporary file was used, copy it to the correct file stream if ($originalFilename != $pFilename) { - if (copy($pFilename, $originalFilename) === false) { + if (stream_copy_to_stream($this->fileHandle, fopen($originalFilename, 'wb+')) === false) { throw new WriterException("Could not copy temporary zip file $pFilename to $originalFilename."); } @unlink($pFilename); From 11499aad9ae44409b81245e9f489a66f1fa6599e Mon Sep 17 00:00:00 2001 From: basbl Date: Mon, 16 Dec 2019 09:38:41 +0100 Subject: [PATCH 022/659] Add resource parameter handling to html, csv and xls writers --- src/PhpSpreadsheet/Writer/Csv.php | 14 +++++++++++--- src/PhpSpreadsheet/Writer/Html.php | 9 +++++++-- src/PhpSpreadsheet/Writer/Xls.php | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Csv.php b/src/PhpSpreadsheet/Writer/Csv.php index 1166bd25b1..1cf646341b 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -4,6 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; class Csv extends BaseWriter { @@ -77,7 +78,7 @@ public function __construct(Spreadsheet $spreadsheet) /** * Save PhpSpreadsheet to file. * - * @param string $pFilename + * @param resource|string $pFilename * * @throws Exception */ @@ -92,9 +93,14 @@ public function save($pFilename) Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE); // Open file - $fileHandle = fopen($pFilename, 'wb+'); + if (is_resource($pFilename)) { + $fileHandle = $pFilename; + } else { + $fileHandle = fopen($pFilename, 'wb+'); + } + if ($fileHandle === false) { - throw new Exception("Could not open file $pFilename for writing."); + throw new WriterException("Could not open file $pFilename for writing."); } if ($this->excelCompatibility) { @@ -126,6 +132,8 @@ public function save($pFilename) } // Close file + rewind($fileHandle); + fclose($fileHandle); Calculation::setArrayReturnType($saveArrayReturnType); diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 37d68e912e..91beedb76d 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -146,7 +146,7 @@ public function __construct(Spreadsheet $spreadsheet) /** * Save Spreadsheet to file. * - * @param string $pFilename + * @param resource|string $pFilename * * @throws WriterException */ @@ -164,7 +164,12 @@ public function save($pFilename) $this->buildCSS(!$this->useInlineCss); // Open file - $fileHandle = fopen($pFilename, 'wb+'); + if (is_resource($pFilename)) { + $fileHandle = $pFilename; + } else { + $fileHandle = fopen($pFilename, 'wb+'); + } + if ($fileHandle === false) { throw new WriterException("Could not open file $pFilename for writing."); } diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index 6932eb1ac4..95693ddeaa 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -115,7 +115,7 @@ public function __construct(Spreadsheet $spreadsheet) /** * Save Spreadsheet to file. * - * @param string $pFilename + * @param resource|string $pFilename * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ From b60b1d25c04180a3c8ce71dc84cf1c841f5f5b5c Mon Sep 17 00:00:00 2001 From: basbl Date: Mon, 27 Apr 2020 11:47:22 +0200 Subject: [PATCH 023/659] Test scrutinizer --- src/PhpSpreadsheet/Writer/Ods.php | 30 ++++++++++++++++++----------- src/PhpSpreadsheet/Writer/Xlsx.php | 31 ++++++++++++++++++------------ 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Ods.php b/src/PhpSpreadsheet/Writer/Ods.php index 2a1dba02eb..08bd2629cb 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -93,18 +93,18 @@ public function save($pFilename) // garbage collect $this->spreadSheet->garbageCollect(); - // If $pFilename is php://output or php://stdout, make it a temporary file... $originalFilename = $pFilename; if (is_resource($pFilename)) { $this->fileHandle = $pFilename; - } elseif (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { + } else { // If $pFilename is php://output or php://stdout, make it a temporary file... - $pFilename = @tempnam(File::sysGetTempDir(), 'phpxltmp'); - if ($pFilename == '') { - $pFilename = $originalFilename; + if (in_array(strtolower($pFilename), ['php://output', 'php://stdout'], true)) { + $pFilename = @tempnam(File::sysGetTempDir(), 'phpxltmp'); + if ($pFilename === '') { + $pFilename = $originalFilename; + } } - $this->fileHandle = fopen($pFilename, 'wb+'); - } else { + $this->fileHandle = fopen($pFilename, 'wb+'); } @@ -128,11 +128,19 @@ public function save($pFilename) rewind($this->fileHandle); // If a temporary file was used, copy it to the correct file stream - if ($originalFilename != $pFilename) { - if (stream_copy_to_stream($this->fileHandle, fopen($originalFilename, 'wb+')) === false) { + if ($originalFilename !== $pFilename) { + $destinationFileHandle = fopen($originalFilename, 'wb+'); + if (!is_resource($destinationFileHandle)) { + throw new WriterException("Could not open resource $originalFilename for writing."); + } + + if (stream_copy_to_stream($this->fileHandle, $destinationFileHandle) === false) { throw new WriterException("Could not copy temporary zip file $pFilename to $originalFilename."); } - @unlink($pFilename); + + if (is_string($pFilename) && !unlink($pFilename)) { + throw new WriterException('Could not unlink temporary zip file.'); + } } } @@ -146,7 +154,7 @@ public function save($pFilename) private function createZip() { // Try opening the ZIP file - if ($this->fileHandle === false) { + if (!is_resource($this->fileHandle)) { throw new WriterException('Could not open resource for writing.'); } diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index 2297002bb5..9c947d0a9d 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -185,22 +185,21 @@ public function save($pFilename) $this->spreadSheet->garbageCollect(); $originalFilename = $pFilename; - if (is_resource($pFilename)) { $this->fileHandle = $pFilename; - } elseif (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { + } else { // If $pFilename is php://output or php://stdout, make it a temporary file... - $pFilename = @tempnam(File::sysGetTempDir(), 'phpxltmp'); - if ($pFilename == '') { - $pFilename = $originalFilename; + if (in_array(strtolower($pFilename), ['php://output', 'php://stdout'], true)) { + $pFilename = @tempnam(File::sysGetTempDir(), 'phpxltmp'); + if ($pFilename === '') { + $pFilename = $originalFilename; + } } - $this->fileHandle = fopen($pFilename, 'wb+'); - } else { + $this->fileHandle = fopen($pFilename, 'wb+'); } - // Try opening the ZIP file - if ($this->fileHandle === false) { + if (!is_resource($this->fileHandle)) { throw new WriterException('Could not open resource for writing.'); } @@ -428,11 +427,19 @@ public function save($pFilename) rewind($this->fileHandle); // If a temporary file was used, copy it to the correct file stream - if ($originalFilename != $pFilename) { - if (stream_copy_to_stream($this->fileHandle, fopen($originalFilename, 'wb+')) === false) { + if ($originalFilename !== $pFilename) { + $destinationFileHandle = fopen($originalFilename, 'wb+'); + if (!is_resource($destinationFileHandle)) { + throw new WriterException("Could not open resource $originalFilename for writing."); + } + + if (stream_copy_to_stream($this->fileHandle, $destinationFileHandle) === false) { throw new WriterException("Could not copy temporary zip file $pFilename to $originalFilename."); } - @unlink($pFilename); + + if (is_string($pFilename) && !unlink($pFilename)) { + throw new WriterException('Could not unlink temporary zip file.'); + } } } else { throw new WriterException('PhpSpreadsheet object unassigned.'); From 588ca6beb39e4d8b8d68df445507830f8c73e9d6 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 2 May 2020 12:34:20 +0900 Subject: [PATCH 024/659] Replace migration tool with RectorPHP Fixes #1445 --- CHANGELOG.md | 1 + bin/migrate-from-phpexcel | 8 - docs/topics/migration-from-PHPExcel.md | 427 +----------------- src/PhpSpreadsheet/Helper/Migrator.php | 333 -------------- .../Helper/MigratorTest.php | 88 ---- 5 files changed, 9 insertions(+), 848 deletions(-) delete mode 100755 bin/migrate-from-phpexcel delete mode 100644 src/PhpSpreadsheet/Helper/Migrator.php delete mode 100644 tests/PhpSpreadsheetTests/Helper/MigratorTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f5c002c31..4bf9b93180 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Changed - Drop support for PHP 7.1, according to https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support +- Drop partial migration tool in favor of complete migration via RectorPHP [#1445](https://github.com/PHPOffice/PhpSpreadsheet/issues/1445) ## [1.12.0] - 2020-04-27 diff --git a/bin/migrate-from-phpexcel b/bin/migrate-from-phpexcel deleted file mode 100755 index 51c60d495a..0000000000 --- a/bin/migrate-from-phpexcel +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env php -migrate(); diff --git a/docs/topics/migration-from-PHPExcel.md b/docs/topics/migration-from-PHPExcel.md index 011b377075..cc46976856 100644 --- a/docs/topics/migration-from-PHPExcel.md +++ b/docs/topics/migration-from-PHPExcel.md @@ -8,426 +8,15 @@ need to be done. ## Automated tool -The tool is included in PhpSpreadsheet. It scans recursively all files -and directories, starting from the current directory. Assuming it was -installed with composer, it can be run like so: +[RectorPHP](https://github.com/rectorphp/rector) can be used to migrate +automatically your codebase. Assuming your files to be migrated lives +in `src/`, you can run the migration like so: ``` sh -cd /project/to/migrate/src -php /project/to/migrate/vendor/phpoffice/phpspreadsheet/bin/migrate-from-phpexcel +composer require rector/rector --dev +vendor/bin/rector process src --set phpexcel-to-phpspreadsheet +composer remove rector/rector ``` -**Important** The tool will irreversibly modify your sources, be sure to -backup everything, and double check the result before committing. - -## Manual changes - -In addition to automated changes, a few things need to be migrated manually. - -### Renamed readers and writers - -When using `IOFactory::createReader()`, `IOFactory::createWriter()` and -`IOFactory::identify()`, the reader/writer short names are used. Those were -changed, along as their corresponding class, to remove ambiguity: - -Before | After ------------------|--------- -`'CSV'` | `'Csv'` -`'Excel2003XML'` | `'Xml'` -`'Excel2007'` | `'Xlsx'` -`'Excel5'` | `'Xls'` -`'Gnumeric'` | `'Gnumeric'` -`'HTML'` | `'Html'` -`'OOCalc'` | `'Ods'` -`'OpenDocument'` | `'Ods'` -`'PDF'` | `'Pdf'` -`'SYLK'` | `'Slk'` - -### Simplified IOFactory - -The following methods : - -- `PHPExcel_IOFactory::getSearchLocations()` -- `PHPExcel_IOFactory::setSearchLocations()` -- `PHPExcel_IOFactory::addSearchLocation()` - -were replaced by `IOFactory::registerReader()` and `IOFactory::registerWriter()`. That means -IOFactory now relies on classes autoloading. - -Before: - -```php -\PHPExcel_IOFactory::addSearchLocation($type, $location, $classname); -``` - -After: - -```php -\PhpOffice\PhpSpreadsheet\IOFactory::registerReader($type, $classname); -``` - -### Removed deprecated things - -#### Worksheet::duplicateStyleArray() - -``` php -// Before -$worksheet->duplicateStyleArray($styles, $range, $advanced); - -// After -$worksheet->getStyle($range)->applyFromArray($styles, $advanced); -``` - -#### DataType::dataTypeForValue() - -``` php -// Before -DataType::dataTypeForValue($value); - -// After -DefaultValueBinder::dataTypeForValue($value); -``` - -#### Conditional::getCondition() - -``` php -// Before -$conditional->getCondition(); - -// After -$conditional->getConditions()[0]; -``` - -#### Conditional::setCondition() - -``` php -// Before -$conditional->setCondition($value); - -// After -$conditional->setConditions($value); -``` - -#### Worksheet::getDefaultStyle() - -``` php -// Before -$worksheet->getDefaultStyle(); - -// After -$worksheet->getParent()->getDefaultStyle(); -``` - -#### Worksheet::setDefaultStyle() - -``` php -// Before -$worksheet->setDefaultStyle($value); - -// After -$worksheet->getParent()->getDefaultStyle()->applyFromArray([ - 'font' => [ - 'name' => $pValue->getFont()->getName(), - 'size' => $pValue->getFont()->getSize(), - ], -]); - -``` - -#### Worksheet::setSharedStyle() - -``` php -// Before -$worksheet->setSharedStyle($sharedStyle, $range); - -// After -$worksheet->duplicateStyle($sharedStyle, $range); -``` - -#### Worksheet::getSelectedCell() - -``` php -// Before -$worksheet->getSelectedCell(); - -// After -$worksheet->getSelectedCells(); -``` - -#### Writer\Xls::setTempDir() - -``` php -// Before -$writer->setTempDir(); - -// After, there is no way to set temporary storage directory anymore -``` - -### Autoloader - -The class `PHPExcel_Autoloader` was removed entirely and is replaced by composer -autoloading mechanism. - -### Writing PDF - -PDF libraries must be installed via composer. And the following methods were removed -and are replaced by `IOFactory::registerWriter()` instead: - -- `PHPExcel_Settings::getPdfRenderer()` -- `PHPExcel_Settings::setPdfRenderer()` -- `PHPExcel_Settings::getPdfRendererName()` -- `PHPExcel_Settings::setPdfRendererName()` - -Before: - -```php -\PHPExcel_Settings::setPdfRendererName(PHPExcel_Settings::PDF_RENDERER_MPDF); -\PHPExcel_Settings::setPdfRenderer($somePath); -$writer = \PHPExcel_IOFactory::createWriter($spreadsheet, 'PDF'); -``` - -After: - -```php -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Mpdf'); - -// Or alternatively -\PhpOffice\PhpSpreadsheet\IOFactory::registerWriter('Pdf', \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf::class); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Pdf'); - -// Or alternatively -$writer = new \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf($spreadsheet); -``` - -### Rendering charts - -When rendering charts for HTML or PDF outputs, the process was also simplified. And while -JpGraph support is still available, it is unfortunately not up to date for latest PHP versions -and it will generate various warnings. - -If you rely on this feature, please consider -contributing either patches to JpGraph or another `IRenderer` implementation (a good -candidate might be [CpChart](https://github.com/szymach/c-pchart)). - -Before: - -```php -$rendererName = \PHPExcel_Settings::CHART_RENDERER_JPGRAPH; -$rendererLibrary = 'jpgraph3.5.0b1/src/'; -$rendererLibraryPath = '/php/libraries/Charts/' . $rendererLibrary; - -\PHPExcel_Settings::setChartRenderer($rendererName, $rendererLibraryPath); -``` - -After: - -Require the dependency via composer: - -```sh -composer require jpgraph/jpgraph -``` - -And then: - -```php -Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class); -``` - -### PclZip and ZipArchive - -Support for PclZip were dropped in favor of the more complete and modern -[PHP extension ZipArchive](https://php.net/manual/en/book.zip.php). -So the following were removed: - -- `PclZip` -- `PHPExcel_Settings::setZipClass()` -- `PHPExcel_Settings::getZipClass()` -- `PHPExcel_Shared_ZipArchive` -- `PHPExcel_Shared_ZipStreamWrapper` - -### Cell caching - -Cell caching was heavily refactored to leverage -[PSR-16](https://www.php-fig.org/psr/psr-16/). That means most classes -related to that feature were removed: - -- `PHPExcel_CachedObjectStorage_APC` -- `PHPExcel_CachedObjectStorage_DiscISAM` -- `PHPExcel_CachedObjectStorage_ICache` -- `PHPExcel_CachedObjectStorage_Igbinary` -- `PHPExcel_CachedObjectStorage_Memcache` -- `PHPExcel_CachedObjectStorage_Memory` -- `PHPExcel_CachedObjectStorage_MemoryGZip` -- `PHPExcel_CachedObjectStorage_MemorySerialized` -- `PHPExcel_CachedObjectStorage_PHPTemp` -- `PHPExcel_CachedObjectStorage_SQLite` -- `PHPExcel_CachedObjectStorage_SQLite3` -- `PHPExcel_CachedObjectStorage_Wincache` - -In addition to that, `\PhpOffice\PhpSpreadsheet::getCellCollection()` was renamed -to `\PhpOffice\PhpSpreadsheet::getCoordinates()` and -`\PhpOffice\PhpSpreadsheet::getCellCacheController()` to -`\PhpOffice\PhpSpreadsheet::getCellCollection()` for clarity. - -Refer to [the new documentation](./memory_saving.md) to see how to migrate. - -### Dropped conditionally returned cell - -For all the following methods, it is no more possible to change the type of -returned value. It always return the Worksheet and never the Cell or Rule: - -- Worksheet::setCellValue() -- Worksheet::setCellValueByColumnAndRow() -- Worksheet::setCellValueExplicit() -- Worksheet::setCellValueExplicitByColumnAndRow() -- Worksheet::addRule() - -Migration would be similar to: - -``` php -// Before -$cell = $worksheet->setCellValue('A1', 'value', true); - -// After -$cell = $worksheet->getCell('A1')->setValue('value'); -``` - -### Standardized keys for styling - -Array keys used for styling have been standardized for a more coherent experience. -It now uses the same wording and casing as the getter and setter: - -```php -// Before -$style = [ - 'numberformat' => [ - 'code' => NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE, - ], - 'font' => [ - 'strike' => true, - 'superScript' => true, - 'subScript' => true, - ], - 'alignment' => [ - 'rotation' => 90, - 'readorder' => Alignment::READORDER_RTL, - 'wrap' => true, - ], - 'borders' => [ - 'diagonaldirection' => Borders::DIAGONAL_BOTH, - 'allborders' => [ - 'style' => Border::BORDER_THIN, - ], - ], - 'fill' => [ - 'type' => Fill::FILL_GRADIENT_LINEAR, - 'startcolor' => [ - 'argb' => 'FFA0A0A0', - ], - 'endcolor' => [ - 'argb' => 'FFFFFFFF', - ], - ], -]; - -// After -$style = [ - 'numberFormat' => [ - 'formatCode' => NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE, - ], - 'font' => [ - 'strikethrough' => true, - 'superscript' => true, - 'subscript' => true, - ], - 'alignment' => [ - 'textRotation' => 90, - 'readOrder' => Alignment::READORDER_RTL, - 'wrapText' => true, - ], - 'borders' => [ - 'diagonalDirection' => Borders::DIAGONAL_BOTH, - 'allBorders' => [ - 'borderStyle' => Border::BORDER_THIN, - ], - ], - 'fill' => [ - 'fillType' => Fill::FILL_GRADIENT_LINEAR, - 'startColor' => [ - 'argb' => 'FFA0A0A0', - ], - 'endColor' => [ - 'argb' => 'FFFFFFFF', - ], - ], -]; -``` - -### Dedicated class to manipulate coordinates - -Methods to manipulate coordinates that used to exists in `PHPExcel_Cell` were extracted -to a dedicated new class `\PhpOffice\PhpSpreadsheet\Cell\Coordinate`. The methods are: - -- `absoluteCoordinate()` -- `absoluteReference()` -- `buildRange()` -- `columnIndexFromString()` -- `coordinateFromString()` -- `extractAllCellReferencesInRange()` -- `getRangeBoundaries()` -- `mergeRangesInCollection()` -- `rangeBoundaries()` -- `rangeDimension()` -- `splitRange()` -- `stringFromColumnIndex()` - -### Column index based on 1 - -Column indexes are now based on 1. So column `A` is the index `1`. This is consistent -with rows starting at 1 and Excel function `COLUMN()` that returns `1` for column `A`. -So the code must be adapted with something like: - -```php -// Before -$cell = $worksheet->getCellByColumnAndRow($column, $row); - -for ($column = 0; $column < $max; $column++) { - $worksheet->setCellValueByColumnAndRow($column, $row, 'value ' . $column); -} - -// After -$cell = $worksheet->getCellByColumnAndRow($column + 1, $row); - -for ($column = 1; $column <= $max; $column++) { - $worksheet->setCellValueByColumnAndRow($column, $row, 'value ' . $column); -} -``` - -All the following methods are affected: - -- `PHPExcel_Worksheet::cellExistsByColumnAndRow()` -- `PHPExcel_Worksheet::freezePaneByColumnAndRow()` -- `PHPExcel_Worksheet::getCellByColumnAndRow()` -- `PHPExcel_Worksheet::getColumnDimensionByColumn()` -- `PHPExcel_Worksheet::getCommentByColumnAndRow()` -- `PHPExcel_Worksheet::getStyleByColumnAndRow()` -- `PHPExcel_Worksheet::insertNewColumnBeforeByIndex()` -- `PHPExcel_Worksheet::mergeCellsByColumnAndRow()` -- `PHPExcel_Worksheet::protectCellsByColumnAndRow()` -- `PHPExcel_Worksheet::removeColumnByIndex()` -- `PHPExcel_Worksheet::setAutoFilterByColumnAndRow()` -- `PHPExcel_Worksheet::setBreakByColumnAndRow()` -- `PHPExcel_Worksheet::setCellValueByColumnAndRow()` -- `PHPExcel_Worksheet::setCellValueExplicitByColumnAndRow()` -- `PHPExcel_Worksheet::setSelectedCellByColumnAndRow()` -- `PHPExcel_Worksheet::stringFromColumnIndex()` -- `PHPExcel_Worksheet::unmergeCellsByColumnAndRow()` -- `PHPExcel_Worksheet::unprotectCellsByColumnAndRow()` -- `PHPExcel_Worksheet_PageSetup::addPrintAreaByColumnAndRow()` -- `PHPExcel_Worksheet_PageSetup::setPrintAreaByColumnAndRow()` - -### Removed default values - -Default values for many methods were removed when it did not make sense. Typically, -setter methods should not have default values. For a complete list of methods and -their original default values, see [that commit](https://github.com/PHPOffice/PhpSpreadsheet/commit/033a4bdad56340795a5bf7ec3c8a2fde005cda24). +For more details, see +[RectorPHP blog post](https://getrector.org/blog/2020/04/16/how-to-migrate-from-phpexcel-to-phpspreadsheet-with-rector-in-30-minutes). diff --git a/src/PhpSpreadsheet/Helper/Migrator.php b/src/PhpSpreadsheet/Helper/Migrator.php deleted file mode 100644 index 26d5fcead8..0000000000 --- a/src/PhpSpreadsheet/Helper/Migrator.php +++ /dev/null @@ -1,333 +0,0 @@ -from = array_keys($this->getMapping()); - $this->to = array_values($this->getMapping()); - } - - /** - * Return the ordered mapping from old PHPExcel class names to new PhpSpreadsheet one. - * - * @return string[] - */ - public function getMapping() - { - // Order matters here, we should have the deepest namespaces first (the most "unique" strings) - $classes = [ - 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip::class, - 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer\SpContainer::class, - 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::class, - 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer::class, - 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer::class, - 'PHPExcel_Shared_OLE_PPS_File' => \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS\File::class, - 'PHPExcel_Shared_OLE_PPS_Root' => \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS\Root::class, - 'PHPExcel_Worksheet_AutoFilter_Column_Rule' => \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::class, - 'PHPExcel_Writer_OpenDocument_Cell_Comment' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Cell\Comment::class, - 'PHPExcel_Calculation_Token_Stack' => \PhpOffice\PhpSpreadsheet\Calculation\Token\Stack::class, - 'PHPExcel_Chart_Renderer_jpgraph' => \PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class, - 'PHPExcel_Reader_Excel5_Escher' => \PhpOffice\PhpSpreadsheet\Reader\Xls\Escher::class, - 'PHPExcel_Reader_Excel5_MD5' => \PhpOffice\PhpSpreadsheet\Reader\Xls\MD5::class, - 'PHPExcel_Reader_Excel5_RC4' => \PhpOffice\PhpSpreadsheet\Reader\Xls\RC4::class, - 'PHPExcel_Reader_Excel2007_Chart' => \PhpOffice\PhpSpreadsheet\Reader\Xlsx\Chart::class, - 'PHPExcel_Reader_Excel2007_Theme' => \PhpOffice\PhpSpreadsheet\Reader\Xlsx\Theme::class, - 'PHPExcel_Shared_Escher_DgContainer' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer::class, - 'PHPExcel_Shared_Escher_DggContainer' => \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer::class, - 'CholeskyDecomposition' => \PhpOffice\PhpSpreadsheet\Shared\JAMA\CholeskyDecomposition::class, - 'EigenvalueDecomposition' => \PhpOffice\PhpSpreadsheet\Shared\JAMA\EigenvalueDecomposition::class, - 'PHPExcel_Shared_JAMA_LUDecomposition' => \PhpOffice\PhpSpreadsheet\Shared\JAMA\LUDecomposition::class, - 'PHPExcel_Shared_JAMA_Matrix' => \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix::class, - 'QRDecomposition' => \PhpOffice\PhpSpreadsheet\Shared\JAMA\QRDecomposition::class, - 'PHPExcel_Shared_JAMA_QRDecomposition' => \PhpOffice\PhpSpreadsheet\Shared\JAMA\QRDecomposition::class, - 'SingularValueDecomposition' => \PhpOffice\PhpSpreadsheet\Shared\JAMA\SingularValueDecomposition::class, - 'PHPExcel_Shared_OLE_ChainedBlockStream' => \PhpOffice\PhpSpreadsheet\Shared\OLE\ChainedBlockStream::class, - 'PHPExcel_Shared_OLE_PPS' => \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS::class, - 'PHPExcel_Best_Fit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\BestFit::class, - 'PHPExcel_Exponential_Best_Fit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\ExponentialBestFit::class, - 'PHPExcel_Linear_Best_Fit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\LinearBestFit::class, - 'PHPExcel_Logarithmic_Best_Fit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\LogarithmicBestFit::class, - 'polynomialBestFit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\PolynomialBestFit::class, - 'PHPExcel_Polynomial_Best_Fit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\PolynomialBestFit::class, - 'powerBestFit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\PowerBestFit::class, - 'PHPExcel_Power_Best_Fit' => \PhpOffice\PhpSpreadsheet\Shared\Trend\PowerBestFit::class, - 'trendClass' => \PhpOffice\PhpSpreadsheet\Shared\Trend\Trend::class, - 'PHPExcel_Worksheet_AutoFilter_Column' => \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::class, - 'PHPExcel_Worksheet_Drawing_Shadow' => \PhpOffice\PhpSpreadsheet\Worksheet\Drawing\Shadow::class, - 'PHPExcel_Writer_OpenDocument_Content' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Content::class, - 'PHPExcel_Writer_OpenDocument_Meta' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Meta::class, - 'PHPExcel_Writer_OpenDocument_MetaInf' => \PhpOffice\PhpSpreadsheet\Writer\Ods\MetaInf::class, - 'PHPExcel_Writer_OpenDocument_Mimetype' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Mimetype::class, - 'PHPExcel_Writer_OpenDocument_Settings' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Settings::class, - 'PHPExcel_Writer_OpenDocument_Styles' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Styles::class, - 'PHPExcel_Writer_OpenDocument_Thumbnails' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Thumbnails::class, - 'PHPExcel_Writer_OpenDocument_WriterPart' => \PhpOffice\PhpSpreadsheet\Writer\Ods\WriterPart::class, - 'PHPExcel_Writer_PDF_Core' => \PhpOffice\PhpSpreadsheet\Writer\Pdf::class, - 'PHPExcel_Writer_PDF_DomPDF' => \PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf::class, - 'PHPExcel_Writer_PDF_mPDF' => \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf::class, - 'PHPExcel_Writer_PDF_tcPDF' => \PhpOffice\PhpSpreadsheet\Writer\Pdf\Tcpdf::class, - 'PHPExcel_Writer_Excel5_BIFFwriter' => \PhpOffice\PhpSpreadsheet\Writer\Xls\BIFFwriter::class, - 'PHPExcel_Writer_Excel5_Escher' => \PhpOffice\PhpSpreadsheet\Writer\Xls\Escher::class, - 'PHPExcel_Writer_Excel5_Font' => \PhpOffice\PhpSpreadsheet\Writer\Xls\Font::class, - 'PHPExcel_Writer_Excel5_Parser' => \PhpOffice\PhpSpreadsheet\Writer\Xls\Parser::class, - 'PHPExcel_Writer_Excel5_Workbook' => \PhpOffice\PhpSpreadsheet\Writer\Xls\Workbook::class, - 'PHPExcel_Writer_Excel5_Worksheet' => \PhpOffice\PhpSpreadsheet\Writer\Xls\Worksheet::class, - 'PHPExcel_Writer_Excel5_Xf' => \PhpOffice\PhpSpreadsheet\Writer\Xls\Xf::class, - 'PHPExcel_Writer_Excel2007_Chart' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Chart::class, - 'PHPExcel_Writer_Excel2007_Comments' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Comments::class, - 'PHPExcel_Writer_Excel2007_ContentTypes' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\ContentTypes::class, - 'PHPExcel_Writer_Excel2007_DocProps' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\DocProps::class, - 'PHPExcel_Writer_Excel2007_Drawing' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Drawing::class, - 'PHPExcel_Writer_Excel2007_Rels' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Rels::class, - 'PHPExcel_Writer_Excel2007_RelsRibbon' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\RelsRibbon::class, - 'PHPExcel_Writer_Excel2007_RelsVBA' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\RelsVBA::class, - 'PHPExcel_Writer_Excel2007_StringTable' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\StringTable::class, - 'PHPExcel_Writer_Excel2007_Style' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style::class, - 'PHPExcel_Writer_Excel2007_Theme' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Theme::class, - 'PHPExcel_Writer_Excel2007_Workbook' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Workbook::class, - 'PHPExcel_Writer_Excel2007_Worksheet' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet::class, - 'PHPExcel_Writer_Excel2007_WriterPart' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\WriterPart::class, - 'PHPExcel_CachedObjectStorage_CacheBase' => \PhpOffice\PhpSpreadsheet\Collection\Cells::class, - 'PHPExcel_CalcEngine_CyclicReferenceStack' => \PhpOffice\PhpSpreadsheet\Calculation\Engine\CyclicReferenceStack::class, - 'PHPExcel_CalcEngine_Logger' => \PhpOffice\PhpSpreadsheet\Calculation\Engine\Logger::class, - 'PHPExcel_Calculation_Functions' => \PhpOffice\PhpSpreadsheet\Calculation\Functions::class, - 'PHPExcel_Calculation_Function' => \PhpOffice\PhpSpreadsheet\Calculation\Category::class, - 'PHPExcel_Calculation_Database' => \PhpOffice\PhpSpreadsheet\Calculation\Database::class, - 'PHPExcel_Calculation_DateTime' => \PhpOffice\PhpSpreadsheet\Calculation\DateTime::class, - 'PHPExcel_Calculation_Engineering' => \PhpOffice\PhpSpreadsheet\Calculation\Engineering::class, - 'PHPExcel_Calculation_Exception' => \PhpOffice\PhpSpreadsheet\Calculation\Exception::class, - 'PHPExcel_Calculation_ExceptionHandler' => \PhpOffice\PhpSpreadsheet\Calculation\ExceptionHandler::class, - 'PHPExcel_Calculation_Financial' => \PhpOffice\PhpSpreadsheet\Calculation\Financial::class, - 'PHPExcel_Calculation_FormulaParser' => \PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::class, - 'PHPExcel_Calculation_FormulaToken' => \PhpOffice\PhpSpreadsheet\Calculation\FormulaToken::class, - 'PHPExcel_Calculation_Logical' => \PhpOffice\PhpSpreadsheet\Calculation\Logical::class, - 'PHPExcel_Calculation_LookupRef' => \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::class, - 'PHPExcel_Calculation_MathTrig' => \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::class, - 'PHPExcel_Calculation_Statistical' => \PhpOffice\PhpSpreadsheet\Calculation\Statistical::class, - 'PHPExcel_Calculation_TextData' => \PhpOffice\PhpSpreadsheet\Calculation\TextData::class, - 'PHPExcel_Cell_AdvancedValueBinder' => \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder::class, - 'PHPExcel_Cell_DataType' => \PhpOffice\PhpSpreadsheet\Cell\DataType::class, - 'PHPExcel_Cell_DataValidation' => \PhpOffice\PhpSpreadsheet\Cell\DataValidation::class, - 'PHPExcel_Cell_DefaultValueBinder' => \PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder::class, - 'PHPExcel_Cell_Hyperlink' => \PhpOffice\PhpSpreadsheet\Cell\Hyperlink::class, - 'PHPExcel_Cell_IValueBinder' => \PhpOffice\PhpSpreadsheet\Cell\IValueBinder::class, - 'PHPExcel_Chart_Axis' => \PhpOffice\PhpSpreadsheet\Chart\Axis::class, - 'PHPExcel_Chart_DataSeries' => \PhpOffice\PhpSpreadsheet\Chart\DataSeries::class, - 'PHPExcel_Chart_DataSeriesValues' => \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::class, - 'PHPExcel_Chart_Exception' => \PhpOffice\PhpSpreadsheet\Chart\Exception::class, - 'PHPExcel_Chart_GridLines' => \PhpOffice\PhpSpreadsheet\Chart\GridLines::class, - 'PHPExcel_Chart_Layout' => \PhpOffice\PhpSpreadsheet\Chart\Layout::class, - 'PHPExcel_Chart_Legend' => \PhpOffice\PhpSpreadsheet\Chart\Legend::class, - 'PHPExcel_Chart_PlotArea' => \PhpOffice\PhpSpreadsheet\Chart\PlotArea::class, - 'PHPExcel_Properties' => \PhpOffice\PhpSpreadsheet\Chart\Properties::class, - 'PHPExcel_Chart_Title' => \PhpOffice\PhpSpreadsheet\Chart\Title::class, - 'PHPExcel_DocumentProperties' => \PhpOffice\PhpSpreadsheet\Document\Properties::class, - 'PHPExcel_DocumentSecurity' => \PhpOffice\PhpSpreadsheet\Document\Security::class, - 'PHPExcel_Helper_HTML' => \PhpOffice\PhpSpreadsheet\Helper\Html::class, - 'PHPExcel_Reader_Abstract' => \PhpOffice\PhpSpreadsheet\Reader\BaseReader::class, - 'PHPExcel_Reader_CSV' => \PhpOffice\PhpSpreadsheet\Reader\Csv::class, - 'PHPExcel_Reader_DefaultReadFilter' => \PhpOffice\PhpSpreadsheet\Reader\DefaultReadFilter::class, - 'PHPExcel_Reader_Excel2003XML' => \PhpOffice\PhpSpreadsheet\Reader\Xml::class, - 'PHPExcel_Reader_Exception' => \PhpOffice\PhpSpreadsheet\Reader\Exception::class, - 'PHPExcel_Reader_Gnumeric' => \PhpOffice\PhpSpreadsheet\Reader\Gnumeric::class, - 'PHPExcel_Reader_HTML' => \PhpOffice\PhpSpreadsheet\Reader\Html::class, - 'PHPExcel_Reader_IReadFilter' => \PhpOffice\PhpSpreadsheet\Reader\IReadFilter::class, - 'PHPExcel_Reader_IReader' => \PhpOffice\PhpSpreadsheet\Reader\IReader::class, - 'PHPExcel_Reader_OOCalc' => \PhpOffice\PhpSpreadsheet\Reader\Ods::class, - 'PHPExcel_Reader_SYLK' => \PhpOffice\PhpSpreadsheet\Reader\Slk::class, - 'PHPExcel_Reader_Excel5' => \PhpOffice\PhpSpreadsheet\Reader\Xls::class, - 'PHPExcel_Reader_Excel2007' => \PhpOffice\PhpSpreadsheet\Reader\Xlsx::class, - 'PHPExcel_RichText_ITextElement' => \PhpOffice\PhpSpreadsheet\RichText\ITextElement::class, - 'PHPExcel_RichText_Run' => \PhpOffice\PhpSpreadsheet\RichText\Run::class, - 'PHPExcel_RichText_TextElement' => \PhpOffice\PhpSpreadsheet\RichText\TextElement::class, - 'PHPExcel_Shared_CodePage' => \PhpOffice\PhpSpreadsheet\Shared\CodePage::class, - 'PHPExcel_Shared_Date' => \PhpOffice\PhpSpreadsheet\Shared\Date::class, - 'PHPExcel_Shared_Drawing' => \PhpOffice\PhpSpreadsheet\Shared\Drawing::class, - 'PHPExcel_Shared_Escher' => \PhpOffice\PhpSpreadsheet\Shared\Escher::class, - 'PHPExcel_Shared_File' => \PhpOffice\PhpSpreadsheet\Shared\File::class, - 'PHPExcel_Shared_Font' => \PhpOffice\PhpSpreadsheet\Shared\Font::class, - 'PHPExcel_Shared_OLE' => \PhpOffice\PhpSpreadsheet\Shared\OLE::class, - 'PHPExcel_Shared_OLERead' => \PhpOffice\PhpSpreadsheet\Shared\OLERead::class, - 'PHPExcel_Shared_PasswordHasher' => \PhpOffice\PhpSpreadsheet\Shared\PasswordHasher::class, - 'PHPExcel_Shared_String' => \PhpOffice\PhpSpreadsheet\Shared\StringHelper::class, - 'PHPExcel_Shared_TimeZone' => \PhpOffice\PhpSpreadsheet\Shared\TimeZone::class, - 'PHPExcel_Shared_XMLWriter' => \PhpOffice\PhpSpreadsheet\Shared\XMLWriter::class, - 'PHPExcel_Shared_Excel5' => \PhpOffice\PhpSpreadsheet\Shared\Xls::class, - 'PHPExcel_Style_Alignment' => \PhpOffice\PhpSpreadsheet\Style\Alignment::class, - 'PHPExcel_Style_Border' => \PhpOffice\PhpSpreadsheet\Style\Border::class, - 'PHPExcel_Style_Borders' => \PhpOffice\PhpSpreadsheet\Style\Borders::class, - 'PHPExcel_Style_Color' => \PhpOffice\PhpSpreadsheet\Style\Color::class, - 'PHPExcel_Style_Conditional' => \PhpOffice\PhpSpreadsheet\Style\Conditional::class, - 'PHPExcel_Style_Fill' => \PhpOffice\PhpSpreadsheet\Style\Fill::class, - 'PHPExcel_Style_Font' => \PhpOffice\PhpSpreadsheet\Style\Font::class, - 'PHPExcel_Style_NumberFormat' => \PhpOffice\PhpSpreadsheet\Style\NumberFormat::class, - 'PHPExcel_Style_Protection' => \PhpOffice\PhpSpreadsheet\Style\Protection::class, - 'PHPExcel_Style_Supervisor' => \PhpOffice\PhpSpreadsheet\Style\Supervisor::class, - 'PHPExcel_Worksheet_AutoFilter' => \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter::class, - 'PHPExcel_Worksheet_BaseDrawing' => \PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::class, - 'PHPExcel_Worksheet_CellIterator' => \PhpOffice\PhpSpreadsheet\Worksheet\CellIterator::class, - 'PHPExcel_Worksheet_Column' => \PhpOffice\PhpSpreadsheet\Worksheet\Column::class, - 'PHPExcel_Worksheet_ColumnCellIterator' => \PhpOffice\PhpSpreadsheet\Worksheet\ColumnCellIterator::class, - 'PHPExcel_Worksheet_ColumnDimension' => \PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension::class, - 'PHPExcel_Worksheet_ColumnIterator' => \PhpOffice\PhpSpreadsheet\Worksheet\ColumnIterator::class, - 'PHPExcel_Worksheet_Drawing' => \PhpOffice\PhpSpreadsheet\Worksheet\Drawing::class, - 'PHPExcel_Worksheet_HeaderFooter' => \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter::class, - 'PHPExcel_Worksheet_HeaderFooterDrawing' => \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing::class, - 'PHPExcel_WorksheetIterator' => \PhpOffice\PhpSpreadsheet\Worksheet\Iterator::class, - 'PHPExcel_Worksheet_MemoryDrawing' => \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::class, - 'PHPExcel_Worksheet_PageMargins' => \PhpOffice\PhpSpreadsheet\Worksheet\PageMargins::class, - 'PHPExcel_Worksheet_PageSetup' => \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::class, - 'PHPExcel_Worksheet_Protection' => \PhpOffice\PhpSpreadsheet\Worksheet\Protection::class, - 'PHPExcel_Worksheet_Row' => \PhpOffice\PhpSpreadsheet\Worksheet\Row::class, - 'PHPExcel_Worksheet_RowCellIterator' => \PhpOffice\PhpSpreadsheet\Worksheet\RowCellIterator::class, - 'PHPExcel_Worksheet_RowDimension' => \PhpOffice\PhpSpreadsheet\Worksheet\RowDimension::class, - 'PHPExcel_Worksheet_RowIterator' => \PhpOffice\PhpSpreadsheet\Worksheet\RowIterator::class, - 'PHPExcel_Worksheet_SheetView' => \PhpOffice\PhpSpreadsheet\Worksheet\SheetView::class, - 'PHPExcel_Writer_Abstract' => \PhpOffice\PhpSpreadsheet\Writer\BaseWriter::class, - 'PHPExcel_Writer_CSV' => \PhpOffice\PhpSpreadsheet\Writer\Csv::class, - 'PHPExcel_Writer_Exception' => \PhpOffice\PhpSpreadsheet\Writer\Exception::class, - 'PHPExcel_Writer_HTML' => \PhpOffice\PhpSpreadsheet\Writer\Html::class, - 'PHPExcel_Writer_IWriter' => \PhpOffice\PhpSpreadsheet\Writer\IWriter::class, - 'PHPExcel_Writer_OpenDocument' => \PhpOffice\PhpSpreadsheet\Writer\Ods::class, - 'PHPExcel_Writer_PDF' => \PhpOffice\PhpSpreadsheet\Writer\Pdf::class, - 'PHPExcel_Writer_Excel5' => \PhpOffice\PhpSpreadsheet\Writer\Xls::class, - 'PHPExcel_Writer_Excel2007' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx::class, - 'PHPExcel_CachedObjectStorageFactory' => \PhpOffice\PhpSpreadsheet\Collection\CellsFactory::class, - 'PHPExcel_Calculation' => \PhpOffice\PhpSpreadsheet\Calculation\Calculation::class, - 'PHPExcel_Cell' => \PhpOffice\PhpSpreadsheet\Cell\Cell::class, - 'PHPExcel_Chart' => \PhpOffice\PhpSpreadsheet\Chart\Chart::class, - 'PHPExcel_Comment' => \PhpOffice\PhpSpreadsheet\Comment::class, - 'PHPExcel_Exception' => \PhpOffice\PhpSpreadsheet\Exception::class, - 'PHPExcel_HashTable' => \PhpOffice\PhpSpreadsheet\HashTable::class, - 'PHPExcel_IComparable' => \PhpOffice\PhpSpreadsheet\IComparable::class, - 'PHPExcel_IOFactory' => \PhpOffice\PhpSpreadsheet\IOFactory::class, - 'PHPExcel_NamedRange' => \PhpOffice\PhpSpreadsheet\NamedRange::class, - 'PHPExcel_ReferenceHelper' => \PhpOffice\PhpSpreadsheet\ReferenceHelper::class, - 'PHPExcel_RichText' => \PhpOffice\PhpSpreadsheet\RichText\RichText::class, - 'PHPExcel_Settings' => \PhpOffice\PhpSpreadsheet\Settings::class, - 'PHPExcel_Style' => \PhpOffice\PhpSpreadsheet\Style\Style::class, - 'PHPExcel_Worksheet' => \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::class, - ]; - - $methods = [ - 'MINUTEOFHOUR' => 'MINUTE', - 'SECONDOFMINUTE' => 'SECOND', - 'DAYOFWEEK' => 'WEEKDAY', - 'WEEKOFYEAR' => 'WEEKNUM', - 'ExcelToPHPObject' => 'excelToDateTimeObject', - 'ExcelToPHP' => 'excelToTimestamp', - 'FormattedPHPToExcel' => 'formattedPHPToExcel', - 'Cell::absoluteCoordinate' => 'Coordinate::absoluteCoordinate', - 'Cell::absoluteReference' => 'Coordinate::absoluteReference', - 'Cell::buildRange' => 'Coordinate::buildRange', - 'Cell::columnIndexFromString' => 'Coordinate::columnIndexFromString', - 'Cell::coordinateFromString' => 'Coordinate::coordinateFromString', - 'Cell::extractAllCellReferencesInRange' => 'Coordinate::extractAllCellReferencesInRange', - 'Cell::getRangeBoundaries' => 'Coordinate::getRangeBoundaries', - 'Cell::mergeRangesInCollection' => 'Coordinate::mergeRangesInCollection', - 'Cell::rangeBoundaries' => 'Coordinate::rangeBoundaries', - 'Cell::rangeDimension' => 'Coordinate::rangeDimension', - 'Cell::splitRange' => 'Coordinate::splitRange', - 'Cell::stringFromColumnIndex' => 'Coordinate::stringFromColumnIndex', - ]; - - // Keep '\' prefix for class names - $prefixedClasses = []; - foreach ($classes as $key => &$value) { - $value = str_replace('PhpOffice\\', '\\PhpOffice\\', $value); - $prefixedClasses['\\' . $key] = $value; - } - $mapping = $prefixedClasses + $classes + $methods; - - return $mapping; - } - - /** - * Search in all files in given directory. - * - * @param string $path - */ - private function recursiveReplace($path) - { - $patterns = [ - '/*.md', - '/*.txt', - '/*.TXT', - '/*.php', - '/*.phpt', - '/*.php3', - '/*.php4', - '/*.php5', - '/*.phtml', - ]; - - foreach ($patterns as $pattern) { - foreach (glob($path . $pattern) as $file) { - if (strpos($path, '/vendor/') !== false) { - echo $file . " skipped\n"; - - continue; - } - $original = file_get_contents($file); - $converted = $this->replace($original); - - if ($original !== $converted) { - echo $file . " converted\n"; - file_put_contents($file, $converted); - } - } - } - - // Do the recursion in subdirectory - foreach (glob($path . '/*', GLOB_ONLYDIR) as $subpath) { - if (strpos($subpath, $path . '/') === 0) { - $this->recursiveReplace($subpath); - } - } - } - - public function migrate() - { - $path = realpath(getcwd()); - echo 'This will search and replace recursively in ' . $path . PHP_EOL; - echo 'You MUST backup your files first, or you risk losing data.' . PHP_EOL; - echo 'Are you sure ? (y/n)'; - - $confirm = fread(STDIN, 1); - if ($confirm === 'y') { - $this->recursiveReplace($path); - } - } - - /** - * Migrate the given code from PHPExcel to PhpSpreadsheet. - * - * @param string $original - * - * @return string - */ - public function replace($original) - { - $converted = str_replace($this->from, $this->to, $original); - - // The string "PHPExcel" gets special treatment because of how common it might be. - // This regex requires a word boundary around the string, and it can't be - // preceded by $ or -> (goal is to filter out cases where a variable is named $PHPExcel or similar) - $converted = preg_replace('~(?)(\b|\\\\)PHPExcel\b~', '\\' . \PhpOffice\PhpSpreadsheet\Spreadsheet::class, $converted); - - return $converted; - } -} diff --git a/tests/PhpSpreadsheetTests/Helper/MigratorTest.php b/tests/PhpSpreadsheetTests/Helper/MigratorTest.php deleted file mode 100644 index a64cda80f6..0000000000 --- a/tests/PhpSpreadsheetTests/Helper/MigratorTest.php +++ /dev/null @@ -1,88 +0,0 @@ -getMapping() as $classname) { - if (substr_count($classname, '\\')) { - self::assertTrue(class_exists($classname) || interface_exists($classname), 'mapping is wrong, class does not exists in project: ' . $classname); - } - } - } - - public function testReplace() - { - $input = <<<'STRING' -do(); - $fooobjPHPExcel->do(); - $objPHPExcel->do(); - $this->objPHPExcel->do(); - $this->PHPExcel->do(); - - return \PHPExcel_Cell::stringFromColumnIndex(9); - } -} -STRING; - - $expected = <<<'STRING' -do(); - $fooobjPHPExcel->do(); - $objPHPExcel->do(); - $this->objPHPExcel->do(); - $this->PHPExcel->do(); - - return \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex(9); - } -} -STRING; - - $migrator = new Migrator(); - self::assertSame($expected, $migrator->replace($input)); - } -} From 925fafdecf7dca23bc66799ba500de0417ed281c Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 2 May 2020 12:35:42 +0900 Subject: [PATCH 025/659] Placeholder for new changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bf9b93180..6b2b502c74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org). ## [Unreleased] +### Added + +- ... + +### Fixed + +- ... + ### Changed - Drop support for PHP 7.1, according to https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support From 4b5c92273119d1fc5c3b41a993331c64398ea063 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 2 May 2020 21:45:11 +0900 Subject: [PATCH 026/659] Follow redirect to download phpDocumentor --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2e51c7a4a1..31ae804ea2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,9 +41,9 @@ jobs: if: tag is present AND branch = master php: 7.4 before_script: - - curl -O https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.0.0-rc/phpDocumentor.phar + - curl -LO https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.0.0-rc/phpDocumentor.phar script: - - php phpDocumentor.phar --directory src/ --target docs/api + - php phpDocumentor.phar --directory src/ --target docs/api deploy: provider: pages skip-cleanup: true From 9cdbddf3bfa82fefc59052cee67bfbe08e94d49a Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 16 May 2020 18:08:10 +0900 Subject: [PATCH 027/659] Early bail out if resource cannot be opened --- src/PhpSpreadsheet/Writer/Ods.php | 9 +++++++-- src/PhpSpreadsheet/Writer/Xlsx.php | 11 ++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Ods.php b/src/PhpSpreadsheet/Writer/Ods.php index 08bd2629cb..9de19eb43f 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -33,7 +33,7 @@ class Ods extends BaseWriter private $spreadSheet; /** - * @var bool|resource + * @var resource */ private $fileHandle; @@ -105,7 +105,12 @@ public function save($pFilename) } } - $this->fileHandle = fopen($pFilename, 'wb+'); + $fileHandle = fopen($pFilename, 'wb+'); + if ($fileHandle === false) { + throw new WriterException('Could not open file ' . $pFilename . ' for writing.'); + } + + $this->fileHandle = $fileHandle; } $zip = $this->createZip(); diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index 9c947d0a9d..3b4bdfd9bc 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -108,7 +108,7 @@ class Xlsx extends BaseWriter private $drawingHashTable; /** - * @var bool|resource + * @var resource */ private $fileHandle; @@ -196,11 +196,12 @@ public function save($pFilename) } } - $this->fileHandle = fopen($pFilename, 'wb+'); - } + $fileHandle = fopen($pFilename, 'wb+'); + if ($fileHandle === false) { + throw new WriterException('Could not open file ' . $pFilename . ' for writing.'); + } - if (!is_resource($this->fileHandle)) { - throw new WriterException('Could not open resource for writing.'); + $this->fileHandle = $fileHandle; } $saveDebugLog = Calculation::getInstance($this->spreadSheet)->getDebugLog()->getWriteDebugLog(); From fcf78204670fe5c7ab298d9c2cdd9b1c15000c31 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 16 May 2020 20:12:28 +0900 Subject: [PATCH 028/659] All writers can write to stream --- src/PhpSpreadsheet/Shared/OLE/PPS/Root.php | 44 ++---------------- src/PhpSpreadsheet/Writer/BaseWriter.php | 45 +++++++++++++++++++ src/PhpSpreadsheet/Writer/Csv.php | 5 --- src/PhpSpreadsheet/Writer/Html.php | 21 +++------ src/PhpSpreadsheet/Writer/Ods.php | 43 +----------------- src/PhpSpreadsheet/Writer/Pdf.php | 10 ++--- src/PhpSpreadsheet/Writer/Pdf/Mpdf.php | 2 +- src/PhpSpreadsheet/Writer/Xls.php | 4 +- src/PhpSpreadsheet/Writer/Xlsx.php | 43 +----------------- .../Functional/StreamTest.php | 45 +++++++++++++++++++ 10 files changed, 111 insertions(+), 151 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/Functional/StreamTest.php diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php index c52cea239f..472483ebaa 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php @@ -22,7 +22,6 @@ // use PhpOffice\PhpSpreadsheet\Shared\OLE; use PhpOffice\PhpSpreadsheet\Shared\OLE\PPS; -use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; /** * Class for creating Root PPS's for OLE containers. @@ -33,23 +32,11 @@ */ class Root extends PPS { - /** - * Directory for temporary files. - * - * @var string - */ - protected $tempDirectory; - /** * @var resource */ private $fileHandle; - /** - * @var string - */ - private $tempFilename; - /** * @var int */ @@ -67,8 +54,6 @@ class Root extends PPS */ public function __construct($time_1st, $time_2nd, $raChild) { - $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); } @@ -79,14 +64,14 @@ public function __construct($time_1st, $time_2nd, $raChild) * If a resource pointer to a stream created by fopen() is passed * it will be used, but you have to close such stream by yourself. * - * @param resource|string $filename the name of the file or stream where to save the OLE container - * - * @throws WriterException + * @param resource $fileHandle the name of the file or stream where to save the OLE container * * @return bool true on success */ - public function save($filename) + public function save($fileHandle) { + $this->fileHandle = $fileHandle; + // Initial Setting for saving $this->bigBlockSize = pow( 2, @@ -97,23 +82,6 @@ public function save($filename) (isset($this->smallBlockSize)) ? self::adjust2($this->smallBlockSize) : 6 ); - if (is_resource($filename)) { - $this->fileHandle = $filename; - } elseif ($filename == '-' || $filename == '') { - if ($this->tempDirectory === null) { - $this->tempDirectory = \PhpOffice\PhpSpreadsheet\Shared\File::sysGetTempDir(); - } - $this->tempFilename = tempnam($this->tempDirectory, 'OLE_PPS_Root'); - $this->fileHandle = fopen($this->tempFilename, 'w+b'); - if ($this->fileHandle == false) { - throw new WriterException("Can't create temporary file."); - } - } else { - $this->fileHandle = fopen($filename, 'wb'); - } - if ($this->fileHandle == false) { - throw new WriterException("Can't open $filename. It may be in use or protected."); - } // Make an array of PPS's (for Save) $aList = []; PPS::_savePpsSetPnt($aList, [$this]); @@ -132,10 +100,6 @@ public function save($filename) // Write Big Block Depot and BDList and Adding Header informations $this->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt); - if (!is_resource($filename)) { - fclose($this->fileHandle); - } - return true; } diff --git a/src/PhpSpreadsheet/Writer/BaseWriter.php b/src/PhpSpreadsheet/Writer/BaseWriter.php index f13150d7eb..dc7a04317f 100644 --- a/src/PhpSpreadsheet/Writer/BaseWriter.php +++ b/src/PhpSpreadsheet/Writer/BaseWriter.php @@ -35,6 +35,16 @@ abstract class BaseWriter implements IWriter */ private $diskCachingDirectory = './'; + /** + * @var resource + */ + protected $fileHandle; + + /** + * @var bool + */ + private $shouldCloseFile; + public function getIncludeCharts() { return $this->includeCharts; @@ -83,4 +93,39 @@ public function getDiskCachingDirectory() { return $this->diskCachingDirectory; } + + /** + * Open file handle. + * + * @param resource|string $filename + */ + public function openFileHandle($filename): void + { + if (is_resource($filename)) { + $this->fileHandle = $filename; + $this->shouldCloseFile = false; + + return; + } + + $fileHandle = fopen($filename, 'wb+'); + if ($fileHandle === false) { + throw new Exception('Could not open file ' . $filename . ' for writing.'); + } + + $this->fileHandle = $fileHandle; + $this->shouldCloseFile = true; + } + + /** + * Close file handle only we opened it ourselves. + */ + protected function maybeCloseFileHandle(): void + { + if ($this->shouldCloseFile) { + if (!fclose($this->fileHandle)) { + throw new Exception('Could not close file after writing.'); + } + } + } } diff --git a/src/PhpSpreadsheet/Writer/Csv.php b/src/PhpSpreadsheet/Writer/Csv.php index 1cf646341b..e5c08c1347 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -131,11 +131,6 @@ public function save($pFilename) $this->writeLine($fileHandle, $cellsArray[0]); } - // Close file - rewind($fileHandle); - - fclose($fileHandle); - Calculation::setArrayReturnType($saveArrayReturnType); Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); } diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 91beedb76d..ed6db1b730 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -164,32 +164,23 @@ public function save($pFilename) $this->buildCSS(!$this->useInlineCss); // Open file - if (is_resource($pFilename)) { - $fileHandle = $pFilename; - } else { - $fileHandle = fopen($pFilename, 'wb+'); - } - - if ($fileHandle === false) { - throw new WriterException("Could not open file $pFilename for writing."); - } + $this->openFileHandle($pFilename); // Write headers - fwrite($fileHandle, $this->generateHTMLHeader(!$this->useInlineCss)); + fwrite($this->fileHandle, $this->generateHTMLHeader(!$this->useInlineCss)); // Write navigation (tabs) if ((!$this->isPdf) && ($this->generateSheetNavigationBlock)) { - fwrite($fileHandle, $this->generateNavigation()); + fwrite($this->fileHandle, $this->generateNavigation()); } // Write data - fwrite($fileHandle, $this->generateSheetData()); + fwrite($this->fileHandle, $this->generateSheetData()); // Write footer - fwrite($fileHandle, $this->generateHTMLFooter()); + fwrite($this->fileHandle, $this->generateHTMLFooter()); - // Close file - fclose($fileHandle); + $this->maybeCloseFileHandle(); Calculation::setArrayReturnType($saveArrayReturnType); Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); diff --git a/src/PhpSpreadsheet/Writer/Ods.php b/src/PhpSpreadsheet/Writer/Ods.php index 9de19eb43f..bb981d35bb 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -32,11 +32,6 @@ class Ods extends BaseWriter */ private $spreadSheet; - /** - * @var resource - */ - private $fileHandle; - /** * Create a new Ods. * @@ -93,25 +88,7 @@ public function save($pFilename) // garbage collect $this->spreadSheet->garbageCollect(); - $originalFilename = $pFilename; - if (is_resource($pFilename)) { - $this->fileHandle = $pFilename; - } else { - // If $pFilename is php://output or php://stdout, make it a temporary file... - if (in_array(strtolower($pFilename), ['php://output', 'php://stdout'], true)) { - $pFilename = @tempnam(File::sysGetTempDir(), 'phpxltmp'); - if ($pFilename === '') { - $pFilename = $originalFilename; - } - } - - $fileHandle = fopen($pFilename, 'wb+'); - if ($fileHandle === false) { - throw new WriterException('Could not open file ' . $pFilename . ' for writing.'); - } - - $this->fileHandle = $fileHandle; - } + $this->openFileHandle($pFilename); $zip = $this->createZip(); @@ -130,23 +107,7 @@ public function save($pFilename) throw new WriterException('Could not close resource.'); } - rewind($this->fileHandle); - - // If a temporary file was used, copy it to the correct file stream - if ($originalFilename !== $pFilename) { - $destinationFileHandle = fopen($originalFilename, 'wb+'); - if (!is_resource($destinationFileHandle)) { - throw new WriterException("Could not open resource $originalFilename for writing."); - } - - if (stream_copy_to_stream($this->fileHandle, $destinationFileHandle) === false) { - throw new WriterException("Could not copy temporary zip file $pFilename to $originalFilename."); - } - - if (is_string($pFilename) && !unlink($pFilename)) { - throw new WriterException('Could not unlink temporary zip file.'); - } - } + $this->maybeCloseFileHandle(); } /** diff --git a/src/PhpSpreadsheet/Writer/Pdf.php b/src/PhpSpreadsheet/Writer/Pdf.php index d91845603a..52f9574989 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -255,17 +255,14 @@ protected function prepareForSave($pFilename) Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE); // Open file - $fileHandle = fopen($pFilename, 'w'); - if ($fileHandle === false) { - throw new WriterException("Could not open file $pFilename for writing."); - } + $this->openFileHandle($pFilename); // Set PDF $this->isPdf = true; // Build CSS $this->buildCSS(true); - return $fileHandle; + return $this->fileHandle; } /** @@ -275,8 +272,7 @@ protected function prepareForSave($pFilename) */ protected function restoreStateAfterSave($fileHandle) { - // Close file - fclose($fileHandle); + $this->maybeCloseFileHandle(); Calculation::setArrayReturnType($this->saveArrayReturnType); } diff --git a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php index fd2664a823..5fdc4ea8c6 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php @@ -65,7 +65,7 @@ public function save($pFilename) } // Create PDF - $config = ['tempDir' => $this->tempDir]; + $config = ['tempDir' => $this->tempDir . '/mpdf']; $pdf = $this->createExternalWriterInstance($config); $ortmp = $orientation; $pdf->_setPageSize(strtoupper($paperSize), $ortmp); diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index 95693ddeaa..fb42bf9e0d 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -221,7 +221,9 @@ public function save($pFilename) $root = new Root(time(), time(), $arrRootData); // save the OLE file - $root->save($pFilename); + $this->openFileHandle($pFilename); + $root->save($this->fileHandle); + $this->maybeCloseFileHandle(); Functions::setReturnDateType($saveDateReturnType); Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index 3b4bdfd9bc..aea6a26cd3 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -107,11 +107,6 @@ class Xlsx extends BaseWriter */ private $drawingHashTable; - /** - * @var resource - */ - private $fileHandle; - /** * Create a new Xlsx Writer. * @@ -184,25 +179,7 @@ public function save($pFilename) // garbage collect $this->spreadSheet->garbageCollect(); - $originalFilename = $pFilename; - if (is_resource($pFilename)) { - $this->fileHandle = $pFilename; - } else { - // If $pFilename is php://output or php://stdout, make it a temporary file... - if (in_array(strtolower($pFilename), ['php://output', 'php://stdout'], true)) { - $pFilename = @tempnam(File::sysGetTempDir(), 'phpxltmp'); - if ($pFilename === '') { - $pFilename = $originalFilename; - } - } - - $fileHandle = fopen($pFilename, 'wb+'); - if ($fileHandle === false) { - throw new WriterException('Could not open file ' . $pFilename . ' for writing.'); - } - - $this->fileHandle = $fileHandle; - } + $this->openFileHandle($pFilename); $saveDebugLog = Calculation::getInstance($this->spreadSheet)->getDebugLog()->getWriteDebugLog(); Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog(false); @@ -425,23 +402,7 @@ public function save($pFilename) throw new WriterException('Could not close resource.'); } - rewind($this->fileHandle); - - // If a temporary file was used, copy it to the correct file stream - if ($originalFilename !== $pFilename) { - $destinationFileHandle = fopen($originalFilename, 'wb+'); - if (!is_resource($destinationFileHandle)) { - throw new WriterException("Could not open resource $originalFilename for writing."); - } - - if (stream_copy_to_stream($this->fileHandle, $destinationFileHandle) === false) { - throw new WriterException("Could not copy temporary zip file $pFilename to $originalFilename."); - } - - if (is_string($pFilename) && !unlink($pFilename)) { - throw new WriterException('Could not unlink temporary zip file.'); - } - } + $this->maybeCloseFileHandle(); } else { throw new WriterException('PhpSpreadsheet object unassigned.'); } diff --git a/tests/PhpSpreadsheetTests/Functional/StreamTest.php b/tests/PhpSpreadsheetTests/Functional/StreamTest.php new file mode 100644 index 0000000000..20e588bb4c --- /dev/null +++ b/tests/PhpSpreadsheetTests/Functional/StreamTest.php @@ -0,0 +1,45 @@ +getActiveSheet()->setCellValue('A1', 'foo'); + $writer = IOFactory::createWriter($spreadsheet, $format); + + $stream = fopen('php://memory', 'wb+'); + self::assertSame(0, fstat($stream)['size']); + + $writer->save($stream); + + self::assertIsResource($stream, 'should not close the stream for further usage out of PhpSpreadsheet'); + self::assertGreaterThan(0, fstat($stream)['size'], 'something should have been written to the stream'); + self::assertGreaterThan(0, ftell($stream), 'should not be rewinded, because not all streams support it'); + } +} From e34535329da3696b2ac5a432652e6cc6e504de8b Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 16 May 2020 20:25:01 +0900 Subject: [PATCH 029/659] Remove obsolete arguments --- src/PhpSpreadsheet/Writer/Pdf.php | 4 +--- src/PhpSpreadsheet/Writer/Pdf/Dompdf.php | 2 +- src/PhpSpreadsheet/Writer/Pdf/Mpdf.php | 2 +- src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Pdf.php b/src/PhpSpreadsheet/Writer/Pdf.php index 52f9574989..f0c1798fd2 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -267,10 +267,8 @@ protected function prepareForSave($pFilename) /** * Save PhpSpreadsheet to PDF file, post-save. - * - * @param resource $fileHandle */ - protected function restoreStateAfterSave($fileHandle) + protected function restoreStateAfterSave(): void { $this->maybeCloseFileHandle(); diff --git a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php index 3c3044d711..783bf253c2 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php @@ -73,6 +73,6 @@ public function save($pFilename) // Write to file fwrite($fileHandle, $pdf->output()); - parent::restoreStateAfterSave($fileHandle); + parent::restoreStateAfterSave(); } } diff --git a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php index 5fdc4ea8c6..2922db1501 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php @@ -95,7 +95,7 @@ public function save($pFilename) // Write to file fwrite($fileHandle, $pdf->Output('', 'S')); - parent::restoreStateAfterSave($fileHandle); + parent::restoreStateAfterSave(); } /** diff --git a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php index 8a97b8fed5..6ba77c753d 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php @@ -93,6 +93,6 @@ public function save($pFilename) // Write to file fwrite($fileHandle, $pdf->output($pFilename, 'S')); - parent::restoreStateAfterSave($fileHandle); + parent::restoreStateAfterSave(); } } From 65795519542e2bd55cabe63e94246905112e46ac Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 16 May 2020 20:27:47 +0900 Subject: [PATCH 030/659] Update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b2b502c74..57bad0aa09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Added -- ... +- Support writing to streams in all writers [#1292](https://github.com/PHPOffice/PhpSpreadsheet/issues/1292) ### Fixed From 7e79782dae60edeea90040bf9abec25c8befaea7 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 16 May 2020 20:33:25 +0900 Subject: [PATCH 031/659] Remove @throws comment Those are extremely hard to maintain properly and bring almost no value, especially if they are outdated --- .../Calculation/Calculation.php | 10 ---- .../Calculation/Engineering.php | 2 - .../Calculation/FormulaParser.php | 4 -- .../Cell/AdvancedValueBinder.php | 2 - src/PhpSpreadsheet/Cell/Cell.php | 20 ------- src/PhpSpreadsheet/Cell/Coordinate.php | 8 --- .../Cell/DefaultValueBinder.php | 2 - src/PhpSpreadsheet/Cell/StringValueBinder.php | 2 - src/PhpSpreadsheet/Chart/DataSeriesValues.php | 4 -- src/PhpSpreadsheet/Collection/Cells.php | 8 --- src/PhpSpreadsheet/DocumentGenerator.php | 10 ---- src/PhpSpreadsheet/HashTable.php | 4 -- src/PhpSpreadsheet/IOFactory.php | 10 ---- src/PhpSpreadsheet/NamedRange.php | 2 - src/PhpSpreadsheet/Reader/BaseReader.php | 2 - src/PhpSpreadsheet/Reader/Csv.php | 6 -- src/PhpSpreadsheet/Reader/Gnumeric.php | 6 -- src/PhpSpreadsheet/Reader/Html.php | 8 --- src/PhpSpreadsheet/Reader/IReader.php | 2 - src/PhpSpreadsheet/Reader/Ods.php | 10 ---- .../Reader/Security/XmlScanner.php | 4 -- src/PhpSpreadsheet/Reader/Slk.php | 6 -- src/PhpSpreadsheet/Reader/Xls.php | 14 ----- src/PhpSpreadsheet/Reader/Xlsx.php | 8 --- src/PhpSpreadsheet/Reader/Xml.php | 12 ---- src/PhpSpreadsheet/ReferenceHelper.php | 12 ---- src/PhpSpreadsheet/RichText/RichText.php | 7 --- src/PhpSpreadsheet/Settings.php | 2 - src/PhpSpreadsheet/Shared/CodePage.php | 2 - src/PhpSpreadsheet/Shared/Date.php | 8 --- src/PhpSpreadsheet/Shared/File.php | 2 - src/PhpSpreadsheet/Shared/Font.php | 2 - .../Shared/JAMA/LUDecomposition.php | 3 - src/PhpSpreadsheet/Shared/OLE.php | 4 -- src/PhpSpreadsheet/Shared/OLERead.php | 2 - src/PhpSpreadsheet/Shared/TimeZone.php | 2 - src/PhpSpreadsheet/Spreadsheet.php | 32 ----------- src/PhpSpreadsheet/Style/Alignment.php | 4 -- src/PhpSpreadsheet/Style/Border.php | 6 -- src/PhpSpreadsheet/Style/Borders.php | 12 ---- src/PhpSpreadsheet/Style/Color.php | 4 -- src/PhpSpreadsheet/Style/Fill.php | 8 --- src/PhpSpreadsheet/Style/Font.php | 6 -- src/PhpSpreadsheet/Style/NumberFormat.php | 3 - src/PhpSpreadsheet/Style/Protection.php | 4 -- src/PhpSpreadsheet/Worksheet/AutoFilter.php | 16 ------ .../Worksheet/AutoFilter/Column.php | 6 -- .../Worksheet/AutoFilter/Column/Rule.php | 10 ---- src/PhpSpreadsheet/Worksheet/BaseDrawing.php | 2 - src/PhpSpreadsheet/Worksheet/CellIterator.php | 6 -- .../Worksheet/ColumnCellIterator.php | 8 --- .../Worksheet/ColumnIterator.php | 4 -- src/PhpSpreadsheet/Worksheet/Dimension.php | 2 - src/PhpSpreadsheet/Worksheet/Drawing.php | 2 - src/PhpSpreadsheet/Worksheet/PageSetup.php | 12 ---- .../Worksheet/RowCellIterator.php | 10 ---- src/PhpSpreadsheet/Worksheet/RowIterator.php | 4 -- src/PhpSpreadsheet/Worksheet/SheetView.php | 6 -- src/PhpSpreadsheet/Worksheet/Worksheet.php | 56 ------------------- src/PhpSpreadsheet/Writer/Csv.php | 2 - src/PhpSpreadsheet/Writer/Html.php | 15 ----- src/PhpSpreadsheet/Writer/IWriter.php | 4 -- src/PhpSpreadsheet/Writer/Ods.php | 6 -- src/PhpSpreadsheet/Writer/Ods/Content.php | 6 -- src/PhpSpreadsheet/Writer/Ods/Meta.php | 2 - src/PhpSpreadsheet/Writer/Ods/MetaInf.php | 2 - src/PhpSpreadsheet/Writer/Ods/Settings.php | 2 - src/PhpSpreadsheet/Writer/Ods/Styles.php | 2 - src/PhpSpreadsheet/Writer/Pdf.php | 4 -- src/PhpSpreadsheet/Writer/Pdf/Dompdf.php | 2 - src/PhpSpreadsheet/Writer/Pdf/Mpdf.php | 4 -- src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php | 2 - src/PhpSpreadsheet/Writer/Xls.php | 2 - src/PhpSpreadsheet/Writer/Xlsx.php | 4 -- src/PhpSpreadsheet/Writer/Xlsx/Chart.php | 16 ------ src/PhpSpreadsheet/Writer/Xlsx/Comments.php | 6 -- .../Writer/Xlsx/ContentTypes.php | 8 --- src/PhpSpreadsheet/Writer/Xlsx/DocProps.php | 6 -- src/PhpSpreadsheet/Writer/Xlsx/Drawing.php | 6 -- src/PhpSpreadsheet/Writer/Xlsx/Rels.php | 14 ----- src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php | 2 - src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php | 2 - .../Writer/Xlsx/StringTable.php | 3 - src/PhpSpreadsheet/Writer/Xlsx/Style.php | 4 -- src/PhpSpreadsheet/Writer/Xlsx/Theme.php | 2 - src/PhpSpreadsheet/Writer/Xlsx/Workbook.php | 10 ---- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 11 ---- .../Calculation/CalculationTest.php | 2 - .../DocumentGeneratorTest.php | 4 -- 89 files changed, 590 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 69f72033a3..e1469b1f47 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -2315,8 +2315,6 @@ public function getDebugLog() /** * __clone implementation. Cloning should not be allowed in a Singleton! - * - * @throws Exception */ final public function __clone() { @@ -2765,8 +2763,6 @@ public static function unwrapResult($value) * * @param Cell $pCell Cell to calculate * - * @throws Exception - * * @return mixed */ public function calculate(Cell $pCell = null) @@ -2784,8 +2780,6 @@ public function calculate(Cell $pCell = null) * @param Cell $pCell Cell to calculate * @param bool $resetLog Flag indicating whether the debug log should be reset or not * - * @throws \PhpOffice\PhpSpreadsheet\Exception - * * @return mixed */ public function calculateCellValue(Cell $pCell = null, $resetLog = true) @@ -2888,8 +2882,6 @@ public function parseFormula($formula) * @param string $cellID Address of the cell to calculate * @param Cell $pCell Cell to calculate * - * @throws \PhpOffice\PhpSpreadsheet\Exception - * * @return mixed */ public function calculateFormula($formula, $cellID = null, Cell $pCell = null) @@ -2965,8 +2957,6 @@ public function saveValueToCache($cellReference, $cellValue) * @param string $cellID The ID (e.g. A3) of the cell that we are calculating * @param Cell $pCell Cell to calculate * - * @throws Exception - * * @return mixed */ public function _calculateFormulaValue($formula, $cellID = null, Cell $pCell = null) diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php index c3942b2b2b..1a79ff71e7 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -2346,8 +2346,6 @@ public static function erfVal($x) * * @param mixed $value * - * @throws Exception - * * @return int */ private static function validateBitwiseArgument($value) diff --git a/src/PhpSpreadsheet/Calculation/FormulaParser.php b/src/PhpSpreadsheet/Calculation/FormulaParser.php index 9b3c66e9e8..38c725c2de 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaParser.php +++ b/src/PhpSpreadsheet/Calculation/FormulaParser.php @@ -62,8 +62,6 @@ class FormulaParser * Create a new FormulaParser. * * @param string $pFormula Formula to parse - * - * @throws Exception */ public function __construct($pFormula = '') { @@ -93,8 +91,6 @@ public function getFormula() * * @param int $pId Token id * - * @throws Exception - * * @return string */ public function getToken($pId = 0) diff --git a/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php b/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php index 1d28f247e7..cf638d05ab 100644 --- a/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php +++ b/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php @@ -16,8 +16,6 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell * - * @throws \PhpOffice\PhpSpreadsheet\Exception - * * @return bool */ public function bindValue(Cell $cell, $value = null) diff --git a/src/PhpSpreadsheet/Cell/Cell.php b/src/PhpSpreadsheet/Cell/Cell.php index e618436ed2..30be33535d 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -92,8 +92,6 @@ public function attach(Cells $parent) * @param mixed $pValue * @param string $pDataType * @param Worksheet $pSheet - * - * @throws Exception */ public function __construct($pValue, $pDataType, Worksheet $pSheet) { @@ -175,8 +173,6 @@ public function getFormattedValue() * * @param mixed $pValue Value * - * @throws Exception - * * @return $this */ public function setValue($pValue) @@ -194,8 +190,6 @@ public function setValue($pValue) * @param mixed $pValue Value * @param string $pDataType Explicit data type, see DataType::TYPE_* * - * @throws Exception - * * @return Cell */ public function setValueExplicit($pValue, $pDataType) @@ -252,8 +246,6 @@ public function setValueExplicit($pValue, $pDataType) * * @param bool $resetLog Whether the calculation engine logger should be reset or not * - * @throws Exception - * * @return mixed */ public function getCalculatedValue($resetLog = true) @@ -362,8 +354,6 @@ public function isFormula() /** * Does this cell contain Data validation rules? * - * @throws Exception - * * @return bool */ public function hasDataValidation() @@ -378,8 +368,6 @@ public function hasDataValidation() /** * Get Data validation rules. * - * @throws Exception - * * @return DataValidation */ public function getDataValidation() @@ -396,8 +384,6 @@ public function getDataValidation() * * @param DataValidation $pDataValidation * - * @throws Exception - * * @return Cell */ public function setDataValidation(DataValidation $pDataValidation = null) @@ -426,8 +412,6 @@ public function hasValidValue() /** * Does this cell contain a Hyperlink? * - * @throws Exception - * * @return bool */ public function hasHyperlink() @@ -442,8 +426,6 @@ public function hasHyperlink() /** * Get Hyperlink. * - * @throws Exception - * * @return Hyperlink */ public function getHyperlink() @@ -460,8 +442,6 @@ public function getHyperlink() * * @param Hyperlink $pHyperlink * - * @throws Exception - * * @return Cell */ public function setHyperlink(Hyperlink $pHyperlink = null) diff --git a/src/PhpSpreadsheet/Cell/Coordinate.php b/src/PhpSpreadsheet/Cell/Coordinate.php index cc0543f6ab..70fed25a01 100644 --- a/src/PhpSpreadsheet/Cell/Coordinate.php +++ b/src/PhpSpreadsheet/Cell/Coordinate.php @@ -25,8 +25,6 @@ abstract class Coordinate * * @param string $pCoordinateString eg: 'A1' * - * @throws Exception - * * @return string[] Array containing column and row (indexes 0 and 1) */ public static function coordinateFromString($pCoordinateString) @@ -60,8 +58,6 @@ public static function coordinateIsRange($coord) * @param string $pCoordinateString e.g. 'A' or '1' or 'A1' * Note that this value can be a row or column reference as well as a cell reference * - * @throws Exception - * * @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1' */ public static function absoluteReference($pCoordinateString) @@ -91,8 +87,6 @@ public static function absoluteReference($pCoordinateString) * * @param string $pCoordinateString e.g. 'A1' * - * @throws Exception - * * @return string Absolute coordinate e.g. '$A$1' */ public static function absoluteCoordinate($pCoordinateString) @@ -145,8 +139,6 @@ public static function splitRange($pRange) * * @param array $pRange Array containg one or more arrays containing one or two coordinate strings * - * @throws Exception - * * @return string String representation of $pRange */ public static function buildRange(array $pRange) diff --git a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php index cd05cf8bdf..3a676c4f89 100644 --- a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php +++ b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php @@ -14,8 +14,6 @@ class DefaultValueBinder implements IValueBinder * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell * - * @throws \PhpOffice\PhpSpreadsheet\Exception - * * @return bool */ public function bindValue(Cell $cell, $value) diff --git a/src/PhpSpreadsheet/Cell/StringValueBinder.php b/src/PhpSpreadsheet/Cell/StringValueBinder.php index 0552677f29..346d025347 100644 --- a/src/PhpSpreadsheet/Cell/StringValueBinder.php +++ b/src/PhpSpreadsheet/Cell/StringValueBinder.php @@ -12,8 +12,6 @@ class StringValueBinder implements IValueBinder * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell * - * @throws \PhpOffice\PhpSpreadsheet\Exception - * * @return bool */ public function bindValue(Cell $cell, $value) diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index ec40cb8424..e15f5da5f5 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -115,8 +115,6 @@ public function getDataType() * DataSeriesValues::DATASERIES_TYPE_NUMBER * Normally used for chart data values * - * @throws Exception - * * @return $this */ public function setDataType($dataType) @@ -247,8 +245,6 @@ public function setFillColor($color) * * @param string $color value for color * - * @throws \Exception thrown if color is invalid - * * @return bool true if validation was successful */ private function validateColor($color) diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php index 84c3d3009c..127403d998 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -105,8 +105,6 @@ public function has($pCoord) * * @param Cell $cell Cell to update * - * @throws PhpSpreadsheetException - * * @return Cell */ public function update(Cell $cell) @@ -382,8 +380,6 @@ public function removeColumn($column) /** * Store cell data in cache for the current cell object if it's "dirty", * and the 'nullify' the current cell object. - * - * @throws PhpSpreadsheetException */ private function storeCurrentCell() { @@ -409,8 +405,6 @@ private function storeCurrentCell() * @param string $pCoord Coordinate of the cell to update * @param Cell $cell Cell to update * - * @throws PhpSpreadsheetException - * * @return \PhpOffice\PhpSpreadsheet\Cell\Cell */ public function add($pCoord, Cell $cell) @@ -432,8 +426,6 @@ public function add($pCoord, Cell $cell) * * @param string $pCoord Coordinate of the cell * - * @throws PhpSpreadsheetException - * * @return \PhpOffice\PhpSpreadsheet\Cell\Cell Cell that was found, or null if not found */ public function get($pCoord) diff --git a/src/PhpSpreadsheet/DocumentGenerator.php b/src/PhpSpreadsheet/DocumentGenerator.php index de6f313f49..8baba6e53a 100644 --- a/src/PhpSpreadsheet/DocumentGenerator.php +++ b/src/PhpSpreadsheet/DocumentGenerator.php @@ -5,7 +5,6 @@ use PhpOffice\PhpSpreadsheet\Calculation\Category; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use ReflectionClass; -use ReflectionException; use UnexpectedValueException; class DocumentGenerator @@ -13,8 +12,6 @@ class DocumentGenerator /** * @param array[] $phpSpreadsheetFunctions * - * @throws ReflectionException - * * @return string */ public static function generateFunctionListByCategory(array $phpSpreadsheetFunctions): string @@ -38,11 +35,6 @@ public static function generateFunctionListByCategory(array $phpSpreadsheetFunct return $result; } - /** - * @throws ReflectionException - * - * @return array - */ private static function getCategories(): array { return (new ReflectionClass(Category::class))->getConstants(); @@ -82,8 +74,6 @@ private static function getPhpSpreadsheetFunctionText($functionCall): string /** * @param array[] $phpSpreadsheetFunctions * - * @throws ReflectionException - * * @return string */ public static function generateFunctionListByName(array $phpSpreadsheetFunctions): string diff --git a/src/PhpSpreadsheet/HashTable.php b/src/PhpSpreadsheet/HashTable.php index 4e8f0a5c91..4d1e7b4d88 100644 --- a/src/PhpSpreadsheet/HashTable.php +++ b/src/PhpSpreadsheet/HashTable.php @@ -22,8 +22,6 @@ class HashTable * Create a new \PhpOffice\PhpSpreadsheet\HashTable. * * @param IComparable[] $pSource Optional source array to create HashTable from - * - * @throws Exception */ public function __construct($pSource = null) { @@ -37,8 +35,6 @@ public function __construct($pSource = null) * Add HashTable items from source. * * @param IComparable[] $pSource Source array to create HashTable from - * - * @throws Exception */ public function addFromSource(array $pSource = null) { diff --git a/src/PhpSpreadsheet/IOFactory.php b/src/PhpSpreadsheet/IOFactory.php index 4266ea546a..38c0f221f4 100644 --- a/src/PhpSpreadsheet/IOFactory.php +++ b/src/PhpSpreadsheet/IOFactory.php @@ -40,8 +40,6 @@ abstract class IOFactory * @param Spreadsheet $spreadsheet * @param string $writerType Example: Xlsx * - * @throws Writer\Exception - * * @return Writer\IWriter */ public static function createWriter(Spreadsheet $spreadsheet, $writerType) @@ -61,8 +59,6 @@ public static function createWriter(Spreadsheet $spreadsheet, $writerType) * * @param string $readerType Example: Xlsx * - * @throws Reader\Exception - * * @return Reader\IReader */ public static function createReader($readerType) @@ -82,8 +78,6 @@ public static function createReader($readerType) * * @param string $pFilename The name of the spreadsheet file * - * @throws Reader\Exception - * * @return Spreadsheet */ public static function load($pFilename) @@ -98,8 +92,6 @@ public static function load($pFilename) * * @param string $pFilename The name of the spreadsheet file to identify * - * @throws Reader\Exception - * * @return string */ public static function identify($pFilename) @@ -117,8 +109,6 @@ public static function identify($pFilename) * * @param string $filename The name of the spreadsheet file * - * @throws Reader\Exception - * * @return Reader\IReader */ public static function createReaderForFile($filename) diff --git a/src/PhpSpreadsheet/NamedRange.php b/src/PhpSpreadsheet/NamedRange.php index e539b7c530..576f17d738 100644 --- a/src/PhpSpreadsheet/NamedRange.php +++ b/src/PhpSpreadsheet/NamedRange.php @@ -49,8 +49,6 @@ class NamedRange * @param string $pRange * @param bool $pLocalOnly * @param null|Worksheet $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope. - * - * @throws Exception */ public function __construct($pName, Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null) { diff --git a/src/PhpSpreadsheet/Reader/BaseReader.php b/src/PhpSpreadsheet/Reader/BaseReader.php index f7af1557ff..35466e7325 100644 --- a/src/PhpSpreadsheet/Reader/BaseReader.php +++ b/src/PhpSpreadsheet/Reader/BaseReader.php @@ -144,8 +144,6 @@ public function getSecurityScanner() * Open file for reading. * * @param string $pFilename - * - * @throws Exception */ protected function openFile($pFilename) { diff --git a/src/PhpSpreadsheet/Reader/Csv.php b/src/PhpSpreadsheet/Reader/Csv.php index 4713409881..ed3b70f1e3 100644 --- a/src/PhpSpreadsheet/Reader/Csv.php +++ b/src/PhpSpreadsheet/Reader/Csv.php @@ -272,8 +272,6 @@ private function getNextLine($line = '') * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetInfo($pFilename) @@ -317,8 +315,6 @@ public function listWorksheetInfo($pFilename) * * @param string $pFilename * - * @throws Exception - * * @return Spreadsheet */ public function load($pFilename) @@ -336,8 +332,6 @@ public function load($pFilename) * @param string $pFilename * @param Spreadsheet $spreadsheet * - * @throws Exception - * * @return Spreadsheet */ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index 44ab701d13..83ff293cde 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -46,8 +46,6 @@ public function __construct() * * @param string $pFilename * - * @throws Exception - * * @return bool */ public function canRead($pFilename) @@ -169,8 +167,6 @@ private function gzfileGetContents($filename) * * @param string $pFilename * - * @throws Exception - * * @return Spreadsheet */ public function load($pFilename) @@ -188,8 +184,6 @@ public function load($pFilename) * @param string $pFilename * @param Spreadsheet $spreadsheet * - * @throws Exception - * * @return Spreadsheet */ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index a255cfd9eb..86263a2040 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -205,8 +205,6 @@ private static function containsTags($data) * * @param string $pFilename * - * @throws Exception - * * @return Spreadsheet */ public function load($pFilename) @@ -581,8 +579,6 @@ protected function processDomElement(DOMNode $element, Worksheet $sheet, &$row, * @param string $pFilename * @param Spreadsheet $spreadsheet * - * @throws Exception - * * @return Spreadsheet */ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) @@ -630,8 +626,6 @@ public function loadFromString($content, ?Spreadsheet $spreadsheet = null): Spre * @param DOMDocument $document * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Exception - * * @return Spreadsheet */ private function loadDocument(DOMDocument $document, Spreadsheet $spreadsheet): Spreadsheet @@ -862,8 +856,6 @@ public function getStyleColor($value) * @param string $column * @param int $row * @param array $attributes - * - * @throws \PhpOffice\PhpSpreadsheet\Exception */ private function insertImage(Worksheet $sheet, $column, $row, array $attributes) { diff --git a/src/PhpSpreadsheet/Reader/IReader.php b/src/PhpSpreadsheet/Reader/IReader.php index 70a7a200d7..3f5a7e49e9 100644 --- a/src/PhpSpreadsheet/Reader/IReader.php +++ b/src/PhpSpreadsheet/Reader/IReader.php @@ -129,8 +129,6 @@ public function setReadFilter(IReadFilter $pValue); * * @param string $pFilename * - * @throws Exception - * * @return \PhpOffice\PhpSpreadsheet\Spreadsheet */ public function load($pFilename); diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index 5fff07aa38..41fd34a8d9 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -34,8 +34,6 @@ public function __construct() * * @param string $pFilename * - * @throws Exception - * * @return bool */ public function canRead($pFilename) @@ -85,8 +83,6 @@ public function canRead($pFilename) * * @param string $pFilename * - * @throws Exception - * * @return string[] */ public function listWorksheetNames($pFilename) @@ -139,8 +135,6 @@ public function listWorksheetNames($pFilename) * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetInfo($pFilename) @@ -233,8 +227,6 @@ public function listWorksheetInfo($pFilename) * * @param string $pFilename * - * @throws Exception - * * @return Spreadsheet */ public function load($pFilename) @@ -252,8 +244,6 @@ public function load($pFilename) * @param string $pFilename * @param Spreadsheet $spreadsheet * - * @throws Exception - * * @return Spreadsheet */ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) diff --git a/src/PhpSpreadsheet/Reader/Security/XmlScanner.php b/src/PhpSpreadsheet/Reader/Security/XmlScanner.php index 732f0bf612..33e21f9d1c 100644 --- a/src/PhpSpreadsheet/Reader/Security/XmlScanner.php +++ b/src/PhpSpreadsheet/Reader/Security/XmlScanner.php @@ -114,8 +114,6 @@ private function toUtf8($xml) * * @param mixed $xml * - * @throws Reader\Exception - * * @return string */ public function scan($xml) @@ -143,8 +141,6 @@ public function scan($xml) * * @param string $filestream * - * @throws Reader\Exception - * * @return string */ public function scanFile($filestream) diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index 9912e9376b..278abd582a 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -107,8 +107,6 @@ public function getInputEncoding() * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetInfo($pFilename) @@ -177,8 +175,6 @@ public function listWorksheetInfo($pFilename) * * @param string $pFilename * - * @throws Exception - * * @return Spreadsheet */ public function load($pFilename) @@ -196,8 +192,6 @@ public function load($pFilename) * @param string $pFilename * @param Spreadsheet $spreadsheet * - * @throws Exception - * * @return Spreadsheet */ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index 313d7216ba..ec5879a9ef 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -444,8 +444,6 @@ public function canRead($pFilename) * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetNames($pFilename) @@ -504,8 +502,6 @@ public function listWorksheetNames($pFilename) * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetInfo($pFilename) @@ -618,8 +614,6 @@ public function listWorksheetInfo($pFilename) * * @param string $pFilename * - * @throws Exception - * * @return Spreadsheet */ public function load($pFilename) @@ -5516,8 +5510,6 @@ private function createFormulaFromTokens($tokens, $additionalData) * @param string $formulaData Formula data * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas * - * @throws Exception - * * @return array */ private function getNextToken($formulaData, $baseCell = 'A1') @@ -7186,8 +7178,6 @@ private function readBIFF8CellAddressB($cellAddressStructure, $baseCell = 'A1') * * @param string $subData * - * @throws Exception - * * @return string */ private function readBIFF5CellRangeAddressFixed($subData) @@ -7227,8 +7217,6 @@ private function readBIFF5CellRangeAddressFixed($subData) * * @param string $subData * - * @throws Exception - * * @return string */ private function readBIFF8CellRangeAddressFixed($subData) @@ -7465,8 +7453,6 @@ private function readBIFF5CellRangeAddressList($subData) * * @param int $index * - * @throws Exception - * * @return false|string */ private function readSheetRangeByRefIndex($index) diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 566e9fbbf0..40814c64fd 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -69,8 +69,6 @@ public function __construct() * * @param string $pFilename * - * @throws Exception - * * @return bool */ public function canRead($pFilename) @@ -95,8 +93,6 @@ public function canRead($pFilename) * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetNames($pFilename) @@ -140,8 +136,6 @@ public function listWorksheetNames($pFilename) * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetInfo($pFilename) @@ -318,8 +312,6 @@ private function getFromZipArchive(ZipArchive $archive, $fileName = '') * * @param string $pFilename * - * @throws Exception - * * @return Spreadsheet */ public function load($pFilename) diff --git a/src/PhpSpreadsheet/Reader/Xml.php b/src/PhpSpreadsheet/Reader/Xml.php index b4fffa4fb8..03099e3e47 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -50,8 +50,6 @@ public function __construct() * * @param string $pFilename * - * @throws Exception - * * @return bool */ public function canRead($pFilename) @@ -103,8 +101,6 @@ public function canRead($pFilename) * * @param string $pFilename * - * @throws Exception - * * @return false|\SimpleXMLElement */ public function trySimpleXMLLoadString($pFilename) @@ -127,8 +123,6 @@ public function trySimpleXMLLoadString($pFilename) * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetNames($pFilename) @@ -158,8 +152,6 @@ public function listWorksheetNames($pFilename) * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetInfo($pFilename) @@ -229,8 +221,6 @@ public function listWorksheetInfo($pFilename) * * @param string $pFilename * - * @throws Exception - * * @return Spreadsheet */ public function load($pFilename) @@ -300,8 +290,6 @@ protected static function hex2str($hex) * @param string $pFilename * @param Spreadsheet $spreadsheet * - * @throws Exception - * * @return Spreadsheet */ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index 143e80d8ce..6d65573054 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -363,8 +363,6 @@ protected function adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $p * @param int $pNumCols Number of columns to insert/delete (negative values indicate deletion) * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) * @param Worksheet $pSheet The worksheet that we're editing - * - * @throws Exception */ public function insertNewBefore($pBefore, $pNumCols, $pNumRows, Worksheet $pSheet) { @@ -624,8 +622,6 @@ public function insertNewBefore($pBefore, $pNumCols, $pNumRows, Worksheet $pShee * @param int $pNumRows Number of rows to insert * @param string $sheetName Worksheet name/title * - * @throws Exception - * * @return string Updated formula */ public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '') @@ -766,8 +762,6 @@ public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCo * @param int $pNumCols Number of columns to increment * @param int $pNumRows Number of rows to increment * - * @throws Exception - * * @return string Updated cell range */ public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) @@ -824,8 +818,6 @@ public function updateNamedFormulas(Spreadsheet $spreadsheet, $oldName = '', $ne * @param int $pNumCols Number of columns to increment * @param int $pNumRows Number of rows to increment * - * @throws Exception - * * @return string Updated cell range */ private function updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) @@ -864,8 +856,6 @@ private function updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCo * @param int $pNumCols Number of columns to increment * @param int $pNumRows Number of rows to increment * - * @throws Exception - * * @return string Updated cell reference */ private function updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) @@ -900,8 +890,6 @@ private function updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A /** * __clone implementation. Cloning should not be allowed in a Singleton! - * - * @throws Exception */ final public function __clone() { diff --git a/src/PhpSpreadsheet/RichText/RichText.php b/src/PhpSpreadsheet/RichText/RichText.php index 6e90fa355f..4fa5f2bdf9 100644 --- a/src/PhpSpreadsheet/RichText/RichText.php +++ b/src/PhpSpreadsheet/RichText/RichText.php @@ -4,7 +4,6 @@ use PhpOffice\PhpSpreadsheet\Cell\Cell; use PhpOffice\PhpSpreadsheet\Cell\DataType; -use PhpOffice\PhpSpreadsheet\Exception; use PhpOffice\PhpSpreadsheet\IComparable; class RichText implements IComparable @@ -20,8 +19,6 @@ class RichText implements IComparable * Create a new RichText instance. * * @param Cell $pCell - * - * @throws Exception */ public function __construct(Cell $pCell = null) { @@ -61,8 +58,6 @@ public function addText(ITextElement $pText) * * @param string $pText Text * - * @throws Exception - * * @return TextElement */ public function createText($pText) @@ -78,8 +73,6 @@ public function createText($pText) * * @param string $pText Text * - * @throws Exception - * * @return Run */ public function createTextRun($pText) diff --git a/src/PhpSpreadsheet/Settings.php b/src/PhpSpreadsheet/Settings.php index d9d74cb06c..56f778e57b 100644 --- a/src/PhpSpreadsheet/Settings.php +++ b/src/PhpSpreadsheet/Settings.php @@ -59,8 +59,6 @@ public static function setLocale($locale) * * @param string $rendererClass Class name of the chart renderer * eg: PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph - * - * @throws Exception */ public static function setChartRenderer($rendererClass) { diff --git a/src/PhpSpreadsheet/Shared/CodePage.php b/src/PhpSpreadsheet/Shared/CodePage.php index 4b57824203..b395293ced 100644 --- a/src/PhpSpreadsheet/Shared/CodePage.php +++ b/src/PhpSpreadsheet/Shared/CodePage.php @@ -12,8 +12,6 @@ class CodePage * * @param int $codePage Microsoft Code Page Indentifier * - * @throws PhpSpreadsheetException - * * @return string Code Page Name */ public static function numberToName($codePage) diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index 5d2deb32c9..8be255c5e5 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -95,8 +95,6 @@ public static function getExcelCalendar() * * @param DateTimeZone|string $timeZone The timezone to set for all Excel datetimestamp to PHP DateTime Object conversions * - * @throws \Exception - * * @return bool Success or failure * @return bool Success or failure */ @@ -130,8 +128,6 @@ public static function getDefaultTimezone() * * @param DateTimeZone|string $timeZone The timezone to validate, either as a timezone string or object * - * @throws \Exception - * * @return DateTimeZone The timezone as a timezone object * @return DateTimeZone The timezone as a timezone object */ @@ -154,8 +150,6 @@ protected static function validateTimeZone($timeZone) * if you don't want to treat it as a UTC value * Use the default (UST) unless you absolutely need a conversion * - * @throws \Exception - * * @return \DateTime PHP date/time object */ public static function excelToDateTimeObject($excelTimestamp, $timeZone = null) @@ -203,8 +197,6 @@ public static function excelToDateTimeObject($excelTimestamp, $timeZone = null) * if you don't want to treat it as a UTC value * Use the default (UST) unless you absolutely need a conversion * - * @throws \Exception - * * @return int Unix timetamp for this date/time */ public static function excelToTimestamp($excelTimestamp, $timeZone = null) diff --git a/src/PhpSpreadsheet/Shared/File.php b/src/PhpSpreadsheet/Shared/File.php index 239c8375a1..6b1fe6f563 100644 --- a/src/PhpSpreadsheet/Shared/File.php +++ b/src/PhpSpreadsheet/Shared/File.php @@ -128,8 +128,6 @@ public static function sysGetTempDir() * Assert that given path is an existing file and is readable, otherwise throw exception. * * @param string $filename - * - * @throws InvalidArgumentException */ public static function assertFile($filename) { diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index bee13e2921..89d91be74d 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -276,8 +276,6 @@ public static function calculateColumnWidth(\PhpOffice\PhpSpreadsheet\Style\Font * @param \PhpOffice\PhpSpreadsheet\Style\Font * @param int $rotation * - * @throws PhpSpreadsheetException - * * @return int */ public static function getTextWidthPixelsExact($text, \PhpOffice\PhpSpreadsheet\Style\Font $font, $rotation = 0) diff --git a/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php index bb2b4b040a..4aecff7343 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php +++ b/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php @@ -242,9 +242,6 @@ public function det() * * @param mixed $B a Matrix with as many rows as A and any number of columns * - * @throws CalculationException illegalArgumentException Matrix row dimensions must agree - * @throws CalculationException runtimeException Matrix is singular - * * @return Matrix X so that L*U*X = B(piv,:) */ public function solve($B) diff --git a/src/PhpSpreadsheet/Shared/OLE.php b/src/PhpSpreadsheet/Shared/OLE.php index efa7522fad..81ebaa34ed 100644 --- a/src/PhpSpreadsheet/Shared/OLE.php +++ b/src/PhpSpreadsheet/Shared/OLE.php @@ -113,8 +113,6 @@ class OLE * * @param string $file * - * @throws ReaderException - * * @return bool true on success, PEAR_Error on failure */ public function read($file) @@ -539,8 +537,6 @@ public static function localDateToOLE($date) * * @param string $oleTimestamp A binary string with the encoded date * - * @throws ReaderException - * * @return int The Unix timestamp corresponding to the string */ public static function OLE2LocalDate($oleTimestamp) diff --git a/src/PhpSpreadsheet/Shared/OLERead.php b/src/PhpSpreadsheet/Shared/OLERead.php index 3af3970057..3526c7e69c 100644 --- a/src/PhpSpreadsheet/Shared/OLERead.php +++ b/src/PhpSpreadsheet/Shared/OLERead.php @@ -94,8 +94,6 @@ class OLERead * Read the file. * * @param $pFilename string Filename - * - * @throws ReaderException */ public function read($pFilename) { diff --git a/src/PhpSpreadsheet/Shared/TimeZone.php b/src/PhpSpreadsheet/Shared/TimeZone.php index e5a99b9b6b..a87987dffc 100644 --- a/src/PhpSpreadsheet/Shared/TimeZone.php +++ b/src/PhpSpreadsheet/Shared/TimeZone.php @@ -61,8 +61,6 @@ public static function getTimeZone() * @param string $timezone The timezone for finding the adjustment to UST * @param int $timestamp PHP date/time value * - * @throws PhpSpreadsheetException - * * @return int Number of seconds for timezone adjustment */ public static function getTimeZoneAdjustment($timezone, $timestamp) diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index d33a98719f..6023c61668 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -571,8 +571,6 @@ public function setSecurity(Document\Security $pValue) /** * Get active sheet. * - * @throws Exception - * * @return Worksheet */ public function getActiveSheet() @@ -585,8 +583,6 @@ public function getActiveSheet() * * @param null|int $sheetIndex Index where sheet should go (0,1,..., or null for last) * - * @throws Exception - * * @return Worksheet */ public function createSheet($sheetIndex = null) @@ -615,8 +611,6 @@ public function sheetNameExists($pSheetName) * @param Worksheet $pSheet * @param null|int $iSheetIndex Index where sheet should go (0,1,..., or null for last) * - * @throws Exception - * * @return Worksheet */ public function addSheet(Worksheet $pSheet, $iSheetIndex = null) @@ -658,8 +652,6 @@ public function addSheet(Worksheet $pSheet, $iSheetIndex = null) * Remove sheet by index. * * @param int $pIndex Active sheet index - * - * @throws Exception */ public function removeSheetByIndex($pIndex) { @@ -683,8 +675,6 @@ public function removeSheetByIndex($pIndex) * * @param int $pIndex Sheet index * - * @throws Exception - * * @return Worksheet */ public function getSheet($pIndex) @@ -734,8 +724,6 @@ public function getSheetByName($pName) * * @param Worksheet $pSheet * - * @throws Exception - * * @return int index */ public function getIndex(Worksheet $pSheet) @@ -755,8 +743,6 @@ public function getIndex(Worksheet $pSheet) * @param string $sheetName Sheet name to modify index for * @param int $newIndex New index for the sheet * - * @throws Exception - * * @return int New sheet index */ public function setIndexByName($sheetName, $newIndex) @@ -802,8 +788,6 @@ public function getActiveSheetIndex() * * @param int $pIndex Active sheet index * - * @throws Exception - * * @return Worksheet */ public function setActiveSheetIndex($pIndex) @@ -825,8 +809,6 @@ public function setActiveSheetIndex($pIndex) * * @param string $pValue Sheet title * - * @throws Exception - * * @return Worksheet */ public function setActiveSheetIndexByName($pValue) @@ -862,8 +844,6 @@ public function getSheetNames() * @param Worksheet $pSheet External sheet to add * @param null|int $iSheetIndex Index where sheet should go (0,1,..., or null for last) * - * @throws Exception - * * @return Worksheet */ public function addExternalSheet(Worksheet $pSheet, $iSheetIndex = null) @@ -1067,8 +1047,6 @@ public function cellXfExists($pCellStyle) /** * Get default style. * - * @throws Exception - * * @return Style */ public function getDefaultStyle() @@ -1095,8 +1073,6 @@ public function addCellXf(Style $style) * Remove cellXf by index. It is ensured that all cells get their xf index updated. * * @param int $pIndex Index to cellXf - * - * @throws Exception */ public function removeCellXfByIndex($pIndex) { @@ -1188,8 +1164,6 @@ public function addCellStyleXf(Style $pStyle) * Remove cellStyleXf by index. * * @param int $pIndex Index to cellXf - * - * @throws Exception */ public function removeCellStyleXfByIndex($pIndex) { @@ -1405,8 +1379,6 @@ public function getFirstSheetIndex() * Set the first sheet in the book view. * * @param int $firstSheetIndex First sheet in book view - * - * @throws Exception if the given value is invalid */ public function setFirstSheetIndex($firstSheetIndex) { @@ -1444,8 +1416,6 @@ public function getVisibility() * user interface. * * @param string $visibility visibility status of the workbook - * - * @throws Exception if the given value is invalid */ public function setVisibility($visibility) { @@ -1476,8 +1446,6 @@ public function getTabRatio() * TabRatio is assumed to be out of 1000 of the horizontal window width. * * @param int $tabRatio Ratio between the tabs bar and the horizontal scroll bar - * - * @throws Exception if the given value is invalid */ public function setTabRatio($tabRatio) { diff --git a/src/PhpSpreadsheet/Style/Alignment.php b/src/PhpSpreadsheet/Style/Alignment.php index 5eb7c2b0f4..e54fa2a18d 100644 --- a/src/PhpSpreadsheet/Style/Alignment.php +++ b/src/PhpSpreadsheet/Style/Alignment.php @@ -138,8 +138,6 @@ public function getStyleArray($array) * * @param array $pStyles Array containing style information * - * @throws PhpSpreadsheetException - * * @return $this */ public function applyFromArray(array $pStyles) @@ -267,8 +265,6 @@ public function getTextRotation() * * @param int $pValue * - * @throws PhpSpreadsheetException - * * @return $this */ public function setTextRotation($pValue) diff --git a/src/PhpSpreadsheet/Style/Border.php b/src/PhpSpreadsheet/Style/Border.php index 5fa0cae70d..2e076a9267 100644 --- a/src/PhpSpreadsheet/Style/Border.php +++ b/src/PhpSpreadsheet/Style/Border.php @@ -69,8 +69,6 @@ public function __construct($isSupervisor = false, $isConditional = false) * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor. * - * @throws PhpSpreadsheetException - * * @return Border */ public function getSharedComponent() @@ -125,8 +123,6 @@ public function getStyleArray($array) * * @param array $pStyles Array containing style information * - * @throws PhpSpreadsheetException - * * @return $this */ public function applyFromArray(array $pStyles) @@ -200,8 +196,6 @@ public function getColor() * * @param Color $pValue * - * @throws PhpSpreadsheetException - * * @return $this */ public function setColor(Color $pValue) diff --git a/src/PhpSpreadsheet/Style/Borders.php b/src/PhpSpreadsheet/Style/Borders.php index 8f005a9980..e75d7eeb6d 100644 --- a/src/PhpSpreadsheet/Style/Borders.php +++ b/src/PhpSpreadsheet/Style/Borders.php @@ -195,8 +195,6 @@ public function getStyleArray($array) * * @param array $pStyles Array containing style information * - * @throws PhpSpreadsheetException - * * @return $this */ public function applyFromArray(array $pStyles) @@ -286,8 +284,6 @@ public function getDiagonal() /** * Get AllBorders (pseudo-border). Only applies to supervisor. * - * @throws PhpSpreadsheetException - * * @return Border */ public function getAllBorders() @@ -302,8 +298,6 @@ public function getAllBorders() /** * Get Outline (pseudo-border). Only applies to supervisor. * - * @throws PhpSpreadsheetException - * * @return Border */ public function getOutline() @@ -318,8 +312,6 @@ public function getOutline() /** * Get Inside (pseudo-border). Only applies to supervisor. * - * @throws PhpSpreadsheetException - * * @return Border */ public function getInside() @@ -334,8 +326,6 @@ public function getInside() /** * Get Vertical (pseudo-border). Only applies to supervisor. * - * @throws PhpSpreadsheetException - * * @return Border */ public function getVertical() @@ -350,8 +340,6 @@ public function getVertical() /** * Get Horizontal (pseudo-border). Only applies to supervisor. * - * @throws PhpSpreadsheetException - * * @return Border */ public function getHorizontal() diff --git a/src/PhpSpreadsheet/Style/Color.php b/src/PhpSpreadsheet/Style/Color.php index ab22cbe324..d8ba08b29c 100644 --- a/src/PhpSpreadsheet/Style/Color.php +++ b/src/PhpSpreadsheet/Style/Color.php @@ -2,8 +2,6 @@ namespace PhpOffice\PhpSpreadsheet\Style; -use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; - class Color extends Supervisor { const NAMED_COLORS = [ @@ -104,8 +102,6 @@ public function getStyleArray($array) * * @param array $pStyles Array containing style information * - * @throws PhpSpreadsheetException - * * @return $this */ public function applyFromArray(array $pStyles) diff --git a/src/PhpSpreadsheet/Style/Fill.php b/src/PhpSpreadsheet/Style/Fill.php index 1d6bace147..789a9801d5 100644 --- a/src/PhpSpreadsheet/Style/Fill.php +++ b/src/PhpSpreadsheet/Style/Fill.php @@ -2,8 +2,6 @@ namespace PhpOffice\PhpSpreadsheet\Style; -use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; - class Fill extends Supervisor { // Fill types @@ -139,8 +137,6 @@ public function getStyleArray($array) * * @param array $pStyles Array containing style information * - * @throws PhpSpreadsheetException - * * @return $this */ public function applyFromArray(array $pStyles) @@ -250,8 +246,6 @@ public function getStartColor() * * @param Color $pValue * - * @throws PhpSpreadsheetException - * * @return $this */ public function setStartColor(Color $pValue) @@ -284,8 +278,6 @@ public function getEndColor() * * @param Color $pValue * - * @throws PhpSpreadsheetException - * * @return $this */ public function setEndColor(Color $pValue) diff --git a/src/PhpSpreadsheet/Style/Font.php b/src/PhpSpreadsheet/Style/Font.php index 0341cad0dc..5ab58dcae6 100644 --- a/src/PhpSpreadsheet/Style/Font.php +++ b/src/PhpSpreadsheet/Style/Font.php @@ -2,8 +2,6 @@ namespace PhpOffice\PhpSpreadsheet\Style; -use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; - class Font extends Supervisor { // Underline types @@ -159,8 +157,6 @@ public function getStyleArray($array) * * @param array $pStyles Array containing style information * - * @throws PhpSpreadsheetException - * * @return $this */ public function applyFromArray(array $pStyles) @@ -510,8 +506,6 @@ public function getColor() * * @param Color $pValue * - * @throws PhpSpreadsheetException - * * @return $this */ public function setColor(Color $pValue) diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index df4ca76f4f..079e1d20dc 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -3,7 +3,6 @@ namespace PhpOffice\PhpSpreadsheet\Style; use PhpOffice\PhpSpreadsheet\Calculation\MathTrig; -use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; use PhpOffice\PhpSpreadsheet\Shared\Date; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; @@ -137,8 +136,6 @@ public function getStyleArray($array) * * @param array $pStyles Array containing style information * - * @throws PhpSpreadsheetException - * * @return $this */ public function applyFromArray(array $pStyles) diff --git a/src/PhpSpreadsheet/Style/Protection.php b/src/PhpSpreadsheet/Style/Protection.php index 8112bc6204..f695837dfe 100644 --- a/src/PhpSpreadsheet/Style/Protection.php +++ b/src/PhpSpreadsheet/Style/Protection.php @@ -2,8 +2,6 @@ namespace PhpOffice\PhpSpreadsheet\Style; -use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; - class Protection extends Supervisor { /** Protection styles */ @@ -84,8 +82,6 @@ public function getStyleArray($array) * * @param array $pStyles Array containing style information * - * @throws PhpSpreadsheetException - * * @return $this */ public function applyFromArray(array $pStyles) diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index dcbc4da5b4..e6cd40e32c 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -83,8 +83,6 @@ public function getRange() * * @param string $pRange Cell range (i.e. A1:E10) * - * @throws PhpSpreadsheetException - * * @return $this */ public function setRange($pRange) @@ -132,8 +130,6 @@ public function getColumns() * * @param string $column Column name (e.g. A) * - * @throws PhpSpreadsheetException - * * @return int The column offset within the autofilter range */ public function testColumnInRange($column) @@ -156,8 +152,6 @@ public function testColumnInRange($column) * * @param string $pColumn Column name (e.g. A) * - * @throws PhpSpreadsheetException - * * @return int The offset of the specified column within the autofilter range */ public function getColumnOffset($pColumn) @@ -170,8 +164,6 @@ public function getColumnOffset($pColumn) * * @param string $pColumn Column name (e.g. A) * - * @throws PhpSpreadsheetException - * * @return AutoFilter\Column */ public function getColumn($pColumn) @@ -190,8 +182,6 @@ public function getColumn($pColumn) * * @param int $pColumnOffset Column offset within range (starting from 0) * - * @throws PhpSpreadsheetException - * * @return AutoFilter\Column */ public function getColumnByOffset($pColumnOffset) @@ -208,8 +198,6 @@ public function getColumnByOffset($pColumnOffset) * @param AutoFilter\Column|string $pColumn * A simple string containing a Column ID like 'A' is permitted * - * @throws PhpSpreadsheetException - * * @return $this */ public function setColumn($pColumn) @@ -239,8 +227,6 @@ public function setColumn($pColumn) * * @param string $pColumn Column name (e.g. A) * - * @throws PhpSpreadsheetException - * * @return $this */ public function clearColumn($pColumn) @@ -615,8 +601,6 @@ private function calculateTopTenValue($columnID, $startRow, $endRow, $ruleType, /** * Apply the AutoFilter rules to the AutoFilter Range. * - * @throws PhpSpreadsheetException - * * @return $this */ public function showHideRows() diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php index 3ed7270a14..a36740a3ef 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php @@ -115,8 +115,6 @@ public function getColumnIndex() * * @param string $pColumn Column (e.g. A) * - * @throws PhpSpreadsheetException - * * @return $this */ public function setColumnIndex($pColumn) @@ -171,8 +169,6 @@ public function getFilterType() * * @param string $pFilterType * - * @throws PhpSpreadsheetException - * * @return $this */ public function setFilterType($pFilterType) @@ -201,8 +197,6 @@ public function getJoin() * * @param string $pJoin And/Or * - * @throws PhpSpreadsheetException - * * @return $this */ public function setJoin($pJoin) diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php index 09a2bacdd9..28286cee19 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php @@ -260,8 +260,6 @@ public function getRuleType() * * @param string $pRuleType see self::AUTOFILTER_RULETYPE_* * - * @throws PhpSpreadsheetException - * * @return $this */ public function setRuleType($pRuleType) @@ -290,8 +288,6 @@ public function getValue() * * @param string|string[] $pValue * - * @throws PhpSpreadsheetException - * * @return $this */ public function setValue($pValue) @@ -334,8 +330,6 @@ public function getOperator() * * @param string $pOperator see self::AUTOFILTER_COLUMN_RULE_* * - * @throws PhpSpreadsheetException - * * @return $this */ public function setOperator($pOperator) @@ -367,8 +361,6 @@ public function getGrouping() * * @param string $pGrouping * - * @throws PhpSpreadsheetException - * * @return $this */ public function setGrouping($pGrouping) @@ -391,8 +383,6 @@ public function setGrouping($pGrouping) * @param string|string[] $pValue * @param string $pGrouping * - * @throws PhpSpreadsheetException - * * @return $this */ public function setRule($pOperator, $pValue, $pGrouping = null) diff --git a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php index 7d24e4496b..bcea3435b4 100644 --- a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php @@ -203,8 +203,6 @@ public function getWorksheet() * @param Worksheet $pValue * @param bool $pOverrideOld If a Worksheet has already been assigned, overwrite it and remove image from old Worksheet? * - * @throws PhpSpreadsheetException - * * @return $this */ public function setWorksheet(Worksheet $pValue = null, $pOverrideOld = false) diff --git a/src/PhpSpreadsheet/Worksheet/CellIterator.php b/src/PhpSpreadsheet/Worksheet/CellIterator.php index d97e33f7d1..472609a369 100644 --- a/src/PhpSpreadsheet/Worksheet/CellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/CellIterator.php @@ -2,8 +2,6 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; -use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; - abstract class CellIterator implements \Iterator { /** @@ -40,8 +38,6 @@ public function getIterateOnlyExistingCells() /** * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary. - * - * @throws PhpSpreadsheetException */ abstract protected function adjustForExistingOnlyRange(); @@ -49,8 +45,6 @@ abstract protected function adjustForExistingOnlyRange(); * Set the iterator to loop only existing cells. * * @param bool $value - * - * @throws PhpSpreadsheetException */ public function setIterateOnlyExistingCells($value) { diff --git a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php index d75da89881..184f488803 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php @@ -57,8 +57,6 @@ public function __construct(Worksheet $subject = null, $columnIndex = 'A', $star * * @param int $startRow The row number at which to start iterating * - * @throws PhpSpreadsheetException - * * @return $this */ public function resetStart($startRow = 1) @@ -75,8 +73,6 @@ public function resetStart($startRow = 1) * * @param int $endRow The row number at which to stop iterating * - * @throws PhpSpreadsheetException - * * @return $this */ public function resetEnd($endRow = null) @@ -92,8 +88,6 @@ public function resetEnd($endRow = null) * * @param int $row The row number to set the current pointer at * - * @throws PhpSpreadsheetException - * * @return $this */ public function seek($row = 1) @@ -172,8 +166,6 @@ public function valid() /** * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary. - * - * @throws PhpSpreadsheetException */ protected function adjustForExistingOnlyRange() { diff --git a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php index c8913cc164..0aff48599a 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php @@ -64,8 +64,6 @@ public function __destruct() * * @param string $startColumn The column address at which to start iterating * - * @throws Exception - * * @return $this */ public function resetStart($startColumn = 'A') @@ -104,8 +102,6 @@ public function resetEnd($endColumn = null) * * @param string $column The column address to set the current pointer at * - * @throws PhpSpreadsheetException - * * @return $this */ public function seek($column = 'A') diff --git a/src/PhpSpreadsheet/Worksheet/Dimension.php b/src/PhpSpreadsheet/Worksheet/Dimension.php index ce40cf57f7..a27daf092d 100644 --- a/src/PhpSpreadsheet/Worksheet/Dimension.php +++ b/src/PhpSpreadsheet/Worksheet/Dimension.php @@ -85,8 +85,6 @@ public function getOutlineLevel() * * @param int $pValue * - * @throws PhpSpreadsheetException - * * @return $this */ public function setOutlineLevel($pValue) diff --git a/src/PhpSpreadsheet/Worksheet/Drawing.php b/src/PhpSpreadsheet/Worksheet/Drawing.php index da492b4c30..1f1dae93ab 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing.php @@ -76,8 +76,6 @@ public function getPath() * @param string $pValue File path * @param bool $pVerifyFile Verify file * - * @throws PhpSpreadsheetException - * * @return $this */ public function setPath($pValue, $pVerifyFile = true) diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index 38a0973639..19eabcf493 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -323,8 +323,6 @@ public function getScale() * @param null|int $pValue * @param bool $pUpdate Update fitToPage so scaling applies rather than fitToHeight / fitToWidth * - * @throws PhpSpreadsheetException - * * @return $this */ public function setScale($pValue, $pUpdate = true) @@ -589,8 +587,6 @@ public function setVerticalCentered($value) * Otherwise, the specific range identified by the value of $index will be returned * Print areas are numbered from 1 * - * @throws PhpSpreadsheetException - * * @return string */ public function getPrintArea($index = 0) @@ -669,8 +665,6 @@ public function clearPrintArea($index = 0) * Default behaviour, or the "O" method, overwrites existing print area * The "I" method, inserts the new print area before any specified index, or at the end of the list * - * @throws PhpSpreadsheetException - * * @return $this */ public function setPrintArea($value, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE) @@ -730,8 +724,6 @@ public function setPrintArea($value, $index = 0, $method = self::SETPRINTRANGE_O * list. * Print areas are numbered from 1 * - * @throws PhpSpreadsheetException - * * @return $this */ public function addPrintArea($value, $index = -1) @@ -760,8 +752,6 @@ public function addPrintArea($value, $index = -1) * Default behaviour, or the "O" method, overwrites existing print area * The "I" method, inserts the new print area before any specified index, or at the end of the list * - * @throws PhpSpreadsheetException - * * @return $this */ public function setPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE) @@ -787,8 +777,6 @@ public function setPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $in * list. * Print areas are numbered from 1 * - * @throws PhpSpreadsheetException - * * @return $this */ public function addPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = -1) diff --git a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php index 9746d6403d..09a5b0a149 100644 --- a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php @@ -57,8 +57,6 @@ public function __construct(Worksheet $worksheet = null, $rowIndex = 1, $startCo * * @param string $startColumn The column address at which to start iterating * - * @throws PhpSpreadsheetException - * * @return $this */ public function resetStart($startColumn = 'A') @@ -75,8 +73,6 @@ public function resetStart($startColumn = 'A') * * @param string $endColumn The column address at which to stop iterating * - * @throws PhpSpreadsheetException - * * @return $this */ public function resetEnd($endColumn = null) @@ -93,8 +89,6 @@ public function resetEnd($endColumn = null) * * @param string $column The column address to set the current pointer at * - * @throws PhpSpreadsheetException - * * @return $this */ public function seek($column = 'A') @@ -150,8 +144,6 @@ public function next() /** * Set the iterator to its previous value. - * - * @throws PhpSpreadsheetException */ public function prev() { @@ -182,8 +174,6 @@ public function getCurrentColumnIndex() /** * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary. - * - * @throws PhpSpreadsheetException */ protected function adjustForExistingOnlyRange() { diff --git a/src/PhpSpreadsheet/Worksheet/RowIterator.php b/src/PhpSpreadsheet/Worksheet/RowIterator.php index 3b9d0e2653..62cede7b25 100644 --- a/src/PhpSpreadsheet/Worksheet/RowIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowIterator.php @@ -62,8 +62,6 @@ public function __destruct() * * @param int $startRow The row number at which to start iterating * - * @throws PhpSpreadsheetException - * * @return $this */ public function resetStart($startRow = 1) @@ -100,8 +98,6 @@ public function resetEnd($endRow = null) * * @param int $row The row number to set the current pointer at * - * @throws PhpSpreadsheetException - * * @return $this */ public function seek($row = 1) diff --git a/src/PhpSpreadsheet/Worksheet/SheetView.php b/src/PhpSpreadsheet/Worksheet/SheetView.php index fa85bd27d6..e19ff80805 100644 --- a/src/PhpSpreadsheet/Worksheet/SheetView.php +++ b/src/PhpSpreadsheet/Worksheet/SheetView.php @@ -77,8 +77,6 @@ public function getZoomScale() * * @param int $pValue * - * @throws PhpSpreadsheetException - * * @return $this */ public function setZoomScale($pValue) @@ -110,8 +108,6 @@ public function getZoomScaleNormal() * * @param int $pValue * - * @throws PhpSpreadsheetException - * * @return $this */ public function setZoomScaleNormal($pValue) @@ -163,8 +159,6 @@ public function getView() * * @param string $pValue * - * @throws PhpSpreadsheetException - * * @return $this */ public function setView($pValue) diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index 9a3f96471d..e8a61b78ae 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -424,8 +424,6 @@ public static function getInvalidCharacters() * * @param string $pValue The string to check * - * @throws Exception - * * @return string The valid string */ private static function checkSheetCodeName($pValue) @@ -454,8 +452,6 @@ private static function checkSheetCodeName($pValue) * * @param string $pValue The string to check * - * @throws Exception - * * @return string The valid string */ private static function checkSheetTitle($pValue) @@ -1185,8 +1181,6 @@ public function setCellValueExplicitByColumnAndRow($columnIndex, $row, $value, $ * @param bool $createIfNotExists Flag indicating whether a new cell should be created if it doesn't * already exist, or a null should be returned instead * - * @throws Exception - * * @return null|Cell Cell that was found/created or null */ public function getCell($pCoordinate, $createIfNotExists = true) @@ -1293,8 +1287,6 @@ private function createNewCell($pCoordinate) * * @param string $pCoordinate Coordinate of the cell eg: 'A1' * - * @throws Exception - * * @return bool */ public function cellExists($pCoordinate) @@ -1431,8 +1423,6 @@ public function getStyles() * * @param string $pCellCoordinate Cell coordinate (or range) to get style for, eg: 'A1' * - * @throws Exception - * * @return Style */ public function getStyle($pCellCoordinate) @@ -1543,8 +1533,6 @@ public function getStyleByColumnAndRow($columnIndex1, $row1, $columnIndex2 = nul * @param Style $pCellStyle Cell style to duplicate * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") * - * @throws Exception - * * @return $this */ public function duplicateStyle(Style $pCellStyle, $pRange) @@ -1588,8 +1576,6 @@ public function duplicateStyle(Style $pCellStyle, $pRange) * @param Conditional[] $pCellStyle Cell style to duplicate * @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1") * - * @throws Exception - * * @return $this */ public function duplicateConditionalStyle(array $pCellStyle, $pRange = '') @@ -1626,8 +1612,6 @@ public function duplicateConditionalStyle(array $pCellStyle, $pRange = '') * @param string $pCoordinate Cell coordinate (e.g. A1) * @param int $pBreak Break type (type of Worksheet::BREAK_*) * - * @throws Exception - * * @return $this */ public function setBreak($pCoordinate, $pBreak) @@ -1679,8 +1663,6 @@ public function getBreaks() * * @param string $pRange Cell range (e.g. A1:E1) * - * @throws Exception - * * @return $this */ public function mergeCells($pRange) @@ -1724,8 +1706,6 @@ public function mergeCells($pRange) * @param int $columnIndex2 Numeric column coordinate of the last cell * @param int $row2 Numeric row coordinate of the last cell * - * @throws Exception - * * @return $this */ public function mergeCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2) @@ -1740,8 +1720,6 @@ public function mergeCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $r * * @param string $pRange Cell range (e.g. A1:E1) * - * @throws Exception - * * @return $this */ public function unmergeCells($pRange) @@ -1770,8 +1748,6 @@ public function unmergeCells($pRange) * @param int $columnIndex2 Numeric column coordinate of the last cell * @param int $row2 Numeric row coordinate of the last cell * - * @throws Exception - * * @return $this */ public function unmergeCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2) @@ -1852,8 +1828,6 @@ public function protectCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, * * @param string $pRange Cell (e.g. A1) or cell range (e.g. A1:E1) * - * @throws Exception - * * @return $this */ public function unprotectCells($pRange) @@ -1878,8 +1852,6 @@ public function unprotectCells($pRange) * @param int $columnIndex2 Numeric column coordinate of the last cell * @param int $row2 Numeric row coordinate of the last cell * - * @throws Exception - * * @return $this */ public function unprotectCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2) @@ -1915,8 +1887,6 @@ public function getAutoFilter() * @param AutoFilter|string $pValue * A simple string containing a Cell range like 'A1:E10' is permitted for backward compatibility * - * @throws Exception - * * @return $this */ public function setAutoFilter($pValue) @@ -1938,8 +1908,6 @@ public function setAutoFilter($pValue) * @param int $columnIndex2 Numeric column coordinate of the second cell * @param int $row2 Numeric row coordinate of the second cell * - * @throws Exception - * * @return $this */ public function setAutoFilterByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2) @@ -1985,8 +1953,6 @@ public function getFreezePane() * @param null|string $cell Position of the split * @param null|string $topLeftCell default position of the right bottom pane * - * @throws Exception - * * @return $this */ public function freezePane($cell, $topLeftCell = null) @@ -2045,8 +2011,6 @@ public function getTopLeftCell() * @param int $pBefore Insert before this one * @param int $pNumRows Number of rows to insert * - * @throws Exception - * * @return $this */ public function insertNewRowBefore($pBefore, $pNumRows = 1) @@ -2067,8 +2031,6 @@ public function insertNewRowBefore($pBefore, $pNumRows = 1) * @param string $pBefore Insert before this one, eg: 'A' * @param int $pNumCols Number of columns to insert * - * @throws Exception - * * @return $this */ public function insertNewColumnBefore($pBefore, $pNumCols = 1) @@ -2089,8 +2051,6 @@ public function insertNewColumnBefore($pBefore, $pNumCols = 1) * @param int $beforeColumnIndex Insert before this one (numeric column coordinate of the cell) * @param int $pNumCols Number of columns to insert * - * @throws Exception - * * @return $this */ public function insertNewColumnBeforeByIndex($beforeColumnIndex, $pNumCols = 1) @@ -2108,8 +2068,6 @@ public function insertNewColumnBeforeByIndex($beforeColumnIndex, $pNumCols = 1) * @param int $pRow Remove starting with this one * @param int $pNumRows Number of rows to remove * - * @throws Exception - * * @return $this */ public function removeRow($pRow, $pNumRows = 1) @@ -2144,8 +2102,6 @@ public function removeRow($pRow, $pNumRows = 1) * @param string $pColumn Remove starting with this one, eg: 'A' * @param int $pNumCols Number of columns to remove * - * @throws Exception - * * @return $this */ public function removeColumn($pColumn, $pNumCols = 1) @@ -2184,8 +2140,6 @@ public function removeColumn($pColumn, $pNumCols = 1) * @param int $columnIndex Remove starting with this one (numeric column coordinate of the cell) * @param int $numColumns Number of columns to remove * - * @throws Exception - * * @return $this */ public function removeColumnByIndex($columnIndex, $numColumns = 1) @@ -2346,8 +2300,6 @@ public function setComments(array $pValue) * * @param string $pCellCoordinate Cell coordinate to get comment for, eg: 'A1' * - * @throws Exception - * * @return Comment */ public function getComment($pCellCoordinate) @@ -2461,8 +2413,6 @@ public function setSelectedCells($pCoordinate) * @param int $columnIndex Numeric column coordinate of the cell * @param int $row Numeric row coordinate of the cell * - * @throws Exception - * * @return $this */ public function setSelectedCellByColumnAndRow($columnIndex, $row) @@ -2502,8 +2452,6 @@ public function setRightToLeft($value) * @param string $startCell Insert array starting from this cell address as the top left coordinate * @param bool $strictNullComparison Apply strict comparison when testing for null values in the array * - * @throws Exception - * * @return $this */ public function fromArray(array $source, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) @@ -2619,8 +2567,6 @@ public function rangeToArray($pRange, $nullValue = null, $calculateFormulas = tr * @param bool $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero * True - Return rows and columns indexed by their actual row and column IDs * - * @throws Exception - * * @return array */ public function namedRangeToArray($pNamedRange, $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) @@ -3010,8 +2956,6 @@ public function __clone() * @param bool $validate False to skip validation of new title. WARNING: This should only be set * at parse time (by Readers), where titles can be assumed to be valid. * - * @throws Exception - * * @return $this */ public function setCodeName($pValue, $validate = true) diff --git a/src/PhpSpreadsheet/Writer/Csv.php b/src/PhpSpreadsheet/Writer/Csv.php index e5c08c1347..142f15b8a5 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -79,8 +79,6 @@ public function __construct(Spreadsheet $spreadsheet) * Save PhpSpreadsheet to file. * * @param resource|string $pFilename - * - * @throws Exception */ public function save($pFilename) { diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index ed6db1b730..ec75400144 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -23,7 +23,6 @@ use PhpOffice\PhpSpreadsheet\Worksheet\Drawing; use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; -use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; class Html extends BaseWriter { @@ -147,8 +146,6 @@ public function __construct(Spreadsheet $spreadsheet) * Save Spreadsheet to file. * * @param resource|string $pFilename - * - * @throws WriterException */ public function save($pFilename) { @@ -343,8 +340,6 @@ public function writeAllSheets() * * @param bool $pIncludeStyles Include styles? * - * @throws WriterException - * * @return string */ public function generateHTMLHeader($pIncludeStyles = false) @@ -398,8 +393,6 @@ public function generateHTMLHeader($pIncludeStyles = false) /** * Generate sheet data. * - * @throws WriterException - * * @return string */ public function generateSheetData() @@ -514,8 +507,6 @@ public function generateSheetData() /** * Generate sheet tabs. * - * @throws WriterException - * * @return string */ public function generateNavigation() @@ -743,8 +734,6 @@ private function writeChartInCell(Worksheet $pSheet, $coordinates) * * @param bool $generateSurroundingHTML Generate surrounding HTML tags? (<style> and </style>) * - * @throws WriterException - * * @return string */ public function generateStyles($generateSurroundingHTML = true) @@ -782,8 +771,6 @@ public function generateStyles($generateSurroundingHTML = true) * * @param bool $generateSurroundingHTML Generate surrounding HTML style? (html { }) * - * @throws WriterException - * * @return array */ public function buildCSS($generateSurroundingHTML = true) @@ -1158,8 +1145,6 @@ private function generateTableFooter() * @param int $pRow Row number (0-based) * @param string $cellType eg: 'td' * - * @throws WriterException - * * @return string */ private function generateRow(Worksheet $pSheet, array $pValues, $pRow, $cellType) diff --git a/src/PhpSpreadsheet/Writer/IWriter.php b/src/PhpSpreadsheet/Writer/IWriter.php index 97b14bef7c..2732953713 100644 --- a/src/PhpSpreadsheet/Writer/IWriter.php +++ b/src/PhpSpreadsheet/Writer/IWriter.php @@ -60,8 +60,6 @@ public function setPreCalculateFormulas($pValue); * Save PhpSpreadsheet to file. * * @param resource|string $pFilename Name of the file to save - * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ public function save($pFilename); @@ -78,8 +76,6 @@ public function getUseDiskCaching(); * @param bool $pValue * @param string $pDirectory Disk caching directory * - * @throws Exception when directory does not exist - * * @return IWriter */ public function setUseDiskCaching($pValue, $pDirectory = null); diff --git a/src/PhpSpreadsheet/Writer/Ods.php b/src/PhpSpreadsheet/Writer/Ods.php index bb981d35bb..e3a0ca9888 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -76,8 +76,6 @@ public function getWriterPart($pPartName) * Save PhpSpreadsheet to file. * * @param resource|string $pFilename - * - * @throws WriterException */ public function save($pFilename) { @@ -113,8 +111,6 @@ public function save($pFilename) /** * Create zip object. * - * @throws WriterException - * * @return ZipStream */ private function createZip() @@ -135,8 +131,6 @@ private function createZip() /** * Get Spreadsheet object. * - * @throws WriterException - * * @return Spreadsheet */ public function getSpreadsheet() diff --git a/src/PhpSpreadsheet/Writer/Ods/Content.php b/src/PhpSpreadsheet/Writer/Ods/Content.php index dea5100f59..cbf303bd8d 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Content.php +++ b/src/PhpSpreadsheet/Writer/Ods/Content.php @@ -32,8 +32,6 @@ class Content extends WriterPart /** * Write content.xml to XML format. * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * * @return string XML Output */ public function write() @@ -169,8 +167,6 @@ private function writeRows(XMLWriter $objWriter, Worksheet $sheet) * * @param XMLWriter $objWriter * @param Row $row - * - * @throws Exception */ private function writeCells(XMLWriter $objWriter, Row $row) { @@ -373,8 +369,6 @@ private function writeXfStyles(XMLWriter $writer, Spreadsheet $spreadsheet) * * @param XMLWriter $objWriter * @param Cell $cell - * - * @throws \PhpOffice\PhpSpreadsheet\Exception */ private function writeCellMerge(XMLWriter $objWriter, Cell $cell) { diff --git a/src/PhpSpreadsheet/Writer/Ods/Meta.php b/src/PhpSpreadsheet/Writer/Ods/Meta.php index ffe5eff792..eb2ebf9edc 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Meta.php +++ b/src/PhpSpreadsheet/Writer/Ods/Meta.php @@ -12,8 +12,6 @@ class Meta extends WriterPart * * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * * @return string XML Output */ public function write(Spreadsheet $spreadsheet = null) diff --git a/src/PhpSpreadsheet/Writer/Ods/MetaInf.php b/src/PhpSpreadsheet/Writer/Ods/MetaInf.php index 1ec9d1eb44..c9085cf8ce 100644 --- a/src/PhpSpreadsheet/Writer/Ods/MetaInf.php +++ b/src/PhpSpreadsheet/Writer/Ods/MetaInf.php @@ -9,8 +9,6 @@ class MetaInf extends WriterPart /** * Write META-INF/manifest.xml to XML format. * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * * @return string XML Output */ public function writeManifest() diff --git a/src/PhpSpreadsheet/Writer/Ods/Settings.php b/src/PhpSpreadsheet/Writer/Ods/Settings.php index 18f7ee6d5c..11d13341f9 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Settings.php +++ b/src/PhpSpreadsheet/Writer/Ods/Settings.php @@ -12,8 +12,6 @@ class Settings extends WriterPart * * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * * @return string XML Output */ public function write(Spreadsheet $spreadsheet = null) diff --git a/src/PhpSpreadsheet/Writer/Ods/Styles.php b/src/PhpSpreadsheet/Writer/Ods/Styles.php index eaf5cad952..cd71566f54 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Styles.php +++ b/src/PhpSpreadsheet/Writer/Ods/Styles.php @@ -12,8 +12,6 @@ class Styles extends WriterPart * * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * * @return string XML Output */ public function write(Spreadsheet $spreadsheet = null) diff --git a/src/PhpSpreadsheet/Writer/Pdf.php b/src/PhpSpreadsheet/Writer/Pdf.php index f0c1798fd2..bb9f4aefd9 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -222,8 +222,6 @@ public function getTempDir() * * @param string $pValue Temporary storage directory * - * @throws WriterException when directory does not exist - * * @return self */ public function setTempDir($pValue) @@ -242,8 +240,6 @@ public function setTempDir($pValue) * * @param string $pFilename Name of the file to save as * - * @throws WriterException - * * @return resource */ protected function prepareForSave($pFilename) diff --git a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php index 783bf253c2..4506468bb4 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php @@ -21,8 +21,6 @@ protected function createExternalWriterInstance() * Save Spreadsheet to file. * * @param string $pFilename Name of the file to save as - * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ public function save($pFilename) { diff --git a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php index 2922db1501..6f3cc57f68 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php @@ -2,7 +2,6 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Pdf; -use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; use PhpOffice\PhpSpreadsheet\Writer\Pdf; @@ -24,9 +23,6 @@ protected function createExternalWriterInstance($config) * Save Spreadsheet to file. * * @param string $pFilename Name of the file to save as - * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * @throws PhpSpreadsheetException */ public function save($pFilename) { diff --git a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php index 6ba77c753d..5c31af8f8b 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php @@ -25,8 +25,6 @@ protected function createExternalWriterInstance($orientation, $unit, $paperSize) * Save Spreadsheet to file. * * @param string $pFilename Name of the file to save as - * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ public function save($pFilename) { diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index fb42bf9e0d..06611789c8 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -116,8 +116,6 @@ public function __construct(Spreadsheet $spreadsheet) * Save Spreadsheet to file. * * @param resource|string $pFilename - * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ public function save($pFilename) { diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index aea6a26cd3..4d4d79d6ea 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -170,8 +170,6 @@ public function getWriterPart($pPartName) * Save PhpSpreadsheet to file. * * @param resource|string $pFilename - * - * @throws WriterException */ public function save($pFilename) { @@ -411,8 +409,6 @@ public function save($pFilename) /** * Get Spreadsheet object. * - * @throws WriterException - * * @return Spreadsheet */ public function getSpreadsheet() diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php index c9c3e055b2..aeb7a76b26 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php @@ -29,8 +29,6 @@ class Chart extends WriterPart * @param \PhpOffice\PhpSpreadsheet\Chart\Chart $pChart * @param mixed $calculateCellValues * - * @throws WriterException - * * @return string XML Output */ public function writeChart(\PhpOffice\PhpSpreadsheet\Chart\Chart $pChart, $calculateCellValues = true) @@ -109,8 +107,6 @@ public function writeChart(\PhpOffice\PhpSpreadsheet\Chart\Chart $pChart, $calcu * * @param XMLWriter $objWriter XML Writer * @param Title $title - * - * @throws WriterException */ private function writeTitle(XMLWriter $objWriter, Title $title = null) { @@ -154,8 +150,6 @@ private function writeTitle(XMLWriter $objWriter, Title $title = null) * * @param XMLWriter $objWriter XML Writer * @param Legend $legend - * - * @throws WriterException */ private function writeLegend(XMLWriter $objWriter, Legend $legend = null) { @@ -212,8 +206,6 @@ private function writeLegend(XMLWriter $objWriter, Legend $legend = null) * @param Axis $yAxis * @param null|GridLines $majorGridlines * @param null|GridLines $minorGridlines - * - * @throws WriterException */ private function writePlotArea(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet, PlotArea $plotArea, Title $xAxisLabel = null, Title $yAxisLabel = null, Axis $xAxis = null, Axis $yAxis = null, GridLines $majorGridlines = null, GridLines $minorGridlines = null) { @@ -395,8 +387,6 @@ private function writeDataLabels(XMLWriter $objWriter, Layout $chartLayout = nul * @param string $id2 * @param bool $isMultiLevelSeries * @param Axis $yAxis - * - * @throws WriterException */ private function writeCategoryAxis($objWriter, $xAxisLabel, $id1, $id2, $isMultiLevelSeries, Axis $yAxis) { @@ -518,8 +508,6 @@ private function writeCategoryAxis($objWriter, $xAxisLabel, $id1, $id2, $isMulti * @param Axis $xAxis * @param GridLines $majorGridlines * @param GridLines $minorGridlines - * - * @throws WriterException */ private function writeValueAxis($objWriter, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, Axis $xAxis, GridLines $majorGridlines, GridLines $minorGridlines) { @@ -999,8 +987,6 @@ private function writeValueAxis($objWriter, $yAxisLabel, $groupType, $id1, $id2, * * @param PlotArea $plotArea * - * @throws WriterException - * * @return array|string */ private static function getChartType($plotArea) @@ -1064,8 +1050,6 @@ private function writePlotSeriesValuesElement($objWriter, $val = 3, $fillColor = * @param bool &$catIsMultiLevelSeries Is category a multi-series category * @param bool &$valIsMultiLevelSeries Is value set a multi-series set * @param string &$plotGroupingType Type of grouping for multi-series values - * - * @throws WriterException */ private function writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMultiLevelSeries, &$valIsMultiLevelSeries, &$plotGroupingType) { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php index a95298afcd..ee34e318b8 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php @@ -13,8 +13,6 @@ class Comments extends WriterPart * * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * * @return string XML Output */ public function writeComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet) @@ -73,8 +71,6 @@ public function writeComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWo * @param string $pCellReference Cell reference * @param Comment $pComment Comment * @param array $pAuthors Array of authors - * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ private function writeComment(XMLWriter $objWriter, $pCellReference, Comment $pComment, array $pAuthors) { @@ -96,8 +92,6 @@ private function writeComment(XMLWriter $objWriter, $pCellReference, Comment $pC * * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * * @return string XML Output */ public function writeVMLComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet) diff --git a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php index 6b22d7134f..421f1e73ac 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php @@ -16,8 +16,6 @@ class ContentTypes extends WriterPart * @param Spreadsheet $spreadsheet * @param bool $includeCharts Flag indicating if we should include drawing details for charts * - * @throws WriterException - * * @return string XML Output */ public function writeContentTypes(Spreadsheet $spreadsheet, $includeCharts = false) @@ -188,8 +186,6 @@ public function writeContentTypes(Spreadsheet $spreadsheet, $includeCharts = fal * * @param string $pFile Filename * - * @throws WriterException - * * @return string Mime Type */ private function getImageMimeType($pFile) @@ -209,8 +205,6 @@ private function getImageMimeType($pFile) * @param XMLWriter $objWriter XML Writer * @param string $pPartname Part name * @param string $pContentType Content type - * - * @throws WriterException */ private function writeDefaultContentType(XMLWriter $objWriter, $pPartname, $pContentType) { @@ -231,8 +225,6 @@ private function writeDefaultContentType(XMLWriter $objWriter, $pPartname, $pCon * @param XMLWriter $objWriter XML Writer * @param string $pPartname Part name * @param string $pContentType Content type - * - * @throws WriterException */ private function writeOverrideContentType(XMLWriter $objWriter, $pPartname, $pContentType) { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php b/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php index 2a18d5c7e3..289d08c731 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php @@ -12,8 +12,6 @@ class DocProps extends WriterPart * * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * * @return string XML Output */ public function writeDocPropsApp(Spreadsheet $spreadsheet) @@ -111,8 +109,6 @@ public function writeDocPropsApp(Spreadsheet $spreadsheet) * * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * * @return string XML Output */ public function writeDocPropsCore(Spreadsheet $spreadsheet) @@ -180,8 +176,6 @@ public function writeDocPropsCore(Spreadsheet $spreadsheet) * * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * * @return string XML Output */ public function writeDocPropsCustom(Spreadsheet $spreadsheet) diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php index 08256a1d5b..4c5a413e85 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php @@ -17,8 +17,6 @@ class Drawing extends WriterPart * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * @param bool $includeCharts Flag indicating if we should include drawing details for charts * - * @throws WriterException - * * @return string XML Output */ public function writeDrawings(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet, $includeCharts = false) @@ -156,8 +154,6 @@ public function writeChart(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Chart * @param BaseDrawing $pDrawing * @param int $pRelationId * @param null|int $hlinkClickId - * - * @throws WriterException */ public function writeDrawing(XMLWriter $objWriter, BaseDrawing $pDrawing, $pRelationId = -1, $hlinkClickId = null) { @@ -289,8 +285,6 @@ public function writeDrawing(XMLWriter $objWriter, BaseDrawing $pDrawing, $pRela * * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * - * @throws WriterException - * * @return string XML Output */ public function writeVMLHeaderFooterImages(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet) diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php index 76c196b449..6dc415029f 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php @@ -14,8 +14,6 @@ class Rels extends WriterPart * * @param Spreadsheet $spreadsheet * - * @throws WriterException - * * @return string XML Output */ public function writeRelationships(Spreadsheet $spreadsheet) @@ -89,8 +87,6 @@ public function writeRelationships(Spreadsheet $spreadsheet) * * @param Spreadsheet $spreadsheet * - * @throws WriterException - * * @return string XML Output */ public function writeWorkbookRelationships(Spreadsheet $spreadsheet) @@ -172,8 +168,6 @@ public function writeWorkbookRelationships(Spreadsheet $spreadsheet) * @param int $pWorksheetId * @param bool $includeCharts Flag indicating if we should write charts * - * @throws WriterException - * * @return string XML Output */ public function writeWorksheetRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet, $pWorksheetId = 1, $includeCharts = false) @@ -301,8 +295,6 @@ private function writeUnparsedRelationship(\PhpOffice\PhpSpreadsheet\Worksheet\W * @param int &$chartRef Chart ID * @param bool $includeCharts Flag indicating if we should write charts * - * @throws WriterException - * * @return string XML Output */ public function writeDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet, &$chartRef, $includeCharts = false) @@ -370,8 +362,6 @@ public function writeDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Wo * * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * - * @throws WriterException - * * @return string XML Output */ public function writeHeaderFooterDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet) @@ -415,8 +405,6 @@ public function writeHeaderFooterDrawingRelationships(\PhpOffice\PhpSpreadsheet\ * @param string $pType Relationship type * @param string $pTarget Relationship target * @param string $pTargetMode Relationship target mode - * - * @throws WriterException */ private function writeRelationship(XMLWriter $objWriter, $pId, $pType, $pTarget, $pTargetMode = '') { @@ -442,8 +430,6 @@ private function writeRelationship(XMLWriter $objWriter, $pId, $pType, $pTarget, * @param \PhpOffice\PhpSpreadsheet\Worksheet\Drawing $drawing * @param $i * - * @throws WriterException - * * @return int */ private function writeDrawingHyperLink($objWriter, $drawing, $i) diff --git a/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php b/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php index 8a0cfe3450..531111abd9 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php @@ -12,8 +12,6 @@ class RelsRibbon extends WriterPart * * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * * @return string XML Output */ public function writeRibbonRelationships(Spreadsheet $spreadsheet) diff --git a/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php b/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php index 01ad38de67..fb508c6b50 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php @@ -12,8 +12,6 @@ class RelsVBA extends WriterPart * * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * * @return string XML Output */ public function writeVBARelationships(Spreadsheet $spreadsheet) diff --git a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php index 19604e4486..8e18e6f869 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php @@ -8,7 +8,6 @@ use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; -use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; class StringTable extends WriterPart { @@ -62,8 +61,6 @@ public function createStringTable(Worksheet $pSheet, $pExistingTable = null) * * @param string[] $pStringTable * - * @throws WriterException - * * @return string XML Output */ public function writeStringTable(array $pStringTable) diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Style.php b/src/PhpSpreadsheet/Writer/Xlsx/Style.php index 16e800e01f..54ec664fe1 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Style.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Style.php @@ -20,8 +20,6 @@ class Style extends WriterPart * * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * * @return string XML Output */ public function writeStyles(Spreadsheet $spreadsheet) @@ -369,8 +367,6 @@ private function writeBorder(XMLWriter $objWriter, Borders $pBorders) * @param XMLWriter $objWriter XML Writer * @param \PhpOffice\PhpSpreadsheet\Style\Style $pStyle Style * @param Spreadsheet $spreadsheet Workbook - * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ private function writeCellStyleXf(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Style $pStyle, Spreadsheet $spreadsheet) { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Theme.php b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php index f5f8dc0752..c609039501 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Theme.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php @@ -111,8 +111,6 @@ class Theme extends WriterPart * * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * * @return string XML Output */ public function writeTheme(Spreadsheet $spreadsheet) diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php index fd936748ad..a56c5b72fb 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php @@ -18,8 +18,6 @@ class Workbook extends WriterPart * @param Spreadsheet $spreadsheet * @param bool $recalcRequired Indicate whether formulas should be recalculated before writing * - * @throws WriterException - * * @return string XML Output */ public function writeWorkbook(Spreadsheet $spreadsheet, $recalcRequired = false) @@ -185,8 +183,6 @@ private function writeCalcPr(XMLWriter $objWriter, $recalcRequired = true) * * @param XMLWriter $objWriter XML Writer * @param Spreadsheet $spreadsheet - * - * @throws WriterException */ private function writeSheets(XMLWriter $objWriter, Spreadsheet $spreadsheet) { @@ -215,8 +211,6 @@ private function writeSheets(XMLWriter $objWriter, Spreadsheet $spreadsheet) * @param int $pSheetId Sheet id * @param int $pRelId Relationship ID * @param string $sheetState Sheet state (visible, hidden, veryHidden) - * - * @throws WriterException */ private function writeSheet(XMLWriter $objWriter, $pSheetname, $pSheetId = 1, $pRelId = 1, $sheetState = 'visible') { @@ -240,8 +234,6 @@ private function writeSheet(XMLWriter $objWriter, $pSheetname, $pSheetId = 1, $p * * @param XMLWriter $objWriter XML Writer * @param Spreadsheet $spreadsheet - * - * @throws WriterException */ private function writeDefinedNames(XMLWriter $objWriter, Spreadsheet $spreadsheet) { @@ -275,8 +267,6 @@ private function writeDefinedNames(XMLWriter $objWriter, Spreadsheet $spreadshee * * @param XMLWriter $objWriter XML Writer * @param Spreadsheet $spreadsheet - * - * @throws WriterException */ private function writeNamedRanges(XMLWriter $objWriter, Spreadsheet $spreadsheet) { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 1d5a995a8b..0c042fe138 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -12,7 +12,6 @@ use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule; use PhpOffice\PhpSpreadsheet\Worksheet\SheetView; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet as PhpspreadsheetWorksheet; -use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; /** * @category PhpSpreadsheet @@ -28,8 +27,6 @@ class Worksheet extends WriterPart * @param string[] $pStringTable * @param bool $includeCharts Flag indicating if we should write charts * - * @throws WriterException - * * @return string XML Output */ public function writeWorksheet(PhpspreadsheetWorksheet $pSheet, $pStringTable = null, $includeCharts = false) @@ -194,8 +191,6 @@ private function writeDimension(XMLWriter $objWriter, PhpspreadsheetWorksheet $p * * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet - * - * @throws WriterException */ private function writeSheetViews(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { @@ -459,8 +454,6 @@ private function writeSheetProtection(XMLWriter $objWriter, PhpspreadsheetWorksh * * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet - * - * @throws WriterException */ private function writeConditionalFormatting(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { @@ -956,8 +949,6 @@ private function writeBreaks(XMLWriter $objWriter, PhpspreadsheetWorksheet $pShe * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet * @param string[] $pStringTable String table - * - * @throws WriterException */ private function writeSheetData(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet, array $pStringTable) { @@ -1044,8 +1035,6 @@ private function writeSheetData(XMLWriter $objWriter, PhpspreadsheetWorksheet $p * @param PhpspreadsheetWorksheet $pSheet Worksheet * @param Cell $pCellAddress Cell Address * @param string[] $pFlippedStringTable String table (flipped), for faster index searching - * - * @throws WriterException */ private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet, $pCellAddress, array $pFlippedStringTable) { diff --git a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php index 14cd993a35..f74d29ef26 100644 --- a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php @@ -310,8 +310,6 @@ public function testBranchPruningFormulaParsingInequalitiesConditionsCase() * be set in cache * @param string[] $shouldNotBeSetInCacheCells coordinates of cells that must * not be set in cache because of pruning - * - * @throws \PhpOffice\PhpSpreadsheet\Exception * @dataProvider dataProviderBranchPruningFullExecution */ public function testFullExecution( diff --git a/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php index b0aed46699..214fe593d3 100644 --- a/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php +++ b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php @@ -15,8 +15,6 @@ class DocumentGeneratorTest extends TestCase * * @param array $phpSpreadsheetFunctions * @param string $expected - * - * @throws \ReflectionException */ public function testGenerateFunctionListByName(array $phpSpreadsheetFunctions, string $expected): void { @@ -28,8 +26,6 @@ public function testGenerateFunctionListByName(array $phpSpreadsheetFunctions, s * * @param array $phpSpreadsheetFunctions * @param string $expected - * - * @throws \ReflectionException */ public function testGenerateFunctionListByCategory(array $phpSpreadsheetFunctions, string $expected): void { From bc101dafbce9535eb6bce5c83ceba87b1c28878e Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 16 May 2020 13:40:36 +0200 Subject: [PATCH 032/659] README - add link to migration path to show people easier way (#1460) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index df683a1e1b..893b3784b1 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ PhpSpreadsheet is the next version of PHPExcel. It breaks compatibility to drama Because all efforts have shifted to PhpSpreadsheet, PHPExcel will no longer be maintained. All contributions for PHPExcel, patches and new features, should target PhpSpreadsheet `master` branch. +Do you need to migrate? There is [an automated tool](/docs/topics/migration-from-PHPExcel.md) for that. + ## License PhpSpreadsheet is licensed under [MIT](https://github.com/PHPOffice/PhpSpreadsheet/blob/master/LICENSE). From c4931de1f93509b786f7a73f94b3836e0ffcab72 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Tue, 24 Mar 2020 11:52:22 +0100 Subject: [PATCH 033/659] Limit composer package to `src/` While there is value in providing those, they also clutter IDE auto-complete feature. Now they users can opt-in to download them via `--prefer-source` flag. Closes #908 Closes #1424 --- .gitattributes | 16 ++++++++++++++-- CHANGELOG.md | 1 + docs/index.md | 11 +++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.gitattributes b/.gitattributes index 0375f55833..0186deae8c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,16 @@ -/tests export-ignore -README.md export-ignore *.min.js binary +/.gitattributes export-ignore /.github export-ignore +/.gitignore export-ignore +/.php_cs.dist export-ignore +/.sami.php export-ignore +/.scrutinizer.yml export-ignore +/.travis.yml export-ignore +/CHANGELOG.PHPExcel.md export-ignore +/bin export-ignore +/composer.lock export-ignore +/docs export-ignore +/mkdocs.yml export-ignore +/phpunit.xml.dist export-ignore +/samples export-ignore +/tests export-ignore diff --git a/CHANGELOG.md b/CHANGELOG.md index 57bad0aa09..4101e2eb63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Drop support for PHP 7.1, according to https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support - Drop partial migration tool in favor of complete migration via RectorPHP [#1445](https://github.com/PHPOffice/PhpSpreadsheet/issues/1445) +- Limit composer package to `src/` [#1424](https://github.com/PHPOffice/PhpSpreadsheet/pull/1424) ## [1.12.0] - 2020-04-27 diff --git a/docs/index.md b/docs/index.md index 808fb75957..c1a064595c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -42,6 +42,13 @@ Use [composer](https://getcomposer.org) to install PhpSpreadsheet into your proj composer require phpoffice/phpspreadsheet ``` +Or also download the documentation and samples if you plan to use them: + +```sh +composer require phpoffice/phpspreadsheet --prefer-source +``` + + ## Hello World This would be the simplest way to write a spreadsheet: @@ -64,8 +71,8 @@ $writer->save('hello world.xlsx'); ## Learn by example -A good way to get started is to run some of the samples. Serve the samples via -PHP built-in webserver: +A good way to get started is to run some of the samples. Don't forget to download them via `--prefer-source` composer +flag. And then serve them via PHP built-in webserver: ```sh php -S localhost:8000 -t vendor/phpoffice/phpspreadsheet/samples From 3090c1e73f1a659a48752508d8bbbf85952e74b7 Mon Sep 17 00:00:00 2001 From: drewblin Date: Tue, 12 May 2020 11:17:07 +0300 Subject: [PATCH 034/659] Support CSV files with data wrapping a lot of lines If there is "line" splited on lot of lines we can reach limit of recursion nesting. It's better to use while instead of recursion. Closes #1468 --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Reader/Csv.php | 40 +++++++++++++++---------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4101e2eb63..e3ba3de84c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Added - Support writing to streams in all writers [#1292](https://github.com/PHPOffice/PhpSpreadsheet/issues/1292) +- Support CSV files with data wrapping a lot of lines [#1468](https://github.com/PHPOffice/PhpSpreadsheet/pull/1468) ### Fixed diff --git a/src/PhpSpreadsheet/Reader/Csv.php b/src/PhpSpreadsheet/Reader/Csv.php index ed3b70f1e3..4d10459565 100644 --- a/src/PhpSpreadsheet/Reader/Csv.php +++ b/src/PhpSpreadsheet/Reader/Csv.php @@ -236,33 +236,31 @@ function ($sum, $value) use ($median) { /** * Get the next full line from the file. * - * @param string $line - * - * @return bool|string + * @return false|string */ - private function getNextLine($line = '') + private function getNextLine() { - // Get the next line in the file - $newLine = fgets($this->fileHandle); + $line = ''; + $enclosure = '(?escapeCharacter, '/') . ')' . preg_quote($this->enclosure, '/'); - // Return false if there is no next line - if ($newLine === false) { - return false; - } + do { + // Get the next line in the file + $newLine = fgets($this->fileHandle); - // Add the new line to the line passed in - $line = $line . $newLine; + // Return false if there is no next line + if ($newLine === false) { + return false; + } - // Drop everything that is enclosed to avoid counting false positives in enclosures - $enclosure = '(?escapeCharacter, '/') . ')' - . preg_quote($this->enclosure, '/'); - $line = preg_replace('/(' . $enclosure . '.*' . $enclosure . ')/Us', '', $line); + // Add the new line to the line passed in + $line = $line . $newLine; - // See if we have any enclosures left in the line - // if we still have an enclosure then we need to read the next line as well - if (preg_match('/(' . $enclosure . ')/', $line) > 0) { - $line = $this->getNextLine($line); - } + // Drop everything that is enclosed to avoid counting false positives in enclosures + $line = preg_replace('/(' . $enclosure . '.*' . $enclosure . ')/Us', '', $line); + + // See if we have any enclosures left in the line + // if we still have an enclosure then we need to read the next line as well + } while (preg_match('/(' . $enclosure . ')/', $line) > 0); return $line; } From 7517cdd008c5fa874ac18180f5835026b6368e2b Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 17 May 2020 02:15:18 -0700 Subject: [PATCH 035/659] Improve Coverage for CSV (#1475) I believe that both CSV Reader and Writer are 100% covered now. There were some errors uncovered during development. The reader specifically permits encodings other than UTF-8 to be used. However, fgetcsv will not properly handle other encodings. I tried replacing it with fgets/iconv/strgetcsv, but that could not handle line breaks within a cell, even for UTF-8. This is, I'm sure, a very rare use case. I eventually handled it by using php://memory to hold the translated file contents for non-UTF8. There were no tests for this situation, and now there are (probably too many). "Contiguous" read was not handle correctly. There is a file in samples which uses it. It was designed to read a large sheet, and split it into three. The first sheet was corrrect, but the second and third were almost entirely empty. This has been corrected, and the sample code was adapted into a formal test with assertions to confirm that it works as designed. I made a minor documentation change. Unlike HTML, where you never need a BOM because you can declare the encoding in the file, a CSV with non-ASCII characters must explicitly include a BOM for Excel to handle it correctly. This was explained in the Reading CSV section, but was glossed over in the Writing CSV section, which I have updated. --- docs/topics/reading-and-writing-to-file.md | 8 +- .../Basic/13_CalculationCyclicFormulae.php | 2 +- src/PhpSpreadsheet/Reader/Csv.php | 84 +++++-------- src/PhpSpreadsheet/Writer/Csv.php | 7 +- .../Reader/CsvContiguousFilter.php | 57 +++++++++ .../Reader/CsvContiguousTest.php | 81 +++++++++++++ tests/PhpSpreadsheetTests/Reader/CsvTest.php | 110 ++++++++++++++++++ .../Writer/Csv/CsvWriteTest.php | 60 ++++++++++ tests/data/Reader/CSV/encoding.iso88591.csv | 2 + tests/data/Reader/CSV/encoding.utf16be.csv | Bin 0 -> 20 bytes tests/data/Reader/CSV/encoding.utf16le.csv | Bin 0 -> 20 bytes tests/data/Reader/CSV/encoding.utf32be.csv | Bin 0 -> 40 bytes tests/data/Reader/CSV/encoding.utf32le.csv | Bin 0 -> 40 bytes tests/data/Reader/CSV/encoding.utf8.csv | 2 + tests/data/Reader/CSV/encoding.utf8bom.csv | 2 + tests/data/Reader/CSV/sep.csv | 3 + .../CSV/utf16be.line_break_in_enclosure.csv | Bin 0 -> 818 bytes 17 files changed, 358 insertions(+), 60 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/Reader/CsvContiguousFilter.php create mode 100644 tests/PhpSpreadsheetTests/Reader/CsvContiguousTest.php create mode 100644 tests/PhpSpreadsheetTests/Writer/Csv/CsvWriteTest.php create mode 100644 tests/data/Reader/CSV/encoding.iso88591.csv create mode 100644 tests/data/Reader/CSV/encoding.utf16be.csv create mode 100644 tests/data/Reader/CSV/encoding.utf16le.csv create mode 100644 tests/data/Reader/CSV/encoding.utf32be.csv create mode 100644 tests/data/Reader/CSV/encoding.utf32le.csv create mode 100644 tests/data/Reader/CSV/encoding.utf8.csv create mode 100644 tests/data/Reader/CSV/encoding.utf8bom.csv create mode 100644 tests/data/Reader/CSV/sep.csv create mode 100644 tests/data/Reader/CSV/utf16be.line_break_in_enclosure.csv diff --git a/docs/topics/reading-and-writing-to-file.md b/docs/topics/reading-and-writing-to-file.md index 3b6a037cdc..c0dc7c033e 100644 --- a/docs/topics/reading-and-writing-to-file.md +++ b/docs/topics/reading-and-writing-to-file.md @@ -535,8 +535,12 @@ $writer->save("05featuredemo.csv"); #### Writing UTF-8 CSV files -A CSV file can be marked as UTF-8 by writing a BOM file header. This can -be enabled by using the following code: +CSV files are written in UTF-8. If they do not contain characters +outside the ASCII range, nothing else need be done. +However, if such characters are in the file, +it should explicitly include a BOM file header; +if it doesn't, Excel will not interpret those characters correctly. +This can be enabled by using the following code: ``` php $writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet); diff --git a/samples/Basic/13_CalculationCyclicFormulae.php b/samples/Basic/13_CalculationCyclicFormulae.php index 26e9784db4..a446e56e08 100644 --- a/samples/Basic/13_CalculationCyclicFormulae.php +++ b/samples/Basic/13_CalculationCyclicFormulae.php @@ -16,7 +16,7 @@ ->setCellValue('B1', '=A1+1') ->setCellValue('B2', '=A2'); -Calculation::getInstance($spreadsheet)->cyclicFormulaCount = 100; +Calculation::getInstance($spreadsheet)->cyclicFormulaCount = 15; // Calculated data $helper->log('Calculated data'); diff --git a/src/PhpSpreadsheet/Reader/Csv.php b/src/PhpSpreadsheet/Reader/Csv.php index 4d10459565..2e485109ce 100644 --- a/src/PhpSpreadsheet/Reader/Csv.php +++ b/src/PhpSpreadsheet/Reader/Csv.php @@ -43,13 +43,6 @@ class Csv extends BaseReader */ private $contiguous = false; - /** - * Row counter for loading rows contiguously. - * - * @var int - */ - private $contiguousRow = -1; - /** * The character that can escape the enclosure. * @@ -101,28 +94,6 @@ protected function skipBOM() fgets($this->fileHandle, 4) == "\xEF\xBB\xBF" ? fseek($this->fileHandle, 3) : fseek($this->fileHandle, 0); - break; - case 'UTF-16LE': - fgets($this->fileHandle, 3) == "\xFF\xFE" ? - fseek($this->fileHandle, 2) : fseek($this->fileHandle, 0); - - break; - case 'UTF-16BE': - fgets($this->fileHandle, 3) == "\xFE\xFF" ? - fseek($this->fileHandle, 2) : fseek($this->fileHandle, 0); - - break; - case 'UTF-32LE': - fgets($this->fileHandle, 5) == "\xFF\xFE\x00\x00" ? - fseek($this->fileHandle, 4) : fseek($this->fileHandle, 0); - - break; - case 'UTF-32BE': - fgets($this->fileHandle, 5) == "\x00\x00\xFE\xFF" ? - fseek($this->fileHandle, 4) : fseek($this->fileHandle, 0); - - break; - default: break; } } @@ -275,10 +246,7 @@ private function getNextLine() public function listWorksheetInfo($pFilename) { // Open file - if (!$this->canRead($pFilename)) { - throw new Exception($pFilename . ' is an Invalid Spreadsheet file.'); - } - $this->openFile($pFilename); + $this->openFileOrMemory($pFilename); $fileHandle = $this->fileHandle; // Skip BOM, if any @@ -324,6 +292,24 @@ public function load($pFilename) return $this->loadIntoExisting($pFilename, $spreadsheet); } + private function openFileOrMemory($pFilename) + { + // Open file + $fhandle = $this->canRead($pFilename); + if (!$fhandle) { + throw new Exception($pFilename . ' is an Invalid Spreadsheet file.'); + } + $this->openFile($pFilename); + if ($this->inputEncoding !== 'UTF-8') { + fclose($this->fileHandle); + $entireFile = file_get_contents($pFilename); + $this->fileHandle = fopen('php://memory', 'r+'); + $data = StringHelper::convertEncoding($entireFile, 'UTF-8', $this->inputEncoding); + fwrite($this->fileHandle, $data); + rewind($this->fileHandle); + } + } + /** * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * @@ -338,10 +324,7 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) ini_set('auto_detect_line_endings', true); // Open file - if (!$this->canRead($pFilename)) { - throw new Exception($pFilename . ' is an Invalid Spreadsheet file.'); - } - $this->openFile($pFilename); + $this->openFileOrMemory($pFilename); $fileHandle = $this->fileHandle; // Skip BOM, if any @@ -357,22 +340,24 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) // Set our starting row based on whether we're in contiguous mode or not $currentRow = 1; - if ($this->contiguous) { - $currentRow = ($this->contiguousRow == -1) ? $sheet->getHighestRow() : $this->contiguousRow; - } + $outRow = 0; // Loop through each line of the file in turn while (($rowData = fgetcsv($fileHandle, 0, $this->delimiter, $this->enclosure, $this->escapeCharacter)) !== false) { + $noOutputYet = true; $columnLetter = 'A'; foreach ($rowData as $rowDatum) { if ($rowDatum != '' && $this->readFilter->readCell($columnLetter, $currentRow)) { - // Convert encoding if necessary - if ($this->inputEncoding !== 'UTF-8') { - $rowDatum = StringHelper::convertEncoding($rowDatum, 'UTF-8', $this->inputEncoding); + if ($this->contiguous) { + if ($noOutputYet) { + $noOutputYet = false; + ++$outRow; + } + } else { + $outRow = $currentRow; } - // Set cell value - $sheet->getCell($columnLetter . $currentRow)->setValue($rowDatum); + $sheet->getCell($columnLetter . $outRow)->setValue($rowDatum); } ++$columnLetter; } @@ -382,10 +367,6 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) // Close file fclose($fileHandle); - if ($this->contiguous) { - $this->contiguousRow = $currentRow; - } - ini_set('auto_detect_line_endings', $lineEnding); // Return @@ -477,9 +458,6 @@ public function setSheetIndex($pValue) public function setContiguous($contiguous) { $this->contiguous = (bool) $contiguous; - if (!$contiguous) { - $this->contiguousRow = -1; - } return $this; } @@ -530,7 +508,7 @@ public function canRead($pFilename) // Check if file exists try { $this->openFile($pFilename); - } catch (Exception $e) { + } catch (\InvalidArgumentException $e) { return false; } diff --git a/src/PhpSpreadsheet/Writer/Csv.php b/src/PhpSpreadsheet/Writer/Csv.php index 142f15b8a5..cabfe450ec 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -93,6 +93,8 @@ public function save($pFilename) // Open file if (is_resource($pFilename)) { $fileHandle = $pFilename; + } elseif (!$pFilename) { + $fileHandle = false; } else { $fileHandle = fopen($pFilename, 'wb+'); } @@ -176,10 +178,7 @@ public function getEnclosure() */ public function setEnclosure($pValue) { - if ($pValue == '') { - $pValue = null; - } - $this->enclosure = $pValue; + $this->enclosure = $pValue ? $pValue : '"'; return $this; } diff --git a/tests/PhpSpreadsheetTests/Reader/CsvContiguousFilter.php b/tests/PhpSpreadsheetTests/Reader/CsvContiguousFilter.php new file mode 100644 index 0000000000..95f7e78721 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/CsvContiguousFilter.php @@ -0,0 +1,57 @@ +startRow = $startRow; + $this->endRow = $startRow + $chunkSize; + } + + public function setFilterType($type) + { + $this->filterType = $type; + } + + public function filter1($row) + { + // Include rows 1-10, followed by 100-110, etc. + return $row % 100 <= 10; + } + + public function filter0($row) + { + // Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow + if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) { + return true; + } + + return false; + } + + public function readCell($column, $row, $worksheetName = '') + { + if ($this->filterType == 1) { + return $this->filter1($row); + } + + return $this->filter0($row); + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/CsvContiguousTest.php b/tests/PhpSpreadsheetTests/Reader/CsvContiguousTest.php new file mode 100644 index 0000000000..4fe2006d65 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/CsvContiguousTest.php @@ -0,0 +1,81 @@ +getContiguous()); + $reader->setReadFilter($chunkFilter) + ->setContiguous(true); + + // Instantiate a new PhpSpreadsheet object manually + $spreadsheet = new Spreadsheet(); + + // Set a sheet index + $sheet = 0; + // Loop to read our worksheet in "chunk size" blocks + /** $startRow is set to 2 initially because we always read the headings in row #1 * */ + for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) { + // Tell the Read Filter, the limits on which rows we want to read this iteration + $chunkFilter->setRows($startRow, $chunkSize); + + // Increment the worksheet index pointer for the Reader + $reader->setSheetIndex($sheet); + // Load only the rows that match our filter into a new worksheet in the PhpSpreadsheet Object + $reader->loadIntoExisting($this->inputFileName, $spreadsheet); + // Set the worksheet title (to reference the "sheet" of data that we've loaded) + // and increment the sheet index as well + $spreadsheet->getActiveSheet()->setTitle('Country Data #' . (++$sheet)); + } + + $sheet = $spreadsheet->getSheetByName('Country Data #1'); + self::assertEquals('Kabul', $sheet->getCell('A2')->getValue()); + $sheet = $spreadsheet->getSheetByName('Country Data #2'); + self::assertEquals('Lesotho', $sheet->getCell('B4')->getValue()); + $sheet = $spreadsheet->getSheetByName('Country Data #3'); + self::assertEquals(-20.1, $sheet->getCell('C6')->getValue()); + } + + public function testContiguous2() + { + // Create a new Reader of the type defined in $inputFileType + $reader = new Csv(); + + // Create a new Instance of our Read Filter + $chunkFilter = new CsvContiguousFilter(); + $chunkFilter->setFilterType(1); + + // Tell the Reader that we want to use the Read Filter that we've Instantiated + // and that we want to store it in contiguous rows/columns + $reader->setReadFilter($chunkFilter) + ->setContiguous(true); + + // Instantiate a new PhpSpreadsheet object manually + $spreadsheet = new Spreadsheet(); + + // Loop to read our worksheet in "chunk size" blocks + $reader->loadIntoExisting($this->inputFileName, $spreadsheet); + + $sheet = $spreadsheet->getActiveSheet(); + self::assertEquals('Kabul', $sheet->getCell('A2')->getValue()); + self::assertEquals('Kuwait', $sheet->getCell('B11')->getValue()); + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/CsvTest.php b/tests/PhpSpreadsheetTests/Reader/CsvTest.php index be08f6a65e..bb593ce861 100644 --- a/tests/PhpSpreadsheetTests/Reader/CsvTest.php +++ b/tests/PhpSpreadsheetTests/Reader/CsvTest.php @@ -3,6 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Reader; use PhpOffice\PhpSpreadsheet\Reader\Csv; +use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException; use PHPUnit\Framework\TestCase; class CsvTest extends TestCase @@ -130,4 +131,113 @@ public function testEscapeCharacters() $this->assertSame('"', $reader->getEscapeCharacter()); $this->assertSame($expected, $worksheet->toArray()); } + + /** + * @dataProvider providerEncodings + * + * @param string $filename + * @param string $encoding + */ + public function testEncodings($filename, $encoding) + { + $reader = new Csv(); + $reader->setInputEncoding($encoding); + $spreadsheet = $reader->load($filename); + $sheet = $spreadsheet->getActiveSheet(); + self::assertEquals('Å', $sheet->getCell('A1')->getValue()); + } + + public function testInvalidWorkSheetInfo() + { + $this->expectException(ReaderException::class); + $reader = new Csv(); + $reader->listWorksheetInfo(''); + } + + /** + * @dataProvider providerEncodings + * + * @param string $filename + * @param string $encoding + */ + public function testWorkSheetInfo($filename, $encoding) + { + $reader = new Csv(); + $reader->setInputEncoding($encoding); + $info = $reader->listWorksheetInfo($filename); + self::assertEquals('Worksheet', $info[0]['worksheetName']); + self::assertEquals('B', $info[0]['lastColumnLetter']); + self::assertEquals(1, $info[0]['lastColumnIndex']); + self::assertEquals(2, $info[0]['totalRows']); + self::assertEquals(2, $info[0]['totalColumns']); + } + + public function providerEncodings() + { + return [ + ['data/Reader/CSV/encoding.iso88591.csv', 'ISO-8859-1'], + ['data/Reader/CSV/encoding.utf8.csv', 'UTF-8'], + ['data/Reader/CSV/encoding.utf8bom.csv', 'UTF-8'], + ['data/Reader/CSV/encoding.utf16be.csv', 'UTF-16BE'], + ['data/Reader/CSV/encoding.utf16le.csv', 'UTF-16LE'], + ['data/Reader/CSV/encoding.utf32be.csv', 'UTF-32BE'], + ['data/Reader/CSV/encoding.utf32le.csv', 'UTF-32LE'], + ]; + } + + public function testUtf16LineBreak() + { + $reader = new Csv(); + $reader->setInputEncoding('UTF-16BE'); + $spreadsheet = $reader->load('data/Reader/CSV/utf16be.line_break_in_enclosure.csv'); + $sheet = $spreadsheet->getActiveSheet(); + $expected = <<getCell('B3')->getValue()); + } + + public function testSeparatorLine() + { + $reader = new Csv(); + $reader->setSheetIndex(3); + $spreadsheet = $reader->load('data/Reader/CSV/sep.csv'); + self::assertEquals(';', $reader->getDelimiter()); + $sheet = $spreadsheet->getActiveSheet(); + self::assertEquals(3, $reader->getSheetIndex()); + self::assertEquals(3, $spreadsheet->getActiveSheetIndex()); + self::assertEquals('A', $sheet->getCell('A1')->getValue()); + self::assertEquals(1, $sheet->getCell('B1')->getValue()); + self::assertEquals(2, $sheet->getCell('A2')->getValue()); + self::assertEquals(3, $sheet->getCell('B2')->getValue()); + } + + public function testDefaultSettings() + { + $reader = new Csv(); + self::assertEquals('UTF-8', $reader->getInputEncoding()); + self::assertEquals('"', $reader->getEnclosure()); + $reader->setEnclosure('\''); + self::assertEquals('\'', $reader->getEnclosure()); + $reader->setEnclosure(''); + self::assertEquals('"', $reader->getEnclosure()); + } + + public function testReadEmptyFileName() + { + $this->expectException(ReaderException::class); + $reader = new Csv(); + $filename = ''; + $reader->load($filename); + } + + public function testReadNonexistentFileName() + { + $this->expectException(ReaderException::class); + $reader = new Csv(); + $reader->load('data/Reader/CSV/encoding.utf8.csvxxx'); + } } diff --git a/tests/PhpSpreadsheetTests/Writer/Csv/CsvWriteTest.php b/tests/PhpSpreadsheetTests/Writer/Csv/CsvWriteTest.php new file mode 100644 index 0000000000..f55781dad5 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Csv/CsvWriteTest.php @@ -0,0 +1,60 @@ +getActiveSheet(); + $sheet->setCellValue('A1', 'First Sheet'); + $sheet = $spreadsheet->createSheet(); + $sheet->setCellValue('A1', 'Second Sheet'); + $sheet = $spreadsheet->createSheet(); + $sheet->setCellValue('A1', 'Third Sheet'); + $writer = new CsvWriter($spreadsheet); + $writer->setSheetIndex(1); + self::assertEquals(1, $writer->getSheetIndex()); + $filename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); + $writer->save($filename); + $reader = new CsvReader(); + $newspreadsheet = $reader->load($filename); + unlink($filename); + $sheet = $newspreadsheet->getActiveSheet(); + self::assertEquals('Second Sheet', $sheet->getCell('A1')->getValue()); + self::assertEquals(0, $newspreadsheet->getActiveSheetIndex()); + } + + public function testWriteEmptyFileName() + { + $this->expectException(WriterException::class); + $spreadsheet = new Spreadsheet(); + $writer = new CsvWriter($spreadsheet); + $filename = ''; + $writer->save($filename); + } + + public function testDefaultSettings() + { + $spreadsheet = new Spreadsheet(); + $writer = new CsvWriter($spreadsheet); + self::assertEquals('"', $writer->getEnclosure()); + $writer->setEnclosure('\''); + self::assertEquals('\'', $writer->getEnclosure()); + $writer->setEnclosure(''); + self::assertEquals('"', $writer->getEnclosure()); + self::assertEquals(PHP_EOL, $writer->getLineEnding()); + self::assertFalse($writer->getUseBOM()); + self::assertFalse($writer->getIncludeSeparatorLine()); + self::assertFalse($writer->getExcelCompatibility()); + self::assertEquals(0, $writer->getSheetIndex()); + } +} diff --git a/tests/data/Reader/CSV/encoding.iso88591.csv b/tests/data/Reader/CSV/encoding.iso88591.csv new file mode 100644 index 0000000000..84ecfd91de --- /dev/null +++ b/tests/data/Reader/CSV/encoding.iso88591.csv @@ -0,0 +1,2 @@ +,1 +2,3 diff --git a/tests/data/Reader/CSV/encoding.utf16be.csv b/tests/data/Reader/CSV/encoding.utf16be.csv new file mode 100644 index 0000000000000000000000000000000000000000..8c9665ea01b13e99c5db4b27769138b2405fc7ab GIT binary patch literal 20 XcmZQL%Amtw$iU0M#b5+v8G~2=8M^`E literal 0 HcmV?d00001 diff --git a/tests/data/Reader/CSV/encoding.utf16le.csv b/tests/data/Reader/CSV/encoding.utf16le.csv new file mode 100644 index 0000000000000000000000000000000000000000..1299a8b9ae0a7fce544eeb57935b7c3081113483 GIT binary patch literal 20 WcmX@gpu=Fuz{|kJU<70tgINF@oB`qh literal 0 HcmV?d00001 diff --git a/tests/data/Reader/CSV/encoding.utf32be.csv b/tests/data/Reader/CSV/encoding.utf32be.csv new file mode 100644 index 0000000000000000000000000000000000000000..eaf28f699809360d614ebec0acfafd69c0cb4be8 GIT binary patch literal 40 hcmZQzU^vRaz@P)fhCs{<#9TmZ1jHaQV;}~L0RS{Xuyn0sB*ok!*n7KRm&Vyy1FE#{f z3UXF7v^+$6wyc>lVJFiO&CSFm7hl=ngD4Js()Q+~nv6 Date: Sun, 17 May 2020 18:35:55 +0900 Subject: [PATCH 036/659] Allow to run an entire folder of tests We now can do something like: ```sh ./vendor/bin/phpunit tests/PhpSpreadsheetTests/Reader/ ``` --- .../Calculation/CalculationTest.php | 4 +- .../Calculation/FinancialTest.php | 70 +++++++++---------- .../Calculation/FormulaAsStringTest.php | 2 +- .../Functions/DateTime/DateDifTest.php | 2 +- .../Functions/DateTime/DateTest.php | 2 +- .../Functions/DateTime/DateValueTest.php | 2 +- .../Functions/DateTime/DayTest.php | 2 +- .../Functions/DateTime/Days360Test.php | 2 +- .../Functions/DateTime/DaysTest.php | 2 +- .../Functions/DateTime/EDateTest.php | 2 +- .../Functions/DateTime/EoMonthTest.php | 2 +- .../Functions/DateTime/HourTest.php | 2 +- .../Functions/DateTime/IsoWeekNumTest.php | 2 +- .../Functions/DateTime/MinuteTest.php | 2 +- .../Functions/DateTime/MonthTest.php | 2 +- .../Functions/DateTime/NetworkDaysTest.php | 2 +- .../Functions/DateTime/SecondTest.php | 2 +- .../Functions/DateTime/TimeTest.php | 2 +- .../Functions/DateTime/TimeValueTest.php | 2 +- .../Functions/DateTime/WeekDayTest.php | 2 +- .../Functions/DateTime/WeekNumTest.php | 2 +- .../Functions/DateTime/WorkDayTest.php | 2 +- .../Functions/DateTime/YearFracTest.php | 2 +- .../Functions/DateTime/YearTest.php | 2 +- .../Functions/Engineering/BesselITest.php | 2 +- .../Functions/Engineering/BesselJTest.php | 2 +- .../Functions/Engineering/BesselKTest.php | 2 +- .../Functions/Engineering/BesselYTest.php | 2 +- .../Functions/Engineering/Bin2DecTest.php | 2 +- .../Functions/Engineering/Bin2HexTest.php | 2 +- .../Functions/Engineering/Bin2OctTest.php | 2 +- .../Functions/Engineering/BitAndTest.php | 2 +- .../Functions/Engineering/BitLShiftTest.php | 2 +- .../Functions/Engineering/BitOrTest.php | 2 +- .../Functions/Engineering/BitRShiftTest.php | 2 +- .../Functions/Engineering/BitXorTest.php | 2 +- .../Functions/Engineering/ComplexTest.php | 2 +- .../Functions/Engineering/ConvertUoMTest.php | 2 +- .../Functions/Engineering/Dec2BinTest.php | 2 +- .../Functions/Engineering/Dec2HexTest.php | 2 +- .../Functions/Engineering/Dec2OctTest.php | 2 +- .../Functions/Engineering/DeltaTest.php | 2 +- .../Functions/Engineering/ErfCTest.php | 2 +- .../Functions/Engineering/ErfPreciseTest.php | 2 +- .../Functions/Engineering/ErfTest.php | 2 +- .../Functions/Engineering/GeStepTest.php | 2 +- .../Functions/Engineering/Hex2BinTest.php | 2 +- .../Functions/Engineering/Hex2DecTest.php | 2 +- .../Functions/Engineering/Hex2OctTest.php | 2 +- .../Functions/Engineering/ImAbsTest.php | 2 +- .../Functions/Engineering/ImArgumentTest.php | 2 +- .../Functions/Engineering/ImConjugateTest.php | 2 +- .../Functions/Engineering/ImCosTest.php | 2 +- .../Functions/Engineering/ImCoshTest.php | 2 +- .../Functions/Engineering/ImCotTest.php | 2 +- .../Functions/Engineering/ImCscTest.php | 2 +- .../Functions/Engineering/ImCschTest.php | 2 +- .../Functions/Engineering/ImDivTest.php | 2 +- .../Functions/Engineering/ImExpTest.php | 2 +- .../Functions/Engineering/ImLnTest.php | 2 +- .../Functions/Engineering/ImLog10Test.php | 2 +- .../Functions/Engineering/ImLog2Test.php | 2 +- .../Functions/Engineering/ImPowerTest.php | 2 +- .../Functions/Engineering/ImProductTest.php | 2 +- .../Functions/Engineering/ImRealTest.php | 2 +- .../Functions/Engineering/ImSecTest.php | 2 +- .../Functions/Engineering/ImSechTest.php | 2 +- .../Functions/Engineering/ImSinTest.php | 2 +- .../Functions/Engineering/ImSinhTest.php | 2 +- .../Functions/Engineering/ImSqrtTest.php | 2 +- .../Functions/Engineering/ImSubTest.php | 2 +- .../Functions/Engineering/ImSumTest.php | 2 +- .../Functions/Engineering/ImTanTest.php | 2 +- .../Functions/Engineering/ImaginaryTest.php | 2 +- .../Functions/Engineering/Oct2BinTest.php | 2 +- .../Functions/Engineering/Oct2DecTest.php | 2 +- .../Functions/Engineering/Oct2HexTest.php | 2 +- .../Functions/Financial/AccrintMTest.php | 2 +- .../Functions/Financial/AccrintTest.php | 2 +- .../Calculation/Functions/Logical/AndTest.php | 2 +- .../Functions/Logical/IfErrorTest.php | 2 +- .../Functions/Logical/IfNaTest.php | 2 +- .../Calculation/Functions/Logical/IfTest.php | 2 +- .../Calculation/Functions/Logical/NotTest.php | 2 +- .../Calculation/Functions/Logical/OrTest.php | 2 +- .../Functions/Logical/SwitchTest.php | 2 +- .../Calculation/Functions/Logical/XorTest.php | 2 +- .../Functions/LookupRef/ChooseTest.php | 2 +- .../Functions/LookupRef/ColumnsTest.php | 2 +- .../Functions/LookupRef/HLookupTest.php | 2 +- .../Functions/LookupRef/IndexTest.php | 2 +- .../Functions/LookupRef/LookupTest.php | 2 +- .../Functions/LookupRef/MatchTest.php | 2 +- .../Functions/LookupRef/RowsTest.php | 2 +- .../Functions/LookupRef/VLookupTest.php | 2 +- .../Functions/MathTrig/AcotTest.php | 2 +- .../Functions/MathTrig/AcothTest.php | 2 +- .../Functions/MathTrig/ArabicTest.php | 2 +- .../Functions/MathTrig/Atan2Test.php | 2 +- .../Functions/MathTrig/BaseTest.php | 2 +- .../Functions/MathTrig/CeilingTest.php | 2 +- .../Functions/MathTrig/CombinTest.php | 2 +- .../Functions/MathTrig/CotTest.php | 2 +- .../Functions/MathTrig/CothTest.php | 2 +- .../Functions/MathTrig/CscTest.php | 2 +- .../Functions/MathTrig/CschTest.php | 2 +- .../Functions/MathTrig/EvenTest.php | 2 +- .../Functions/MathTrig/FactDoubleTest.php | 2 +- .../Functions/MathTrig/FactTest.php | 2 +- .../Functions/MathTrig/FloorMathTest.php | 2 +- .../Functions/MathTrig/FloorPreciseTest.php | 2 +- .../Functions/MathTrig/FloorTest.php | 2 +- .../Functions/MathTrig/GcdTest.php | 2 +- .../Functions/MathTrig/IntTest.php | 2 +- .../Functions/MathTrig/LcmTest.php | 2 +- .../Functions/MathTrig/LogTest.php | 2 +- .../Functions/MathTrig/MInverseTest.php | 2 +- .../Functions/MathTrig/MMultTest.php | 2 +- .../Functions/MathTrig/MRoundTest.php | 2 +- .../Functions/MathTrig/MdeTermTest.php | 2 +- .../Functions/MathTrig/ModTest.php | 2 +- .../Functions/MathTrig/MultinomialTest.php | 2 +- .../Functions/MathTrig/OddTest.php | 2 +- .../Functions/MathTrig/PowerTest.php | 2 +- .../Functions/MathTrig/ProductTest.php | 2 +- .../Functions/MathTrig/QuotientTest.php | 2 +- .../Functions/MathTrig/RomanTest.php | 2 +- .../Functions/MathTrig/RoundDownTest.php | 2 +- .../Functions/MathTrig/RoundUpTest.php | 2 +- .../Functions/MathTrig/SecTest.php | 2 +- .../Functions/MathTrig/SechTest.php | 2 +- .../Functions/MathTrig/SeriesSumTest.php | 2 +- .../Functions/MathTrig/SignTest.php | 2 +- .../Functions/MathTrig/SqrtPiTest.php | 2 +- .../Functions/MathTrig/SubTotalTest.php | 6 +- .../Functions/MathTrig/SumIfTest.php | 2 +- .../Functions/MathTrig/SumIfsTest.php | 2 +- .../Functions/MathTrig/SumProductTest.php | 2 +- .../Functions/MathTrig/SumSqTest.php | 2 +- .../Functions/MathTrig/SumX2MY2Test.php | 2 +- .../Functions/MathTrig/SumX2PY2Test.php | 2 +- .../Functions/MathTrig/SumXMY2Test.php | 2 +- .../Functions/MathTrig/TruncTest.php | 2 +- .../Functions/Statistical/AveDevTest.php | 2 +- .../Functions/Statistical/AverageATest.php | 2 +- .../Functions/Statistical/AverageIfTest.php | 2 +- .../Functions/Statistical/AverageTest.php | 2 +- .../Functions/Statistical/BetaDistTest.php | 2 +- .../Functions/Statistical/BetaInvTest.php | 2 +- .../Functions/Statistical/BinomDistTest.php | 2 +- .../Functions/Statistical/ChiDistTest.php | 2 +- .../Functions/Statistical/ChiInvTest.php | 2 +- .../Functions/Statistical/ConfidenceTest.php | 2 +- .../Functions/Statistical/CorrelTest.php | 2 +- .../Functions/Statistical/CountATest.php | 2 +- .../Functions/Statistical/CountBlankTest.php | 2 +- .../Functions/Statistical/CountIfTest.php | 2 +- .../Functions/Statistical/CountIfsTest.php | 2 +- .../Functions/Statistical/CountTest.php | 8 +-- .../Functions/Statistical/CovarTest.php | 2 +- .../Functions/Statistical/ExponDistTest.php | 2 +- .../Functions/Statistical/FisherInvTest.php | 2 +- .../Functions/Statistical/FisherTest.php | 2 +- .../Functions/Statistical/ForecastTest.php | 2 +- .../Functions/Statistical/GammaDistTest.php | 2 +- .../Functions/Statistical/GammaInvTest.php | 2 +- .../Functions/Statistical/GammaLnTest.php | 2 +- .../Functions/Statistical/GeoMeanTest.php | 2 +- .../Functions/Statistical/HarMeanTest.php | 2 +- .../Functions/Statistical/InterceptTest.php | 2 +- .../Functions/Statistical/MaxIfsTest.php | 2 +- .../Functions/Statistical/MedianTest.php | 2 +- .../Functions/Statistical/MinIfsTest.php | 2 +- .../Functions/Statistical/PermutTest.php | 2 +- .../Functions/Statistical/RsqTest.php | 2 +- .../Functions/Statistical/SlopeTest.php | 2 +- .../Functions/Statistical/SteyxTest.php | 2 +- .../Functions/TextData/CharTest.php | 2 +- .../Functions/TextData/CleanTest.php | 2 +- .../Functions/TextData/CodeTest.php | 2 +- .../Functions/TextData/ConcatenateTest.php | 2 +- .../Functions/TextData/DollarTest.php | 2 +- .../Functions/TextData/ExactTest.php | 2 +- .../Functions/TextData/FindTest.php | 2 +- .../Functions/TextData/FixedTest.php | 2 +- .../Functions/TextData/LeftTest.php | 2 +- .../Functions/TextData/LenTest.php | 2 +- .../Functions/TextData/LowerTest.php | 2 +- .../Functions/TextData/MidTest.php | 2 +- .../Functions/TextData/NumberValueTest.php | 2 +- .../Functions/TextData/ProperTest.php | 2 +- .../Functions/TextData/ReplaceTest.php | 2 +- .../Functions/TextData/RightTest.php | 2 +- .../Functions/TextData/SearchTest.php | 2 +- .../Functions/TextData/SubstituteTest.php | 2 +- .../Calculation/Functions/TextData/TTest.php | 2 +- .../Functions/TextData/TextJoinTest.php | 2 +- .../Functions/TextData/TextTest.php | 2 +- .../Functions/TextData/TrimTest.php | 2 +- .../Functions/TextData/UpperTest.php | 2 +- .../Functions/TextData/ValueTest.php | 2 +- .../Calculation/FunctionsTest.php | 30 ++++---- .../Calculation/LookupRefTest.php | 2 +- tests/PhpSpreadsheetTests/Cell/CellTest.php | 4 +- .../Cell/CoordinateTest.php | 26 +++---- .../Cell/DefaultValueBinderTest.php | 2 +- .../TypeAttributePreservationTest.php | 2 +- .../PhpSpreadsheetTests/Helper/SampleTest.php | 2 +- tests/PhpSpreadsheetTests/IOFactoryTest.php | 14 ++-- .../Reader/CondNumFmtTest.php | 2 +- .../Reader/CsvContiguousTest.php | 2 +- tests/PhpSpreadsheetTests/Reader/CsvTest.php | 60 ++++++++-------- tests/PhpSpreadsheetTests/Reader/HtmlTest.php | 4 +- tests/PhpSpreadsheetTests/Reader/OdsTest.php | 8 +-- .../Reader/Security/XmlScannerTest.php | 8 +-- tests/PhpSpreadsheetTests/Reader/XlsTest.php | 2 +- .../PhpSpreadsheetTests/Reader/Xlsx2Test.php | 4 +- tests/PhpSpreadsheetTests/Reader/XlsxTest.php | 22 +++--- tests/PhpSpreadsheetTests/Reader/XmlTest.php | 6 +- .../Shared/CodePageTest.php | 2 +- tests/PhpSpreadsheetTests/Shared/DateTest.php | 16 ++--- tests/PhpSpreadsheetTests/Shared/FontTest.php | 6 +- .../Shared/OLEReadTest.php | 4 +- .../Shared/PasswordHasherTest.php | 2 +- tests/PhpSpreadsheetTests/Style/ColorTest.php | 8 +-- .../Style/NumberFormatTest.php | 4 +- .../Writer/Ods/ContentTest.php | 2 +- .../Writer/Xlsx/UnparsedDataTest.php | 2 +- tests/bootstrap.php | 5 -- 229 files changed, 364 insertions(+), 369 deletions(-) diff --git a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php index f74d29ef26..b424236443 100644 --- a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php @@ -40,7 +40,7 @@ public function testBinaryComparisonOperation($formula, $expectedResultExcel, $e public function providerBinaryComparisonOperation() { - return require 'data/CalculationBinaryComparisonOperation.php'; + return require 'tests/data/CalculationBinaryComparisonOperation.php'; } /** @@ -351,6 +351,6 @@ public function testFullExecution( public function dataProviderBranchPruningFullExecution() { - return require 'data/Calculation/Calculation.php'; + return require 'tests/data/Calculation/Calculation.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php index 27eb3d61b5..e9a62af37c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php @@ -26,7 +26,7 @@ public function testAMORDEGRC($expectedResult, ...$args) public function providerAMORDEGRC() { - return require 'data/Calculation/Financial/AMORDEGRC.php'; + return require 'tests/data/Calculation/Financial/AMORDEGRC.php'; } /** @@ -42,7 +42,7 @@ public function testAMORLINC($expectedResult, ...$args) public function providerAMORLINC() { - return require 'data/Calculation/Financial/AMORLINC.php'; + return require 'tests/data/Calculation/Financial/AMORLINC.php'; } /** @@ -58,7 +58,7 @@ public function testCOUPDAYBS($expectedResult, ...$args) public function providerCOUPDAYBS() { - return require 'data/Calculation/Financial/COUPDAYBS.php'; + return require 'tests/data/Calculation/Financial/COUPDAYBS.php'; } /** @@ -74,7 +74,7 @@ public function testCOUPDAYS($expectedResult, ...$args) public function providerCOUPDAYS() { - return require 'data/Calculation/Financial/COUPDAYS.php'; + return require 'tests/data/Calculation/Financial/COUPDAYS.php'; } /** @@ -90,7 +90,7 @@ public function testCOUPDAYSNC($expectedResult, ...$args) public function providerCOUPDAYSNC() { - return require 'data/Calculation/Financial/COUPDAYSNC.php'; + return require 'tests/data/Calculation/Financial/COUPDAYSNC.php'; } /** @@ -106,7 +106,7 @@ public function testCOUPNCD($expectedResult, ...$args) public function providerCOUPNCD() { - return require 'data/Calculation/Financial/COUPNCD.php'; + return require 'tests/data/Calculation/Financial/COUPNCD.php'; } /** @@ -122,7 +122,7 @@ public function testCOUPNUM($expectedResult, ...$args) public function providerCOUPNUM() { - return require 'data/Calculation/Financial/COUPNUM.php'; + return require 'tests/data/Calculation/Financial/COUPNUM.php'; } /** @@ -138,7 +138,7 @@ public function testCOUPPCD($expectedResult, ...$args) public function providerCOUPPCD() { - return require 'data/Calculation/Financial/COUPPCD.php'; + return require 'tests/data/Calculation/Financial/COUPPCD.php'; } /** @@ -154,7 +154,7 @@ public function testCUMIPMT($expectedResult, ...$args) public function providerCUMIPMT() { - return require 'data/Calculation/Financial/CUMIPMT.php'; + return require 'tests/data/Calculation/Financial/CUMIPMT.php'; } /** @@ -170,7 +170,7 @@ public function testCUMPRINC($expectedResult, ...$args) public function providerCUMPRINC() { - return require 'data/Calculation/Financial/CUMPRINC.php'; + return require 'tests/data/Calculation/Financial/CUMPRINC.php'; } /** @@ -186,7 +186,7 @@ public function testDB($expectedResult, ...$args) public function providerDB() { - return require 'data/Calculation/Financial/DB.php'; + return require 'tests/data/Calculation/Financial/DB.php'; } /** @@ -202,7 +202,7 @@ public function testDDB($expectedResult, ...$args) public function providerDDB() { - return require 'data/Calculation/Financial/DDB.php'; + return require 'tests/data/Calculation/Financial/DDB.php'; } /** @@ -218,7 +218,7 @@ public function testDISC($expectedResult, ...$args) public function providerDISC() { - return require 'data/Calculation/Financial/DISC.php'; + return require 'tests/data/Calculation/Financial/DISC.php'; } /** @@ -234,7 +234,7 @@ public function testDOLLARDE($expectedResult, ...$args) public function providerDOLLARDE() { - return require 'data/Calculation/Financial/DOLLARDE.php'; + return require 'tests/data/Calculation/Financial/DOLLARDE.php'; } /** @@ -250,7 +250,7 @@ public function testDOLLARFR($expectedResult, ...$args) public function providerDOLLARFR() { - return require 'data/Calculation/Financial/DOLLARFR.php'; + return require 'tests/data/Calculation/Financial/DOLLARFR.php'; } /** @@ -266,7 +266,7 @@ public function testEFFECT($expectedResult, ...$args) public function providerEFFECT() { - return require 'data/Calculation/Financial/EFFECT.php'; + return require 'tests/data/Calculation/Financial/EFFECT.php'; } /** @@ -282,7 +282,7 @@ public function testFV($expectedResult, ...$args) public function providerFV() { - return require 'data/Calculation/Financial/FV.php'; + return require 'tests/data/Calculation/Financial/FV.php'; } /** @@ -298,7 +298,7 @@ public function testFVSCHEDULE($expectedResult, ...$args) public function providerFVSCHEDULE() { - return require 'data/Calculation/Financial/FVSCHEDULE.php'; + return require 'tests/data/Calculation/Financial/FVSCHEDULE.php'; } /** @@ -314,7 +314,7 @@ public function testINTRATE($expectedResult, ...$args) public function providerINTRATE() { - return require 'data/Calculation/Financial/INTRATE.php'; + return require 'tests/data/Calculation/Financial/INTRATE.php'; } /** @@ -330,7 +330,7 @@ public function testIPMT($expectedResult, ...$args) public function providerIPMT() { - return require 'data/Calculation/Financial/IPMT.php'; + return require 'tests/data/Calculation/Financial/IPMT.php'; } /** @@ -346,7 +346,7 @@ public function testIRR($expectedResult, ...$args) public function providerIRR() { - return require 'data/Calculation/Financial/IRR.php'; + return require 'tests/data/Calculation/Financial/IRR.php'; } /** @@ -362,7 +362,7 @@ public function testISPMT($expectedResult, ...$args) public function providerISPMT() { - return require 'data/Calculation/Financial/ISPMT.php'; + return require 'tests/data/Calculation/Financial/ISPMT.php'; } /** @@ -378,7 +378,7 @@ public function testMIRR($expectedResult, ...$args) public function providerMIRR() { - return require 'data/Calculation/Financial/MIRR.php'; + return require 'tests/data/Calculation/Financial/MIRR.php'; } /** @@ -394,7 +394,7 @@ public function testNOMINAL($expectedResult, ...$args) public function providerNOMINAL() { - return require 'data/Calculation/Financial/NOMINAL.php'; + return require 'tests/data/Calculation/Financial/NOMINAL.php'; } /** @@ -410,7 +410,7 @@ public function testNPER($expectedResult, ...$args) public function providerNPER() { - return require 'data/Calculation/Financial/NPER.php'; + return require 'tests/data/Calculation/Financial/NPER.php'; } /** @@ -426,7 +426,7 @@ public function testNPV($expectedResult, ...$args) public function providerNPV() { - return require 'data/Calculation/Financial/NPV.php'; + return require 'tests/data/Calculation/Financial/NPV.php'; } /** @@ -444,7 +444,7 @@ public function testPRICE($expectedResult, ...$args) public function providerPRICE() { - return require 'data/Calculation/Financial/PRICE.php'; + return require 'tests/data/Calculation/Financial/PRICE.php'; } /** @@ -460,7 +460,7 @@ public function testPRICEDISC($expectedResult, array $args) public function providerPRICEDISC() { - return require 'data/Calculation/Financial/PRICEDISC.php'; + return require 'tests/data/Calculation/Financial/PRICEDISC.php'; } /** @@ -476,7 +476,7 @@ public function testPV($expectedResult, array $args) public function providerPV() { - return require 'data/Calculation/Financial/PV.php'; + return require 'tests/data/Calculation/Financial/PV.php'; } /** @@ -494,7 +494,7 @@ public function testRATE($expectedResult, ...$args) public function providerRATE() { - return require 'data/Calculation/Financial/RATE.php'; + return require 'tests/data/Calculation/Financial/RATE.php'; } /** @@ -511,7 +511,7 @@ public function testXIRR($expectedResult, $message, ...$args) public function providerXIRR() { - return require 'data/Calculation/Financial/XIRR.php'; + return require 'tests/data/Calculation/Financial/XIRR.php'; } /** @@ -527,7 +527,7 @@ public function testPDURATION($expectedResult, array $args) public function providerPDURATION() { - return require 'data/Calculation/Financial/PDURATION.php'; + return require 'tests/data/Calculation/Financial/PDURATION.php'; } /** @@ -543,7 +543,7 @@ public function testRRI($expectedResult, array $args) public function providerRRI() { - return require 'data/Calculation/Financial/RRI.php'; + return require 'tests/data/Calculation/Financial/RRI.php'; } /** @@ -559,7 +559,7 @@ public function testSLN($expectedResult, array $args) public function providerSLN() { - return require 'data/Calculation/Financial/SLN.php'; + return require 'tests/data/Calculation/Financial/SLN.php'; } /** @@ -575,6 +575,6 @@ public function testSYD($expectedResult, array $args) public function providerSYD() { - return require 'data/Calculation/Financial/SYD.php'; + return require 'tests/data/Calculation/Financial/SYD.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/FormulaAsStringTest.php b/tests/PhpSpreadsheetTests/Calculation/FormulaAsStringTest.php index c51e520a95..abf7589a08 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FormulaAsStringTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FormulaAsStringTest.php @@ -41,6 +41,6 @@ public function testFunctionsAsString($expectedResult, $formula) public function providerFunctionsAsString() { - return require 'data/Calculation/FunctionsAsString.php'; + return require 'tests/data/Calculation/FunctionsAsString.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php index adbc52218c..35fbe05bc5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php @@ -32,6 +32,6 @@ public function testDATEDIF($expectedResult, $startDate, $endDate, $unit) public function providerDATEDIF() { - return require 'data/Calculation/DateTime/DATEDIF.php'; + return require 'tests/data/Calculation/DateTime/DATEDIF.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php index ef3d60eeb4..c354f851b2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php @@ -32,7 +32,7 @@ public function testDATE($expectedResult, $year, $month, $day) public function providerDATE() { - return require 'data/Calculation/DateTime/DATE.php'; + return require 'tests/data/Calculation/DateTime/DATE.php'; } public function testDATEtoUnixTimestamp() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php index 3c5d7a56a8..205418015c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php @@ -31,7 +31,7 @@ public function testDATEVALUE($expectedResult, $dateValue) public function providerDATEVALUE() { - return require 'data/Calculation/DateTime/DATEVALUE.php'; + return require 'tests/data/Calculation/DateTime/DATEVALUE.php'; } public function testDATEVALUEtoUnixTimestamp() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php index 1b2bf43034..77c2993924 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php @@ -36,6 +36,6 @@ public function testDAY($expectedResultExcel, $expectedResultOpenOffice, $dateTi public function providerDAY() { - return require 'data/Calculation/DateTime/DAY.php'; + return require 'tests/data/Calculation/DateTime/DAY.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php index aa1da8236b..40e86f311c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php @@ -32,6 +32,6 @@ public function testDAYS360($expectedResult, $startDate, $endDate, $method) public function providerDAYS360() { - return require 'data/Calculation/DateTime/DAYS360.php'; + return require 'tests/data/Calculation/DateTime/DAYS360.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php index 0d805245d2..3c04395064 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php @@ -31,6 +31,6 @@ public function testDAYS($expectedResult, $endDate, $startDate) public function providerDAYS() { - return require 'data/Calculation/DateTime/DAYS.php'; + return require 'tests/data/Calculation/DateTime/DAYS.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php index fbd4dee476..f931543e7e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php @@ -31,7 +31,7 @@ public function testEDATE($expectedResult, $dateValue, $adjustmentMonths) public function providerEDATE() { - return require 'data/Calculation/DateTime/EDATE.php'; + return require 'tests/data/Calculation/DateTime/EDATE.php'; } public function testEDATEtoUnixTimestamp() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php index deb679929a..7c8352fe84 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php @@ -31,7 +31,7 @@ public function testEOMONTH($expectedResult, $dateValue, $adjustmentMonths) public function providerEOMONTH() { - return require 'data/Calculation/DateTime/EOMONTH.php'; + return require 'tests/data/Calculation/DateTime/EOMONTH.php'; } public function testEOMONTHtoUnixTimestamp() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php index dc6931010c..5110f93c8c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php @@ -30,6 +30,6 @@ public function testHOUR($expectedResult, $dateTimeValue) public function providerHOUR() { - return require 'data/Calculation/DateTime/HOUR.php'; + return require 'tests/data/Calculation/DateTime/HOUR.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php index 61a8427a10..608a1bf859 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php @@ -30,6 +30,6 @@ public function testISOWEEKNUM($expectedResult, $dateValue) public function providerISOWEEKNUM() { - return require 'data/Calculation/DateTime/ISOWEEKNUM.php'; + return require 'tests/data/Calculation/DateTime/ISOWEEKNUM.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php index 986ce48049..36e248be53 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php @@ -30,6 +30,6 @@ public function testMINUTE($expectedResult, $dateTimeValue) public function providerMINUTE() { - return require 'data/Calculation/DateTime/MINUTE.php'; + return require 'tests/data/Calculation/DateTime/MINUTE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php index d0060af19c..8f938c8341 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php @@ -30,6 +30,6 @@ public function testMONTH($expectedResult, $dateTimeValue) public function providerMONTH() { - return require 'data/Calculation/DateTime/MONTH.php'; + return require 'tests/data/Calculation/DateTime/MONTH.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php index f4340d9cda..4fa86be8fc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php @@ -29,6 +29,6 @@ public function testNETWORKDAYS($expectedResult, ...$args) public function providerNETWORKDAYS() { - return require 'data/Calculation/DateTime/NETWORKDAYS.php'; + return require 'tests/data/Calculation/DateTime/NETWORKDAYS.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php index aa1dba7ea6..e1032b9465 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php @@ -30,6 +30,6 @@ public function testSECOND($expectedResult, $dateTimeValue) public function providerSECOND() { - return require 'data/Calculation/DateTime/SECOND.php'; + return require 'tests/data/Calculation/DateTime/SECOND.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php index 3be2678672..1cd0c89b0a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php @@ -29,7 +29,7 @@ public function testTIME($expectedResult, ...$args) public function providerTIME() { - return require 'data/Calculation/DateTime/TIME.php'; + return require 'tests/data/Calculation/DateTime/TIME.php'; } public function testTIMEtoUnixTimestamp() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php index 263e665e56..ed025cff99 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php @@ -30,7 +30,7 @@ public function testTIMEVALUE($expectedResult, $timeValue) public function providerTIMEVALUE() { - return require 'data/Calculation/DateTime/TIMEVALUE.php'; + return require 'tests/data/Calculation/DateTime/TIMEVALUE.php'; } public function testTIMEVALUEtoUnixTimestamp() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php index 72c8ac232a..fe81c1a4a7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php @@ -29,6 +29,6 @@ public function testWEEKDAY($expectedResult, ...$args) public function providerWEEKDAY() { - return require 'data/Calculation/DateTime/WEEKDAY.php'; + return require 'tests/data/Calculation/DateTime/WEEKDAY.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php index a7c3260dad..96c2077ba3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php @@ -29,6 +29,6 @@ public function testWEEKNUM($expectedResult, ...$args) public function providerWEEKNUM() { - return require 'data/Calculation/DateTime/WEEKNUM.php'; + return require 'tests/data/Calculation/DateTime/WEEKNUM.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php index 2edc8609cc..bc6fd6cc42 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php @@ -29,6 +29,6 @@ public function testWORKDAY($expectedResult, ...$args) public function providerWORKDAY() { - return require 'data/Calculation/DateTime/WORKDAY.php'; + return require 'tests/data/Calculation/DateTime/WORKDAY.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php index 2d87c53263..37364030c7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php @@ -29,6 +29,6 @@ public function testYEARFRAC($expectedResult, ...$args) public function providerYEARFRAC() { - return require 'data/Calculation/DateTime/YEARFRAC.php'; + return require 'tests/data/Calculation/DateTime/YEARFRAC.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php index 3545140f19..26e416ec2f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php @@ -30,6 +30,6 @@ public function testYEAR($expectedResult, $dateTimeValue) public function providerYEAR() { - return require 'data/Calculation/DateTime/YEAR.php'; + return require 'tests/data/Calculation/DateTime/YEAR.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php index e6fa29245c..d7b23909ea 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php @@ -28,6 +28,6 @@ public function testBESSELI($expectedResult, ...$args) public function providerBESSELI() { - return require 'data/Calculation/Engineering/BESSELI.php'; + return require 'tests/data/Calculation/Engineering/BESSELI.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php index 1458ece94a..5e4d2f3bcf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php @@ -28,6 +28,6 @@ public function testBESSELJ($expectedResult, ...$args) public function providerBESSEJ() { - return require 'data/Calculation/Engineering/BESSELJ.php'; + return require 'tests/data/Calculation/Engineering/BESSELJ.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php index f2ab0529be..6a048f3743 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php @@ -28,6 +28,6 @@ public function testBESSELK($expectedResult, ...$args) public function providerBESSELK() { - return require 'data/Calculation/Engineering/BESSELK.php'; + return require 'tests/data/Calculation/Engineering/BESSELK.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php index 66af44c94d..98c238e2ef 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php @@ -28,6 +28,6 @@ public function testBESSELY($expectedResult, ...$args) public function providerBESSELY() { - return require 'data/Calculation/Engineering/BESSELY.php'; + return require 'tests/data/Calculation/Engineering/BESSELY.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php index 61fe3423b2..341493ea10 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php @@ -26,6 +26,6 @@ public function testBIN2DEC($expectedResult, ...$args) public function providerBIN2DEC() { - return require 'data/Calculation/Engineering/BIN2DEC.php'; + return require 'tests/data/Calculation/Engineering/BIN2DEC.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php index 77e9722d4b..63945fd151 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php @@ -26,6 +26,6 @@ public function testBIN2HEX($expectedResult, ...$args) public function providerBIN2HEX() { - return require 'data/Calculation/Engineering/BIN2HEX.php'; + return require 'tests/data/Calculation/Engineering/BIN2HEX.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php index a8f7095ee7..2aeeb1bca7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php @@ -26,6 +26,6 @@ public function testBIN2OCT($expectedResult, ...$args) public function providerBIN2OCT() { - return require 'data/Calculation/Engineering/BIN2OCT.php'; + return require 'tests/data/Calculation/Engineering/BIN2OCT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php index e60aa79b07..483bf09968 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php @@ -27,6 +27,6 @@ public function testBITAND($expectedResult, array $args) public function providerBITAND() { - return require 'data/Calculation/Engineering/BITAND.php'; + return require 'tests/data/Calculation/Engineering/BITAND.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php index 47703c51bf..bf280f1628 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php @@ -27,6 +27,6 @@ public function testBITLSHIFT($expectedResult, array $args) public function providerBITLSHIFT() { - return require 'data/Calculation/Engineering/BITLSHIFT.php'; + return require 'tests/data/Calculation/Engineering/BITLSHIFT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php index 19a5a6b1ee..6e45543172 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php @@ -27,6 +27,6 @@ public function testBITOR($expectedResult, array $args) public function providerBITOR() { - return require 'data/Calculation/Engineering/BITOR.php'; + return require 'tests/data/Calculation/Engineering/BITOR.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php index 597fa33388..26bece5345 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php @@ -27,6 +27,6 @@ public function testBITRSHIFT($expectedResult, array $args) public function providerBITRSHIFT() { - return require 'data/Calculation/Engineering/BITRSHIFT.php'; + return require 'tests/data/Calculation/Engineering/BITRSHIFT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php index fc3df89378..51401f636a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php @@ -27,6 +27,6 @@ public function testBITXOR($expectedResult, array $args) public function providerBITXOR() { - return require 'data/Calculation/Engineering/BITXOR.php'; + return require 'tests/data/Calculation/Engineering/BITXOR.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php index dbdd825796..5bb7fbcd3e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php @@ -26,6 +26,6 @@ public function testCOMPLEX($expectedResult, ...$args) public function providerCOMPLEX() { - return require 'data/Calculation/Engineering/COMPLEX.php'; + return require 'tests/data/Calculation/Engineering/COMPLEX.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php index 593bfc65b0..3d6a077785 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php @@ -50,6 +50,6 @@ public function testCONVERTUOM($expectedResult, ...$args) public function providerCONVERTUOM() { - return require 'data/Calculation/Engineering/CONVERTUOM.php'; + return require 'tests/data/Calculation/Engineering/CONVERTUOM.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php index f5c8f089f1..740fe3c979 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php @@ -26,6 +26,6 @@ public function testDEC2BIN($expectedResult, ...$args) public function providerDEC2BIN() { - return require 'data/Calculation/Engineering/DEC2BIN.php'; + return require 'tests/data/Calculation/Engineering/DEC2BIN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php index 2bdeff25fa..c7aae44135 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php @@ -26,6 +26,6 @@ public function testDEC2HEX($expectedResult, ...$args) public function providerDEC2HEX() { - return require 'data/Calculation/Engineering/DEC2HEX.php'; + return require 'tests/data/Calculation/Engineering/DEC2HEX.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php index 93fa46c7d9..68456d1a26 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php @@ -26,6 +26,6 @@ public function testDEC2OCT($expectedResult, ...$args) public function providerDEC2OCT() { - return require 'data/Calculation/Engineering/DEC2OCT.php'; + return require 'tests/data/Calculation/Engineering/DEC2OCT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php index 241530ac91..fc2df95b71 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php @@ -26,6 +26,6 @@ public function testDELTA($expectedResult, ...$args) public function providerDELTA() { - return require 'data/Calculation/Engineering/DELTA.php'; + return require 'tests/data/Calculation/Engineering/DELTA.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php index 7dbb415869..5409db5f53 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php @@ -29,6 +29,6 @@ public function testERFC($expectedResult, ...$args) public function providerERFC() { - return require 'data/Calculation/Engineering/ERFC.php'; + return require 'tests/data/Calculation/Engineering/ERFC.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php index f42ebde116..857e41c13a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php @@ -29,6 +29,6 @@ public function testERFPRECISE($expectedResult, ...$args) public function providerERFPRECISE() { - return require 'data/Calculation/Engineering/ERFPRECISE.php'; + return require 'tests/data/Calculation/Engineering/ERFPRECISE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php index fbc004fad3..d148501bc8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php @@ -29,6 +29,6 @@ public function testERF($expectedResult, ...$args) public function providerERF() { - return require 'data/Calculation/Engineering/ERF.php'; + return require 'tests/data/Calculation/Engineering/ERF.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php index b96dbcec04..24ba1a0f43 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php @@ -26,6 +26,6 @@ public function testGESTEP($expectedResult, ...$args) public function providerGESTEP() { - return require 'data/Calculation/Engineering/GESTEP.php'; + return require 'tests/data/Calculation/Engineering/GESTEP.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php index 4e779fbace..83fcb1e7a9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php @@ -26,6 +26,6 @@ public function testHEX2BIN($expectedResult, ...$args) public function providerHEX2BIN() { - return require 'data/Calculation/Engineering/HEX2BIN.php'; + return require 'tests/data/Calculation/Engineering/HEX2BIN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php index acefad656a..5765494e20 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php @@ -26,6 +26,6 @@ public function testHEX2DEC($expectedResult, ...$args) public function providerHEX2DEC() { - return require 'data/Calculation/Engineering/HEX2DEC.php'; + return require 'tests/data/Calculation/Engineering/HEX2DEC.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php index 2db814d68f..25ba63005d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php @@ -26,6 +26,6 @@ public function testHEX2OCT($expectedResult, ...$args) public function providerHEX2OCT() { - return require 'data/Calculation/Engineering/HEX2OCT.php'; + return require 'tests/data/Calculation/Engineering/HEX2OCT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php index fb68d58073..c812fdfa15 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php @@ -29,6 +29,6 @@ public function testIMABS($expectedResult, $value) public function providerIMABS() { - return require 'data/Calculation/Engineering/IMABS.php'; + return require 'tests/data/Calculation/Engineering/IMABS.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php index ffc051ef2d..60883e1499 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php @@ -29,6 +29,6 @@ public function testIMARGUMENT($expectedResult, $value) public function providerIMARGUMENT() { - return require 'data/Calculation/Engineering/IMARGUMENT.php'; + return require 'tests/data/Calculation/Engineering/IMARGUMENT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php index d431429a3e..81323a53a8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php @@ -44,6 +44,6 @@ public function testIMCONJUGATE($expectedResult, $value) public function providerIMCONJUGATE() { - return require 'data/Calculation/Engineering/IMCONJUGATE.php'; + return require 'tests/data/Calculation/Engineering/IMCONJUGATE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php index 1e7a0ac008..c1c610fba5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php @@ -44,6 +44,6 @@ public function testIMCOS($expectedResult, $value) public function providerIMCOS() { - return require 'data/Calculation/Engineering/IMCOS.php'; + return require 'tests/data/Calculation/Engineering/IMCOS.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php index ada76b6250..7dacb7cd01 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php @@ -44,6 +44,6 @@ public function testIMCOSH($expectedResult, $value) public function providerIMCOSH() { - return require 'data/Calculation/Engineering/IMCOSH.php'; + return require 'tests/data/Calculation/Engineering/IMCOSH.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php index 91089820a9..512d96f9a9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php @@ -44,6 +44,6 @@ public function testIMCOT($expectedResult, $value) public function providerIMCOT() { - return require 'data/Calculation/Engineering/IMCOT.php'; + return require 'tests/data/Calculation/Engineering/IMCOT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php index 151216db47..5fb3f49d99 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php @@ -44,6 +44,6 @@ public function testIMCSC($expectedResult, $value) public function providerIMCSC() { - return require 'data/Calculation/Engineering/IMCSC.php'; + return require 'tests/data/Calculation/Engineering/IMCSC.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php index 5ce9d6bc5f..9b1934bbe7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php @@ -44,6 +44,6 @@ public function testIMCSCH($expectedResult, $value) public function providerIMCSCH() { - return require 'data/Calculation/Engineering/IMCSCH.php'; + return require 'tests/data/Calculation/Engineering/IMCSCH.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php index ee75c99670..7809ab0600 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php @@ -43,6 +43,6 @@ public function testIMDIV($expectedResult, ...$args) public function providerIMDIV() { - return require 'data/Calculation/Engineering/IMDIV.php'; + return require 'tests/data/Calculation/Engineering/IMDIV.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php index 8d38fe5722..3af044d772 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php @@ -44,6 +44,6 @@ public function testIMEXP($expectedResult, $value) public function providerIMEXP() { - return require 'data/Calculation/Engineering/IMEXP.php'; + return require 'tests/data/Calculation/Engineering/IMEXP.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php index 54bf5db00d..bb09860aea 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php @@ -44,6 +44,6 @@ public function testIMLN($expectedResult, $value) public function providerIMLN() { - return require 'data/Calculation/Engineering/IMLN.php'; + return require 'tests/data/Calculation/Engineering/IMLN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php index 69930da5a0..4831387dbc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php @@ -44,6 +44,6 @@ public function testIMLOG10($expectedResult, $value) public function providerIMLOG10() { - return require 'data/Calculation/Engineering/IMLOG10.php'; + return require 'tests/data/Calculation/Engineering/IMLOG10.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php index aee9f4427e..b6f25123bf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php @@ -44,6 +44,6 @@ public function testIMLOG2($expectedResult, $value) public function providerIMLOG2() { - return require 'data/Calculation/Engineering/IMLOG2.php'; + return require 'tests/data/Calculation/Engineering/IMLOG2.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php index 6321143986..c198ffb928 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php @@ -43,6 +43,6 @@ public function testIMPOWER($expectedResult, ...$args) public function providerIMPOWER() { - return require 'data/Calculation/Engineering/IMPOWER.php'; + return require 'tests/data/Calculation/Engineering/IMPOWER.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php index d13d1a6c85..2fd383c437 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php @@ -43,6 +43,6 @@ public function testIMPRODUCT($expectedResult, ...$args) public function providerIMPRODUCT() { - return require 'data/Calculation/Engineering/IMPRODUCT.php'; + return require 'tests/data/Calculation/Engineering/IMPRODUCT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php index 013e6d934c..bd4baf9f54 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php @@ -29,6 +29,6 @@ public function testIMREAL($expectedResult, $value) public function providerIMREAL() { - return require 'data/Calculation/Engineering/IMREAL.php'; + return require 'tests/data/Calculation/Engineering/IMREAL.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php index 4f2957fa1a..4de6fcffd8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php @@ -44,6 +44,6 @@ public function testIMSEC($expectedResult, $value) public function providerIMSEC() { - return require 'data/Calculation/Engineering/IMSEC.php'; + return require 'tests/data/Calculation/Engineering/IMSEC.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php index 6b842566b4..11aa8e28d7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php @@ -44,6 +44,6 @@ public function testIMSECH($expectedResult, $value) public function providerIMSECH() { - return require 'data/Calculation/Engineering/IMSECH.php'; + return require 'tests/data/Calculation/Engineering/IMSECH.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php index ca3ceb228d..f3c6afe99b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php @@ -44,6 +44,6 @@ public function testIMSIN($expectedResult, $value) public function providerIMSIN() { - return require 'data/Calculation/Engineering/IMSIN.php'; + return require 'tests/data/Calculation/Engineering/IMSIN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php index b30d8280f9..7478c15c94 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php @@ -44,6 +44,6 @@ public function testIMSINH($expectedResult, $value) public function providerIMSINH() { - return require 'data/Calculation/Engineering/IMSINH.php'; + return require 'tests/data/Calculation/Engineering/IMSINH.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php index 0bff1eef3a..f9a151953a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php @@ -44,6 +44,6 @@ public function testIMSQRT($expectedResult, $value) public function providerIMSQRT() { - return require 'data/Calculation/Engineering/IMSQRT.php'; + return require 'tests/data/Calculation/Engineering/IMSQRT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php index 0daa18276e..2ddc3f57e6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php @@ -43,6 +43,6 @@ public function testIMSUB($expectedResult, ...$args) public function providerIMSUB() { - return require 'data/Calculation/Engineering/IMSUB.php'; + return require 'tests/data/Calculation/Engineering/IMSUB.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php index c4fbc3e72c..23f716ca98 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php @@ -43,6 +43,6 @@ public function testIMSUM($expectedResult, ...$args) public function providerIMSUM() { - return require 'data/Calculation/Engineering/IMSUM.php'; + return require 'tests/data/Calculation/Engineering/IMSUM.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php index c3e5eb1c71..d9f39ad522 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php @@ -44,6 +44,6 @@ public function testIMTAN($expectedResult, $value) public function providerIMTAN() { - return require 'data/Calculation/Engineering/IMTAN.php'; + return require 'tests/data/Calculation/Engineering/IMTAN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php index 6f9e67cf9e..4d2e678169 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php @@ -29,6 +29,6 @@ public function testIMAGINARY($expectedResult, $value) public function providerIMAGINARY() { - return require 'data/Calculation/Engineering/IMAGINARY.php'; + return require 'tests/data/Calculation/Engineering/IMAGINARY.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php index 97558b6523..217494fae4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php @@ -26,6 +26,6 @@ public function testOCT2BIN($expectedResult, ...$args) public function providerOCT2BIN() { - return require 'data/Calculation/Engineering/OCT2BIN.php'; + return require 'tests/data/Calculation/Engineering/OCT2BIN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php index ed51ab486d..c959236c94 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php @@ -26,6 +26,6 @@ public function testOCT2DEC($expectedResult, ...$args) public function providerOCT2DEC() { - return require 'data/Calculation/Engineering/OCT2DEC.php'; + return require 'tests/data/Calculation/Engineering/OCT2DEC.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php index 35764d2be9..1d14bd7866 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php @@ -26,6 +26,6 @@ public function testOCT2HEX($expectedResult, ...$args) public function providerOCT2HEX() { - return require 'data/Calculation/Engineering/OCT2HEX.php'; + return require 'tests/data/Calculation/Engineering/OCT2HEX.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php index 84f459629a..33921bb3a3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php @@ -26,6 +26,6 @@ public function testACCRINTM($expectedResult, ...$args) public function providerACCRINTM() { - return require 'data/Calculation/Financial/ACCRINTM.php'; + return require 'tests/data/Calculation/Financial/ACCRINTM.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php index 55ee6747c8..21aadd0af8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php @@ -26,6 +26,6 @@ public function testACCRINT($expectedResult, ...$args) public function providerACCRINT() { - return require 'data/Calculation/Financial/ACCRINT.php'; + return require 'tests/data/Calculation/Financial/ACCRINT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php index 74c426ea63..c133498856 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php @@ -26,6 +26,6 @@ public function testAND($expectedResult, ...$args) public function providerAND() { - return require 'data/Calculation/Logical/AND.php'; + return require 'tests/data/Calculation/Logical/AND.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php index 20d71025b8..1e9ef8bc1e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php @@ -28,6 +28,6 @@ public function testIFERROR($expectedResult, $value, $return) public function providerIFERROR() { - return require 'data/Calculation/Logical/IFERROR.php'; + return require 'tests/data/Calculation/Logical/IFERROR.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php index 02181b64e8..e151cd75f9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php @@ -28,6 +28,6 @@ public function testIFNA($expectedResult, $value, $return) public function providerIFNA() { - return require 'data/Calculation/Logical/IFNA.php'; + return require 'tests/data/Calculation/Logical/IFNA.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php index 6f0b408735..f289995a0d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php @@ -26,6 +26,6 @@ public function testIF($expectedResult, ...$args) public function providerIF() { - return require 'data/Calculation/Logical/IF.php'; + return require 'tests/data/Calculation/Logical/IF.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php index 5dd40fdc30..abc0e5bc7b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php @@ -26,6 +26,6 @@ public function testNOT($expectedResult, ...$args) public function providerNOT() { - return require 'data/Calculation/Logical/NOT.php'; + return require 'tests/data/Calculation/Logical/NOT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php index a91fc5b0cf..46046b7c96 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php @@ -26,6 +26,6 @@ public function testOR($expectedResult, ...$args) public function providerOR() { - return require 'data/Calculation/Logical/OR.php'; + return require 'tests/data/Calculation/Logical/OR.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php index d85ca4f319..2781334deb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php @@ -26,6 +26,6 @@ public function testSWITCH($expectedResult, ...$args) public function providerSwitch() { - return require 'data/Calculation/Logical/SWITCH.php'; + return require 'tests/data/Calculation/Logical/SWITCH.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php index dc264f527f..8f7a921b88 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php @@ -26,6 +26,6 @@ public function testXOR($expectedResult, ...$args) public function providerXOR() { - return require 'data/Calculation/Logical/XOR.php'; + return require 'tests/data/Calculation/Logical/XOR.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php index 9e72056658..00e2c61ccb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php @@ -26,6 +26,6 @@ public function testCHOOSE($expectedResult, ...$args) public function providerCHOOSE() { - return require 'data/Calculation/LookupRef/CHOOSE.php'; + return require 'tests/data/Calculation/LookupRef/CHOOSE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php index f34a3f64ba..61c0f8b4ef 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php @@ -26,6 +26,6 @@ public function testCOLUMNS($expectedResult, ...$args) public function providerCOLUMNS() { - return require 'data/Calculation/LookupRef/COLUMNS.php'; + return require 'tests/data/Calculation/LookupRef/COLUMNS.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php index 2baaa4f83d..d317089d1b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php @@ -26,6 +26,6 @@ public function testHLOOKUP($expectedResult, ...$args) public function providerHLOOKUP() { - return require 'data/Calculation/LookupRef/HLOOKUP.php'; + return require 'tests/data/Calculation/LookupRef/HLOOKUP.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php index 972e7511ef..241d86f772 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php @@ -26,6 +26,6 @@ public function testINDEX($expectedResult, ...$args) public function providerINDEX() { - return require 'data/Calculation/LookupRef/INDEX.php'; + return require 'tests/data/Calculation/LookupRef/INDEX.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php index f643783d90..6e1fb73a3b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php @@ -26,6 +26,6 @@ public function testLOOKUP($expectedResult, ...$args) public function providerLOOKUP() { - return require 'data/Calculation/LookupRef/LOOKUP.php'; + return require 'tests/data/Calculation/LookupRef/LOOKUP.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php index 3c956b663d..2bf322fcfa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php @@ -26,6 +26,6 @@ public function testMATCH($expectedResult, ...$args) public function providerMATCH() { - return require 'data/Calculation/LookupRef/MATCH.php'; + return require 'tests/data/Calculation/LookupRef/MATCH.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php index 0a97382ffe..41b0bd2b1d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php @@ -26,6 +26,6 @@ public function testROWS($expectedResult, ...$args) public function providerROWS() { - return require 'data/Calculation/LookupRef/ROWS.php'; + return require 'tests/data/Calculation/LookupRef/ROWS.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php index cf4b3059e9..bffecb8ec1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php @@ -26,6 +26,6 @@ public function testVLOOKUP($expectedResult, ...$args) public function providerVLOOKUP() { - return require 'data/Calculation/LookupRef/VLOOKUP.php'; + return require 'tests/data/Calculation/LookupRef/VLOOKUP.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php index e77c4ffbbb..2a3cd654e1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php @@ -27,6 +27,6 @@ public function testACOT($expectedResult, $number) public function providerACOT() { - return require 'data/Calculation/MathTrig/ACOT.php'; + return require 'tests/data/Calculation/MathTrig/ACOT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php index 695df0108f..9661b6761d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php @@ -27,6 +27,6 @@ public function testACOTH($expectedResult, $number) public function providerACOTH() { - return require 'data/Calculation/MathTrig/ACOTH.php'; + return require 'tests/data/Calculation/MathTrig/ACOTH.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php index 10135e115e..0371e0a762 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php @@ -27,6 +27,6 @@ public function testARABIC($expectedResult, $romanNumeral) public function providerARABIC() { - return require 'data/Calculation/MathTrig/ARABIC.php'; + return require 'tests/data/Calculation/MathTrig/ARABIC.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php index dc96530573..c6281fc210 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php @@ -28,6 +28,6 @@ public function testATAN2($expectedResult, $x, $y) public function providerATAN2() { - return require 'data/Calculation/MathTrig/ATAN2.php'; + return require 'tests/data/Calculation/MathTrig/ATAN2.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php index 1368df190a..fdca1f49ed 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php @@ -26,6 +26,6 @@ public function testBASE($expectedResult, ...$args) public function providerBASE() { - return require 'data/Calculation/MathTrig/BASE.php'; + return require 'tests/data/Calculation/MathTrig/BASE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php index f60fae7265..c987cc2ed2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php @@ -26,6 +26,6 @@ public function testCEILING($expectedResult, ...$args) public function providerCEILING() { - return require 'data/Calculation/MathTrig/CEILING.php'; + return require 'tests/data/Calculation/MathTrig/CEILING.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php index d3a4ee4430..8c982b6b3e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php @@ -26,6 +26,6 @@ public function testCOMBIN($expectedResult, ...$args) public function providerCOMBIN() { - return require 'data/Calculation/MathTrig/COMBIN.php'; + return require 'tests/data/Calculation/MathTrig/COMBIN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php index 6263c9fd88..f864d226ad 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php @@ -27,6 +27,6 @@ public function testCOT($expectedResult, $angle) public function providerCOT() { - return require 'data/Calculation/MathTrig/COT.php'; + return require 'tests/data/Calculation/MathTrig/COT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php index 2dfa57a59c..9243c09551 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php @@ -27,6 +27,6 @@ public function testCOTH($expectedResult, $angle) public function providerCOTH() { - return require 'data/Calculation/MathTrig/COTH.php'; + return require 'tests/data/Calculation/MathTrig/COTH.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php index 1b0cdbf7e3..24abad4ee7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php @@ -27,6 +27,6 @@ public function testCSC($expectedResult, $angle) public function providerCSC() { - return require 'data/Calculation/MathTrig/CSC.php'; + return require 'tests/data/Calculation/MathTrig/CSC.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php index 82e286da09..393c088350 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php @@ -27,6 +27,6 @@ public function testCSCH($expectedResult, $angle) public function providerCSCH() { - return require 'data/Calculation/MathTrig/CSCH.php'; + return require 'tests/data/Calculation/MathTrig/CSCH.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php index 3bd84ddd0d..b81b119f92 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php @@ -27,6 +27,6 @@ public function testEVEN($expectedResult, $value) public function providerEVEN() { - return require 'data/Calculation/MathTrig/EVEN.php'; + return require 'tests/data/Calculation/MathTrig/EVEN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php index 2dfe8fad25..c311894239 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php @@ -27,6 +27,6 @@ public function testFACTDOUBLE($expectedResult, $value) public function providerFACTDOUBLE() { - return require 'data/Calculation/MathTrig/FACTDOUBLE.php'; + return require 'tests/data/Calculation/MathTrig/FACTDOUBLE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php index 0f3294e343..b765d4125a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php @@ -27,6 +27,6 @@ public function testFACT($expectedResult, $value) public function providerFACT() { - return require 'data/Calculation/MathTrig/FACT.php'; + return require 'tests/data/Calculation/MathTrig/FACT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php index 63b694f3c1..c5b797f149 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php @@ -26,6 +26,6 @@ public function testFLOORMATH($expectedResult, ...$args) public function providerFLOORMATH() { - return require 'data/Calculation/MathTrig/FLOORMATH.php'; + return require 'tests/data/Calculation/MathTrig/FLOORMATH.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php index e84e596a69..399f05d2eb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php @@ -26,6 +26,6 @@ public function testFLOOR($expectedResult, ...$args) public function providerFLOORPRECISE() { - return require 'data/Calculation/MathTrig/FLOORPRECISE.php'; + return require 'tests/data/Calculation/MathTrig/FLOORPRECISE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php index 60ff5bb7f1..fac02f16b9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php @@ -26,6 +26,6 @@ public function testFLOOR($expectedResult, ...$args) public function providerFLOOR() { - return require 'data/Calculation/MathTrig/FLOOR.php'; + return require 'tests/data/Calculation/MathTrig/FLOOR.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php index d6f588d1a2..825a9d059b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php @@ -26,6 +26,6 @@ public function testGCD($expectedResult, ...$args) public function providerGCD() { - return require 'data/Calculation/MathTrig/GCD.php'; + return require 'tests/data/Calculation/MathTrig/GCD.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php index 3a287aa3ee..3a9b1e5b72 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php @@ -27,6 +27,6 @@ public function testINT($expectedResult, $value) public function providerINT() { - return require 'data/Calculation/MathTrig/INT.php'; + return require 'tests/data/Calculation/MathTrig/INT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php index a5cc2312ef..58ea6a6b1e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php @@ -26,6 +26,6 @@ public function testLCM($expectedResult, ...$args) public function providerLCM() { - return require 'data/Calculation/MathTrig/LCM.php'; + return require 'tests/data/Calculation/MathTrig/LCM.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php index 2e54654ea8..82c63f9960 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php @@ -26,6 +26,6 @@ public function testLOG($expectedResult, ...$args) public function providerLOG() { - return require 'data/Calculation/MathTrig/LOG.php'; + return require 'tests/data/Calculation/MathTrig/LOG.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php index 2a4f1af04d..3d784a871c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php @@ -26,6 +26,6 @@ public function testMINVERSE($expectedResult, ...$args) public function providerMINVERSE() { - return require 'data/Calculation/MathTrig/MINVERSE.php'; + return require 'tests/data/Calculation/MathTrig/MINVERSE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php index 337abbea86..16a52e75c8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php @@ -26,6 +26,6 @@ public function testMMULT($expectedResult, ...$args) public function providerMMULT() { - return require 'data/Calculation/MathTrig/MMULT.php'; + return require 'tests/data/Calculation/MathTrig/MMULT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php index ca14bc1c0e..7356874771 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php @@ -26,6 +26,6 @@ public function testMROUND($expectedResult, ...$args) public function providerMROUND() { - return require 'data/Calculation/MathTrig/MROUND.php'; + return require 'tests/data/Calculation/MathTrig/MROUND.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php index 84911aafa5..672d5dec62 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php @@ -26,6 +26,6 @@ public function testMDETERM($expectedResult, ...$args) public function providerMDETERM() { - return require 'data/Calculation/MathTrig/MDETERM.php'; + return require 'tests/data/Calculation/MathTrig/MDETERM.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php index 8d1666187b..ae8637923c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php @@ -26,6 +26,6 @@ public function testMOD($expectedResult, ...$args) public function providerMOD() { - return require 'data/Calculation/MathTrig/MOD.php'; + return require 'tests/data/Calculation/MathTrig/MOD.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php index 1f751351af..dd2faf2c95 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php @@ -26,6 +26,6 @@ public function testMULTINOMIAL($expectedResult, ...$args) public function providerMULTINOMIAL() { - return require 'data/Calculation/MathTrig/MULTINOMIAL.php'; + return require 'tests/data/Calculation/MathTrig/MULTINOMIAL.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php index 8ba4beaf71..7a9d367c75 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php @@ -27,6 +27,6 @@ public function testODD($expectedResult, $value) public function providerODD() { - return require 'data/Calculation/MathTrig/ODD.php'; + return require 'tests/data/Calculation/MathTrig/ODD.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php index 9df08b5f55..05edecf984 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php @@ -26,6 +26,6 @@ public function testPOWER($expectedResult, ...$args) public function providerPOWER() { - return require 'data/Calculation/MathTrig/POWER.php'; + return require 'tests/data/Calculation/MathTrig/POWER.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php index fecc806a20..3e185bd73d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php @@ -26,6 +26,6 @@ public function testPRODUCT($expectedResult, ...$args) public function providerPRODUCT() { - return require 'data/Calculation/MathTrig/PRODUCT.php'; + return require 'tests/data/Calculation/MathTrig/PRODUCT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php index e81414fee9..96e0b84a41 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php @@ -26,6 +26,6 @@ public function testQUOTIENT($expectedResult, ...$args) public function providerQUOTIENT() { - return require 'data/Calculation/MathTrig/QUOTIENT.php'; + return require 'tests/data/Calculation/MathTrig/QUOTIENT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php index edc7228930..a136371498 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php @@ -26,6 +26,6 @@ public function testROMAN($expectedResult, ...$args) public function providerROMAN() { - return require 'data/Calculation/MathTrig/ROMAN.php'; + return require 'tests/data/Calculation/MathTrig/ROMAN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php index 4d95dac7f0..17b6780b94 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php @@ -26,6 +26,6 @@ public function testROUNDDOWN($expectedResult, ...$args) public function providerROUNDDOWN() { - return require 'data/Calculation/MathTrig/ROUNDDOWN.php'; + return require 'tests/data/Calculation/MathTrig/ROUNDDOWN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php index 143aa65319..6d1c57ba16 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php @@ -26,6 +26,6 @@ public function testROUNDUP($expectedResult, ...$args) public function providerROUNDUP() { - return require 'data/Calculation/MathTrig/ROUNDUP.php'; + return require 'tests/data/Calculation/MathTrig/ROUNDUP.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php index 944c3e376e..8dad0b9d94 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php @@ -27,6 +27,6 @@ public function testSEC($expectedResult, $angle) public function providerSEC() { - return require 'data/Calculation/MathTrig/SEC.php'; + return require 'tests/data/Calculation/MathTrig/SEC.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php index 42fecb0b0f..f98b673e50 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php @@ -27,6 +27,6 @@ public function testSECH($expectedResult, $angle) public function providerSECH() { - return require 'data/Calculation/MathTrig/SECH.php'; + return require 'tests/data/Calculation/MathTrig/SECH.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php index 7923fbc1d7..4f8d4db143 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php @@ -26,6 +26,6 @@ public function testSERIESSUM($expectedResult, ...$args) public function providerSERIESSUM() { - return require 'data/Calculation/MathTrig/SERIESSUM.php'; + return require 'tests/data/Calculation/MathTrig/SERIESSUM.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php index c0ff7b5ec2..d7b6bacb4c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php @@ -27,6 +27,6 @@ public function testSIGN($expectedResult, $value) public function providerSIGN() { - return require 'data/Calculation/MathTrig/SIGN.php'; + return require 'tests/data/Calculation/MathTrig/SIGN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php index 19a182c540..38528548b0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php @@ -27,6 +27,6 @@ public function testSQRTPI($expectedResult, $value) public function providerSQRTPI() { - return require 'data/Calculation/MathTrig/SQRTPI.php'; + return require 'tests/data/Calculation/MathTrig/SQRTPI.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php index 2711c657da..38434278f5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php @@ -54,7 +54,7 @@ public function testSUBTOTAL($expectedResult, ...$args) public function providerSUBTOTAL() { - return require 'data/Calculation/MathTrig/SUBTOTAL.php'; + return require 'tests/data/Calculation/MathTrig/SUBTOTAL.php'; } protected function rowVisibility() @@ -125,7 +125,7 @@ public function testHiddenSUBTOTAL($expectedResult, ...$args) public function providerHiddenSUBTOTAL() { - return require 'data/Calculation/MathTrig/SUBTOTALHIDDEN.php'; + return require 'tests/data/Calculation/MathTrig/SUBTOTALHIDDEN.php'; } protected function cellValues(array $cellValues) @@ -193,6 +193,6 @@ public function testNestedSUBTOTAL($expectedResult, ...$args) public function providerNestedSUBTOTAL() { - return require 'data/Calculation/MathTrig/SUBTOTALNESTED.php'; + return require 'tests/data/Calculation/MathTrig/SUBTOTALNESTED.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php index 359fef443f..639e8bdd59 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php @@ -26,6 +26,6 @@ public function testSUMIF($expectedResult, ...$args) public function providerSUMIF() { - return require 'data/Calculation/MathTrig/SUMIF.php'; + return require 'tests/data/Calculation/MathTrig/SUMIF.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php index 9127705a4d..dab255c250 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php @@ -26,6 +26,6 @@ public function testSUMIFS($expectedResult, ...$args) public function providerSUMIFS() { - return require 'data/Calculation/MathTrig/SUMIFS.php'; + return require 'tests/data/Calculation/MathTrig/SUMIFS.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php index c409ee184c..6b94dafaaa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php @@ -26,6 +26,6 @@ public function testSUMPRODUCT($expectedResult, ...$args) public function providerSUMPRODUCT() { - return require 'data/Calculation/MathTrig/SUMPRODUCT.php'; + return require 'tests/data/Calculation/MathTrig/SUMPRODUCT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php index bfd2d87490..bcb00acc42 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php @@ -26,6 +26,6 @@ public function testSUMSQ($expectedResult, ...$args) public function providerSUMSQ() { - return require 'data/Calculation/MathTrig/SUMSQ.php'; + return require 'tests/data/Calculation/MathTrig/SUMSQ.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php index 937043ee5d..1bfe592309 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php @@ -26,6 +26,6 @@ public function testSUMX2MY2($expectedResult, ...$args) public function providerSUMX2MY2() { - return require 'data/Calculation/MathTrig/SUMX2MY2.php'; + return require 'tests/data/Calculation/MathTrig/SUMX2MY2.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php index c58f28a29d..c53630de8f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php @@ -26,6 +26,6 @@ public function testSUMX2PY2($expectedResult, ...$args) public function providerSUMX2PY2() { - return require 'data/Calculation/MathTrig/SUMX2PY2.php'; + return require 'tests/data/Calculation/MathTrig/SUMX2PY2.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php index a4a6e8a1bc..bb4dc527c7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php @@ -26,6 +26,6 @@ public function testSUMXMY2($expectedResult, ...$args) public function providerSUMXMY2() { - return require 'data/Calculation/MathTrig/SUMXMY2.php'; + return require 'tests/data/Calculation/MathTrig/SUMXMY2.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php index b5bb6e43fb..244889dc49 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php @@ -26,6 +26,6 @@ public function testTRUNC($expectedResult, ...$args) public function providerTRUNC() { - return require 'data/Calculation/MathTrig/TRUNC.php'; + return require 'tests/data/Calculation/MathTrig/TRUNC.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php index 94f214a3ab..a61730add7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php @@ -26,6 +26,6 @@ public function testAVEDEV($expectedResult, ...$args) public function providerAVEDEV() { - return require 'data/Calculation/Statistical/AVEDEV.php'; + return require 'tests/data/Calculation/Statistical/AVEDEV.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php index 526875f3e7..6c5f4093df 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php @@ -26,6 +26,6 @@ public function testAVERAGEA($expectedResult, ...$args) public function providerAVERAGEA() { - return require 'data/Calculation/Statistical/AVERAGEA.php'; + return require 'tests/data/Calculation/Statistical/AVERAGEA.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php index 0d7863bf94..f1b4081ac7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php @@ -26,6 +26,6 @@ public function testAVERAGEIF($expectedResult, ...$args) public function providerAVERAGEIF() { - return require 'data/Calculation/Statistical/AVERAGEIF.php'; + return require 'tests/data/Calculation/Statistical/AVERAGEIF.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php index 30503a3a2f..3d03524ea4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php @@ -26,6 +26,6 @@ public function testAVERAGE($expectedResult, ...$args) public function providerAVERAGE() { - return require 'data/Calculation/Statistical/AVERAGE.php'; + return require 'tests/data/Calculation/Statistical/AVERAGE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php index 6b1aed8235..1cd9280ddc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php @@ -26,6 +26,6 @@ public function testBETADIST($expectedResult, ...$args) public function providerBETADIST() { - return require 'data/Calculation/Statistical/BETADIST.php'; + return require 'tests/data/Calculation/Statistical/BETADIST.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php index b0fc38d7ca..10c47c7697 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php @@ -26,6 +26,6 @@ public function testBETAINV($expectedResult, ...$args) public function providerBETAINV() { - return require 'data/Calculation/Statistical/BETAINV.php'; + return require 'tests/data/Calculation/Statistical/BETAINV.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php index c16ff6c27a..e489154675 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php @@ -26,6 +26,6 @@ public function testBINOMDIST($expectedResult, ...$args) public function providerBINOMDIST() { - return require 'data/Calculation/Statistical/BINOMDIST.php'; + return require 'tests/data/Calculation/Statistical/BINOMDIST.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php index 3d027c2343..d00d5fb0af 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php @@ -26,6 +26,6 @@ public function testCHIDIST($expectedResult, ...$args) public function providerCHIDIST() { - return require 'data/Calculation/Statistical/CHIDIST.php'; + return require 'tests/data/Calculation/Statistical/CHIDIST.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php index d176ee78e9..e2b93e95c3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php @@ -26,6 +26,6 @@ public function testCHIINV($expectedResult, ...$args) public function providerCHIINV() { - return require 'data/Calculation/Statistical/CHIINV.php'; + return require 'tests/data/Calculation/Statistical/CHIINV.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php index 5d4472d4e9..9a131ed0fc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php @@ -26,6 +26,6 @@ public function testCONFIDENCE($expectedResult, ...$args) public function providerCONFIDENCE() { - return require 'data/Calculation/Statistical/CONFIDENCE.php'; + return require 'tests/data/Calculation/Statistical/CONFIDENCE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php index c489d4c80c..f2bba8d758 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php @@ -26,6 +26,6 @@ public function testCORREL($expectedResult, array $xargs, array $yargs) public function providerCORREL() { - return require 'data/Calculation/Statistical/CORREL.php'; + return require 'tests/data/Calculation/Statistical/CORREL.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php index 4edb187464..15f9c4bf0f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php @@ -26,6 +26,6 @@ public function testCOUNTA($expectedResult, ...$args) public function providerCOUNTA() { - return require 'data/Calculation/Statistical/COUNTA.php'; + return require 'tests/data/Calculation/Statistical/COUNTA.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php index 5bd008e85a..8e61bb4768 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php @@ -26,6 +26,6 @@ public function testCOUNTBLANK($expectedResult, ...$args) public function providerCOUNTBLANK() { - return require 'data/Calculation/Statistical/COUNTBLANK.php'; + return require 'tests/data/Calculation/Statistical/COUNTBLANK.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php index ec3a25b36c..7f1dd221ab 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php @@ -26,6 +26,6 @@ public function testCOUNTIF($expectedResult, ...$args) public function providerCOUNTIF() { - return require 'data/Calculation/Statistical/COUNTIF.php'; + return require 'tests/data/Calculation/Statistical/COUNTIF.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php index 0170c277c0..301c3f4c82 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php @@ -26,6 +26,6 @@ public function testCOUNTIFS($expectedResult, ...$args) public function providerCOUNTIFS() { - return require 'data/Calculation/Statistical/COUNTIFS.php'; + return require 'tests/data/Calculation/Statistical/COUNTIFS.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php index 798bcbd995..1bfac28e76 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php @@ -26,7 +26,7 @@ public function testBasicCOUNT($expectedResult, ...$args) public function providerBasicCOUNT() { - return require 'data/Calculation/Statistical/BasicCOUNT.php'; + return require 'tests/data/Calculation/Statistical/BasicCOUNT.php'; } /** @@ -42,7 +42,7 @@ public function testExcelCOUNT($expectedResult, ...$args) public function providerExcelCOUNT() { - return require 'data/Calculation/Statistical/ExcelCOUNT.php'; + return require 'tests/data/Calculation/Statistical/ExcelCOUNT.php'; } /** @@ -60,7 +60,7 @@ public function testOpenOfficeCOUNT($expectedResult, ...$args) public function providerOpenOfficeCOUNT() { - return require 'data/Calculation/Statistical/OpenOfficeCOUNT.php'; + return require 'tests/data/Calculation/Statistical/OpenOfficeCOUNT.php'; } /** @@ -78,6 +78,6 @@ public function testGnumericCOUNT($expectedResult, ...$args) public function providerGnumericCOUNT() { - return require 'data/Calculation/Statistical/GnumericCOUNT.php'; + return require 'tests/data/Calculation/Statistical/GnumericCOUNT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php index 7658d44554..c34e36d2c5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php @@ -26,6 +26,6 @@ public function testCOVAR($expectedResult, ...$args) public function providerCOVAR() { - return require 'data/Calculation/Statistical/COVAR.php'; + return require 'tests/data/Calculation/Statistical/COVAR.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php index a9184eddbe..cf3e884973 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php @@ -26,6 +26,6 @@ public function testEXPONDIST($expectedResult, ...$args) public function providerEXPONDIST() { - return require 'data/Calculation/Statistical/EXPONDIST.php'; + return require 'tests/data/Calculation/Statistical/EXPONDIST.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php index 0488d50400..f8eb7554b9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php @@ -27,6 +27,6 @@ public function testFISHERINV($expectedResult, $value) public function providerFISHERINV() { - return require 'data/Calculation/Statistical/FISHERINV.php'; + return require 'tests/data/Calculation/Statistical/FISHERINV.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php index 25ca6b481b..5f9733ab51 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php @@ -27,6 +27,6 @@ public function testFISHER($expectedResult, $value) public function providerFISHER() { - return require 'data/Calculation/Statistical/FISHER.php'; + return require 'tests/data/Calculation/Statistical/FISHER.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php index e0227ad795..4de6450058 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php @@ -26,6 +26,6 @@ public function testFORECAST($expectedResult, ...$args) public function providerFORECAST() { - return require 'data/Calculation/Statistical/FORECAST.php'; + return require 'tests/data/Calculation/Statistical/FORECAST.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php index 325f662dd3..41806e5637 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php @@ -26,6 +26,6 @@ public function testGAMMADIST($expectedResult, ...$args) public function providerGAMMADIST() { - return require 'data/Calculation/Statistical/GAMMADIST.php'; + return require 'tests/data/Calculation/Statistical/GAMMADIST.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php index 76f5e30c3c..ad72277a46 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php @@ -26,6 +26,6 @@ public function testGAMMAINV($expectedResult, ...$args) public function providerGAMMAINV() { - return require 'data/Calculation/Statistical/GAMMAINV.php'; + return require 'tests/data/Calculation/Statistical/GAMMAINV.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php index 11363b1f23..2fde78aa35 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php @@ -27,6 +27,6 @@ public function testGAMMALN($expectedResult, $value) public function providerGAMMALN() { - return require 'data/Calculation/Statistical/GAMMALN.php'; + return require 'tests/data/Calculation/Statistical/GAMMALN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php index cbb7b33d14..6f8f60533b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php @@ -26,6 +26,6 @@ public function testGEOMEAN($expectedResult, ...$args) public function providerGEOMEAN() { - return require 'data/Calculation/Statistical/GEOMEAN.php'; + return require 'tests/data/Calculation/Statistical/GEOMEAN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php index 5777204dbe..38ad95db79 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php @@ -26,6 +26,6 @@ public function testHARMEAN($expectedResult, ...$args) public function providerHARMEAN() { - return require 'data/Calculation/Statistical/HARMEAN.php'; + return require 'tests/data/Calculation/Statistical/HARMEAN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php index 9362e692e5..e3f9383cec 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php @@ -26,6 +26,6 @@ public function testINTERCEPT($expectedResult, array $xargs, array $yargs) public function providerINTERCEPT() { - return require 'data/Calculation/Statistical/INTERCEPT.php'; + return require 'tests/data/Calculation/Statistical/INTERCEPT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php index 06fc226313..c8d3d02c18 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php @@ -26,6 +26,6 @@ public function testMAXIFS($expectedResult, ...$args) public function providerMAXIFS() { - return require 'data/Calculation/Statistical/MAXIFS.php'; + return require 'tests/data/Calculation/Statistical/MAXIFS.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php index 29497689ca..571fca237f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php @@ -26,6 +26,6 @@ public function testMEDIAN($expectedResult, ...$args) public function providerMEDIAN() { - return require 'data/Calculation/Statistical/MEDIAN.php'; + return require 'tests/data/Calculation/Statistical/MEDIAN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php index 4721043f0b..b8c1e29100 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php @@ -26,6 +26,6 @@ public function testMINIFS($expectedResult, ...$args) public function providerMINIFS() { - return require 'data/Calculation/Statistical/MINIFS.php'; + return require 'tests/data/Calculation/Statistical/MINIFS.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php index 4e0c9da949..7e7ae7a7c2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php @@ -26,6 +26,6 @@ public function testPERMUT($expectedResult, ...$args) public function providerPERMUT() { - return require 'data/Calculation/Statistical/PERMUT.php'; + return require 'tests/data/Calculation/Statistical/PERMUT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php index 229c221fcd..a0959eacf3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php @@ -26,6 +26,6 @@ public function testRSQ($expectedResult, array $xargs, array $yargs) public function providerRSQ() { - return require 'data/Calculation/Statistical/RSQ.php'; + return require 'tests/data/Calculation/Statistical/RSQ.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php index 4bdaef025b..fe28f5ebc5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php @@ -26,6 +26,6 @@ public function testSLOPE($expectedResult, array $xargs, array $yargs) public function providerSLOPE() { - return require 'data/Calculation/Statistical/SLOPE.php'; + return require 'tests/data/Calculation/Statistical/SLOPE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php index 271c2175ba..5ab6b66227 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php @@ -26,6 +26,6 @@ public function testSTEYX($expectedResult, array $xargs, array $yargs) public function providerSTEYX() { - return require 'data/Calculation/Statistical/STEYX.php'; + return require 'tests/data/Calculation/Statistical/STEYX.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php index 66bbdc20eb..86483180df 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php @@ -39,6 +39,6 @@ public function testCHAR($expectedResult, $character) public function providerCHAR() { - return require 'data/Calculation/TextData/CHAR.php'; + return require 'tests/data/Calculation/TextData/CHAR.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php index 0f0e391af4..63042fa5bd 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php @@ -39,6 +39,6 @@ public function testCLEAN($expectedResult, $value) public function providerCLEAN() { - return require 'data/Calculation/TextData/CLEAN.php'; + return require 'tests/data/Calculation/TextData/CLEAN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php index 99f7dcf5b9..b39b66bfec 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php @@ -39,6 +39,6 @@ public function testCODE($expectedResult, $character) public function providerCODE() { - return require 'data/Calculation/TextData/CODE.php'; + return require 'tests/data/Calculation/TextData/CODE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php index 7b93f56eb4..6d32298e08 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php @@ -38,6 +38,6 @@ public function testCONCATENATE($expectedResult, ...$args) public function providerCONCATENATE() { - return require 'data/Calculation/TextData/CONCATENATE.php'; + return require 'tests/data/Calculation/TextData/CONCATENATE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php index 827860bc0b..3f0ae34fce 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php @@ -38,6 +38,6 @@ public function testDOLLAR($expectedResult, ...$args) public function providerDOLLAR() { - return require 'data/Calculation/TextData/DOLLAR.php'; + return require 'tests/data/Calculation/TextData/DOLLAR.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php index ddf685c4b2..ad44c03ff8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php @@ -46,6 +46,6 @@ public function testEXACT($expectedResult, ...$args) */ public function providerEXACT() { - return require 'data/Calculation/TextData/EXACT.php'; + return require 'tests/data/Calculation/TextData/EXACT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php index 495339ab9c..c20d7df3b6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php @@ -38,6 +38,6 @@ public function testFIND($expectedResult, ...$args) public function providerFIND() { - return require 'data/Calculation/TextData/FIND.php'; + return require 'tests/data/Calculation/TextData/FIND.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php index af9b02ca26..010278fc4c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php @@ -38,6 +38,6 @@ public function testFIXED($expectedResult, ...$args) public function providerFIXED() { - return require 'data/Calculation/TextData/FIXED.php'; + return require 'tests/data/Calculation/TextData/FIXED.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php index b42a4ac33d..d1eba19ef8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php @@ -38,6 +38,6 @@ public function testLEFT($expectedResult, ...$args) public function providerLEFT() { - return require 'data/Calculation/TextData/LEFT.php'; + return require 'tests/data/Calculation/TextData/LEFT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php index ad5bffb695..8e711fa9a7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php @@ -39,6 +39,6 @@ public function testLEN($expectedResult, $value) public function providerLEN() { - return require 'data/Calculation/TextData/LEN.php'; + return require 'tests/data/Calculation/TextData/LEN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php index 5651e7ae7a..e329dda39a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php @@ -39,6 +39,6 @@ public function testLOWER($expectedResult, $value) public function providerLOWER() { - return require 'data/Calculation/TextData/LOWER.php'; + return require 'tests/data/Calculation/TextData/LOWER.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php index cda1dc015a..5bcc43fc93 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php @@ -38,6 +38,6 @@ public function testMID($expectedResult, ...$args) public function providerMID() { - return require 'data/Calculation/TextData/MID.php'; + return require 'tests/data/Calculation/TextData/MID.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php index 3ffd147d3f..45e3c6be95 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php @@ -39,6 +39,6 @@ public function testNUMBERVALUE($expectedResult, array $args) public function providerNUMBERVALUE() { - return require 'data/Calculation/TextData/NUMBERVALUE.php'; + return require 'tests/data/Calculation/TextData/NUMBERVALUE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php index 0aaf968f10..13efbd9a14 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php @@ -39,6 +39,6 @@ public function testPROPER($expectedResult, $value) public function providerPROPER() { - return require 'data/Calculation/TextData/PROPER.php'; + return require 'tests/data/Calculation/TextData/PROPER.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php index e7592a1f6b..f319b16ed0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php @@ -38,6 +38,6 @@ public function testREPLACE($expectedResult, ...$args) public function providerREPLACE() { - return require 'data/Calculation/TextData/REPLACE.php'; + return require 'tests/data/Calculation/TextData/REPLACE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php index 3ec883f4d3..216050c3f1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php @@ -38,6 +38,6 @@ public function testRIGHT($expectedResult, ...$args) public function providerRIGHT() { - return require 'data/Calculation/TextData/RIGHT.php'; + return require 'tests/data/Calculation/TextData/RIGHT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php index c8b3040b61..ab3fcb115b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php @@ -38,6 +38,6 @@ public function testSEARCH($expectedResult, ...$args) public function providerSEARCH() { - return require 'data/Calculation/TextData/SEARCH.php'; + return require 'tests/data/Calculation/TextData/SEARCH.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php index a88ee81dc9..89a89ba3a8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php @@ -38,6 +38,6 @@ public function testSUBSTITUTE($expectedResult, ...$args) public function providerSUBSTITUTE() { - return require 'data/Calculation/TextData/SUBSTITUTE.php'; + return require 'tests/data/Calculation/TextData/SUBSTITUTE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php index 4cdf3fb406..56b00838cb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php @@ -39,6 +39,6 @@ public function testT($expectedResult, $value) public function providerT() { - return require 'data/Calculation/TextData/T.php'; + return require 'tests/data/Calculation/TextData/T.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php index c4c929db5b..ec04ce1319 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php @@ -39,6 +39,6 @@ public function testTEXTJOIN($expectedResult, array $args) public function providerTEXTJOIN() { - return require 'data/Calculation/TextData/TEXTJOIN.php'; + return require 'tests/data/Calculation/TextData/TEXTJOIN.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php index 306530a558..f7638e4c6b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php @@ -43,6 +43,6 @@ public function testTEXT($expectedResult, ...$args) public function providerTEXT() { - return require 'data/Calculation/TextData/TEXT.php'; + return require 'tests/data/Calculation/TextData/TEXT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php index aa89642775..d5907803bf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php @@ -39,6 +39,6 @@ public function testTRIM($expectedResult, $character) public function providerTRIM() { - return require 'data/Calculation/TextData/TRIM.php'; + return require 'tests/data/Calculation/TextData/TRIM.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php index cdfdb49f48..a69d8279e6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php @@ -39,6 +39,6 @@ public function testUPPER($expectedResult, $value) public function providerUPPER() { - return require 'data/Calculation/TextData/UPPER.php'; + return require 'tests/data/Calculation/TextData/UPPER.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php index f60a12a92d..b2e31ba38a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php @@ -43,6 +43,6 @@ public function testVALUE($expectedResult, $value) public function providerVALUE() { - return require 'data/Calculation/TextData/VALUE.php'; + return require 'tests/data/Calculation/TextData/VALUE.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php index b0c8eb870c..94788c2dc5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php @@ -119,7 +119,7 @@ public function testIsBlank($expectedResult, ...$args) public function providerIsBlank() { - return require 'data/Calculation/Functions/IS_BLANK.php'; + return require 'tests/data/Calculation/Functions/IS_BLANK.php'; } /** @@ -135,7 +135,7 @@ public function testIsErr($expectedResult, ...$args) public function providerIsErr() { - return require 'data/Calculation/Functions/IS_ERR.php'; + return require 'tests/data/Calculation/Functions/IS_ERR.php'; } /** @@ -151,7 +151,7 @@ public function testIsError($expectedResult, ...$args) public function providerIsError() { - return require 'data/Calculation/Functions/IS_ERROR.php'; + return require 'tests/data/Calculation/Functions/IS_ERROR.php'; } /** @@ -167,7 +167,7 @@ public function testErrorType($expectedResult, ...$args) public function providerErrorType() { - return require 'data/Calculation/Functions/ERROR_TYPE.php'; + return require 'tests/data/Calculation/Functions/ERROR_TYPE.php'; } /** @@ -183,7 +183,7 @@ public function testIsLogical($expectedResult, ...$args) public function providerIsLogical() { - return require 'data/Calculation/Functions/IS_LOGICAL.php'; + return require 'tests/data/Calculation/Functions/IS_LOGICAL.php'; } /** @@ -199,7 +199,7 @@ public function testIsNa($expectedResult, ...$args) public function providerIsNa() { - return require 'data/Calculation/Functions/IS_NA.php'; + return require 'tests/data/Calculation/Functions/IS_NA.php'; } /** @@ -215,7 +215,7 @@ public function testIsNumber($expectedResult, ...$args) public function providerIsNumber() { - return require 'data/Calculation/Functions/IS_NUMBER.php'; + return require 'tests/data/Calculation/Functions/IS_NUMBER.php'; } /** @@ -231,7 +231,7 @@ public function testIsText($expectedResult, ...$args) public function providerIsText() { - return require 'data/Calculation/Functions/IS_TEXT.php'; + return require 'tests/data/Calculation/Functions/IS_TEXT.php'; } /** @@ -247,7 +247,7 @@ public function testIsNonText($expectedResult, ...$args) public function providerIsNonText() { - return require 'data/Calculation/Functions/IS_NONTEXT.php'; + return require 'tests/data/Calculation/Functions/IS_NONTEXT.php'; } /** @@ -263,7 +263,7 @@ public function testIsEven($expectedResult, ...$args) public function providerIsEven() { - return require 'data/Calculation/Functions/IS_EVEN.php'; + return require 'tests/data/Calculation/Functions/IS_EVEN.php'; } /** @@ -279,7 +279,7 @@ public function testIsOdd($expectedResult, ...$args) public function providerIsOdd() { - return require 'data/Calculation/Functions/IS_ODD.php'; + return require 'tests/data/Calculation/Functions/IS_ODD.php'; } /** @@ -295,7 +295,7 @@ public function testTYPE($expectedResult, ...$args) public function providerTYPE() { - return require 'data/Calculation/Functions/TYPE.php'; + return require 'tests/data/Calculation/Functions/TYPE.php'; } /** @@ -311,7 +311,7 @@ public function testN($expectedResult, ...$args) public function providerN() { - return require 'data/Calculation/Functions/N.php'; + return require 'tests/data/Calculation/Functions/N.php'; } /** @@ -364,7 +364,7 @@ public function testIsFormula($expectedResult, $reference, $value = 'undefined') public function providerIsFormula() { - return require 'data/Calculation/Functions/ISFORMULA.php'; + return require 'tests/data/Calculation/Functions/ISFORMULA.php'; } /** @@ -380,6 +380,6 @@ public function testIfCondition($expectedResult, ...$args) public function providerIfCondition() { - return require 'data/Calculation/Functions/IF_CONDITION.php'; + return require 'tests/data/Calculation/Functions/IF_CONDITION.php'; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php b/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php index 5694d85984..dff80fadd7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php @@ -71,6 +71,6 @@ public function testFormulaText($expectedResult, $reference, $value = 'undefined public function providerFormulaText() { - return require 'data/Calculation/LookupRef/FORMULATEXT.php'; + return require 'tests/data/Calculation/LookupRef/FORMULATEXT.php'; } } diff --git a/tests/PhpSpreadsheetTests/Cell/CellTest.php b/tests/PhpSpreadsheetTests/Cell/CellTest.php index 38fc42800a..15e1d38407 100644 --- a/tests/PhpSpreadsheetTests/Cell/CellTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CellTest.php @@ -26,7 +26,7 @@ public function testSetValueExplicit($expected, $value, string $dataType) public function providerSetValueExplicit() { - return require 'data/Cell/SetValueExplicit.php'; + return require 'tests/data/Cell/SetValueExplicit.php'; } /** @@ -47,6 +47,6 @@ public function testSetValueExplicitException($value, string $dataType) public function providerSetValueExplicitException() { - return require 'data/Cell/SetValueExplicitException.php'; + return require 'tests/data/Cell/SetValueExplicitException.php'; } } diff --git a/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php b/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php index 8d041c26d5..7a12ceb7c0 100644 --- a/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php @@ -25,7 +25,7 @@ public function testColumnIndexFromString($expectedResult, $string) public function providerColumnString() { - return require 'data/ColumnString.php'; + return require 'tests/data/ColumnString.php'; } public function testColumnIndexFromStringTooLong() @@ -75,7 +75,7 @@ public function testStringFromColumnIndex($expectedResult, $columnIndex) public function providerColumnIndex() { - return require 'data/ColumnIndex.php'; + return require 'tests/data/ColumnIndex.php'; } /** @@ -91,7 +91,7 @@ public function testCoordinateFromString($expectedResult, ...$args) public function providerCoordinates() { - return require 'data/CellCoordinates.php'; + return require 'tests/data/CellCoordinates.php'; } public function testCoordinateFromStringWithRangeAddress() @@ -152,7 +152,7 @@ public function testAbsoluteCoordinateFromString($expectedResult, ...$args) public function providerAbsoluteCoordinates() { - return require 'data/CellAbsoluteCoordinate.php'; + return require 'tests/data/CellAbsoluteCoordinate.php'; } public function testAbsoluteCoordinateFromStringWithRangeAddress() @@ -183,7 +183,7 @@ public function testAbsoluteReferenceFromString($expectedResult, ...$args) public function providerAbsoluteReferences() { - return require 'data/CellAbsoluteReference.php'; + return require 'tests/data/CellAbsoluteReference.php'; } public function testAbsoluteReferenceFromStringWithRangeAddress() @@ -220,7 +220,7 @@ public function testSplitRange($expectedResult, ...$args) public function providerSplitRange() { - return require 'data/CellSplitRange.php'; + return require 'tests/data/CellSplitRange.php'; } /** @@ -236,7 +236,7 @@ public function testBuildRange($expectedResult, ...$args) public function providerBuildRange() { - return require 'data/CellBuildRange.php'; + return require 'tests/data/CellBuildRange.php'; } public function testBuildRangeInvalid() @@ -260,7 +260,7 @@ public function testRangeBoundaries($expectedResult, ...$args) public function providerRangeBoundaries() { - return require 'data/CellRangeBoundaries.php'; + return require 'tests/data/CellRangeBoundaries.php'; } /** @@ -276,7 +276,7 @@ public function testRangeDimension($expectedResult, ...$args) public function providerRangeDimension() { - return require 'data/CellRangeDimension.php'; + return require 'tests/data/CellRangeDimension.php'; } /** @@ -292,7 +292,7 @@ public function testGetRangeBoundaries($expectedResult, ...$args) public function providerGetRangeBoundaries() { - return require 'data/CellGetRangeBoundaries.php'; + return require 'tests/data/CellGetRangeBoundaries.php'; } /** @@ -308,7 +308,7 @@ public function testExtractAllCellReferencesInRange($expectedResult, ...$args) public function providerExtractAllCellReferencesInRange() { - return require 'data/CellExtractAllCellReferencesInRange.php'; + return require 'tests/data/CellExtractAllCellReferencesInRange.php'; } /** @@ -342,7 +342,7 @@ public function testMergeRangesInCollection($expectedResult, ...$args) public function providerMergeRangesInCollection() { - return require 'data/CellMergeRangesInCollection.php'; + return require 'tests/data/CellMergeRangesInCollection.php'; } /** @@ -358,6 +358,6 @@ public function testCoordinateIsRange($expectedResult, ...$args) public function providerCoordinateIsRange() { - return require 'data/CoordinateIsRange.php'; + return require 'tests/data/CoordinateIsRange.php'; } } diff --git a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php index d116fb9998..d22e03cb95 100644 --- a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php @@ -73,7 +73,7 @@ public function testDataTypeForValue($expectedResult, ...$args) public function providerDataTypeForValue() { - return require 'data/Cell/DefaultValueBinder.php'; + return require 'tests/data/Cell/DefaultValueBinder.php'; } public function testDataTypeForRichTextObject() diff --git a/tests/PhpSpreadsheetTests/Functional/TypeAttributePreservationTest.php b/tests/PhpSpreadsheetTests/Functional/TypeAttributePreservationTest.php index 53cc718db3..cca3777adf 100644 --- a/tests/PhpSpreadsheetTests/Functional/TypeAttributePreservationTest.php +++ b/tests/PhpSpreadsheetTests/Functional/TypeAttributePreservationTest.php @@ -9,7 +9,7 @@ class TypeAttributePreservationTest extends AbstractFunctional public function providerFormulae() { $formats = ['Xlsx']; - $data = require 'data/Functional/TypeAttributePreservation/Formula.php'; + $data = require 'tests/data/Functional/TypeAttributePreservation/Formula.php'; $result = []; foreach ($formats as $f) { diff --git a/tests/PhpSpreadsheetTests/Helper/SampleTest.php b/tests/PhpSpreadsheetTests/Helper/SampleTest.php index e97941f766..6bd9c42299 100644 --- a/tests/PhpSpreadsheetTests/Helper/SampleTest.php +++ b/tests/PhpSpreadsheetTests/Helper/SampleTest.php @@ -48,7 +48,7 @@ public function providerSample() foreach ($helper->getSamples() as $samples) { foreach ($samples as $sample) { if (!in_array($sample, $skipped)) { - $file = '../samples/' . $sample; + $file = 'samples/' . $sample; $result[] = [$file]; } } diff --git a/tests/PhpSpreadsheetTests/IOFactoryTest.php b/tests/PhpSpreadsheetTests/IOFactoryTest.php index 90a9af0ea9..5084354fb9 100644 --- a/tests/PhpSpreadsheetTests/IOFactoryTest.php +++ b/tests/PhpSpreadsheetTests/IOFactoryTest.php @@ -120,13 +120,13 @@ public function testLoad($file, $expectedName, $expectedClass) public function providerIdentify() { return [ - ['../samples/templates/26template.xlsx', 'Xlsx', Reader\Xlsx::class], - ['../samples/templates/GnumericTest.gnumeric', 'Gnumeric', Reader\Gnumeric::class], - ['../samples/templates/30template.xls', 'Xls', Reader\Xls::class], - ['../samples/templates/OOCalcTest.ods', 'Ods', Reader\Ods::class], - ['../samples/templates/SylkTest.slk', 'Slk', Reader\Slk::class], - ['../samples/templates/Excel2003XMLTest.xml', 'Xml', Reader\Xml::class], - ['../samples/templates/46readHtml.html', 'Html', Reader\Html::class], + ['samples/templates/26template.xlsx', 'Xlsx', Reader\Xlsx::class], + ['samples/templates/GnumericTest.gnumeric', 'Gnumeric', Reader\Gnumeric::class], + ['samples/templates/30template.xls', 'Xls', Reader\Xls::class], + ['samples/templates/OOCalcTest.ods', 'Ods', Reader\Ods::class], + ['samples/templates/SylkTest.slk', 'Slk', Reader\Slk::class], + ['samples/templates/Excel2003XMLTest.xml', 'Xml', Reader\Xml::class], + ['samples/templates/46readHtml.html', 'Html', Reader\Html::class], ]; } diff --git a/tests/PhpSpreadsheetTests/Reader/CondNumFmtTest.php b/tests/PhpSpreadsheetTests/Reader/CondNumFmtTest.php index ca69d23b48..1743c43353 100644 --- a/tests/PhpSpreadsheetTests/Reader/CondNumFmtTest.php +++ b/tests/PhpSpreadsheetTests/Reader/CondNumFmtTest.php @@ -10,7 +10,7 @@ class CondNumFmtTest extends TestCase { public function testLoadCondNumFmt() { - $filename = './data/Reader/XLSX/condfmtnum.xlsx'; + $filename = 'tests/data/Reader/XLSX/condfmtnum.xlsx'; $reader = new Xlsx(); $spreadsheet = $reader->load($filename); diff --git a/tests/PhpSpreadsheetTests/Reader/CsvContiguousTest.php b/tests/PhpSpreadsheetTests/Reader/CsvContiguousTest.php index 4fe2006d65..4920c00147 100644 --- a/tests/PhpSpreadsheetTests/Reader/CsvContiguousTest.php +++ b/tests/PhpSpreadsheetTests/Reader/CsvContiguousTest.php @@ -8,7 +8,7 @@ class CsvContiguousTest extends TestCase { - private $inputFileName = __DIR__ . '/../../../samples/Reader/sampleData/example2.csv'; + private $inputFileName = 'samples/Reader/sampleData/example2.csv'; public function testContiguous() { diff --git a/tests/PhpSpreadsheetTests/Reader/CsvTest.php b/tests/PhpSpreadsheetTests/Reader/CsvTest.php index bb593ce861..3b6c61b86d 100644 --- a/tests/PhpSpreadsheetTests/Reader/CsvTest.php +++ b/tests/PhpSpreadsheetTests/Reader/CsvTest.php @@ -33,55 +33,55 @@ public function providerDelimiterDetection() { return [ [ - __DIR__ . '/../../data/Reader/CSV/enclosure.csv', + 'tests/data/Reader/CSV/enclosure.csv', ',', 'C4', 'username2', ], [ - __DIR__ . '/../../data/Reader/CSV/semicolon_separated.csv', + 'tests/data/Reader/CSV/semicolon_separated.csv', ';', 'C2', '25,5', ], [ - __DIR__ . '/../../data/Reader/CSV/line_break_in_enclosure.csv', + 'tests/data/Reader/CSV/line_break_in_enclosure.csv', ',', 'A3', 'Test', ], [ - __DIR__ . '/../../data/Reader/CSV/line_break_in_enclosure_with_escaped_quotes.csv', + 'tests/data/Reader/CSV/line_break_in_enclosure_with_escaped_quotes.csv', ',', 'A3', 'Test', ], [ - __DIR__ . '/../../data/Reader/HTML/csv_with_angle_bracket.csv', + 'tests/data/Reader/HTML/csv_with_angle_bracket.csv', ',', 'B1', 'Number of items with weight <= 50kg', ], [ - __DIR__ . '/../../../samples/Reader/sampleData/example1.csv', + 'samples/Reader/sampleData/example1.csv', ',', 'I4', '100%', ], [ - __DIR__ . '/../../../samples/Reader/sampleData/example2.csv', + 'samples/Reader/sampleData/example2.csv', ',', 'D8', -58.373161, ], [ - 'data/Reader/CSV/empty.csv', + 'tests/data/Reader/CSV/empty.csv', ',', 'A1', null, ], [ - 'data/Reader/CSV/no_delimiter.csv', + 'tests/data/Reader/CSV/no_delimiter.csv', ',', 'A1', 'SingleLine', @@ -104,23 +104,23 @@ public function testCanLoad($expected, $filename) public function providerCanLoad() { return [ - [false, 'data/Reader/Ods/data.ods'], - [false, 'data/Reader/Xml/WithoutStyle.xml'], - [true, 'data/Reader/CSV/enclosure.csv'], - [true, 'data/Reader/CSV/semicolon_separated.csv'], - [true, 'data/Reader/CSV/contains_html.csv'], - [true, 'data/Reader/CSV/csv_without_extension'], - [true, 'data/Reader/HTML/csv_with_angle_bracket.csv'], - [true, 'data/Reader/CSV/empty.csv'], - [true, '../samples/Reader/sampleData/example1.csv'], - [true, '../samples/Reader/sampleData/example2.csv'], + [false, 'tests/data/Reader/Ods/data.ods'], + [false, 'tests/data/Reader/Xml/WithoutStyle.xml'], + [true, 'tests/data/Reader/CSV/enclosure.csv'], + [true, 'tests/data/Reader/CSV/semicolon_separated.csv'], + [true, 'tests/data/Reader/CSV/contains_html.csv'], + [true, 'tests/data/Reader/CSV/csv_without_extension'], + [true, 'tests/data/Reader/HTML/csv_with_angle_bracket.csv'], + [true, 'tests/data/Reader/CSV/empty.csv'], + [true, 'samples/Reader/sampleData/example1.csv'], + [true, 'samples/Reader/sampleData/example2.csv'], ]; } public function testEscapeCharacters() { $reader = (new Csv())->setEscapeCharacter('"'); - $worksheet = $reader->load(__DIR__ . '/../../data/Reader/CSV/backslash.csv') + $worksheet = $reader->load('tests/data/Reader/CSV/backslash.csv') ->getActiveSheet(); $expected = [ @@ -175,13 +175,13 @@ public function testWorkSheetInfo($filename, $encoding) public function providerEncodings() { return [ - ['data/Reader/CSV/encoding.iso88591.csv', 'ISO-8859-1'], - ['data/Reader/CSV/encoding.utf8.csv', 'UTF-8'], - ['data/Reader/CSV/encoding.utf8bom.csv', 'UTF-8'], - ['data/Reader/CSV/encoding.utf16be.csv', 'UTF-16BE'], - ['data/Reader/CSV/encoding.utf16le.csv', 'UTF-16LE'], - ['data/Reader/CSV/encoding.utf32be.csv', 'UTF-32BE'], - ['data/Reader/CSV/encoding.utf32le.csv', 'UTF-32LE'], + ['tests/data/Reader/CSV/encoding.iso88591.csv', 'ISO-8859-1'], + ['tests/data/Reader/CSV/encoding.utf8.csv', 'UTF-8'], + ['tests/data/Reader/CSV/encoding.utf8bom.csv', 'UTF-8'], + ['tests/data/Reader/CSV/encoding.utf16be.csv', 'UTF-16BE'], + ['tests/data/Reader/CSV/encoding.utf16le.csv', 'UTF-16LE'], + ['tests/data/Reader/CSV/encoding.utf32be.csv', 'UTF-32BE'], + ['tests/data/Reader/CSV/encoding.utf32le.csv', 'UTF-32LE'], ]; } @@ -189,7 +189,7 @@ public function testUtf16LineBreak() { $reader = new Csv(); $reader->setInputEncoding('UTF-16BE'); - $spreadsheet = $reader->load('data/Reader/CSV/utf16be.line_break_in_enclosure.csv'); + $spreadsheet = $reader->load('tests/data/Reader/CSV/utf16be.line_break_in_enclosure.csv'); $sheet = $spreadsheet->getActiveSheet(); $expected = <<setSheetIndex(3); - $spreadsheet = $reader->load('data/Reader/CSV/sep.csv'); + $spreadsheet = $reader->load('tests/data/Reader/CSV/sep.csv'); self::assertEquals(';', $reader->getDelimiter()); $sheet = $spreadsheet->getActiveSheet(); self::assertEquals(3, $reader->getSheetIndex()); @@ -238,6 +238,6 @@ public function testReadNonexistentFileName() { $this->expectException(ReaderException::class); $reader = new Csv(); - $reader->load('data/Reader/CSV/encoding.utf8.csvxxx'); + $reader->load('tests/data/Reader/CSV/encoding.utf8.csvxxx'); } } diff --git a/tests/PhpSpreadsheetTests/Reader/HtmlTest.php b/tests/PhpSpreadsheetTests/Reader/HtmlTest.php index a91fe73dc2..14cccb6b84 100644 --- a/tests/PhpSpreadsheetTests/Reader/HtmlTest.php +++ b/tests/PhpSpreadsheetTests/Reader/HtmlTest.php @@ -13,7 +13,7 @@ class HtmlTest extends TestCase { public function testCsvWithAngleBracket() { - $filename = __DIR__ . '/../../data/Reader/HTML/csv_with_angle_bracket.csv'; + $filename = 'tests/data/Reader/HTML/csv_with_angle_bracket.csv'; $reader = new Html(); self::assertFalse($reader->canRead($filename)); } @@ -396,7 +396,7 @@ private function loadHtmlIntoSpreadsheet($filename) public function testRowspanInRendering() { - $filename = './data/Reader/HTML/rowspan.html'; + $filename = 'tests/data/Reader/HTML/rowspan.html'; $reader = new Html(); $spreadsheet = $reader->load($filename); diff --git a/tests/PhpSpreadsheetTests/Reader/OdsTest.php b/tests/PhpSpreadsheetTests/Reader/OdsTest.php index bec85f7bb1..82813b7483 100644 --- a/tests/PhpSpreadsheetTests/Reader/OdsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/OdsTest.php @@ -30,7 +30,7 @@ class OdsTest extends TestCase private function loadOdsTestFile() { if (!$this->spreadsheetOdsTest) { - $filename = __DIR__ . '/../../../samples/templates/OOCalcTest.ods'; + $filename = 'samples/templates/OOCalcTest.ods'; // Load into this instance $reader = new Ods(); @@ -46,7 +46,7 @@ private function loadOdsTestFile() protected function loadDataFile() { if (!$this->spreadsheetData) { - $filename = __DIR__ . '/../../data/Reader/Ods/data.ods'; + $filename = 'tests/data/Reader/Ods/data.ods'; // Load into this instance $reader = new Ods(); @@ -58,7 +58,7 @@ protected function loadDataFile() public function testReadFileProperties() { - $filename = __DIR__ . '/../../data/Reader/Ods/data.ods'; + $filename = 'tests/data/Reader/Ods/data.ods'; // Load into this instance $reader = new Ods(); @@ -234,7 +234,7 @@ public function testLoadOdsWorkbookProperties() 'HereAndNow' => ['type' => Properties::PROPERTY_TYPE_DATE, 'value' => '2019-06-30'], ]; - $filename = './data/Reader/Ods/propertyTest.ods'; + $filename = 'tests/data/Reader/Ods/propertyTest.ods'; $reader = new Ods(); $spreadsheet = $reader->load($filename); diff --git a/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php b/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php index 6bb1f02127..4bf4642950 100644 --- a/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php @@ -35,7 +35,7 @@ public function testValidXML($filename, $expectedResult, $libxmlDisableEntityLoa public function providerValidXML() { $tests = []; - foreach (glob(__DIR__ . '/../../../data/Reader/Xml/XEETestValid*.xml') as $file) { + foreach (glob('tests/data/Reader/Xml/XEETestValid*.xml') as $file) { $filename = realpath($file); $expectedResult = file_get_contents($file); $tests[basename($file) . '_libxml_entity_loader_disabled'] = [$filename, $expectedResult, true]; @@ -67,7 +67,7 @@ public function testInvalidXML($filename, $libxmlDisableEntityLoader) public function providerInvalidXML() { $tests = []; - foreach (glob(__DIR__ . '/../../../data/Reader/Xml/XEETestInvalidUTF*.xml') as $file) { + foreach (glob('tests/data/Reader/Xml/XEETestInvalidUTF*.xml') as $file) { $filename = realpath($file); $tests[basename($file) . '_libxml_entity_loader_disabled'] = [$filename, true]; $tests[basename($file) . '_libxml_entity_loader_enabled'] = [$filename, false]; @@ -114,7 +114,7 @@ public function testSecurityScanWithCallback($filename, $expectedResult) public function providerValidXMLForCallback() { $tests = []; - foreach (glob(__DIR__ . '/../../../data/Reader/Xml/SecurityScannerWithCallback*.xml') as $file) { + foreach (glob('tests/data/Reader/Xml/SecurityScannerWithCallback*.xml') as $file) { $tests[basename($file)] = [realpath($file), file_get_contents($file)]; } @@ -127,7 +127,7 @@ public function testLibxmlDisableEntityLoaderIsRestoredWithoutShutdown() unset($reader); $reader = new \XMLReader(); - $opened = $reader->open(__DIR__ . '/../../../data/Reader/Xml/SecurityScannerWithCallbackExample.xml'); + $opened = $reader->open('tests/data/Reader/Xml/SecurityScannerWithCallbackExample.xml'); $this->assertTrue($opened); } diff --git a/tests/PhpSpreadsheetTests/Reader/XlsTest.php b/tests/PhpSpreadsheetTests/Reader/XlsTest.php index f629fed112..dd6344b4c9 100644 --- a/tests/PhpSpreadsheetTests/Reader/XlsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XlsTest.php @@ -12,7 +12,7 @@ class XlsTest extends TestCase */ public function testLoadXlsSample() { - $filename = './data/Reader/XLS/sample.xls'; + $filename = 'tests/data/Reader/XLS/sample.xls'; $reader = new Xls(); $spreadsheet = $reader->load($filename); self::assertEquals('Title', $spreadsheet->getSheet(0)->getCell('A1')->getValue()); diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php index 54908bc2b6..b77796c61b 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php @@ -22,7 +22,7 @@ protected function tearDown(): void public function testLoadXlsxConditionalFormatting2() { // Make sure Conditionals are read correctly from existing file - $filename = './data/Reader/XLSX/conditionalFormatting2Test.xlsx'; + $filename = 'tests/data/Reader/XLSX/conditionalFormatting2Test.xlsx'; $reader = IOFactory::createReader('Xlsx'); $spreadsheet = $reader->load($filename); $worksheet = $spreadsheet->getActiveSheet(); @@ -56,7 +56,7 @@ public function testLoadXlsxConditionalFormatting2() public function testReloadXlsxConditionalFormatting2() { // Make sure conditionals from existing file are maintained across save - $filename = './data/Reader/XLSX/conditionalFormatting2Test.xlsx'; + $filename = 'tests/data/Reader/XLSX/conditionalFormatting2Test.xlsx'; $outfile = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); $reader = IOFactory::createReader('Xlsx'); $spreadshee1 = $reader->load($filename); diff --git a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php index 7c5b08d95b..efa7af72b5 100644 --- a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php @@ -24,7 +24,7 @@ public function testLoadXlsxWorkbookProperties() 'Refactor Date' => ['type' => Properties::PROPERTY_TYPE_DATE, 'value' => '2019-06-10'], ]; - $filename = './data/Reader/XLSX/propertyTest.xlsx'; + $filename = 'tests/data/Reader/XLSX/propertyTest.xlsx'; $reader = new Xlsx(); $spreadsheet = $reader->load($filename); @@ -57,7 +57,7 @@ public function testLoadXlsxWorkbookProperties() public function testLoadXlsxRowColumnAttributes() { - $filename = './data/Reader/XLSX/rowColumnAttributeTest.xlsx'; + $filename = 'tests/data/Reader/XLSX/rowColumnAttributeTest.xlsx'; $reader = new Xlsx(); $spreadsheet = $reader->load($filename); @@ -88,7 +88,7 @@ public function testLoadXlsxWithStyles() 7 => ['A' => '0070C0', 'C' => '00B0F0', 'E' => '00B050'], ]; - $filename = './data/Reader/XLSX/stylesTest.xlsx'; + $filename = 'tests/data/Reader/XLSX/stylesTest.xlsx'; $reader = new Xlsx(); $spreadsheet = $reader->load($filename); @@ -105,7 +105,7 @@ public function testLoadXlsxWithStyles() public function testLoadXlsxAutofilter() { - $filename = './data/Reader/XLSX/autofilterTest.xlsx'; + $filename = 'tests/data/Reader/XLSX/autofilterTest.xlsx'; $reader = new Xlsx(); $spreadsheet = $reader->load($filename); @@ -122,7 +122,7 @@ public function testLoadXlsxAutofilter() public function testLoadXlsxPageSetup() { - $filename = './data/Reader/XLSX/pageSetupTest.xlsx'; + $filename = 'tests/data/Reader/XLSX/pageSetupTest.xlsx'; $reader = new Xlsx(); $spreadsheet = $reader->load($filename); @@ -141,7 +141,7 @@ public function testLoadXlsxPageSetup() public function testLoadXlsxConditionalFormatting() { - $filename = './data/Reader/XLSX/conditionalFormattingTest.xlsx'; + $filename = 'tests/data/Reader/XLSX/conditionalFormattingTest.xlsx'; $reader = new Xlsx(); $spreadsheet = $reader->load($filename); @@ -160,7 +160,7 @@ public function testLoadXlsxConditionalFormatting() public function testLoadXlsxDataValidation() { - $filename = './data/Reader/XLSX/dataValidationTest.xlsx'; + $filename = 'tests/data/Reader/XLSX/dataValidationTest.xlsx'; $reader = new Xlsx(); $spreadsheet = $reader->load($filename); @@ -176,7 +176,7 @@ public function testLoadXlsxDataValidation() */ public function testLoadXlsxWithoutCellReference() { - $filename = './data/Reader/XLSX/without_cell_reference.xlsx'; + $filename = 'tests/data/Reader/XLSX/without_cell_reference.xlsx'; $reader = new Xlsx(); $reader->load($filename); } @@ -186,7 +186,7 @@ public function testLoadXlsxWithoutCellReference() */ public function testLoadWithReadFilter() { - $filename = './data/Reader/XLSX/without_cell_reference.xlsx'; + $filename = 'tests/data/Reader/XLSX/without_cell_reference.xlsx'; $reader = new Xlsx(); $reader->setReadFilter(new OddColumnReadFilter()); $data = $reader->load($filename)->getActiveSheet()->toArray(); @@ -204,7 +204,7 @@ public function testLoadWithReadFilter() */ public function testLoadXlsxWithDoubleAttrDrawing() { - $filename = './data/Reader/XLSX/double_attr_drawing.xlsx'; + $filename = 'tests/data/Reader/XLSX/double_attr_drawing.xlsx'; $reader = new Xlsx(); $reader->load($filename); } @@ -215,7 +215,7 @@ public function testLoadXlsxWithDoubleAttrDrawing() */ public function testLoadSaveWithEmptyDrawings() { - $filename = __DIR__ . '/../../data/Reader/XLSX/empty_drawing.xlsx'; + $filename = 'tests/data/Reader/XLSX/empty_drawing.xlsx'; $reader = new Xlsx(); $excel = $reader->load($filename); $resultFilename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); diff --git a/tests/PhpSpreadsheetTests/Reader/XmlTest.php b/tests/PhpSpreadsheetTests/Reader/XmlTest.php index f085f437ba..116ec03e8d 100644 --- a/tests/PhpSpreadsheetTests/Reader/XmlTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XmlTest.php @@ -24,7 +24,7 @@ public function testInvalidSimpleXML($filename) public function providerInvalidSimpleXML() { $tests = []; - foreach (glob(__DIR__ . '/../../data/Reader/Xml/XEETestInvalidSimpleXML*.xml') as $file) { + foreach (glob('tests/data/Reader/Xml/XEETestInvalidSimpleXML*.xml') as $file) { $tests[basename($file)] = [realpath($file)]; } @@ -37,7 +37,7 @@ public function providerInvalidSimpleXML() public function testReadHyperlinks() { $reader = new Xml(); - $spreadsheet = $reader->load('../samples/templates/Excel2003XMLTest.xml'); + $spreadsheet = $reader->load('samples/templates/Excel2003XMLTest.xml'); $firstSheet = $spreadsheet->getSheet(0); $hyperlink = $firstSheet->getCell('L1'); @@ -50,7 +50,7 @@ public function testReadHyperlinks() public function testReadWithoutStyle() { $reader = new Xml(); - $spreadsheet = $reader->load(__DIR__ . '/../../data/Reader/Xml/WithoutStyle.xml'); + $spreadsheet = $reader->load('tests/data/Reader/Xml/WithoutStyle.xml'); self::assertSame('Test String 1', $spreadsheet->getActiveSheet()->getCell('A1')->getValue()); } } diff --git a/tests/PhpSpreadsheetTests/Shared/CodePageTest.php b/tests/PhpSpreadsheetTests/Shared/CodePageTest.php index b0e5fbfe30..e3638687c4 100644 --- a/tests/PhpSpreadsheetTests/Shared/CodePageTest.php +++ b/tests/PhpSpreadsheetTests/Shared/CodePageTest.php @@ -21,7 +21,7 @@ public function testCodePageNumberToName($expectedResult, ...$args) public function providerCodePage() { - return require 'data/Shared/CodePage.php'; + return require 'tests/data/Shared/CodePage.php'; } public function testNumberToNameWithInvalidCodePage() diff --git a/tests/PhpSpreadsheetTests/Shared/DateTest.php b/tests/PhpSpreadsheetTests/Shared/DateTest.php index 8d844cba33..14930677cb 100644 --- a/tests/PhpSpreadsheetTests/Shared/DateTest.php +++ b/tests/PhpSpreadsheetTests/Shared/DateTest.php @@ -42,7 +42,7 @@ public function testDateTimeExcelToTimestamp1900($expectedResult, ...$args) public function providerDateTimeExcelToTimestamp1900() { - return require 'data/Shared/Date/ExcelToTimestamp1900.php'; + return require 'tests/data/Shared/Date/ExcelToTimestamp1900.php'; } /** @@ -60,7 +60,7 @@ public function testDateTimeTimestampToExcel1900($expectedResult, ...$args) public function providerDateTimeTimestampToExcel1900() { - return require 'data/Shared/Date/TimestampToExcel1900.php'; + return require 'tests/data/Shared/Date/TimestampToExcel1900.php'; } /** @@ -78,7 +78,7 @@ public function testDateTimeDateTimeToExcel($expectedResult, ...$args) public function providerDateTimeDateTimeToExcel() { - return require 'data/Shared/Date/DateTimeToExcel.php'; + return require 'tests/data/Shared/Date/DateTimeToExcel.php'; } /** @@ -96,7 +96,7 @@ public function testDateTimeFormattedPHPToExcel1900($expectedResult, ...$args) public function providerDateTimeFormattedPHPToExcel1900() { - return require 'data/Shared/Date/FormattedPHPToExcel1900.php'; + return require 'tests/data/Shared/Date/FormattedPHPToExcel1900.php'; } /** @@ -114,7 +114,7 @@ public function testDateTimeExcelToTimestamp1904($expectedResult, ...$args) public function providerDateTimeExcelToTimestamp1904() { - return require 'data/Shared/Date/ExcelToTimestamp1904.php'; + return require 'tests/data/Shared/Date/ExcelToTimestamp1904.php'; } /** @@ -132,7 +132,7 @@ public function testDateTimeTimestampToExcel1904($expectedResult, ...$args) public function providerDateTimeTimestampToExcel1904() { - return require 'data/Shared/Date/TimestampToExcel1904.php'; + return require 'tests/data/Shared/Date/TimestampToExcel1904.php'; } /** @@ -148,7 +148,7 @@ public function testIsDateTimeFormatCode($expectedResult, ...$args) public function providerIsDateTimeFormatCode() { - return require 'data/Shared/Date/FormatCodes.php'; + return require 'tests/data/Shared/Date/FormatCodes.php'; } /** @@ -166,6 +166,6 @@ public function testDateTimeExcelToTimestamp1900Timezone($expectedResult, ...$ar public function providerDateTimeExcelToTimestamp1900Timezone() { - return require 'data/Shared/Date/ExcelToTimestamp1900Timezone.php'; + return require 'tests/data/Shared/Date/ExcelToTimestamp1900Timezone.php'; } } diff --git a/tests/PhpSpreadsheetTests/Shared/FontTest.php b/tests/PhpSpreadsheetTests/Shared/FontTest.php index fc1aa64553..03ff2c4ec3 100644 --- a/tests/PhpSpreadsheetTests/Shared/FontTest.php +++ b/tests/PhpSpreadsheetTests/Shared/FontTest.php @@ -49,7 +49,7 @@ public function testFontSizeToPixels($expectedResult, ...$args) public function providerFontSizeToPixels() { - return require 'data/Shared/FontSizeToPixels.php'; + return require 'tests/data/Shared/FontSizeToPixels.php'; } /** @@ -65,7 +65,7 @@ public function testInchSizeToPixels($expectedResult, ...$args) public function providerInchSizeToPixels() { - return require 'data/Shared/InchSizeToPixels.php'; + return require 'tests/data/Shared/InchSizeToPixels.php'; } /** @@ -81,6 +81,6 @@ public function testCentimeterSizeToPixels($expectedResult, ...$args) public function providerCentimeterSizeToPixels() { - return require 'data/Shared/CentimeterSizeToPixels.php'; + return require 'tests/data/Shared/CentimeterSizeToPixels.php'; } } diff --git a/tests/PhpSpreadsheetTests/Shared/OLEReadTest.php b/tests/PhpSpreadsheetTests/Shared/OLEReadTest.php index a004c4aef5..6135232c1a 100644 --- a/tests/PhpSpreadsheetTests/Shared/OLEReadTest.php +++ b/tests/PhpSpreadsheetTests/Shared/OLEReadTest.php @@ -9,9 +9,9 @@ class OLEReadTest extends TestCase { public function testReadOleStreams() { - $dataDir = './data/Shared/OLERead/'; + $dataDir = 'tests/data/Shared/OLERead/'; $ole = new OLERead(); - $ole->read('./data/Reader/XLS/sample.xls'); + $ole->read('tests/data/Reader/XLS/sample.xls'); self::assertEquals( file_get_contents($dataDir . 'wrkbook'), $ole->getStream($ole->wrkbook) diff --git a/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php b/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php index 65b6134520..e92e0886c2 100644 --- a/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php +++ b/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php @@ -20,6 +20,6 @@ public function testHashPassword($expectedResult, ...$args) public function providerHashPassword() { - return require 'data/Shared/PasswordHashes.php'; + return require 'tests/data/Shared/PasswordHashes.php'; } } diff --git a/tests/PhpSpreadsheetTests/Style/ColorTest.php b/tests/PhpSpreadsheetTests/Style/ColorTest.php index a99c8990df..5bd2f20865 100644 --- a/tests/PhpSpreadsheetTests/Style/ColorTest.php +++ b/tests/PhpSpreadsheetTests/Style/ColorTest.php @@ -20,7 +20,7 @@ public function testGetRed($expectedResult, ...$args) public function providerColorGetRed() { - return require 'data/Style/ColorGetRed.php'; + return require 'tests/data/Style/ColorGetRed.php'; } /** @@ -36,7 +36,7 @@ public function testGetGreen($expectedResult, ...$args) public function providerColorGetGreen() { - return require 'data/Style/ColorGetGreen.php'; + return require 'tests/data/Style/ColorGetGreen.php'; } /** @@ -52,7 +52,7 @@ public function testGetBlue($expectedResult, ...$args) public function providerColorGetBlue() { - return require 'data/Style/ColorGetBlue.php'; + return require 'tests/data/Style/ColorGetBlue.php'; } /** @@ -68,6 +68,6 @@ public function testChangeBrightness($expectedResult, ...$args) public function providerColorChangeBrightness() { - return require 'data/Style/ColorChangeBrightness.php'; + return require 'tests/data/Style/ColorChangeBrightness.php'; } } diff --git a/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php b/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php index e0ab660e6a..9dc20fd72a 100644 --- a/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php +++ b/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php @@ -27,7 +27,7 @@ public function testFormatValueWithMask($expectedResult, ...$args) public function providerNumberFormat() { - return require 'data/Style/NumberFormat.php'; + return require 'tests/data/Style/NumberFormat.php'; } /** @@ -43,6 +43,6 @@ public function testFormatValueWithMaskDate($expectedResult, ...$args) public function providerNumberFormatDates() { - return require 'data/Style/NumberFormatDates.php'; + return require 'tests/data/Style/NumberFormatDates.php'; } } diff --git a/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php b/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php index 3caaba7c9a..5641d330c6 100644 --- a/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php @@ -16,7 +16,7 @@ class ContentTest extends TestCase { - private $samplesPath = __DIR__ . '/../../../data/Writer/Ods'; + private $samplesPath = 'tests/data/Writer/Ods'; /** * @var string diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php index 8e0d654fdf..a826dfaac5 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php @@ -15,7 +15,7 @@ class UnparsedDataTest extends TestCase */ public function testLoadSaveXlsxWithUnparsedData() { - $sampleFilename = './data/Writer/XLSX/form_pass_print.xlsm'; + $sampleFilename = 'tests/data/Writer/XLSX/form_pass_print.xlsm'; $resultFilename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); Settings::setLibXmlLoaderOptions(null); // reset to default options $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index f89fe40832..c37c304a67 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,9 +1,4 @@ Date: Sun, 17 May 2020 18:38:49 +0900 Subject: [PATCH 037/659] Use current PHPUnit configuration xsd --- phpunit.xml.dist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 90b66acda1..63d9e6fbb1 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ - ./tests/PhpSpreadsheetTests + ./tests/PhpSpreadsheetTests From 5f413b8a58092ff4939db5a5486623b2dabc9888 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 17 May 2020 18:51:13 +0900 Subject: [PATCH 038/659] Keep sample bootstrap purely in samples --- bin/generate-document | 4 ++-- samples/Basic/01_Simple_download_ods.php | 2 +- samples/Basic/01_Simple_download_pdf.php | 2 +- samples/Basic/01_Simple_download_xls.php | 2 +- samples/Basic/01_Simple_download_xlsx.php | 2 +- {src => samples}/Bootstrap.php | 0 samples/Header.php | 2 +- tests/bootstrap.php | 2 -- 8 files changed, 7 insertions(+), 9 deletions(-) rename {src => samples}/Bootstrap.php (100%) diff --git a/bin/generate-document b/bin/generate-document index 10ac81182b..d44ec624b5 100755 --- a/bin/generate-document +++ b/bin/generate-document @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\DocumentGenerator; -require_once __DIR__ . '/../src/Bootstrap.php'; +require_once 'vendor/autoload.php'; try { $phpSpreadsheetFunctionsProperty = (new ReflectionClass(Calculation::class))->getProperty('phpSpreadsheetFunctions'); @@ -19,6 +19,6 @@ try { DocumentGenerator::generateFunctionListByName($phpSpreadsheetFunctions) ); } catch (ReflectionException $e) { - fwrite(STDERR, (string)$e); + fwrite(STDERR, (string) $e); exit(1); } diff --git a/samples/Basic/01_Simple_download_ods.php b/samples/Basic/01_Simple_download_ods.php index 0c38a0048c..98b5ca1966 100644 --- a/samples/Basic/01_Simple_download_ods.php +++ b/samples/Basic/01_Simple_download_ods.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Spreadsheet; -require_once __DIR__ . '/../../src/Bootstrap.php'; +require_once __DIR__ . '/../Bootstrap.php'; $helper = new Sample(); if ($helper->isCli()) { diff --git a/samples/Basic/01_Simple_download_pdf.php b/samples/Basic/01_Simple_download_pdf.php index 5f3e71d785..ddd99d29cf 100644 --- a/samples/Basic/01_Simple_download_pdf.php +++ b/samples/Basic/01_Simple_download_pdf.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Spreadsheet; -require_once __DIR__ . '/../../src/Bootstrap.php'; +require_once __DIR__ . '/../Bootstrap.php'; $helper = new Sample(); if ($helper->isCli()) { diff --git a/samples/Basic/01_Simple_download_xls.php b/samples/Basic/01_Simple_download_xls.php index 46d1202221..a7df25c486 100644 --- a/samples/Basic/01_Simple_download_xls.php +++ b/samples/Basic/01_Simple_download_xls.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Spreadsheet; -require_once __DIR__ . '/../../src/Bootstrap.php'; +require_once __DIR__ . '/../Bootstrap.php'; $helper = new Sample(); if ($helper->isCli()) { diff --git a/samples/Basic/01_Simple_download_xlsx.php b/samples/Basic/01_Simple_download_xlsx.php index 93efe73df1..c67a17d065 100644 --- a/samples/Basic/01_Simple_download_xlsx.php +++ b/samples/Basic/01_Simple_download_xlsx.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Spreadsheet; -require_once __DIR__ . '/../../src/Bootstrap.php'; +require_once __DIR__ . '/../Bootstrap.php'; $helper = new Sample(); if ($helper->isCli()) { diff --git a/src/Bootstrap.php b/samples/Bootstrap.php similarity index 100% rename from src/Bootstrap.php rename to samples/Bootstrap.php diff --git a/samples/Header.php b/samples/Header.php index fb8bd986eb..6e0f3b4e7d 100644 --- a/samples/Header.php +++ b/samples/Header.php @@ -6,7 +6,7 @@ error_reporting(E_ALL); -require_once __DIR__ . '/../src/Bootstrap.php'; +require_once __DIR__ . '/Bootstrap.php'; $helper = new Sample(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index c37c304a67..77cd522838 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,5 +4,3 @@ // PHP 5.3 Compat date_default_timezone_set('Europe/London'); - -require_once __DIR__ . '/../src/Bootstrap.php'; From c725128a6882184169f9be89f62e835d4679e026 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 17 May 2020 18:58:32 +0900 Subject: [PATCH 039/659] CSV writer also use common code to open file --- src/PhpSpreadsheet/Writer/BaseWriter.php | 6 +++--- src/PhpSpreadsheet/Writer/Csv.php | 22 +++++++--------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/BaseWriter.php b/src/PhpSpreadsheet/Writer/BaseWriter.php index dc7a04317f..afda5c433e 100644 --- a/src/PhpSpreadsheet/Writer/BaseWriter.php +++ b/src/PhpSpreadsheet/Writer/BaseWriter.php @@ -108,9 +108,9 @@ public function openFileHandle($filename): void return; } - $fileHandle = fopen($filename, 'wb+'); + $fileHandle = $filename ? fopen($filename, 'wb+') : false; if ($fileHandle === false) { - throw new Exception('Could not open file ' . $filename . ' for writing.'); + throw new Exception('Could not open file "' . $filename . '" for writing.'); } $this->fileHandle = $fileHandle; @@ -118,7 +118,7 @@ public function openFileHandle($filename): void } /** - * Close file handle only we opened it ourselves. + * Close file handle only if we opened it ourselves. */ protected function maybeCloseFileHandle(): void { diff --git a/src/PhpSpreadsheet/Writer/Csv.php b/src/PhpSpreadsheet/Writer/Csv.php index cabfe450ec..4344a5bd7c 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -4,7 +4,6 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Spreadsheet; -use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; class Csv extends BaseWriter { @@ -91,17 +90,7 @@ public function save($pFilename) Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE); // Open file - if (is_resource($pFilename)) { - $fileHandle = $pFilename; - } elseif (!$pFilename) { - $fileHandle = false; - } else { - $fileHandle = fopen($pFilename, 'wb+'); - } - - if ($fileHandle === false) { - throw new WriterException("Could not open file $pFilename for writing."); - } + $this->openFileHandle($pFilename); if ($this->excelCompatibility) { $this->setUseBOM(true); // Enforce UTF-8 BOM Header @@ -110,13 +99,15 @@ public function save($pFilename) $this->setDelimiter(';'); // Set delimiter to a semi-colon $this->setLineEnding("\r\n"); } + if ($this->useBOM) { // Write the UTF-8 BOM code if required - fwrite($fileHandle, "\xEF\xBB\xBF"); + fwrite($this->fileHandle, "\xEF\xBB\xBF"); } + if ($this->includeSeparatorLine) { // Write the separator line if required - fwrite($fileHandle, 'sep=' . $this->getDelimiter() . $this->lineEnding); + fwrite($this->fileHandle, 'sep=' . $this->getDelimiter() . $this->lineEnding); } // Identify the range that we need to extract from the worksheet @@ -128,9 +119,10 @@ public function save($pFilename) // Convert the row to an array... $cellsArray = $sheet->rangeToArray('A' . $row . ':' . $maxCol . $row, '', $this->preCalculateFormulas); // ... and write to the file - $this->writeLine($fileHandle, $cellsArray[0]); + $this->writeLine($this->fileHandle, $cellsArray[0]); } + $this->maybeCloseFileHandle(); Calculation::setArrayReturnType($saveArrayReturnType); Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); } From d49567aad038fc8183678ab5b2e78caa2e177b7d Mon Sep 17 00:00:00 2001 From: Chris Wolcott Date: Sat, 18 Apr 2020 10:37:45 -0400 Subject: [PATCH 040/659] File containing a chart can be opened by Excel 2003/2013/2019 All chart examples passed the displayBlanksAs parameter as 0 instead of 'gap'. I added a constants EMPTY_AS_GAP, EMPTY_AS_ZERO and EMPTY_AS_SPAN to the DataSeries and then change all chart samples to use this new constant. Fixes #1337 Closes #1448 --- CHANGELOG.md | 2 +- samples/Chart/33_Chart_create_area.php | 2 +- samples/Chart/33_Chart_create_bar_stacked.php | 2 +- samples/Chart/33_Chart_create_column.php | 2 +- samples/Chart/33_Chart_create_column_2.php | 2 +- samples/Chart/33_Chart_create_composite.php | 2 +- samples/Chart/33_Chart_create_line.php | 2 +- samples/Chart/33_Chart_create_multiple_charts.php | 2 +- samples/Chart/33_Chart_create_pie.php | 2 +- samples/Chart/33_Chart_create_pie_custom_colors.php | 2 +- samples/Chart/33_Chart_create_radar.php | 2 +- samples/Chart/33_Chart_create_scatter.php | 2 +- samples/Chart/33_Chart_create_stock.php | 2 +- src/PhpSpreadsheet/Chart/Chart.php | 2 +- src/PhpSpreadsheet/Chart/DataSeries.php | 4 ++++ 15 files changed, 18 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3ba3de84c..deeb00a60f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Fixed -- ... +- Fix Chart samples by updating chart parameter from 0 to DataSeries::EMPTY_AS_GAP [#1448](https://github.com/PHPOffice/PhpSpreadsheet/pull/1448) ### Changed diff --git a/samples/Chart/33_Chart_create_area.php b/samples/Chart/33_Chart_create_area.php index 4478d2ddd6..860c16a6b7 100644 --- a/samples/Chart/33_Chart_create_area.php +++ b/samples/Chart/33_Chart_create_area.php @@ -83,7 +83,7 @@ $legend, // legend $plotArea, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs null, // xAxisLabel $yAxisLabel // yAxisLabel ); diff --git a/samples/Chart/33_Chart_create_bar_stacked.php b/samples/Chart/33_Chart_create_bar_stacked.php index 7ba4d8deb8..0aa211a954 100644 --- a/samples/Chart/33_Chart_create_bar_stacked.php +++ b/samples/Chart/33_Chart_create_bar_stacked.php @@ -86,7 +86,7 @@ $legend, // legend $plotArea, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs null, // xAxisLabel $yAxisLabel // yAxisLabel ); diff --git a/samples/Chart/33_Chart_create_column.php b/samples/Chart/33_Chart_create_column.php index 9ffe9d3f68..694082a46e 100644 --- a/samples/Chart/33_Chart_create_column.php +++ b/samples/Chart/33_Chart_create_column.php @@ -86,7 +86,7 @@ $legend, // legend $plotArea, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs null, // xAxisLabel $yAxisLabel // yAxisLabel ); diff --git a/samples/Chart/33_Chart_create_column_2.php b/samples/Chart/33_Chart_create_column_2.php index bba9210ab8..f5a529b9be 100644 --- a/samples/Chart/33_Chart_create_column_2.php +++ b/samples/Chart/33_Chart_create_column_2.php @@ -95,7 +95,7 @@ $legend, // legend $plotArea, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs $xAxisLabel, // xAxisLabel $yAxisLabel // yAxisLabel ); diff --git a/samples/Chart/33_Chart_create_composite.php b/samples/Chart/33_Chart_create_composite.php index 83dc34a928..dfeacae3ae 100644 --- a/samples/Chart/33_Chart_create_composite.php +++ b/samples/Chart/33_Chart_create_composite.php @@ -139,7 +139,7 @@ $legend, // legend $plotArea, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs null, // xAxisLabel null // yAxisLabel ); diff --git a/samples/Chart/33_Chart_create_line.php b/samples/Chart/33_Chart_create_line.php index bdaf01117f..feae2f27b4 100644 --- a/samples/Chart/33_Chart_create_line.php +++ b/samples/Chart/33_Chart_create_line.php @@ -84,7 +84,7 @@ $legend, // legend $plotArea, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs null, // xAxisLabel $yAxisLabel // yAxisLabel ); diff --git a/samples/Chart/33_Chart_create_multiple_charts.php b/samples/Chart/33_Chart_create_multiple_charts.php index 10a11e13ed..d0de5db419 100644 --- a/samples/Chart/33_Chart_create_multiple_charts.php +++ b/samples/Chart/33_Chart_create_multiple_charts.php @@ -158,7 +158,7 @@ $legend2, // legend $plotArea2, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs null, // xAxisLabel $yAxisLabel2 // yAxisLabel ); diff --git a/samples/Chart/33_Chart_create_pie.php b/samples/Chart/33_Chart_create_pie.php index d4ec0752e2..54d5916bca 100644 --- a/samples/Chart/33_Chart_create_pie.php +++ b/samples/Chart/33_Chart_create_pie.php @@ -84,7 +84,7 @@ $legend1, // legend $plotArea1, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs null, // xAxisLabel null // yAxisLabel - Pie charts don't have a Y-Axis ); diff --git a/samples/Chart/33_Chart_create_pie_custom_colors.php b/samples/Chart/33_Chart_create_pie_custom_colors.php index 727a0cde8c..0e9ce4b731 100644 --- a/samples/Chart/33_Chart_create_pie_custom_colors.php +++ b/samples/Chart/33_Chart_create_pie_custom_colors.php @@ -162,7 +162,7 @@ null, // legend $plotArea2, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs null, // xAxisLabel null // yAxisLabel - Like Pie charts, Donut charts don't have a Y-Axis ); diff --git a/samples/Chart/33_Chart_create_radar.php b/samples/Chart/33_Chart_create_radar.php index e57914abb3..1c5c435f38 100644 --- a/samples/Chart/33_Chart_create_radar.php +++ b/samples/Chart/33_Chart_create_radar.php @@ -96,7 +96,7 @@ $legend, // legend $plotArea, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs null, // xAxisLabel null // yAxisLabel - Radar charts don't have a Y-Axis ); diff --git a/samples/Chart/33_Chart_create_scatter.php b/samples/Chart/33_Chart_create_scatter.php index 12fc2bdc52..02fa866d21 100644 --- a/samples/Chart/33_Chart_create_scatter.php +++ b/samples/Chart/33_Chart_create_scatter.php @@ -80,7 +80,7 @@ $legend, // legend $plotArea, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs null, // xAxisLabel $yAxisLabel // yAxisLabel ); diff --git a/samples/Chart/33_Chart_create_stock.php b/samples/Chart/33_Chart_create_stock.php index 7a9f727452..4e8ffe8e5e 100644 --- a/samples/Chart/33_Chart_create_stock.php +++ b/samples/Chart/33_Chart_create_stock.php @@ -92,7 +92,7 @@ $legend, // legend $plotArea, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs $xAxisLabel, // xAxisLabel $yAxisLabel // yAxisLabel ); diff --git a/src/PhpSpreadsheet/Chart/Chart.php b/src/PhpSpreadsheet/Chart/Chart.php index 59c9ed5d67..bc42c8546d 100644 --- a/src/PhpSpreadsheet/Chart/Chart.php +++ b/src/PhpSpreadsheet/Chart/Chart.php @@ -156,7 +156,7 @@ class Chart * @param null|GridLines $majorGridlines * @param null|GridLines $minorGridlines */ - public function __construct($name, Title $title = null, Legend $legend = null, PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = 'gap', Title $xAxisLabel = null, Title $yAxisLabel = null, Axis $xAxis = null, Axis $yAxis = null, GridLines $majorGridlines = null, GridLines $minorGridlines = null) + public function __construct($name, Title $title = null, Legend $legend = null, PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = DataSeries::EMPTY_AS_GAP, Title $xAxisLabel = null, Title $yAxisLabel = null, Axis $xAxis = null, Axis $yAxis = null, GridLines $majorGridlines = null, GridLines $minorGridlines = null) { $this->name = $name; $this->title = $title; diff --git a/src/PhpSpreadsheet/Chart/DataSeries.php b/src/PhpSpreadsheet/Chart/DataSeries.php index c20efabe80..79f4e8d16b 100644 --- a/src/PhpSpreadsheet/Chart/DataSeries.php +++ b/src/PhpSpreadsheet/Chart/DataSeries.php @@ -40,6 +40,10 @@ class DataSeries const STYLE_MARKER = 'marker'; const STYLE_FILLED = 'filled'; + const EMPTY_AS_GAP = 'gap'; + const EMPTY_AS_ZERO = 'zero'; + const EMPTY_AS_SPAN = 'span'; + /** * Series Plot Type. * From 15bd764a086c63ea0ee9d3eb4ff1cee947166d80 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 17 May 2020 19:35:18 +0900 Subject: [PATCH 041/659] A few more invalid displayBlanksAs --- samples/Chart/33_Chart_create_multiple_charts.php | 2 +- samples/Chart/33_Chart_create_pie.php | 2 +- samples/Chart/33_Chart_create_pie_custom_colors.php | 2 +- samples/templates/chartSpreadsheet.php | 2 +- src/PhpSpreadsheet/Chart/Chart.php | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/samples/Chart/33_Chart_create_multiple_charts.php b/samples/Chart/33_Chart_create_multiple_charts.php index d0de5db419..c25328a814 100644 --- a/samples/Chart/33_Chart_create_multiple_charts.php +++ b/samples/Chart/33_Chart_create_multiple_charts.php @@ -83,7 +83,7 @@ $legend1, // legend $plotArea1, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs null, // xAxisLabel $yAxisLabel1 // yAxisLabel ); diff --git a/samples/Chart/33_Chart_create_pie.php b/samples/Chart/33_Chart_create_pie.php index 54d5916bca..0df4114361 100644 --- a/samples/Chart/33_Chart_create_pie.php +++ b/samples/Chart/33_Chart_create_pie.php @@ -154,7 +154,7 @@ null, // legend $plotArea2, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs null, // xAxisLabel null // yAxisLabel - Like Pie charts, Donut charts don't have a Y-Axis ); diff --git a/samples/Chart/33_Chart_create_pie_custom_colors.php b/samples/Chart/33_Chart_create_pie_custom_colors.php index 0e9ce4b731..137e6e75c0 100644 --- a/samples/Chart/33_Chart_create_pie_custom_colors.php +++ b/samples/Chart/33_Chart_create_pie_custom_colors.php @@ -90,7 +90,7 @@ $legend1, // legend $plotArea1, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs null, // xAxisLabel null // yAxisLabel - Pie charts don't have a Y-Axis ); diff --git a/samples/templates/chartSpreadsheet.php b/samples/templates/chartSpreadsheet.php index 84c8c9567a..44d7b54356 100644 --- a/samples/templates/chartSpreadsheet.php +++ b/samples/templates/chartSpreadsheet.php @@ -83,7 +83,7 @@ $legend, // legend $plotArea, // plotArea true, // plotVisibleOnly - 0, // displayBlanksAs + DataSeries::EMPTY_AS_GAP, // displayBlanksAs null, // xAxisLabel $yAxisLabel // yAxisLabel ); diff --git a/src/PhpSpreadsheet/Chart/Chart.php b/src/PhpSpreadsheet/Chart/Chart.php index bc42c8546d..7064160eb7 100644 --- a/src/PhpSpreadsheet/Chart/Chart.php +++ b/src/PhpSpreadsheet/Chart/Chart.php @@ -68,7 +68,7 @@ class Chart * * @var string */ - private $displayBlanksAs = '0'; + private $displayBlanksAs = DataSeries::EMPTY_AS_GAP; /** * Chart Asix Y as. @@ -148,7 +148,7 @@ class Chart * @param null|Legend $legend * @param null|PlotArea $plotArea * @param mixed $plotVisibleOnly - * @param mixed $displayBlanksAs + * @param string $displayBlanksAs * @param null|Title $xAxisLabel * @param null|Title $yAxisLabel * @param null|Axis $xAxis From 8eaceb0f9246233e0dd84df78bdaa23eb5f1d872 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 17 May 2020 19:42:28 +0900 Subject: [PATCH 042/659] Fix return type docblock for the Cells::get() PHPStorm inspections and PHPStan display an incorrect hint or error if the special type `null` is not specified. Closes #1398 --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Collection/Cells.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index deeb00a60f..3eeeed15c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Fixed - Fix Chart samples by updating chart parameter from 0 to DataSeries::EMPTY_AS_GAP [#1448](https://github.com/PHPOffice/PhpSpreadsheet/pull/1448) +- Fix return type in docblock for the Cells::get() [#1398](https://github.com/PHPOffice/PhpSpreadsheet/pull/1398) ### Changed diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php index 127403d998..b9017e0e14 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -426,7 +426,7 @@ public function add($pCoord, Cell $cell) * * @param string $pCoord Coordinate of the cell * - * @return \PhpOffice\PhpSpreadsheet\Cell\Cell Cell that was found, or null if not found + * @return null|\PhpOffice\PhpSpreadsheet\Cell\Cell Cell that was found, or null if not found */ public function get($pCoord) { From 9ae521cdd40aac4b18c83f3aba1d1257c7d8a291 Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 17 May 2020 03:50:01 -0700 Subject: [PATCH 043/659] Fix RATE, PRICE, XIRR, and XNPV Functions (#1456) There were about 20 skipped tests for RATE and PRICE marked "This test should be fixed". This change does that by fixing the code for those functions, validating the existing tests, and adding new ones. XIRR and XNPV are also substantially changed. As part of this change, the following functions also have minor changes: - isValidFrequency - COUPDAYBS - COUPNUM (additional tests) - DB - DDB PhpUnit reports 100% coverage for all the changed functions. Since I was dealing with skipped tests, I also fixed tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest, which was being skipped in Windows. I also delete the temporary file which it creates. There is now only one remaining test which is skipped - ODS Reader is not complete enough to run some tests against it. Unfortunately, that test is too complicated for me to deal with now. In researching this change, I found several places in the code where special code was added for Gnumeric claiming: - Gnumeric does not handle free-format string dates - Gnumeric adds extra options, not available in Excel, for the frequency parameter for functions such as YIELD - Gnumeric rounds the results for DB and DDB to 2 decimal places None of these claims is true, at least not on a recent version of Gnumeric, and the code which supports these differences is removed. There did not appear to be any tests targeted for these supposed properties of Gnumeric. The PRICE function needed relatively minor changes - mostly additional tests for invalid input. The main problem with the PRICE tests is that Excel appears to have a bug. The algorithm is published: https://support.office.com/en-us/article/price-function-3ea9deac-8dfa-436f-a7c8-17ea02c21b0a The results that Excel returns for basis codes 2 and 3 appear to be incorrect in many cases. I have segregated these tests into a new test PRICE3. The results of these tests agree with the published algorithm, and to the results for LibreOffice and Gnumeric. The results returned by Excel do not agree with them. The tests which remain in the test PRICE all use basis codes other than 2 or 3, and all agree with Excel, LibreOffice, and Gnumeric. For the RATE function, there appears to be a problem with how the secant method was implemented. I studied the implementation of RATE in Python numpy, and adapted its implementation of secant method. The results now agree with numpy, and, more important, with Excel. XIRR, which calls XNPV, permits its dates to be earlier than the start date, whereas XNPV does not. I dealt with this by renaming the existing XNPV function to xnpvOrdered, adding a parameter to indicate whether start date has to be earliest. XNPV calls the new function with that parameter set to TRUE, and XIRR calls it with the parameter set to FALSE. Some additional error checking was added to xnpvOrdered, and also to XIRR. XIRR tests benefited from increasing the value of FINANCIAL_MAX_ITERATIONS. Finally, since this change is very test-related: samples/Basic/13_CalculationCyclicFormulae PhpUnit started reporting an error like "too much regression". The test deals with an infinite cyclic formula, and allowed the calculation engine to run for 100 cycles. The actual number of cycles seems irrelevant for the purpose of this test. I changed it to 15, and PhpUnit no longer complains. --- src/PhpSpreadsheet/Calculation/DateTime.php | 6 +- src/PhpSpreadsheet/Calculation/Financial.php | 360 ++++++++++-------- .../Calculation/FinancialTest.php | 60 ++- .../Writer/Xlsx/LocaleFloatsTest.php | 3 +- tests/data/Calculation/Financial/COUPNUM.php | 35 ++ tests/data/Calculation/Financial/PRICE.php | 177 +++++++-- tests/data/Calculation/Financial/PRICE3.php | 78 ++++ tests/data/Calculation/Financial/RATE.php | 34 ++ tests/data/Calculation/Financial/XIRR.php | 79 +++- tests/data/Calculation/Financial/XNPV.php | 83 ++++ 10 files changed, 718 insertions(+), 197 deletions(-) create mode 100644 tests/data/Calculation/Financial/PRICE3.php create mode 100644 tests/data/Calculation/Financial/XNPV.php diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index 4f85edeb9c..9e1e4cf593 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -59,17 +59,13 @@ private static function dateDiff360($startDay, $startMonth, $startYear, $endDay, /** * getDateValue. * - * @param string $dateValue + * @param mixed $dateValue * * @return mixed Excel date/time serial value, or string if error */ public static function getDateValue($dateValue) { if (!is_numeric($dateValue)) { - if ((is_string($dateValue)) && - (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)) { - return Functions::VALUE(); - } if ((is_object($dateValue)) && ($dateValue instanceof \DateTimeInterface)) { $dateValue = Date::PHPToExcel($dateValue); } else { diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php index 412b7a620e..1a49ac1cd9 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -6,7 +6,7 @@ class Financial { - const FINANCIAL_MAX_ITERATIONS = 32; + const FINANCIAL_MAX_ITERATIONS = 128; const FINANCIAL_PRECISION = 1.0e-08; @@ -50,10 +50,6 @@ private static function isValidFrequency($frequency) if (($frequency == 1) || ($frequency == 2) || ($frequency == 4)) { return true; } - if ((Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) && - (($frequency == 6) || ($frequency == 12))) { - return true; - } return false; } @@ -133,10 +129,6 @@ private static function interestAndPrincipal($rate = 0, $per = 0, $nper = 0, $pv * 1 Annual * 2 Semi-Annual * 4 Quarterly - * If working in Gnumeric Mode, the following frequency options are - * also available - * 6 Bimonthly - * 12 Monthly * @param int $basis The type of day count to use. * 0 or omitted US (NASD) 30/360 * 1 Actual/actual @@ -390,10 +382,6 @@ public static function AMORLINC($cost, $purchased, $firstPeriod, $salvage, $peri * 1 Annual * 2 Semi-Annual * 4 Quarterly - * If working in Gnumeric Mode, the following frequency options are - * also available - * 6 Bimonthly - * 12 Monthly * @param int $basis The type of day count to use. * 0 or omitted US (NASD) 30/360 * 1 Actual/actual @@ -426,6 +414,10 @@ public static function COUPDAYBS($settlement, $maturity, $frequency, $basis = 0) $daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis); $prev = self::couponFirstPeriodDate($settlement, $maturity, $frequency, false); + if ($basis == 1) { + return abs(DateTime::DAYS($prev, $settlement)); + } + return DateTime::YEARFRAC($prev, $settlement, $basis) * $daysPerYear; } @@ -449,10 +441,6 @@ public static function COUPDAYBS($settlement, $maturity, $frequency, $basis = 0) * 1 Annual * 2 Semi-Annual * 4 Quarterly - * If working in Gnumeric Mode, the following frequency options are - * also available - * 6 Bimonthly - * 12 Monthly * @param int $basis The type of day count to use. * 0 or omitted US (NASD) 30/360 * 1 Actual/actual @@ -523,10 +511,6 @@ public static function COUPDAYS($settlement, $maturity, $frequency, $basis = 0) * 1 Annual * 2 Semi-Annual * 4 Quarterly - * If working in Gnumeric Mode, the following frequency options are - * also available - * 6 Bimonthly - * 12 Monthly * @param int $basis The type of day count to use. * 0 or omitted US (NASD) 30/360 * 1 Actual/actual @@ -582,10 +566,6 @@ public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis = 0 * 1 Annual * 2 Semi-Annual * 4 Quarterly - * If working in Gnumeric Mode, the following frequency options are - * also available - * 6 Bimonthly - * 12 Monthly * @param int $basis The type of day count to use. * 0 or omitted US (NASD) 30/360 * 1 Actual/actual @@ -640,10 +620,6 @@ public static function COUPNCD($settlement, $maturity, $frequency, $basis = 0) * 1 Annual * 2 Semi-Annual * 4 Quarterly - * If working in Gnumeric Mode, the following frequency options are - * also available - * 6 Bimonthly - * 12 Monthly * @param int $basis The type of day count to use. * 0 or omitted US (NASD) 30/360 * 1 Actual/actual @@ -673,19 +649,9 @@ public static function COUPNUM($settlement, $maturity, $frequency, $basis = 0) return Functions::NAN(); } - $daysPerYear = self::daysPerYear(DateTime::YEAR($settlement), $basis); - $daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis) * $daysPerYear; + $yearsBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, 0); - switch ($frequency) { - case 1: // annual payments - case 2: // half-yearly - case 4: // quarterly - case 6: // bimonthly - case 12: // monthly - return ceil($daysBetweenSettlementAndMaturity / $daysPerYear * $frequency); - } - - return Functions::VALUE(); + return ceil($yearsBetweenSettlementAndMaturity * $frequency); } /** @@ -708,10 +674,6 @@ public static function COUPNUM($settlement, $maturity, $frequency, $basis = 0) * 1 Annual * 2 Semi-Annual * 4 Quarterly - * If working in Gnumeric Mode, the following frequency options are - * also available - * 6 Bimonthly - * 12 Monthly * @param int $basis The type of day count to use. * 0 or omitted US (NASD) 30/360 * 1 Actual/actual @@ -894,6 +856,7 @@ public static function DB($cost, $salvage, $life, $period, $month = 12) // Loop through each period calculating the depreciation $previousDepreciation = 0; + $depreciation = 0; for ($per = 1; $per <= $period; ++$per) { if ($per == 1) { $depreciation = $cost * $fixedDepreciationRate * $month / 12; @@ -904,9 +867,6 @@ public static function DB($cost, $salvage, $life, $period, $month = 12) } $previousDepreciation += $depreciation; } - if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) { - $depreciation = round($depreciation, 2); - } return $depreciation; } @@ -962,13 +922,11 @@ public static function DDB($cost, $salvage, $life, $period, $factor = 2.0) // Loop through each period calculating the depreciation $previousDepreciation = 0; + $depreciation = 0; for ($per = 1; $per <= $period; ++$per) { $depreciation = min(($cost - $previousDepreciation) * ($factor / $life), ($cost - $salvage - $previousDepreciation)); $previousDepreciation += $depreciation; } - if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) { - $depreciation = round($depreciation, 2); - } return $depreciation; } @@ -1650,22 +1608,54 @@ public static function PPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0) return $interestAndPrincipal[1]; } + private static function validatePrice($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis) + { + if (is_string($settlement)) { + return Functions::VALUE(); + } + if (is_string($maturity)) { + return Functions::VALUE(); + } + if (!is_numeric($rate)) { + return Functions::VALUE(); + } + if (!is_numeric($yield)) { + return Functions::VALUE(); + } + if (!is_numeric($redemption)) { + return Functions::VALUE(); + } + if (!is_numeric($frequency)) { + return Functions::VALUE(); + } + if (!is_numeric($basis)) { + return Functions::VALUE(); + } + + return ''; + } + public static function PRICE($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis = 0) { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); - $rate = (float) Functions::flattenSingleValue($rate); - $yield = (float) Functions::flattenSingleValue($yield); - $redemption = (float) Functions::flattenSingleValue($redemption); - $frequency = (int) Functions::flattenSingleValue($frequency); - $basis = ($basis === null) ? 0 : (int) Functions::flattenSingleValue($basis); + $rate = Functions::flattenSingleValue($rate); + $yield = Functions::flattenSingleValue($yield); + $redemption = Functions::flattenSingleValue($redemption); + $frequency = Functions::flattenSingleValue($frequency); + $basis = Functions::flattenSingleValue($basis); - if (is_string($settlement = DateTime::getDateValue($settlement))) { - return Functions::VALUE(); - } - if (is_string($maturity = DateTime::getDateValue($maturity))) { - return Functions::VALUE(); + $settlement = DateTime::getDateValue($settlement); + $maturity = DateTime::getDateValue($maturity); + $rslt = self::validatePrice($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis); + if ($rslt) { + return $rslt; } + $rate = (float) $rate; + $yield = (float) $yield; + $redemption = (float) $redemption; + $frequency = (int) $frequency; + $basis = (int) $basis; if (($settlement > $maturity) || (!self::isValidFrequency($frequency)) || @@ -1865,7 +1855,7 @@ public static function PV($rate = 0, $nper = 0, $pmt = 0, $fv = 0, $type = 0) * @param float $guess Your guess for what the rate will be. * If you omit guess, it is assumed to be 10 percent. * - * @return float + * @return float|string */ public static function RATE($nper, $pmt, $pv, $fv = 0.0, $type = 0, $guess = 0.1) { @@ -1877,38 +1867,39 @@ public static function RATE($nper, $pmt, $pv, $fv = 0.0, $type = 0, $guess = 0.1 $guess = ($guess === null) ? 0.1 : Functions::flattenSingleValue($guess); $rate = $guess; - if (abs($rate) < self::FINANCIAL_PRECISION) { - $y = $pv * (1 + $nper * $rate) + $pmt * (1 + $rate * $type) * $nper + $fv; - } else { - $f = exp($nper * log(1 + $rate)); - $y = $pv * $f + $pmt * (1 / $rate + $type) * ($f - 1) + $fv; - } - $y0 = $pv + $pmt * $nper + $fv; - $y1 = $pv * $f + $pmt * (1 / $rate + $type) * ($f - 1) + $fv; - - // find root by secant method - $i = $x0 = 0.0; - $x1 = $rate; - while ((abs($y0 - $y1) > self::FINANCIAL_PRECISION) && ($i < self::FINANCIAL_MAX_ITERATIONS)) { - $rate = ($y1 * $x0 - $y0 * $x1) / ($y1 - $y0); - $x0 = $x1; - $x1 = $rate; - if (($nper * abs($pmt)) > ($pv - $fv)) { - $x1 = abs($x1); - } - if (abs($rate) < self::FINANCIAL_PRECISION) { - $y = $pv * (1 + $nper * $rate) + $pmt * (1 + $rate * $type) * $nper + $fv; - } else { - $f = exp($nper * log(1 + $rate)); - $y = $pv * $f + $pmt * (1 / $rate + $type) * ($f - 1) + $fv; + // rest of code adapted from python/numpy + $close = false; + $iter = 0; + while (!$close && $iter < self::FINANCIAL_MAX_ITERATIONS) { + $nextdiff = self::rateNextGuess($rate, $nper, $pmt, $pv, $fv, $type); + if (!is_numeric($nextdiff)) { + break; } + $rate1 = $rate - $nextdiff; + $close = abs($rate1 - $rate) < self::FINANCIAL_PRECISION; + ++$iter; + $rate = $rate1; + } + + return $close ? $rate : Functions::NAN(); + } - $y0 = $y1; - $y1 = $y; - ++$i; + private static function rateNextGuess($rate, $nper, $pmt, $pv, $fv, $type) + { + if ($rate == 0) { + return Functions::NAN(); + } + $tt1 = pow($rate + 1, $nper); + $tt2 = pow($rate + 1, $nper - 1); + $numerator = $fv + $tt1 * $pv + $pmt * ($tt1 - 1) * ($rate * $type + 1) / $rate; + $denominator = $nper * $tt2 * $pv - $pmt * ($tt1 - 1) * ($rate * $type + 1) / ($rate * $rate) + + $nper * $pmt * $tt2 * ($rate * $type + 1) / $rate + + $pmt * ($tt1 - 1) * $type / $rate; + if ($denominator == 0) { + return Functions::NAN(); } - return $rate; + return $numerator / $denominator; } /** @@ -2183,31 +2174,40 @@ public static function TBILLYIELD($settlement, $maturity, $price) return Functions::VALUE(); } - /** - * XIRR. - * - * Returns the internal rate of return for a schedule of cash flows that is not necessarily periodic. - * - * Excel Function: - * =XIRR(values,dates,guess) - * - * @param float[] $values A series of cash flow payments - * The series of values must contain at least one positive value & one negative value - * @param mixed[] $dates A series of payment dates - * The first payment date indicates the beginning of the schedule of payments - * All other dates must be later than this date, but they may occur in any order - * @param float $guess An optional guess at the expected answer - * - * @return float|mixed|string - */ - public static function XIRR($values, $dates, $guess = 0.1) + private static function bothNegAndPos($neg, $pos) + { + return $neg && $pos; + } + + private static function xirrPart2(&$values) + { + $valCount = count($values); + $foundpos = false; + $foundneg = false; + for ($i = 0; $i < $valCount; ++$i) { + $fld = $values[$i]; + if (!is_numeric($fld)) { + return Functions::VALUE(); + } elseif ($fld > 0) { + $foundpos = true; + } elseif ($fld < 0) { + $foundneg = true; + } + } + if (!self::bothNegAndPos($foundneg, $foundpos)) { + return Functions::NAN(); + } + + return ''; + } + + private static function xirrPart1(&$values, &$dates) { if ((!is_array($values)) && (!is_array($dates))) { - return Functions::VALUE(); + return Functions::NA(); } $values = Functions::flattenArray($values); $dates = Functions::flattenArray($dates); - $guess = Functions::flattenSingleValue($guess); if (count($values) != count($dates)) { return Functions::NAN(); } @@ -2219,35 +2219,13 @@ public static function XIRR($values, $dates, $guess = 0.1) return Functions::VALUE(); } } - if (min($dates) != $dates[0]) { - return Functions::NAN(); - } - // create an initial range, with a root somewhere between 0 and guess - $x1 = 0.0; - $x2 = $guess; - $f1 = self::XNPV($x1, $values, $dates); - if (!is_numeric($f1)) { - return $f1; - } - $f2 = self::XNPV($x2, $values, $dates); - if (!is_numeric($f2)) { - return $f2; - } - for ($i = 0; $i < self::FINANCIAL_MAX_ITERATIONS; ++$i) { - if (($f1 * $f2) < 0.0) { - break; - } elseif (abs($f1) < abs($f2)) { - $f1 = self::XNPV($x1 += 1.6 * ($x1 - $x2), $values, $dates); - } else { - $f2 = self::XNPV($x2 += 1.6 * ($x2 - $x1), $values, $dates); - } - } - if (($f1 * $f2) > 0.0) { - return Functions::NAN(); - } + return self::xirrPart2($values); + } - $f = self::XNPV($x1, $values, $dates); + private static function xirrPart3($values, $dates, $x1, $x2) + { + $f = self::xnpvOrdered($x1, $values, $dates, false); if ($f < 0.0) { $rtb = $x1; $dx = $x2 - $x1; @@ -2256,19 +2234,74 @@ public static function XIRR($values, $dates, $guess = 0.1) $dx = $x1 - $x2; } + $rslt = Functions::VALUE(); for ($i = 0; $i < self::FINANCIAL_MAX_ITERATIONS; ++$i) { $dx *= 0.5; $x_mid = $rtb + $dx; - $f_mid = self::XNPV($x_mid, $values, $dates); + $f_mid = self::xnpvOrdered($x_mid, $values, $dates, false); if ($f_mid <= 0.0) { $rtb = $x_mid; } if ((abs($f_mid) < self::FINANCIAL_PRECISION) || (abs($dx) < self::FINANCIAL_PRECISION)) { - return $x_mid; + $rslt = $x_mid; + + break; } } - return Functions::VALUE(); + return $rslt; + } + + /** + * XIRR. + * + * Returns the internal rate of return for a schedule of cash flows that is not necessarily periodic. + * + * Excel Function: + * =XIRR(values,dates,guess) + * + * @param float[] $values A series of cash flow payments + * The series of values must contain at least one positive value & one negative value + * @param mixed[] $dates A series of payment dates + * The first payment date indicates the beginning of the schedule of payments + * All other dates must be later than this date, but they may occur in any order + * @param float $guess An optional guess at the expected answer + * + * @return float|mixed|string + */ + public static function XIRR($values, $dates, $guess = 0.1) + { + $rslt = self::xirrPart1($values, $dates); + if ($rslt) { + return $rslt; + } + + // create an initial range, with a root somewhere between 0 and guess + $guess = Functions::flattenSingleValue($guess); + $x1 = 0.0; + $x2 = $guess ? $guess : 0.1; + $f1 = self::xnpvOrdered($x1, $values, $dates, false); + $f2 = self::xnpvOrdered($x2, $values, $dates, false); + $found = false; + for ($i = 0; $i < self::FINANCIAL_MAX_ITERATIONS; ++$i) { + if (!is_numeric($f1) || !is_numeric($f2)) { + break; + } + if (($f1 * $f2) < 0.0) { + $found = true; + + break; + } elseif (abs($f1) < abs($f2)) { + $f1 = self::xnpvOrdered($x1 += 1.6 * ($x1 - $x2), $values, $dates, false); + } else { + $f2 = self::xnpvOrdered($x2 += 1.6 * ($x2 - $x1), $values, $dates, false); + } + } + if (!$found) { + return Functions::NAN(); + } + + return self::xirrPart3($values, $dates, $x1, $x2); } /** @@ -2293,32 +2326,61 @@ public static function XIRR($values, $dates, $guess = 0.1) */ public static function XNPV($rate, $values, $dates) { - $rate = Functions::flattenSingleValue($rate); + return self::xnpvOrdered($rate, $values, $dates, true); + } + + private static function validateXnpv($rate, $values, $dates) + { if (!is_numeric($rate)) { return Functions::VALUE(); } - if ((!is_array($values)) || (!is_array($dates))) { - return Functions::VALUE(); - } - $values = Functions::flattenArray($values); - $dates = Functions::flattenArray($dates); $valCount = count($values); if ($valCount != count($dates)) { return Functions::NAN(); } - if ((min($values) > 0) || (max($values) < 0)) { + if ($valCount > 1 && ((min($values) > 0) || (max($values) < 0))) { return Functions::NAN(); } + $date0 = DateTime::getDateValue($dates[0]); + if (is_string($date0)) { + return Functions::VALUE(); + } + return ''; + } + + private static function xnpvOrdered($rate, $values, $dates, $ordered = true) + { + $rate = Functions::flattenSingleValue($rate); + $values = Functions::flattenArray($values); + $dates = Functions::flattenArray($dates); + $valCount = count($values); + $date0 = DateTime::getDateValue($dates[0]); + $rslt = self::validateXnpv($rate, $values, $dates); + if ($rslt) { + return $rslt; + } $xnpv = 0.0; for ($i = 0; $i < $valCount; ++$i) { if (!is_numeric($values[$i])) { return Functions::VALUE(); } - $xnpv += $values[$i] / pow(1 + $rate, DateTime::DATEDIF($dates[0], $dates[$i], 'd') / 365); + $datei = DateTime::getDateValue($dates[$i]); + if (is_string($datei)) { + return Functions::VALUE(); + } + if ($date0 > $datei) { + $dif = $ordered ? Functions::NAN() : -DateTime::DATEDIF($datei, $date0, 'd'); + } else { + $dif = DateTime::DATEDIF($date0, $datei, 'd'); + } + if (!is_numeric($dif)) { + return $dif; + } + $xnpv += $values[$i] / pow(1 + $rate, $dif / 365); } - return (is_finite($xnpv)) ? $xnpv : Functions::VALUE(); + return is_finite($xnpv) ? $xnpv : Functions::VALUE(); } /** diff --git a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php index e9a62af37c..f1d51e18da 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php @@ -436,10 +436,8 @@ public function providerNPV() */ public function testPRICE($expectedResult, ...$args) { - $this->markTestIncomplete('TODO: This test should be fixed'); - $result = Financial::PRICE(...$args); - self::assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-7); } public function providerPRICE() @@ -447,6 +445,25 @@ public function providerPRICE() return require 'tests/data/Calculation/Financial/PRICE.php'; } + /** + * @dataProvider providerPRICE3 + * + * @param mixed $expectedResult + */ + public function testPRICE3($expectedResult, ...$args) + { + // These results (PRICE function with basis codes 2 and 3) + // agree with published algorithm, LibreOffice, and Gnumeric. + // They do not agree with Excel. + $result = Financial::PRICE(...$args); + self::assertEqualsWithDelta($expectedResult, $result, 1E-7); + } + + public function providerPRICE3() + { + return require 'data/Calculation/Financial/PRICE3.php'; + } + /** * @dataProvider providerPRICEDISC * @@ -486,8 +503,6 @@ public function providerPV() */ public function testRATE($expectedResult, ...$args) { - $this->markTestIncomplete('TODO: This test should be fixed'); - $result = Financial::RATE(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } @@ -506,7 +521,15 @@ public function providerRATE() public function testXIRR($expectedResult, $message, ...$args) { $result = Financial::XIRR(...$args); - self::assertEqualsWithDelta($expectedResult, $result, Financial::FINANCIAL_PRECISION, $message); + if (is_numeric($result) && is_numeric($expectedResult)) { + if ($expectedResult != 0) { + $frac = $result / $expectedResult; + if ($frac > 0.999999 && $frac < 1.000001) { + $result = $expectedResult; + } + } + } + self::assertEquals($expectedResult, $result, $message); } public function providerXIRR() @@ -514,6 +537,31 @@ public function providerXIRR() return require 'tests/data/Calculation/Financial/XIRR.php'; } + /** + * @dataProvider providerXNPV + * + * @param mixed $expectedResult + * @param mixed $message + */ + public function testXNPV($expectedResult, $message, ...$args) + { + $result = Financial::XNPV(...$args); + if (is_numeric($result) && is_numeric($expectedResult)) { + if ($expectedResult != 0) { + $frac = $result / $expectedResult; + if ($frac > 0.999999 && $frac < 1.000001) { + $result = $expectedResult; + } + } + } + self::assertEquals($expectedResult, $result, $message); + } + + public function providerXNPV() + { + return require 'data/Calculation/Financial/XNPV.php'; + } + /** * @dataProvider providerPDURATION * diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php index 1b088f0b80..f3f0eda2df 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php @@ -14,7 +14,7 @@ protected function setUp(): void { $this->currentLocale = setlocale(LC_ALL, '0'); - if (!setlocale(LC_ALL, 'fr_FR.UTF-8')) { + if (!setlocale(LC_ALL, 'fr_FR.UTF-8', 'fra_fra')) { $this->localeAdjusted = false; return; @@ -45,6 +45,7 @@ public function testLocaleFloatsCorrectlyConvertedByWriter() $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); $spreadsheet = $reader->load($filename); + unlink($filename); $result = $spreadsheet->getActiveSheet()->getCell('A1')->getValue(); diff --git a/tests/data/Calculation/Financial/COUPNUM.php b/tests/data/Calculation/Financial/COUPNUM.php index 683fc317e3..719ad733e5 100644 --- a/tests/data/Calculation/Financial/COUPNUM.php +++ b/tests/data/Calculation/Financial/COUPNUM.php @@ -73,4 +73,39 @@ 4, 0, ], + [ + 16, + '1-Apr-2012', + '31-Mar-2020', + 2, + 0, + ], + [ + 16, + '1-Apr-2012', + '31-Mar-2020', + 2, + 1, + ], + [ + 16, + '1-Apr-2012', + '31-Mar-2020', + 2, + 2, + ], + [ + 16, + '1-Apr-2012', + '31-Mar-2020', + 2, + 3, + ], + [ + 16, + '1-Apr-2012', + '31-Mar-2020', + 2, + 4, + ], ]; diff --git a/tests/data/Calculation/Financial/PRICE.php b/tests/data/Calculation/Financial/PRICE.php index f64f29e096..7fe2934018 100644 --- a/tests/data/Calculation/Financial/PRICE.php +++ b/tests/data/Calculation/Financial/PRICE.php @@ -1,96 +1,215 @@ 0, return NUM', + 0.10, + [1000.0, 1000.1], + ['2018-06-30', '2018-07-30'], + ], + [ + '#NUM!', + 'If maximum value < 0, return NUM', + 0.10, + [-1000.0, -1000.1], + ['2018-06-30', '2018-07-30'], + ], + [ + '#VALUE!', + 'If any value is non-numeric, return VALUE', + 0.10, + [-1000.0, 1000.1, "x"], + ['2018-06-30', '2018-07-30', '2018-08-30'], + ], + [ + '#VALUE!', + 'If first date is non-numeric, return VALUE', + 0.10, + [-1000.0, 1000.1, 1000.2], + ['2018-06x30', '2018-07-30', '2018-08-30'], + ], + [ + '#VALUE!', + 'If any other date is non-numeric, return VALUE', + 0.10, + [-1000.0, 1000.1, 1000.2], + ['2018-06-30', '2018-07-30', '2018-08z30'], + ], + [ + '#NUM!', + 'If any date is before first date, return NUM', + 0.10, + [-1000.0, 1000.1, 1000.2], + ['2018-06-30', '2018-07-30', '2018-05-30'], + ], + [ + 772830.734, + 'XNPV calculation #1 is incorrect', + 0.10, + [0, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000], + ['2018-06-30', '2018-12-31', '2019-12-31', '2020-12-31', '2021-12-31', '2022-12-31', '2023-12-31', '2024-12-31', '2025-12-31', '2026-12-31', '2027-12-31'], + ], + [ + 22.257507852701, + 'Gnumeric gets this right, Excel returns #NUM, Libre returns incorrect result', + -0.10, + [-100.0, 110.0], + ['2019-12-31', '2020-12-31'], + ], +]; From 414e5695efe738c2a5580b2d1748f76711672e6e Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 17 May 2020 19:52:34 +0900 Subject: [PATCH 044/659] Update CHANGELOG --- CHANGELOG.md | 1 + tests/PhpSpreadsheetTests/Calculation/FinancialTest.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3eeeed15c0..fc9946b085 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Fix Chart samples by updating chart parameter from 0 to DataSeries::EMPTY_AS_GAP [#1448](https://github.com/PHPOffice/PhpSpreadsheet/pull/1448) - Fix return type in docblock for the Cells::get() [#1398](https://github.com/PHPOffice/PhpSpreadsheet/pull/1398) +- Fix RATE, PRICE, XIRR, and XNPV Functions [#1456](https://github.com/PHPOffice/PhpSpreadsheet/pull/1456) ### Changed diff --git a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php index f1d51e18da..5c3928eb4d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php @@ -461,7 +461,7 @@ public function testPRICE3($expectedResult, ...$args) public function providerPRICE3() { - return require 'data/Calculation/Financial/PRICE3.php'; + return require 'tests/data/Calculation/Financial/PRICE3.php'; } /** @@ -559,7 +559,7 @@ public function testXNPV($expectedResult, $message, ...$args) public function providerXNPV() { - return require 'data/Calculation/Financial/XNPV.php'; + return require 'tests/data/Calculation/Financial/XNPV.php'; } /** From 4f6d4af39626d5c1cef76f446ee743896d7d6982 Mon Sep 17 00:00:00 2001 From: Owen Leibman Date: Sun, 3 May 2020 07:06:12 -0700 Subject: [PATCH 045/659] Save Excel 2010+ Functions Properly For functions introduced in Excel 2010 and beyond, Excel saves them in formulas with the xlfn_ prefix. PhpSpreadsheet does not do this; as a result, when a spreadsheet so created is opened, the cells which use the new functions display a #NAME? error. This the cause of bug report 1246: https://github.com/PHPOffice/PhpSpreadsheet/issues/1246 This change corrects that problem when the Xlsx writer encounters a 2010+ formula for a cell or a conditional style. A new class Writer/Xlsx/Xlfn, with 2 static methods, is introduced to facilitate this change. As part of the testing for this, I found some additional problems. When an unknown function name is used, Excel generates a #NAME? error. However, when an unknown function is used in PhpSpreadsheet: - if there are no parameters, it returns #VALUE!, which is wrong - if there are parameters, it throws an exception, which is horrible Both of these situations will now return #NAME? Tests have been added for these situations. The MODE (and MODE.SNGL) function is not quite in alignment with Excel. MODE(3, 3, 4, 4) returns 3 in both Excel and PhpSpreadsheet. However, MODE(4, 3, 3, 4) returns 4 in Excel, but 3 in PhpSpreadsheet. Both situations will now match Excel's result. Also, Excel allows its parameters for MODE to be an array, but PhpSpreadsheet did not; it now will. There had not been any tests for MODE. Now there are. The SHEET and SHEETS functions were introduced in Excel 2013, but were not introduced in PhpSpreadsheet. They are now introduced as DUMMY functions so that they can be parsed appropriately. Finally, in common with the "rate" changes for which I am creating a pull request at the same time as this one: samples/Basic/13_CalculationCyclicFormulae PhpUnit started reporting an error like "too much regression". The test deals with an infinite cyclic formula, and allowed the calculation engine to run for 100 cycles. The actual number of cycles seems irrelevant for the purpose of this test. I changed it to 15, and PhpUnit no longer complains. --- CHANGELOG.md | 1 + .../Calculation/Calculation.php | 62 ++-- .../Calculation/Statistical.php | 27 +- .../Calculation/functionlist.txt | 2 + src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 294 ++++++++++-------- src/PhpSpreadsheet/Writer/Xlsx/Xlfn.php | 159 ++++++++++ .../Calculation/CalculationTest.php | 15 + .../Functions/Statistical/ModeTest.php | 43 +++ .../Calculation/XlfnFunctionsTest.php | 99 ++++++ .../Functional/ConditionalTextTest.php | 107 +++++++ tests/data/Calculation/Statistical/MODE.php | 11 + 11 files changed, 665 insertions(+), 155 deletions(-) create mode 100644 src/PhpSpreadsheet/Writer/Xlsx/Xlfn.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ModeTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/XlfnFunctionsTest.php create mode 100644 tests/PhpSpreadsheetTests/Functional/ConditionalTextTest.php create mode 100644 tests/data/Calculation/Statistical/MODE.php diff --git a/CHANGELOG.md b/CHANGELOG.md index fc9946b085..bbc3909215 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Fix Chart samples by updating chart parameter from 0 to DataSeries::EMPTY_AS_GAP [#1448](https://github.com/PHPOffice/PhpSpreadsheet/pull/1448) - Fix return type in docblock for the Cells::get() [#1398](https://github.com/PHPOffice/PhpSpreadsheet/pull/1398) - Fix RATE, PRICE, XIRR, and XNPV Functions [#1456](https://github.com/PHPOffice/PhpSpreadsheet/pull/1456) +- Save Excel 2010+ functions properly in XLSX [#1461](https://github.com/PHPOffice/PhpSpreadsheet/pull/1461) ### Changed diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index e1469b1f47..447ae588f2 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -1853,6 +1853,16 @@ class Calculation 'functionCall' => [MathTrig::class, 'SERIESSUM'], 'argumentCount' => '4', ], + 'SHEET' => [ + 'category' => Category::CATEGORY_INFORMATION, + 'functionCall' => [Functions::class, 'DUMMY'], + 'argumentCount' => '0,1', + ], + 'SHEETS' => [ + 'category' => Category::CATEGORY_INFORMATION, + 'functionCall' => [Functions::class, 'DUMMY'], + 'argumentCount' => '0,1', + ], 'SIGN' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, 'functionCall' => [MathTrig::class, 'SIGN'], @@ -2247,6 +2257,10 @@ class Calculation 'argumentCount' => '*', 'functionCall' => [__CLASS__, 'mkMatrix'], ], + 'NAME.ERROR' => [ + 'argumentCount' => '*', + 'functionCall' => [Functions::class, 'NAME'], + ], ]; public function __construct(Spreadsheet $spreadsheet = null) @@ -3615,33 +3629,33 @@ private function _parseFormula($formula, Cell $pCell = null) $val = preg_replace('/\s/u', '', $val); if (isset(self::$phpSpreadsheetFunctions[strtoupper($matches[1])]) || isset(self::$controlFunctions[strtoupper($matches[1])])) { // it's a function $valToUpper = strtoupper($val); - // here $matches[1] will contain values like "IF" - // and $val "IF(" - if ($this->branchPruningEnabled && ($valToUpper == 'IF(')) { // we handle a new if - $pendingStoreKey = $this->getUnusedBranchStoreKey(); - $pendingStoreKeysStack[] = $pendingStoreKey; - $expectingConditionMap[$pendingStoreKey] = true; - $parenthesisDepthMap[$pendingStoreKey] = 0; - } else { // this is not a if but we good deeper - if (!empty($pendingStoreKey) && array_key_exists($pendingStoreKey, $parenthesisDepthMap)) { - $parenthesisDepthMap[$pendingStoreKey] += 1; - } + } else { + $valToUpper = 'NAME.ERROR('; + } + // here $matches[1] will contain values like "IF" + // and $val "IF(" + if ($this->branchPruningEnabled && ($valToUpper == 'IF(')) { // we handle a new if + $pendingStoreKey = $this->getUnusedBranchStoreKey(); + $pendingStoreKeysStack[] = $pendingStoreKey; + $expectingConditionMap[$pendingStoreKey] = true; + $parenthesisDepthMap[$pendingStoreKey] = 0; + } else { // this is not an if but we go deeper + if (!empty($pendingStoreKey) && array_key_exists($pendingStoreKey, $parenthesisDepthMap)) { + $parenthesisDepthMap[$pendingStoreKey] += 1; } + } - $stack->push('Function', $valToUpper, null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot); - // tests if the function is closed right after opening - $ax = preg_match('/^\s*(\s*\))/ui', substr($formula, $index + $length), $amatch); - if ($ax) { - $stack->push('Operand Count for Function ' . $valToUpper . ')', 0, null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot); - $expectingOperator = true; - } else { - $stack->push('Operand Count for Function ' . $valToUpper . ')', 1, null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot); - $expectingOperator = false; - } - $stack->push('Brace', '('); - } else { // it's a var w/ implicit multiplication - $output[] = ['type' => 'Value', 'value' => $matches[1], 'reference' => null]; + $stack->push('Function', $valToUpper, null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot); + // tests if the function is closed right after opening + $ax = preg_match('/^\s*\)/u', substr($formula, $index + $length)); + if ($ax) { + $stack->push('Operand Count for Function ' . $valToUpper . ')', 0, null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot); + $expectingOperator = true; + } else { + $stack->push('Operand Count for Function ' . $valToUpper . ')', 1, null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot); + $expectingOperator = false; } + $stack->push('Brace', '('); } elseif (preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $val, $matches)) { // Watch for this case-change when modifying to allow cell references in different worksheets... // Should only be applied to the actual cell column, not the worksheet name diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php index b1c7fb020e..2b7fd8c92d 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -2468,11 +2468,27 @@ public static function MINIFS(...$args) private static function modeCalc($data) { $frequencyArray = []; + $index = 0; + $maxfreq = 0; + $maxfreqkey = ''; + $maxfreqdatum = ''; foreach ($data as $datum) { $found = false; + ++$index; foreach ($frequencyArray as $key => $value) { if ((string) $value['value'] == (string) $datum) { ++$frequencyArray[$key]['frequency']; + $freq = $frequencyArray[$key]['frequency']; + if ($freq > $maxfreq) { + $maxfreq = $freq; + $maxfreqkey = $key; + $maxfreqdatum = $datum; + } elseif ($freq == $maxfreq) { + if ($frequencyArray[$key]['index'] < $frequencyArray[$maxfreqkey]['index']) { + $maxfreqkey = $key; + $maxfreqdatum = $datum; + } + } $found = true; break; @@ -2482,21 +2498,16 @@ private static function modeCalc($data) $frequencyArray[] = [ 'value' => $datum, 'frequency' => 1, + 'index' => $index, ]; } } - foreach ($frequencyArray as $key => $value) { - $frequencyList[$key] = $value['frequency']; - $valueList[$key] = $value['value']; - } - array_multisort($frequencyList, SORT_DESC, $valueList, SORT_ASC, SORT_NUMERIC, $frequencyArray); - - if ($frequencyArray[0]['frequency'] == 1) { + if ($maxfreq <= 1) { return Functions::NA(); } - return $frequencyArray[0]['value']; + return $maxfreqdatum; } /** diff --git a/src/PhpSpreadsheet/Calculation/functionlist.txt b/src/PhpSpreadsheet/Calculation/functionlist.txt index 77fd4ee0e4..2556ec9028 100644 --- a/src/PhpSpreadsheet/Calculation/functionlist.txt +++ b/src/PhpSpreadsheet/Calculation/functionlist.txt @@ -316,6 +316,8 @@ SEC SECH SECOND SERIESSUM +SHEET +SHEETS SIGN SIN SINH diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 0c042fe138..febee54dd4 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -449,6 +449,55 @@ private function writeSheetProtection(XMLWriter $objWriter, PhpspreadsheetWorksh $objWriter->endElement(); } + private static function writeAttributeIf(XMLWriter $objWriter, $condition, string $attr, string $val): void + { + if ($condition) { + $objWriter->writeAttribute($attr, $val); + } + } + + private static function writeElementIf(XMLWriter $objWriter, $condition, string $attr, string $val): void + { + if ($condition) { + $objWriter->writeElement($attr, $val); + } + } + + private static function writeOtherCondElements(XMLWriter $objWriter, Conditional $conditional, string $cellCoordinate): void + { + if ($conditional->getConditionType() == Conditional::CONDITION_CELLIS + || $conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT + || $conditional->getConditionType() == Conditional::CONDITION_EXPRESSION) { + foreach ($conditional->getConditions() as $formula) { + // Formula + $objWriter->writeElement('formula', Xlfn::addXlfn($formula)); + } + } elseif ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSBLANKS) { + // formula copied from ms xlsx xml source file + $objWriter->writeElement('formula', 'LEN(TRIM(' . $cellCoordinate . '))=0'); + } elseif ($conditional->getConditionType() == Conditional::CONDITION_NOTCONTAINSBLANKS) { + // formula copied from ms xlsx xml source file + $objWriter->writeElement('formula', 'LEN(TRIM(' . $cellCoordinate . '))>0'); + } + } + + private static function writeTextCondElements(XMLWriter $objWriter, Conditional $conditional, string $cellCoordinate): void + { + $txt = $conditional->getText(); + if ($txt !== null) { + $objWriter->writeAttribute('text', $txt); + if ($conditional->getOperatorType() == Conditional::OPERATOR_CONTAINSTEXT) { + $objWriter->writeElement('formula', 'NOT(ISERROR(SEARCH("' . $txt . '",' . $cellCoordinate . ')))'); + } elseif ($conditional->getOperatorType() == Conditional::OPERATOR_BEGINSWITH) { + $objWriter->writeElement('formula', 'LEFT(' . $cellCoordinate . ',' . strlen($txt) . ')="' . $txt . '"'); + } elseif ($conditional->getOperatorType() == Conditional::OPERATOR_ENDSWITH) { + $objWriter->writeElement('formula', 'RIGHT(' . $cellCoordinate . ',' . strlen($txt) . ')="' . $txt . '"'); + } elseif ($conditional->getOperatorType() == Conditional::OPERATOR_NOTCONTAINS) { + $objWriter->writeElement('formula', 'ISERROR(SEARCH("' . $txt . '",' . $cellCoordinate . '))'); + } + } + } + /** * Write ConditionalFormatting. * @@ -478,49 +527,20 @@ private function writeConditionalFormatting(XMLWriter $objWriter, Phpspreadsheet $objWriter->writeAttribute('dxfId', $this->getParentWriter()->getStylesConditionalHashTable()->getIndexForHashCode($conditional->getHashCode())); $objWriter->writeAttribute('priority', $id++); - if (($conditional->getConditionType() == Conditional::CONDITION_CELLIS || $conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT) - && $conditional->getOperatorType() != Conditional::OPERATOR_NONE) { - $objWriter->writeAttribute('operator', $conditional->getOperatorType()); - } + self::writeAttributeif( + $objWriter, + ($conditional->getConditionType() == Conditional::CONDITION_CELLIS || $conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT) + && $conditional->getOperatorType() != Conditional::OPERATOR_NONE, + 'operator', + $conditional->getOperatorType() + ); - if ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT - && $conditional->getText() !== null) { - $objWriter->writeAttribute('text', $conditional->getText()); - } - - if ($conditional->getStopIfTrue()) { - $objWriter->writeAttribute('stopIfTrue', '1'); - } + self::writeAttributeIf($objWriter, $conditional->getStopIfTrue(), 'stopIfTrue', '1'); - if ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT - && $conditional->getOperatorType() == Conditional::OPERATOR_CONTAINSTEXT - && $conditional->getText() !== null) { - $objWriter->writeElement('formula', 'NOT(ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . ')))'); - } elseif ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT - && $conditional->getOperatorType() == Conditional::OPERATOR_BEGINSWITH - && $conditional->getText() !== null) { - $objWriter->writeElement('formula', 'LEFT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"'); - } elseif ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT - && $conditional->getOperatorType() == Conditional::OPERATOR_ENDSWITH - && $conditional->getText() !== null) { - $objWriter->writeElement('formula', 'RIGHT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"'); - } elseif ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT - && $conditional->getOperatorType() == Conditional::OPERATOR_NOTCONTAINS - && $conditional->getText() !== null) { - $objWriter->writeElement('formula', 'ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . '))'); - } elseif ($conditional->getConditionType() == Conditional::CONDITION_CELLIS - || $conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT - || $conditional->getConditionType() == Conditional::CONDITION_EXPRESSION) { - foreach ($conditional->getConditions() as $formula) { - // Formula - $objWriter->writeElement('formula', $formula); - } - } elseif ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSBLANKS) { - // formula copied from ms xlsx xml source file - $objWriter->writeElement('formula', 'LEN(TRIM(' . $cellCoordinate . '))=0'); - } elseif ($conditional->getConditionType() == Conditional::CONDITION_NOTCONTAINSBLANKS) { - // formula copied from ms xlsx xml source file - $objWriter->writeElement('formula', 'LEN(TRIM(' . $cellCoordinate . '))>0'); + if ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT) { + self::writeTextCondElements($objWriter, $conditional, $cellCoordinate); + } else { + self::writeOtherCondElements($objWriter, $conditional, $cellCoordinate); } $objWriter->endElement(); @@ -1028,15 +1048,115 @@ private function writeSheetData(XMLWriter $objWriter, PhpspreadsheetWorksheet $p $objWriter->endElement(); } + /** + * @param XMLWriter $objWriter + * @param string $mappedType + * @param RichText|string $cellValue + */ + private function writeCellInlineStr(XMLWriter $objWriter, string $mappedType, $cellValue): void + { + $objWriter->writeAttribute('t', $mappedType); + if (!$cellValue instanceof RichText) { + $objWriter->writeElement('t', StringHelper::controlCharacterPHP2OOXML(htmlspecialchars($cellValue))); + } elseif ($cellValue instanceof RichText) { + $objWriter->startElement('is'); + $this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $cellValue); + $objWriter->endElement(); + } + } + + /** + * @param XMLWriter $objWriter + * @param string $mappedType + * @param RichText|string $cellValue + * @param string[] $pFlippedStringTable + */ + private function writeCellString(XMLWriter $objWriter, string $mappedType, $cellValue, array $pFlippedStringTable): void + { + $objWriter->writeAttribute('t', $mappedType); + if (!$cellValue instanceof RichText) { + self::writeElementIf($objWriter, isset($pFlippedStringTable[$cellValue]), 'v', $pFlippedStringTable[$cellValue]); + } else { + $objWriter->writeElement('v', $pFlippedStringTable[$cellValue->getHashCode()]); + } + } + + /** + * @param XMLWriter $objWriter + * @param float|int $cellValue + */ + private function writeCellNumeric(XMLWriter $objWriter, $cellValue): void + { + //force a decimal to be written if the type is float + if (is_float($cellValue)) { + // force point as decimal separator in case current locale uses comma + $cellValue = str_replace(',', '.', (string) $cellValue); + if (strpos($cellValue, '.') === false) { + $cellValue = $cellValue . '.0'; + } + } + $objWriter->writeElement('v', $cellValue); + } + + private function writeCellBoolean(XMLWriter $objWriter, string $mappedType, bool $cellValue): void + { + $objWriter->writeAttribute('t', $mappedType); + $objWriter->writeElement('v', $cellValue ? '1' : '0'); + } + + private function writeCellError(XMLWriter $objWriter, string $mappedType, string $cellValue, string $formulaerr = '#NULL!'): void + { + $objWriter->writeAttribute('t', $mappedType); + $cellIsFormula = substr($cellValue, 0, 1) === '='; + self::writeElementIf($objWriter, $cellIsFormula, 'f', Xlfn::addXlfnStripEquals($cellValue)); + $objWriter->writeElement('v', $cellIsFormula ? $formulaerr : $cellValue); + } + + private function writeCellFormula(XMLWriter $objWriter, string $cellValue, Cell $pCell): void + { + $calculatedValue = $this->getParentWriter()->getPreCalculateFormulas() ? $pCell->getCalculatedValue() : $cellValue; + if (is_string($calculatedValue)) { + if (substr($calculatedValue, 0, 1) === '#') { + $this->writeCellError($objWriter, 'e', $cellValue, $calculatedValue); + + return; + } + $objWriter->writeAttribute('t', 'str'); + } elseif (is_bool($calculatedValue)) { + $objWriter->writeAttribute('t', 'b'); + } + // array values are not yet supported + //$attributes = $pCell->getFormulaAttributes(); + //if (($attributes['t'] ?? null) === 'array') { + // $objWriter->startElement('f'); + // $objWriter->writeAttribute('t', 'array'); + // $objWriter->writeAttribute('ref', $pCellAddress); + // $objWriter->writeAttribute('aca', '1'); + // $objWriter->writeAttribute('ca', '1'); + // $objWriter->text(substr($cellValue, 1)); + // $objWriter->endElement(); + //} else { + // $objWriter->writeElement('f', Xlfn::addXlfnStripEquals($cellValue)); + //} + $objWriter->writeElement('f', Xlfn::addXlfnStripEquals($cellValue)); + self::writeElementIf( + $objWriter, + $this->getParentWriter()->getOffice2003Compatibility() === false, + 'v', + ($this->getParentWriter()->getPreCalculateFormulas() && !is_array($calculatedValue) && substr($calculatedValue, 0, 1) !== '#') + ? StringHelper::formatNumber($calculatedValue) : '0' + ); + } + /** * Write Cell. * * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet - * @param Cell $pCellAddress Cell Address + * @param string $pCellAddress Cell Address * @param string[] $pFlippedStringTable String table (flipped), for faster index searching */ - private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet, $pCellAddress, array $pFlippedStringTable) + private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet, string $pCellAddress, array $pFlippedStringTable) { // Cell $pCell = $pSheet->getCell($pCellAddress); @@ -1044,9 +1164,8 @@ private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet $objWriter->writeAttribute('r', $pCellAddress); // Sheet styles - if ($pCell->getXfIndex() != '') { - $objWriter->writeAttribute('s', $pCell->getXfIndex()); - } + $xfi = $pCell->getXfIndex(); + self::writeAttributeIf($objWriter, $xfi, 's', $xfi); // If cell value is supplied, write cell value $cellValue = $pCell->getValue(); @@ -1054,101 +1173,30 @@ private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet // Map type $mappedType = $pCell->getDataType(); - // Write data type depending on its type - switch (strtolower($mappedType)) { - case 'inlinestr': // Inline string - case 's': // String - case 'b': // Boolean - $objWriter->writeAttribute('t', $mappedType); - - break; - case 'f': // Formula - $calculatedValue = ($this->getParentWriter()->getPreCalculateFormulas()) ? - $pCell->getCalculatedValue() : $cellValue; - if (is_string($calculatedValue)) { - $objWriter->writeAttribute('t', 'str'); - } elseif (is_bool($calculatedValue)) { - $objWriter->writeAttribute('t', 'b'); - } - - break; - case 'e': // Error - $objWriter->writeAttribute('t', $mappedType); - } - // Write data depending on its type switch (strtolower($mappedType)) { case 'inlinestr': // Inline string - if (!$cellValue instanceof RichText) { - $objWriter->writeElement('t', StringHelper::controlCharacterPHP2OOXML(htmlspecialchars($cellValue))); - } elseif ($cellValue instanceof RichText) { - $objWriter->startElement('is'); - $this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $cellValue); - $objWriter->endElement(); - } + $this->writeCellInlineStr($objWriter, $mappedType, $cellValue); break; case 's': // String - if (!$cellValue instanceof RichText) { - if (isset($pFlippedStringTable[$cellValue])) { - $objWriter->writeElement('v', $pFlippedStringTable[$cellValue]); - } - } elseif ($cellValue instanceof RichText) { - $objWriter->writeElement('v', $pFlippedStringTable[$cellValue->getHashCode()]); - } + $this->writeCellString($objWriter, $mappedType, $cellValue, $pFlippedStringTable); break; case 'f': // Formula - $attributes = $pCell->getFormulaAttributes(); - if (($attributes['t'] ?? null) === 'array') { - $objWriter->startElement('f'); - $objWriter->writeAttribute('t', 'array'); - $objWriter->writeAttribute('ref', $pCellAddress); - $objWriter->writeAttribute('aca', '1'); - $objWriter->writeAttribute('ca', '1'); - $objWriter->text(substr($cellValue, 1)); - $objWriter->endElement(); - } else { - $objWriter->writeElement('f', substr($cellValue, 1)); - } - if ($this->getParentWriter()->getOffice2003Compatibility() === false) { - if ($this->getParentWriter()->getPreCalculateFormulas()) { - if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) !== '#') { - $objWriter->writeElement('v', StringHelper::formatNumber($calculatedValue)); - } else { - $objWriter->writeElement('v', '0'); - } - } else { - $objWriter->writeElement('v', '0'); - } - } + $this->writeCellFormula($objWriter, $cellValue, $pCell); break; case 'n': // Numeric - //force a decimal to be written if the type is float - if (is_float($cellValue)) { - // force point as decimal separator in case current locale uses comma - $cellValue = str_replace(',', '.', (string) $cellValue); - if (strpos($cellValue, '.') === false) { - $cellValue = $cellValue . '.0'; - } - } - $objWriter->writeElement('v', $cellValue); + $this->writeCellNumeric($objWriter, $cellValue); break; case 'b': // Boolean - $objWriter->writeElement('v', ($cellValue ? '1' : '0')); + $this->writeCellBoolean($objWriter, $mappedType, $cellValue); break; case 'e': // Error - if (substr($cellValue, 0, 1) === '=') { - $objWriter->writeElement('f', substr($cellValue, 1)); - $objWriter->writeElement('v', substr($cellValue, 1)); - } else { - $objWriter->writeElement('v', $cellValue); - } - - break; + $this->writeCellError($objWriter, $mappedType, $cellValue); } } diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Xlfn.php b/src/PhpSpreadsheet/Writer/Xlsx/Xlfn.php new file mode 100644 index 0000000000..8f7c07e83a --- /dev/null +++ b/src/PhpSpreadsheet/Writer/Xlsx/Xlfn.php @@ -0,0 +1,159 @@ +getActiveSheet(); + $sheet->setCellValue('A1', '=gzorg()'); + $sheet->setCellValue('A2', '=mode.gzorg(1)'); + $sheet->setCellValue('A3', '=gzorg(1,2)'); + $sheet->setCellValue('A4', '=3+IF(gzorg(),1,2)'); + self::assertEquals('#NAME?', $sheet->getCell('A1')->getCalculatedValue()); + self::assertEquals('#NAME?', $sheet->getCell('A2')->getCalculatedValue()); + self::assertEquals('#NAME?', $sheet->getCell('A3')->getCalculatedValue()); + self::assertEquals('#NAME?', $sheet->getCell('A4')->getCalculatedValue()); + } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ModeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ModeTest.php new file mode 100644 index 0000000000..d3eb6f3228 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ModeTest.php @@ -0,0 +1,43 @@ +getActiveSheet(); + + $row = 1; + $sheet->setCellValue("B$row", "=MODE($str)"); + $sheet->setCellValue("C$row", "=MODE.SNGL($str)"); + self::assertEquals($expectedResult, $sheet->getCell("B$row")->getCalculatedValue()); + self::assertEquals($expectedResult, $sheet->getCell("C$row")->getCalculatedValue()); + } + + public function providerMODE(): array + { + return require 'tests/data/Calculation/Statistical/MODE.php'; + } + + public function testMODENoArgs(): void + { + $this->expectException(\PhpOffice\PhpSpreadsheet\Calculation\Exception::class); + + $workbook = new Spreadsheet(); + $sheet = $workbook->getActiveSheet(); + + $sheet->setCellValue('B1', '=MODE()'); + self::assertEquals('#N/A', $sheet->getCell('B1')->getCalculatedValue()); + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/XlfnFunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/XlfnFunctionsTest.php new file mode 100644 index 0000000000..ea20fbf30f --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/XlfnFunctionsTest.php @@ -0,0 +1,99 @@ +getActiveSheet(); + $sheet->setTitle('2010'); + $sheet = $workbook->createSheet(); + $sheet->setTitle('2013'); + $sheet = $workbook->createSheet(); + $sheet->setTitle('2016'); + $sheet = $workbook->createSheet(); + $sheet->setTitle('2019'); + + foreach ($formulas as $values) { + $sheet = $workbook->setActiveSheetIndexByName($values[0]); + $sheet->setCellValue($values[1], $values[2]); + } + + $sheet = $workbook->setActiveSheetIndexByName('2013'); + $sheet->getStyle('A3:A5')->getNumberFormat()->setFormatCode('yyyy-mm-dd'); + $sheet->getColumnDimension('A')->setAutoSize(true); + $condition0 = new Conditional(); + $condition0->setConditionType(Conditional::CONDITION_EXPRESSION); + $condition0->addCondition('ABS(B3)<2'); + $condition0->getStyle()->getFill()->setFillType(Fill::FILL_SOLID); + $condition0->getStyle()->getFill()->getEndColor()->setARGB(Color::COLOR_RED); + $condition1 = new Conditional(); + $condition1->setConditionType(Conditional::CONDITION_EXPRESSION); + $condition1->addCondition('ABS(B3)>2'); + $condition1->getStyle()->getFill()->setFillType(Fill::FILL_SOLID); + $condition1->getStyle()->getFill()->getEndColor()->setARGB(Color::COLOR_GREEN); + $cond = [$condition0, $condition1]; + $sheet->getStyle('B3:B5')->setConditionalStyles($cond); + $condition0 = new Conditional(); + $condition0->setConditionType(Conditional::CONDITION_EXPRESSION); + $condition0->addCondition('ISOWEEKNUM(A3)<10'); + $condition0->getStyle()->getFill()->setFillType(Fill::FILL_SOLID); + $condition0->getStyle()->getFill()->getEndColor()->setARGB(Color::COLOR_RED); + $condition1 = new Conditional(); + $condition1->setConditionType(Conditional::CONDITION_EXPRESSION); + $condition1->addCondition('ISOWEEKNUM(A3)>40'); + $condition1->getStyle()->getFill()->setFillType(Fill::FILL_SOLID); + $condition1->getStyle()->getFill()->getEndColor()->setARGB(Color::COLOR_GREEN); + $cond = [$condition0, $condition1]; + $sheet->getStyle('A3:A5')->setConditionalStyles($cond); + $sheet->setSelectedCell('B1'); + + $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($workbook, 'Xlsx'); + $oufil = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); + $writer->save($oufil); + + $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx'); + $rdobj = $reader->load($oufil); + unlink($oufil); + foreach ($formulas as $values) { + $sheet = $rdobj->setActiveSheetIndexByName($values[0]); + self::assertEquals($values[3], $sheet->getCell($values[1])->getValue()); + if ($values[4] !== null) { + self::assertEquals($values[4], $sheet->getCell($values[1])->getCalculatedValue()); + } + } + $sheet = $rdobj->setActiveSheetIndexByName('2013'); + $cond = $sheet->getConditionalStyles('A3:A5'); + self::assertEquals('_xlfn.ISOWEEKNUM(A3)<10', $cond[0]->getConditions()[0]); + self::assertEquals('_xlfn.ISOWEEKNUM(A3)>40', $cond[1]->getConditions()[0]); + $cond = $sheet->getConditionalStyles('B3:B5'); + self::assertEquals('ABS(B3)<2', $cond[0]->getConditions()[0]); + self::assertEquals('ABS(B3)>2', $cond[1]->getConditions()[0]); + } +} diff --git a/tests/PhpSpreadsheetTests/Functional/ConditionalTextTest.php b/tests/PhpSpreadsheetTests/Functional/ConditionalTextTest.php new file mode 100644 index 0000000000..c8db3bf09a --- /dev/null +++ b/tests/PhpSpreadsheetTests/Functional/ConditionalTextTest.php @@ -0,0 +1,107 @@ +setConditionType(Conditional::CONDITION_CONTAINSTEXT); + $condition0->setOperatorType(Conditional::CONDITION_CONTAINSTEXT); + $condition0->setText('anywhere'); + $condition0->getStyle()->getFill() + ->setFillType(Fill::FILL_SOLID) + ->getEndColor()->setARGB(self::COLOR_RED); + array_push($conditionalStyles, $condition0); + + // if text contains 'Left' on left - green background + $condition1 = new Conditional(); + $condition1->setConditionType(Conditional::CONDITION_CONTAINSTEXT); + $condition1->setOperatorType(Conditional::OPERATOR_BEGINSWITH); + $condition1->setText('Left'); + $condition1->getStyle()->getFill() + ->setFillType(Fill::FILL_SOLID) + ->getEndColor()->setARGB(self::COLOR_GREEN); + array_push($conditionalStyles, $condition1); + + // if text contains 'right' on right - blue background + $condition2 = new Conditional(); + $condition2->setConditionType(Conditional::CONDITION_CONTAINSTEXT); + $condition2->setOperatorType(Conditional::OPERATOR_ENDSWITH); + $condition2->setText('right'); + $condition2->getStyle()->getFill() + ->setFillType(Fill::FILL_SOLID) + ->getEndColor()->setARGB(self::COLOR_BLUE); + array_push($conditionalStyles, $condition2); + + // if text contains no spaces - yellow background + $condition3 = new Conditional(); + $condition3->setConditionType(Conditional::CONDITION_CONTAINSTEXT); + $condition3->setOperatorType(Conditional::OPERATOR_NOTCONTAINS); + $condition3->setText(' '); + $condition3->getStyle()->getFill() + ->setFillType(Fill::FILL_SOLID) + ->getEndColor()->setARGB(self::COLOR_YELLOW); + array_push($conditionalStyles, $condition3); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('B1', 'This should match anywhere, right?'); + $sheet->setCellValue('B2', 'This should match nowhere, right?'); + $sheet->setCellValue('B3', 'Left match'); + $sheet->setCellValue('B4', 'Match on right'); + $sheet->setCellValue('B5', 'nospaces'); + $xpCoordinate = 'B1:B5'; + + $spreadsheet->getActiveSheet()->setConditionalStyles($xpCoordinate, $conditionalStyles); + $sheet->getColumnDimension('B')->setAutoSize(true); + + $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format); + + // see if we successfully written conditional text elements + $newConditionalStyles = $reloadedSpreadsheet->getActiveSheet()->getConditionalStyles($xpCoordinate); + $cnt = count($conditionalStyles); + for ($i = 0; $i < $cnt; ++$i) { + self::assertEquals( + $conditionalStyles[$i]->getConditionType(), + $newConditionalStyles[$i]->getConditionType(), + "Failure on condition type $i" + ); + self::assertEquals( + $conditionalStyles[$i]->getOperatorType(), + $newConditionalStyles[$i]->getOperatorType(), + "Failure on operator type $i" + ); + self::assertEquals( + $conditionalStyles[$i]->getText(), + $newConditionalStyles[$i]->getText(), + "Failure on text $i" + ); + $filCond = $conditionalStyles[$i]->getStyle()->getFill(); + $newCond = $newConditionalStyles[$i]->getStyle()->getFill(); + self::assertEquals( + $filCond->getFillType(), + $newCond->getFillType(), + "Failure on fill type $i" + ); + self::assertEquals( + $filCond->getEndColor()->getARGB(), + $newCond->getEndColor()->getARGB(), + "Failure on end color $i" + ); + } + } +} diff --git a/tests/data/Calculation/Statistical/MODE.php b/tests/data/Calculation/Statistical/MODE.php new file mode 100644 index 0000000000..7d27b33e5e --- /dev/null +++ b/tests/data/Calculation/Statistical/MODE.php @@ -0,0 +1,11 @@ + Date: Sun, 17 May 2020 20:43:18 -0700 Subject: [PATCH 046/659] Improve HTML Writer (#1464) There are a number of situations where HTML write was producing HTML which could not be validated. These include: - inconsistent use of backslash terminating META, IMG, and COL tags - @page style tags in body rather than header. Aside from being non-standard, HTML Reader treats those as spreadsheet data. -
, a construct which is usually better handled through css anyhow. - no alt tag for images (drawings and charts) Other problems: - Windows file names not handled correctly for images - Memory drawings not handled in extendRowsForChartsAndImages - No handling of different values for showing gridlines for screen and print - Mpdf and Dompdf do not require the use of inline css. Tcpdf remains a holdout in the use of this inferior approach. - no need to chunk base64 encoding of embedded images - support for colors in number format was buggy (html tags run through htmlspecialchars) Code has been refactored when practical to reduce the number of very large functions. Coverage is now 100% for the entire HTML Writer module, from 75% lines and 39% methods beforehand. All functions dealing only with charts are bypassed for coverage because the version of Jpgraph available in Composer is not suitable for PHP7. The code will, nevertheless, run successfully, but with warning messages. I have confirmed that the code is entirely covered, without warnings, when the current version of Jpgraph is used in lieu of the one available in Composer. I will be glad to revisit this when the Jpgraph problem is resolved. Directory PhpSpreadsheetTests/Writer/Html was created to house the new tests. It seemed logical to move HtmlCommentsTest to the new directory from PhpSpreadsheetTests/Functional. A function to generate all the HTML is useful, especially for testing, but also in lieu of the multiple other generate* functions. I have added and documented generateHTMLAll. The documentation for the generate* functions (a) produces invalid html, (b) produces html which cannot be handled correctly by HTML reader, and (c) even if those were correct, does not actually affect the display of the spreadsheet. The documentation has been replaced by a valid, and more instructive, example. The (undocumented) useEmbeddedCss property, and the functions to test and set it are no longer needed. Rather than breaking existing code by deleting them, I marked the functions deprecated. This change borrows a change to LocaleFloatsTest from pull request 1456, submitted a little over a week before this one. ## Improve NumberFormat Support First phase of this change included correcting NumberFormat handling in HTML Writer. Certain complex formats could not be handled without changes to Style/NumberFormat, and I did not wish to combine those changes. Once the original change had been pushed, I took this part of it back up. HTML Writer can now handle conditions in formats like: [Blue][>=3000.5]$#,##0.00;[Red][<0]$#,##0.00;$#,##0.00 In testing, I discovered several errors and omissions in handling of some other formats. These are now corrected, and tests added. --- docs/topics/reading-and-writing-to-file.md | 27 +- samples/Basic/17a_Html.php | 14 + samples/Basic/25_In_memory_image.php | 1 + src/PhpSpreadsheet/Style/NumberFormat.php | 144 +- src/PhpSpreadsheet/Writer/Html.php | 1242 ++++++++++------- src/PhpSpreadsheet/Writer/Pdf.php | 26 +- src/PhpSpreadsheet/Writer/Pdf/Dompdf.php | 6 +- src/PhpSpreadsheet/Writer/Pdf/Mpdf.php | 4 +- src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php | 18 +- .../Style/NumberFormatTest.php | 14 + .../Writer/Html/AllOrOneSheetTest.php | 192 +++ .../Writer/Html/GridlinesTest.php | 199 +++ .../Html}/HtmlCommentsTest.php | 5 +- .../Writer/Html/HtmlNumberFormatTest.php | 209 +++ .../Writer/Html/ImagesRootTest.php | 54 + .../Writer/Html/InvalidFileNameTest.php | 53 + .../Writer/Html/RepeatedRowsTest.php | 104 ++ .../Writer/Html/VisibilityTest.php | 111 ++ tests/data/Style/NumberFormat.php | 40 + 19 files changed, 1835 insertions(+), 628 deletions(-) create mode 100644 samples/Basic/17a_Html.php create mode 100644 tests/PhpSpreadsheetTests/Writer/Html/AllOrOneSheetTest.php create mode 100644 tests/PhpSpreadsheetTests/Writer/Html/GridlinesTest.php rename tests/PhpSpreadsheetTests/{Functional => Writer/Html}/HtmlCommentsTest.php (92%) create mode 100644 tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php create mode 100644 tests/PhpSpreadsheetTests/Writer/Html/ImagesRootTest.php create mode 100644 tests/PhpSpreadsheetTests/Writer/Html/InvalidFileNameTest.php create mode 100644 tests/PhpSpreadsheetTests/Writer/Html/RepeatedRowsTest.php create mode 100644 tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php diff --git a/docs/topics/reading-and-writing-to-file.md b/docs/topics/reading-and-writing-to-file.md index c0dc7c033e..8f92e1f232 100644 --- a/docs/topics/reading-and-writing-to-file.md +++ b/docs/topics/reading-and-writing-to-file.md @@ -681,35 +681,26 @@ Supported methods: - `generateStyles()` - `generateSheetData()` - `generateHTMLFooter()` +- `generateHTMLAll()` Here's an example which retrieves all parts independently and merges them into a resulting HTML page: ``` php -generateHTMLHeader(); -?> - - +$newstyle = << +$sty html { - font-family: Times New Roman; - font-size: 9pt; - background-color: white; + background-color: yellow; } - -generateStyles(false); // do not write -?> - ---> - -@', "$newstyle\n", $hdr); echo $writer->generateSheetData(); echo $writer->generateHTMLFooter(); -?> ``` #### Writing UTF-8 HTML files diff --git a/samples/Basic/17a_Html.php b/samples/Basic/17a_Html.php new file mode 100644 index 0000000000..20578fbe36 --- /dev/null +++ b/samples/Basic/17a_Html.php @@ -0,0 +1,14 @@ +getFilename(__FILE__, 'html'); +$writer = new Html($spreadsheet); + +$callStartTime = microtime(true); +$writer->setEmbedImages(true); +$writer->save($filename); +$helper->logWrite($writer, $filename, $callStartTime); diff --git a/samples/Basic/25_In_memory_image.php b/samples/Basic/25_In_memory_image.php index a897486dfd..5985a0a076 100644 --- a/samples/Basic/25_In_memory_image.php +++ b/samples/Basic/25_In_memory_image.php @@ -35,6 +35,7 @@ $drawing->setMimeType(MemoryDrawing::MIMETYPE_DEFAULT); $drawing->setHeight(36); $drawing->setWorksheet($spreadsheet->getActiveSheet()); +$drawing->setCoordinates('C5'); // Save $helper->write($spreadsheet, __FILE__, ['Xlsx', 'Html']); diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index 079e1d20dc..1f4a6c0c74 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -537,7 +537,15 @@ private static function formatAsFraction(&$value, &$format) $adjustedDecimalPart = $decimalPart / $GCD; $adjustedDecimalDivisor = $decimalDivisor / $GCD; - if ((strpos($format, '0') !== false) || (strpos($format, '#') !== false) || (substr($format, 0, 3) == '? ?')) { + if ((strpos($format, '0') !== false)) { + $value = "$sign$integerPart $adjustedDecimalPart/$adjustedDecimalDivisor"; + } elseif ((strpos($format, '#') !== false)) { + if ($integerPart == 0) { + $value = "$sign$adjustedDecimalPart/$adjustedDecimalDivisor"; + } else { + $value = "$sign$integerPart $adjustedDecimalPart/$adjustedDecimalDivisor"; + } + } elseif ((substr($format, 0, 3) == '? ?')) { if ($integerPart == 0) { $integerPart = ''; } @@ -653,9 +661,12 @@ private static function formatStraightNumericValue($value, $format, array $match private static function formatAsNumber($value, $format) { - if ($format === self::FORMAT_CURRENCY_EUR_SIMPLE) { - return 'EUR ' . sprintf('%1.2f', $value); - } + // The "_" in this string has already been stripped out, + // so this test is never true. Furthermore, testing + // on Excel shows this format uses Euro symbol, not "EUR". + //if ($format === self::FORMAT_CURRENCY_EUR_SIMPLE) { + // return 'EUR ' . sprintf('%1.2f', $value); + //} // Some non-number strings are quoted, so we'll get rid of the quotes, likewise any positional * symbols $format = str_replace(['"', '*'], '', $format); @@ -717,6 +728,89 @@ private static function formatAsNumber($value, $format) return $value; } + private static function splitFormatCompare($value, $cond, $val, $dfcond, $dfval) + { + if (!$cond) { + $cond = $dfcond; + $val = $dfval; + } + switch ($cond) { + case '>': + return $value > $val; + + case '<': + return $value < $val; + + case '<=': + return $value <= $val; + + case '<>': + return $value != $val; + + case '=': + return $value == $val; + } + + return $value >= $val; + } + + private static function splitFormat($sections, $value) + { + // Extract the relevant section depending on whether number is positive, negative, or zero? + // Text not supported yet. + // Here is how the sections apply to various values in Excel: + // 1 section: [POSITIVE/NEGATIVE/ZERO/TEXT] + // 2 sections: [POSITIVE/ZERO/TEXT] [NEGATIVE] + // 3 sections: [POSITIVE/TEXT] [NEGATIVE] [ZERO] + // 4 sections: [POSITIVE] [NEGATIVE] [ZERO] [TEXT] + $cnt = count($sections); + $color_regex = '/\\[(' . implode('|', Color::NAMED_COLORS) . ')\\]/'; + $cond_regex = '/\\[(>|>=|<|<=|=|<>)([+-]?\\d+([.]\\d+)?)\\]/'; + $colors = ['', '', '', '', '']; + $condops = ['', '', '', '', '']; + $condvals = [0, 0, 0, 0, 0]; + for ($idx = 0; $idx < $cnt; ++$idx) { + if (preg_match($color_regex, $sections[$idx], $matches)) { + $colors[$idx] = $matches[0]; + $sections[$idx] = preg_replace($color_regex, '', $sections[$idx]); + } + if (preg_match($cond_regex, $sections[$idx], $matches)) { + $condops[$idx] = $matches[1]; + $condvals[$idx] = $matches[2]; + $sections[$idx] = preg_replace($cond_regex, '', $sections[$idx]); + } + } + $color = $colors[0]; + $format = $sections[0]; + $absval = $value; + switch ($cnt) { + case 2: + $absval = abs($value); + if (!self::splitFormatCompare($value, $condops[0], $condvals[0], '>=', 0)) { + $color = $colors[1]; + $format = $sections[1]; + } + + break; + case 3: + case 4: + $absval = abs($value); + if (!self::splitFormatCompare($value, $condops[0], $condvals[0], '>', 0)) { + if (self::splitFormatCompare($value, $condops[1], $condvals[1], '<', 0)) { + $color = $colors[1]; + $format = $sections[1]; + } else { + $color = $colors[2]; + $format = $sections[2]; + } + } + + break; + } + + return [$color, $format, $absval]; + } + /** * Convert a value in a pre-defined format to a PHP string. * @@ -745,50 +839,12 @@ public static function toFormattedString($value, $format, $callBack = null) // Get the sections, there can be up to four sections, separated with a semi-colon (but only if not a quoted literal) $sections = preg_split('/(;)(?=(?:[^"]|"[^"]*")*$)/u', $format); - // Extract the relevant section depending on whether number is positive, negative, or zero? - // Text not supported yet. - // Here is how the sections apply to various values in Excel: - // 1 section: [POSITIVE/NEGATIVE/ZERO/TEXT] - // 2 sections: [POSITIVE/ZERO/TEXT] [NEGATIVE] - // 3 sections: [POSITIVE/TEXT] [NEGATIVE] [ZERO] - // 4 sections: [POSITIVE] [NEGATIVE] [ZERO] [TEXT] - switch (count($sections)) { - case 1: - $format = $sections[0]; - - break; - case 2: - $format = ($value >= 0) ? $sections[0] : $sections[1]; - $value = abs($value); // Use the absolute value - break; - case 3: - $format = ($value > 0) ? - $sections[0] : (($value < 0) ? - $sections[1] : $sections[2]); - $value = abs($value); // Use the absolute value - break; - case 4: - $format = ($value > 0) ? - $sections[0] : (($value < 0) ? - $sections[1] : $sections[2]); - $value = abs($value); // Use the absolute value - break; - default: - // something is wrong, just use first section - $format = $sections[0]; - - break; - } + [$colors, $format, $value] = self::splitFormat($sections, $value); // In Excel formats, "_" is used to add spacing, // The following character indicates the size of the spacing, which we can't do in HTML, so we just use a standard space $format = preg_replace('/_./', ' ', $format); - // Save format with color information for later use below - $formatColor = $format; - // Strip colour information - $color_regex = '/\[(' . implode('|', Color::NAMED_COLORS) . ')\]/'; - $format = preg_replace($color_regex, '', $format); // Let's begin inspecting the format and converting the value to a formatted string // Check for date/time characters (not inside quotes) @@ -809,7 +865,7 @@ public static function toFormattedString($value, $format, $callBack = null) // Additional formatting provided by callback function if ($callBack !== null) { [$writerInstance, $function] = $callBack; - $value = $writerInstance->$function($value, $formatColor); + $value = $writerInstance->$function($value, $colors); } return $value; diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index ec75400144..bb5098069a 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -148,6 +148,23 @@ public function __construct(Spreadsheet $spreadsheet) * @param resource|string $pFilename */ public function save($pFilename) + { + // Open file + $this->openFileHandle($pFilename); + + // Write html + fwrite($this->fileHandle, $this->generateHTMLAll()); + + // Close file + $this->maybeCloseFileHandle(); + } + + /** + * Save Spreadsheet as html to variable. + * + * @return string + */ + public function generateHtmlAll() { // garbage collect $this->spreadsheet->garbageCollect(); @@ -160,29 +177,35 @@ public function save($pFilename) // Build CSS $this->buildCSS(!$this->useInlineCss); - // Open file - $this->openFileHandle($pFilename); + $html = ''; // Write headers - fwrite($this->fileHandle, $this->generateHTMLHeader(!$this->useInlineCss)); + $html .= $this->generateHTMLHeader(!$this->useInlineCss); // Write navigation (tabs) if ((!$this->isPdf) && ($this->generateSheetNavigationBlock)) { - fwrite($this->fileHandle, $this->generateNavigation()); + $html .= $this->generateNavigation(); } // Write data - fwrite($this->fileHandle, $this->generateSheetData()); + $html .= $this->generateSheetData(); // Write footer - fwrite($this->fileHandle, $this->generateHTMLFooter()); - - $this->maybeCloseFileHandle(); + $html .= $this->generateHTMLFooter(); Calculation::setArrayReturnType($saveArrayReturnType); Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); + + return $html; } + const VALIGN_ARR = [ + Alignment::VERTICAL_BOTTOM => 'bottom', + Alignment::VERTICAL_TOP => 'top', + Alignment::VERTICAL_CENTER => 'middle', + Alignment::VERTICAL_JUSTIFY => 'middle', + ]; + /** * Map VAlign. * @@ -192,45 +215,44 @@ public function save($pFilename) */ private function mapVAlign($vAlign) { - switch ($vAlign) { - case Alignment::VERTICAL_BOTTOM: - return 'bottom'; - case Alignment::VERTICAL_TOP: - return 'top'; - case Alignment::VERTICAL_CENTER: - case Alignment::VERTICAL_JUSTIFY: - return 'middle'; - default: - return 'baseline'; - } + return array_key_exists($vAlign, self::VALIGN_ARR) ? self::VALIGN_ARR[$vAlign] : 'baseline'; } + const HALIGN_ARR = [ + Alignment::HORIZONTAL_LEFT => 'left', + Alignment::HORIZONTAL_RIGHT => 'right', + Alignment::HORIZONTAL_CENTER => 'center', + Alignment::HORIZONTAL_CENTER_CONTINUOUS => 'center', + Alignment::HORIZONTAL_JUSTIFY => 'justify', + ]; + /** * Map HAlign. * * @param string $hAlign Horizontal alignment * - * @return false|string + * @return string */ private function mapHAlign($hAlign) { - switch ($hAlign) { - case Alignment::HORIZONTAL_GENERAL: - return false; - case Alignment::HORIZONTAL_LEFT: - return 'left'; - case Alignment::HORIZONTAL_RIGHT: - return 'right'; - case Alignment::HORIZONTAL_CENTER: - case Alignment::HORIZONTAL_CENTER_CONTINUOUS: - return 'center'; - case Alignment::HORIZONTAL_JUSTIFY: - return 'justify'; - default: - return false; - } + return array_key_exists($hAlign, self::HALIGN_ARR) ? self::HALIGN_ARR[$hAlign] : ''; } + const BORDER_ARR = [ + Border::BORDER_NONE => 'none', + Border::BORDER_DASHDOT => '1px dashed', + Border::BORDER_DASHDOTDOT => '1px dotted', + Border::BORDER_DASHED => '1px dashed', + Border::BORDER_DOTTED => '1px dotted', + Border::BORDER_DOUBLE => '3px double', + Border::BORDER_HAIR => '1px solid', + Border::BORDER_MEDIUM => '2px solid', + Border::BORDER_MEDIUMDASHDOT => '2px dashed', + Border::BORDER_MEDIUMDASHDOTDOT => '2px dotted', + Border::BORDER_SLANTDASHDOT => '2px dashed', + Border::BORDER_THICK => '3px solid', + ]; + /** * Map border style. * @@ -240,39 +262,7 @@ private function mapHAlign($hAlign) */ private function mapBorderStyle($borderStyle) { - switch ($borderStyle) { - case Border::BORDER_NONE: - return 'none'; - case Border::BORDER_DASHDOT: - return '1px dashed'; - case Border::BORDER_DASHDOTDOT: - return '1px dotted'; - case Border::BORDER_DASHED: - return '1px dashed'; - case Border::BORDER_DOTTED: - return '1px dotted'; - case Border::BORDER_DOUBLE: - return '3px double'; - case Border::BORDER_HAIR: - return '1px solid'; - case Border::BORDER_MEDIUM: - return '2px solid'; - case Border::BORDER_MEDIUMDASHDOT: - return '2px dashed'; - case Border::BORDER_MEDIUMDASHDOTDOT: - return '2px dotted'; - case Border::BORDER_MEDIUMDASHED: - return '2px dashed'; - case Border::BORDER_SLANTDASHDOT: - return '2px dashed'; - case Border::BORDER_THICK: - return '3px solid'; - case Border::BORDER_THIN: - return '1px solid'; - default: - // map others to thin - return '1px solid'; - } + return array_key_exists($borderStyle, self::BORDER_ARR) ? self::BORDER_ARR[$borderStyle] : '1px solid'; } /** @@ -335,6 +325,11 @@ public function writeAllSheets() return $this; } + private static function generateMeta($val, $desc) + { + return $val ? (' ' . PHP_EOL) : ''; + } + /** * Generate HTML header. * @@ -346,42 +341,22 @@ public function generateHTMLHeader($pIncludeStyles = false) { // Construct HTML $properties = $this->spreadsheet->getProperties(); - $html = '' . PHP_EOL; - $html .= '' . PHP_EOL; + $html = '' . PHP_EOL; + $html .= '' . PHP_EOL; $html .= ' ' . PHP_EOL; - $html .= ' ' . PHP_EOL; - $html .= ' ' . PHP_EOL; - if ($properties->getTitle() > '') { - $html .= ' ' . htmlspecialchars($properties->getTitle()) . '' . PHP_EOL; - } - if ($properties->getCreator() > '') { - $html .= ' ' . PHP_EOL; - } - if ($properties->getTitle() > '') { - $html .= ' ' . PHP_EOL; - } - if ($properties->getDescription() > '') { - $html .= ' ' . PHP_EOL; - } - if ($properties->getSubject() > '') { - $html .= ' ' . PHP_EOL; - } - if ($properties->getKeywords() > '') { - $html .= ' ' . PHP_EOL; - } - if ($properties->getCategory() > '') { - $html .= ' ' . PHP_EOL; - } - if ($properties->getCompany() > '') { - $html .= ' ' . PHP_EOL; - } - if ($properties->getManager() > '') { - $html .= ' ' . PHP_EOL; - } - - if ($pIncludeStyles) { - $html .= $this->generateStyles(true); - } + $html .= ' ' . PHP_EOL; + $html .= ' ' . PHP_EOL; + $html .= ' ' . htmlspecialchars($properties->getTitle()) . '' . PHP_EOL; + $html .= self::generateMeta($properties->getCreator(), 'author'); + $html .= self::generateMeta($properties->getTitle(), 'title'); + $html .= self::generateMeta($properties->getDescription(), 'description'); + $html .= self::generateMeta($properties->getSubject(), 'subject'); + $html .= self::generateMeta($properties->getKeywords(), 'keywords'); + $html .= self::generateMeta($properties->getCategory(), 'category'); + $html .= self::generateMeta($properties->getCompany(), 'company'); + $html .= self::generateMeta($properties->getManager(), 'manager'); + + $html .= $pIncludeStyles ? $this->generateStyles(true) : $this->generatePageDeclarations(true); $html .= ' ' . PHP_EOL; $html .= '' . PHP_EOL; @@ -390,25 +365,61 @@ public function generateHTMLHeader($pIncludeStyles = false) return $html; } - /** - * Generate sheet data. - * - * @return string - */ - public function generateSheetData() + private function generateSheetPrep() { // Ensure that Spans have been calculated? - if ($this->sheetIndex !== null || !$this->spansAreCalculated) { - $this->calculateSpans(); - } + $this->calculateSpans(); // Fetch sheets - $sheets = []; if ($this->sheetIndex === null) { $sheets = $this->spreadsheet->getAllSheets(); } else { - $sheets[] = $this->spreadsheet->getSheet($this->sheetIndex); + $sheets = [$this->spreadsheet->getSheet($this->sheetIndex)]; + } + + return $sheets; + } + + private function generateSheetStarts($sheet, $rowMin) + { + // calculate start of
, + $tbodyStart = $rowMin; + $theadStart = $theadEnd = 0; // default: no no + if ($sheet->getPageSetup()->isRowsToRepeatAtTopSet()) { + $rowsToRepeatAtTop = $sheet->getPageSetup()->getRowsToRepeatAtTop(); + + // we can only support repeating rows that start at top row + if ($rowsToRepeatAtTop[0] == 1) { + $theadStart = $rowsToRepeatAtTop[0]; + $theadEnd = $rowsToRepeatAtTop[1]; + $tbodyStart = $rowsToRepeatAtTop[1] + 1; + } + } + + return [$theadStart, $theadEnd, $tbodyStart]; + } + + private function generateSheetTags($row, $theadStart, $theadEnd, $tbodyStart) + { + // ? + $startTag = ($row == $theadStart) ? (' ' . PHP_EOL) : ''; + if (!$startTag) { + $startTag = ($row == $tbodyStart) ? (' ' . PHP_EOL) : ''; } + $endTag = ($row == $theadEnd) ? (' ' . PHP_EOL) : ''; + $cellType = ($row >= $tbodyStart) ? 'td' : 'th'; + + return [$cellType, $startTag, $endTag]; + } + + /** + * Generate sheet data. + * + * @return string + */ + public function generateSheetData() + { + $sheets = $this->generateSheetPrep(); // Construct HTML $html = ''; @@ -418,7 +429,6 @@ public function generateSheetData() foreach ($sheets as $sheet) { // Write table header $html .= $this->generateTableHeader($sheet); - // Get worksheet dimension $dimension = explode(':', $sheet->calculateWorksheetDimension()); $dimension[0] = Coordinate::coordinateFromString($dimension[0]); @@ -430,34 +440,13 @@ public function generateSheetData() $rowMin = $dimension[0][1]; $rowMax = $dimension[1][1]; - // calculate start of , - $tbodyStart = $rowMin; - $theadStart = $theadEnd = 0; // default: no no - if ($sheet->getPageSetup()->isRowsToRepeatAtTopSet()) { - $rowsToRepeatAtTop = $sheet->getPageSetup()->getRowsToRepeatAtTop(); - - // we can only support repeating rows that start at top row - if ($rowsToRepeatAtTop[0] == 1) { - $theadStart = $rowsToRepeatAtTop[0]; - $theadEnd = $rowsToRepeatAtTop[1]; - $tbodyStart = $rowsToRepeatAtTop[1] + 1; - } - } + [$theadStart, $theadEnd, $tbodyStart] = $this->generateSheetStarts($sheet, $rowMin); // Loop through cells $row = $rowMin - 1; while ($row++ < $rowMax) { - // ? - if ($row == $theadStart) { - $html .= ' ' . PHP_EOL; - $cellType = 'th'; - } - - // ? - if ($row == $tbodyStart) { - $html .= ' ' . PHP_EOL; - $cellType = 'td'; - } + [$cellType, $startTag, $endTag] = $this->generateSheetTags($row, $theadStart, $theadEnd, $tbodyStart); + $html .= $startTag; // Write row if there are HTML table cells in it if (!isset($this->isSpannedRow[$sheet->getParent()->getIndex($sheet)][$row])) { @@ -477,23 +466,16 @@ public function generateSheetData() $html .= $this->generateRow($sheet, $rowData, $row - 1, $cellType); } - // ? - if ($row == $theadEnd) { - $html .= ' ' . PHP_EOL; - } + $html .= $endTag; } $html .= $this->extendRowsForChartsAndImages($sheet, $row); - // Close table body. - $html .= ' ' . PHP_EOL; - // Write table footer $html .= $this->generateTableFooter(); - // Writing PDF? - if ($this->isPdf) { + if ($this->isPdf && $this->useInlineCss) { if ($this->sheetIndex === null && $sheetId + 1 < $this->spreadsheet->getSheetCount()) { - $html .= '
'; + $html .= '
'; } } @@ -540,13 +522,30 @@ public function generateNavigation() return $html; } - private function extendRowsForChartsAndImages(Worksheet $pSheet, $row) + /** + * Extend Row if chart is placed after nominal end of row. + * This code should be exercised by sample: + * Chart/32_Chart_read_write_PDF.php. + * However, that test is suppressed due to out-of-date + * Jpgraph code issuing warnings. So, don't measure + * code coverage for this function till that is fixed. + * + * @param Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet + * @param int $row Row to check for charts + * + * @return array + * + * @codeCoverageIgnore + */ + private function extendRowsForCharts(Worksheet $pSheet, $row) { $rowMax = $row; $colMax = 'A'; + $anyfound = false; if ($this->includeCharts) { foreach ($pSheet->getChartCollection() as $chart) { if ($chart instanceof Chart) { + $anyfound = true; $chartCoordinates = $chart->getTopLeftPosition(); $chartTL = Coordinate::coordinateFromString($chartCoordinates['cell']); $chartCol = Coordinate::columnIndexFromString($chartTL[0]); @@ -560,44 +559,68 @@ private function extendRowsForChartsAndImages(Worksheet $pSheet, $row) } } + return [$rowMax, $colMax, $anyfound]; + } + + private function extendRowsForChartsAndImages(Worksheet $pSheet, $row) + { + [$rowMax, $colMax, $anyfound] = $this->extendRowsForCharts($pSheet, $row); + foreach ($pSheet->getDrawingCollection() as $drawing) { - if ($drawing instanceof Drawing) { - $imageTL = Coordinate::coordinateFromString($drawing->getCoordinates()); - $imageCol = Coordinate::columnIndexFromString($imageTL[0]); - if ($imageTL[1] > $rowMax) { - $rowMax = $imageTL[1]; - if ($imageCol > Coordinate::columnIndexFromString($colMax)) { - $colMax = $imageTL[0]; - } + $anyfound = true; + $imageTL = Coordinate::coordinateFromString($drawing->getCoordinates()); + $imageCol = Coordinate::columnIndexFromString($imageTL[0]); + if ($imageTL[1] > $rowMax) { + $rowMax = $imageTL[1]; + if ($imageCol > Coordinate::columnIndexFromString($colMax)) { + $colMax = $imageTL[0]; } } } // Don't extend rows if not needed - if ($row === $rowMax) { + if ($row === $rowMax || !$anyfound) { return ''; } $html = ''; ++$colMax; - + ++$row; while ($row <= $rowMax) { $html .= '
'; for ($col = 'A'; $col != $colMax; ++$col) { - $html .= '"; + } else { + $html .= ""; } - $html .= ''; } ++$row; - $html .= ''; + $html .= '' . PHP_EOL; } return $html; } + /** + * Convert Windows file name to file protocol URL. + * + * @param string $filename file name on local system + * + * @return string + */ + public static function winFileToUrl($filename) + { + // Windows filename + if (substr($filename, 1, 2) === ':\\') { + $filename = 'file:///' . str_replace('\\', '/', $filename); + } + + return $filename; + } + /** * Generate image tag in cell. * @@ -613,57 +636,44 @@ private function writeImageInCell(Worksheet $pSheet, $coordinates) // Write images foreach ($pSheet->getDrawingCollection() as $drawing) { + if ($drawing->getCoordinates() != $coordinates) { + continue; + } + $filedesc = $drawing->getDescription(); + $filedesc = $filedesc ? htmlspecialchars($filedesc, ENT_QUOTES) : 'Embedded image'; if ($drawing instanceof Drawing) { - if ($drawing->getCoordinates() == $coordinates) { - $filename = $drawing->getPath(); + $filename = $drawing->getPath(); - // Strip off eventual '.' - if (substr($filename, 0, 1) == '.') { - $filename = substr($filename, 1); - } + // Strip off eventual '.' + $filename = preg_replace('/^[.]/', '', $filename); - // Prepend images root - $filename = $this->getImagesRoot() . $filename; + // Prepend images root + $filename = $this->getImagesRoot() . $filename; - // Strip off eventual '.' - if (substr($filename, 0, 1) == '.' && substr($filename, 0, 2) != './') { - $filename = substr($filename, 1); - } + // Strip off eventual '.' if followed by non-/ + $filename = preg_replace('@^[.]([^/])@', '$1', $filename); - // Convert UTF8 data to PCDATA - $filename = htmlspecialchars($filename); + // Convert UTF8 data to PCDATA + $filename = htmlspecialchars($filename); - $html .= PHP_EOL; - if ((!$this->embedImages) || ($this->isPdf)) { - $imageData = $filename; - } else { + $html .= PHP_EOL; + $imageData = self::winFileToUrl($filename); + + if ($this->embedImages && !$this->isPdf) { + $picture = @file_get_contents($filename); + if ($picture !== false) { $imageDetails = getimagesize($filename); - if ($fp = fopen($filename, 'rb', 0)) { - $picture = ''; - while (!feof($fp)) { - $picture .= fread($fp, 1024); - } - fclose($fp); - // base64 encode the binary data, then break it - // into chunks according to RFC 2045 semantics - $base64 = chunk_split(base64_encode($picture)); - $imageData = 'data:' . $imageDetails['mime'] . ';base64,' . $base64; - } else { - $imageData = $filename; - } + // base64 encode the binary data + $base64 = base64_encode($picture); + $imageData = 'data:' . $imageDetails['mime'] . ';base64,' . $base64; } - - $html .= '
'; - $html .= ''; - $html .= '
'; } + + $html .= '' . $filedesc . ''; } elseif ($drawing instanceof MemoryDrawing) { - if ($drawing->getCoordinates() != $coordinates) { - continue; - } ob_start(); // Let's start output buffering. imagepng($drawing->getImageResource()); // This will normally output the image, but because of ob_start(), it won't. $contents = ob_get_contents(); // Instead, output above is saved to $contents @@ -675,7 +685,7 @@ private function writeImageInCell(Worksheet $pSheet, $coordinates) // max-width: 100% ensures that image doesnt overflow containing cell // width: X sets width of supplied image. // As a result, images bigger than cell will be contained and images smaller will not get stretched - $html .= ''; + $html .= '' . $filedesc . ''; } } @@ -684,11 +694,18 @@ private function writeImageInCell(Worksheet $pSheet, $coordinates) /** * Generate chart tag in cell. + * This code should be exercised by sample: + * Chart/32_Chart_read_write_PDF.php. + * However, that test is suppressed due to out-of-date + * Jpgraph code issuing warnings. So, don't measure + * code coverage for this function till that is fixed. * * @param Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet * @param string $coordinates Cell coordinates * * @return string + * + * @codeCoverageIgnore */ private function writeChartInCell(Worksheet $pSheet, $coordinates) { @@ -707,17 +724,17 @@ private function writeChartInCell(Worksheet $pSheet, $coordinates) $html .= PHP_EOL; $imageDetails = getimagesize($chartFileName); + $filedesc = $chart->getTitle(); + $filedesc = $filedesc ? self::getChartCaption($filedesc->getCaption()) : ''; + $filedesc = $filedesc ? htmlspecialchars($filedesc, ENT_QUOTES) : 'Embedded chart'; if ($fp = fopen($chartFileName, 'rb', 0)) { $picture = fread($fp, filesize($chartFileName)); fclose($fp); - // base64 encode the binary data, then break it - // into chunks according to RFC 2045 semantics - $base64 = chunk_split(base64_encode($picture)); + // base64 encode the binary data + $base64 = base64_encode($picture); $imageData = 'data:' . $imageDetails['mime'] . ';base64,' . $base64; - $html .= '
'; - $html .= '' . PHP_EOL; - $html .= '
'; + $html .= '' . $filedesc . '' . PHP_EOL; unlink($chartFileName); } @@ -729,6 +746,27 @@ private function writeChartInCell(Worksheet $pSheet, $coordinates) return $html; } + /** + * Extend Row if chart is placed after nominal end of row. + * This code should be exercised by sample: + * Chart/32_Chart_read_write_PDF.php. + * However, that test is suppressed due to out-of-date + * Jpgraph code issuing warnings. So, don't measure + * code coverage for this function till that is fixed. + * Caption is described in documentation as fixed, + * but in 32_Chart it is somehow an array of RichText. + * + * @param mixed $cap + * + * @return string + * + * @codeCoverageIgnore + */ + private static function getChartCaption($cap) + { + return is_array($cap) ? implode(' ', $cap) : $cap; + } + /** * Generate CSS styles. * @@ -747,7 +785,7 @@ public function generateStyles($generateSurroundingHTML = true) // Start styles if ($generateSurroundingHTML) { $html .= ' \n"; + // Identify which rows should be omitted in HTML. These are the rows where all the cells + // participate in a merge and the where base cells are somewhere above. + $countColumns = Coordinate::columnIndexFromString($sheet->getHighestColumn()); + foreach ($candidateSpannedRow as $rowIndex) { + if (isset($this->isSpannedCell[$sheetIndex][$rowIndex])) { + if (count($this->isSpannedCell[$sheetIndex][$rowIndex]) == $countColumns) { + $this->isSpannedRow[$sheetIndex][$rowIndex] = $rowIndex; + } + } + } + + // For each of the omitted rows we found above, the affected rowspans should be subtracted by 1 + if (isset($this->isSpannedRow[$sheetIndex])) { + foreach ($this->isSpannedRow[$sheetIndex] as $rowIndex) { + $adjustedBaseCells = []; + $c = -1; + $e = $countColumns - 1; + while ($c++ < $e) { + $baseCell = $this->isSpannedCell[$sheetIndex][$rowIndex][$c]['baseCell']; + + if (!in_array($baseCell, $adjustedBaseCells)) { + // subtract rowspan by 1 + --$this->isBaseCell[$sheetIndex][$baseCell[0]][$baseCell[1]]['rowspan']; + $adjustedBaseCells[] = $baseCell; + } + } + } + } } /** @@ -1668,4 +1788,70 @@ private function writeComment(Worksheet $pSheet, $coordinate) return $result; } + + /** + * Generate @page declarations. + * + * @param bool $generateSurroundingHTML + * + * @return string + */ + private function generatePageDeclarations($generateSurroundingHTML) + { + // Ensure that Spans have been calculated? + $this->calculateSpans(); + + // Fetch sheets + $sheets = []; + if ($this->sheetIndex === null) { + $sheets = $this->spreadsheet->getAllSheets(); + } else { + $sheets[] = $this->spreadsheet->getSheet($this->sheetIndex); + } + + // Construct HTML + $htmlPage = $generateSurroundingHTML ? ('' . PHP_EOL) : ''; + + return $htmlPage; + } } diff --git a/src/PhpSpreadsheet/Writer/Pdf.php b/src/PhpSpreadsheet/Writer/Pdf.php index bb9f4aefd9..872204589f 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -2,7 +2,6 @@ namespace PhpOffice\PhpSpreadsheet\Writer; -use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Shared\File; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; @@ -38,13 +37,6 @@ abstract class Pdf extends Html */ protected $paperSize; - /** - * Temporary storage for Save Array Return type. - * - * @var string - */ - private $saveArrayReturnType; - /** * Paper Sizes xRef List. * @@ -127,8 +119,9 @@ abstract class Pdf extends Html public function __construct(Spreadsheet $spreadsheet) { parent::__construct($spreadsheet); - $this->setUseInlineCss(true); - $this->tempDir = File::sysGetTempDir(); + //$this->setUseInlineCss(true); + $this->tempDir = File::sysGetTempDir() . '/phpsppdf'; + $this->isPdf = true; } /** @@ -244,20 +237,9 @@ public function setTempDir($pValue) */ protected function prepareForSave($pFilename) { - // garbage collect - $this->spreadsheet->garbageCollect(); - - $this->saveArrayReturnType = Calculation::getArrayReturnType(); - Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE); - // Open file $this->openFileHandle($pFilename); - // Set PDF - $this->isPdf = true; - // Build CSS - $this->buildCSS(true); - return $this->fileHandle; } @@ -267,7 +249,5 @@ protected function prepareForSave($pFilename) protected function restoreStateAfterSave(): void { $this->maybeCloseFileHandle(); - - Calculation::setArrayReturnType($this->saveArrayReturnType); } } diff --git a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php index 4506468bb4..3ecaff682d 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php @@ -61,11 +61,7 @@ public function save($pFilename) $pdf = $this->createExternalWriterInstance(); $pdf->setPaper(strtolower($paperSize), $orientation); - $pdf->loadHtml( - $this->generateHTMLHeader(false) . - $this->generateSheetData() . - $this->generateHTMLFooter() - ); + $pdf->loadHtml($this->generateHTMLAll()); $pdf->render(); // Write to file diff --git a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php index 6f3cc57f68..4424157555 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php @@ -81,12 +81,10 @@ public function save($pFilename) $pdf->SetKeywords($this->spreadsheet->getProperties()->getKeywords()); $pdf->SetCreator($this->spreadsheet->getProperties()->getCreator()); - $pdf->WriteHTML($this->generateHTMLHeader(false)); - $html = $this->generateSheetData(); + $html = $this->generateHTMLAll(); foreach (\array_chunk(\explode(PHP_EOL, $html), 1000) as $lines) { $pdf->WriteHTML(\implode(PHP_EOL, $lines)); } - $pdf->WriteHTML($this->generateHTMLFooter()); // Write to file fwrite($fileHandle, $pdf->Output('', 'S')); diff --git a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php index 5c31af8f8b..3dc172a2e2 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php @@ -2,11 +2,23 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Pdf; +use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; use PhpOffice\PhpSpreadsheet\Writer\Pdf; class Tcpdf extends Pdf { + /** + * Create a new PDF Writer instance. + * + * @param Spreadsheet $spreadsheet Spreadsheet object + */ + public function __construct(Spreadsheet $spreadsheet) + { + parent::__construct($spreadsheet); + $this->setUseInlineCss(true); + } + /** * Gets the implementation of external PDF library that should be used. * @@ -75,11 +87,7 @@ public function save($pFilename) // Set the appropriate font $pdf->SetFont($this->getFont()); - $pdf->writeHTML( - $this->generateHTMLHeader(false) . - $this->generateSheetData() . - $this->generateHTMLFooter() - ); + $pdf->writeHTML($this->generateHTMLAll()); // Document info $pdf->SetTitle($this->spreadsheet->getProperties()->getTitle()); diff --git a/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php b/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php index 9dc20fd72a..ba44b6afe8 100644 --- a/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php +++ b/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php @@ -45,4 +45,18 @@ public function providerNumberFormatDates() { return require 'tests/data/Style/NumberFormatDates.php'; } + + public function testCurrencyCode() + { + // "Currency symbol" replaces $ in some cases, not in others + $cur = StringHelper::getCurrencyCode(); + StringHelper::setCurrencyCode('€'); + $fmt1 = '#,##0.000\ [$]'; + $rslt = NumberFormat::toFormattedString(12345.679, $fmt1); + self::assertEquals($rslt, '12,345.679 €'); + $fmt2 = '$ #,##0.000'; + $rslt = NumberFormat::toFormattedString(12345.679, $fmt2); + self::assertEquals($rslt, '$ 12,345.679'); + StringHelper::setCurrencyCode($cur); + } } diff --git a/tests/PhpSpreadsheetTests/Writer/Html/AllOrOneSheetTest.php b/tests/PhpSpreadsheetTests/Writer/Html/AllOrOneSheetTest.php new file mode 100644 index 0000000000..03fe741f30 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Html/AllOrOneSheetTest.php @@ -0,0 +1,192 @@ +getActiveSheet(); + $sheet1->setCellValue('A1', 'first'); + $sheet2 = $spreadsheet->createSheet(); + $sheet2->setCellValue('A1', 'second'); + + $writer = new Html($spreadsheet); + self::assertFalse($writer->getEmbedImages()); + $writer->writeAllSheets(); + self::assertTrue($writer->getGenerateSheetNavigationBlock()); + $html = $writer->generateHTMLAll(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('ul'); // sheet navigation + self::assertCount(1, $divs); + $divs = $body->getElementsByTagName('div'); + self::assertCount(2, $divs); + self::assertEquals('page: page0', $divs->item(0)->getAttribute('style')); + $tbl = $divs->item(0)->getElementsByTagName('table'); + self::assertEquals('sheet0', $tbl->item(0)->getAttribute('id')); + self::assertEquals('sheet0 gridlines', $tbl->item(0)->getAttribute('class')); + $tbl = $divs->item(1)->getElementsByTagName('table'); + self::assertEquals('page: page1', $divs->item(1)->getAttribute('style')); + self::assertEquals('sheet1', $tbl->item(0)->getAttribute('id')); + self::assertEquals('sheet1 gridlines', $tbl->item(0)->getAttribute('class')); + $this->writeAndReload($spreadsheet, 'Html'); + } + + public function testWriteAllSheetsNoNav() + { + $spreadsheet = new Spreadsheet(); + $sheet1 = $spreadsheet->getActiveSheet(); + $sheet1->setCellValue('A1', 'first'); + $sheet2 = $spreadsheet->createSheet(); + $sheet2->setCellValue('A1', 'second'); + + $writer = new Html($spreadsheet); + $writer->writeAllSheets(); + $writer->setGenerateSheetNavigationBlock(false); + $html = $writer->generateHTMLAll(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('ul'); // sheet navigation + self::assertCount(0, $divs); + $divs = $body->getElementsByTagName('div'); + self::assertCount(2, $divs); + self::assertEquals('page: page0', $divs->item(0)->getAttribute('style')); + $tbl = $divs->item(0)->getElementsByTagName('table'); + self::assertEquals('sheet0', $tbl->item(0)->getAttribute('id')); + self::assertEquals('sheet0 gridlines', $tbl->item(0)->getAttribute('class')); + $tbl = $divs->item(1)->getElementsByTagName('table'); + self::assertEquals('page: page1', $divs->item(1)->getAttribute('style')); + self::assertEquals('sheet1', $tbl->item(0)->getAttribute('id')); + self::assertEquals('sheet1 gridlines', $tbl->item(0)->getAttribute('class')); + $this->writeAndReload($spreadsheet, 'Html'); + } + + public function testWriteAllSheetsPdf() + { + $spreadsheet = new Spreadsheet(); + $sheet1 = $spreadsheet->getActiveSheet(); + $sheet1->setCellValue('A1', 'first'); + $sheet2 = $spreadsheet->createSheet(); + $sheet2->setCellValue('A1', 'second'); + + $writer = new Mpdf($spreadsheet); + $writer->writeAllSheets(); + $html = $writer->generateHTMLAll(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('ul'); // sheet navigation + self::assertCount(0, $divs); + $divs = $body->getElementsByTagName('div'); + self::assertCount(2, $divs); + self::assertEquals('page: page0', $divs->item(0)->getAttribute('style')); + $tbl = $divs->item(0)->getElementsByTagName('table'); + self::assertEquals('sheet0', $tbl->item(0)->getAttribute('id')); + self::assertEquals('sheet0 gridlines', $tbl->item(0)->getAttribute('class')); + $tbl = $divs->item(1)->getElementsByTagName('table'); + self::assertEquals('page: page1', $divs->item(1)->getAttribute('style')); + self::assertEquals('sheet1', $tbl->item(0)->getAttribute('id')); + self::assertEquals('sheet1 gridlines', $tbl->item(0)->getAttribute('class')); + } + + public function testWriteOneSheet() + { + $spreadsheet = new Spreadsheet(); + $sheet1 = $spreadsheet->getActiveSheet(); + $sheet1->setCellValue('A1', 'first'); + $sheet2 = $spreadsheet->createSheet(); + $sheet2->setCellValue('A1', 'second'); + + $writer = new Html($spreadsheet); + $writer->setSheetIndex(1); + $html = $writer->generateHTMLAll(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('ul'); // sheet navigation + self::assertCount(0, $divs); + $divs = $body->getElementsByTagName('div'); + self::assertCount(1, $divs); + self::assertEquals('page: page1', $divs->item(0)->getAttribute('style')); + $tbl = $divs->item(0)->getElementsByTagName('table'); + self::assertEquals('sheet1', $tbl->item(0)->getAttribute('id')); + self::assertEquals('sheet1 gridlines', $tbl->item(0)->getAttribute('class')); + $this->writeAndReload($spreadsheet, 'Html'); + } + + public function testPageBreak() + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setShowGridlines(true)->setPrintGridlines(true); + $sheet->setCellValue('A1', 1); + $sheet->setCellValue('A2', 'before page break'); + $sheet->setBreak('A2', \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::BREAK_ROW); + $sheet->setCellValue('A3', 'after page break'); + $sheet->setCellValue('A4', 4); + $sheet = $spreadsheet->createSheet(); + $sheet->setCellValue('A1', 'new sheet'); + + $writer = new Html($spreadsheet); + $writer->writeAllSheets(); + + $html = $writer->generateHTMLAll(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('div'); + self::assertCount(3, $divs); + + $sty = $divs[0]->getAttribute('style'); + $cls = $divs[0]->getAttribute('class'); + self::assertEquals('page: page0', $sty); + self::assertEquals('', $cls); + $sty = $divs[1]->getAttribute('style'); + $cls = $divs[1]->getAttribute('class'); + self::assertEquals('page: page0', $sty); + self::assertEquals('scrpgbrk', $cls); + $sty = $divs[2]->getAttribute('style'); + $cls = $divs[2]->getAttribute('class'); + self::assertEquals('page: page1', $sty); + self::assertEquals('', $cls); + + $this->writeAndReload($spreadsheet, 'Html'); + } + + public function testTcpdfPageBreak() + { + $spreadsheet = new Spreadsheet(); + $sheet1 = $spreadsheet->getActiveSheet(); + $sheet1->setCellValue('A1', 'First sheet'); + $sheet2 = $spreadsheet->createSheet(); + $sheet2->setCellValue('A2', 'Second sheet'); + $sheet2->setCellValue('A2', 'before page break'); + $sheet2->setBreak('A2', \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::BREAK_ROW); + $sheet2->setCellValue('A3', 'after page break'); + + $writer = new Tcpdf($spreadsheet); + $writer->writeAllSheets(); + $html = $writer->generateHtmlAll(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('div'); + self::assertCount(5, $divs); + + self::assertEquals('page: page0', $divs[0]->getAttribute('style')); + self::assertEquals('page: page1', $divs[2]->getAttribute('style')); + self::assertEquals('page: page1', $divs[4]->getAttribute('style')); + self::assertEquals('page-break-before:always', $divs[1]->getAttribute('style')); + self::assertEquals('page-break-before:always', $divs[3]->getAttribute('style')); + } +} diff --git a/tests/PhpSpreadsheetTests/Writer/Html/GridlinesTest.php b/tests/PhpSpreadsheetTests/Writer/Html/GridlinesTest.php new file mode 100644 index 0000000000..2bbe3541fb --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Html/GridlinesTest.php @@ -0,0 +1,199 @@ +getActiveSheet(); + $sheet->setShowGridlines(true)->setPrintGridlines(true); + $sheet->setCellValue('A1', 1); + $sheet = $spreadsheet->createSheet(); + $sheet->setShowGridlines(true)->setPrintGridlines(false); + $sheet->setCellValue('A1', 1); + $sheet = $spreadsheet->createSheet(); + $sheet->setShowGridlines(false)->setPrintGridlines(true); + $sheet->setCellValue('A1', 1); + $sheet = $spreadsheet->createSheet(); + $sheet->setShowGridlines(false)->setPrintGridlines(false); + $sheet->setCellValue('A1', 1); + + $writer = new Html($spreadsheet); + $writer->writeAllSheets(); + + $html = $writer->generateHTMLAll(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('div'); + self::assertCount(4, $divs); + + $tbl = $divs[0]->getElementsByTagName('table')[0]; + $cls = $tbl->getAttribute('class'); + self::assertEquals('sheet0 gridlines gridlinesp', $cls); + $tbl = $divs[1]->getElementsByTagName('table')[0]; + $cls = $tbl->getAttribute('class'); + self::assertEquals('sheet1 gridlines', $cls); + $tbl = $divs[2]->getElementsByTagName('table')[0]; + $cls = $tbl->getAttribute('class'); + self::assertEquals('sheet2 gridlinesp', $cls); + $tbl = $divs[3]->getElementsByTagName('table')[0]; + $cls = $tbl->getAttribute('class'); + self::assertEquals('sheet3', $cls); + + $this->writeAndReload($spreadsheet, 'Html'); + } + + public function testGridlinesInline() + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setShowGridlines(true)->setPrintGridlines(true); + $sheet->setCellValue('A1', 1); + $sheet = $spreadsheet->createSheet(); + $sheet->setShowGridlines(true)->setPrintGridlines(false); + $sheet->setCellValue('A1', 1); + $sheet = $spreadsheet->createSheet(); + $sheet->setShowGridlines(false)->setPrintGridlines(true); + $sheet->setCellValue('A1', 1); + $sheet = $spreadsheet->createSheet(); + $sheet->setShowGridlines(false)->setPrintGridlines(false); + $sheet->setCellValue('A1', 1); + + $writer = new Html($spreadsheet); + $writer->writeAllSheets(); + $writer->setUseInlineCss(true); + + $html = $writer->generateHTMLAll(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('div'); + self::assertCount(4, $divs); + + $tbl = $divs[0]->getElementsByTagName('table')[0]; + $cls = $tbl->getAttribute('class'); + self::assertEquals('gridlines gridlinesp', $cls); + $tbl = $divs[1]->getElementsByTagName('table')[0]; + $cls = $tbl->getAttribute('class'); + self::assertEquals('gridlines', $cls); + $tbl = $divs[2]->getElementsByTagName('table')[0]; + $cls = $tbl->getAttribute('class'); + self::assertEquals('gridlinesp', $cls); + $tbl = $divs[3]->getElementsByTagName('table')[0]; + $cls = $tbl->getAttribute('class'); + self::assertEquals('', $cls); + + $this->writeAndReload($spreadsheet, 'Html'); + } + + public function testRichText() + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $emc2 = new \PhpOffice\PhpSpreadsheet\RichText\RichText(); + $part1 = $emc2->createTextRun('e=mc'); + $part1->getFont()->getColor()->setARGB(Color::COLOR_BLUE); + $part2 = $emc2->createTextRun('2'); + $font = $part2->getFont(); + $font->getColor()->setARGB(Color::COLOR_DARKGREEN); + $font->setSuperScript(true); + $sheet->setCellValue('A1', $emc2); + $h2o = new \PhpOffice\PhpSpreadsheet\RichText\RichText(); + $h2o->createTextRun('H'); + $part2 = $h2o->createTextRun('2'); + $font = $part2->getFont(); + $font->setSubScript(true); + $font->getColor()->setARGB(Color::COLOR_RED); + $h2o->createTextRun('O'); + $sheet->setCellValue('A2', $h2o); + $h2so4 = new \PhpOffice\PhpSpreadsheet\RichText\RichText(); + $h2so4->createTextRun('H'); + $part2 = $h2so4->createTextRun('2'); + $font = $part2->getFont(); + $font->setSubScript(true); + $h2so4->createTextRun('SO'); + $part4 = $h2so4->createTextRun('4'); + $part4->getFont()->setSubScript(true); + $sheet->setCellValue('A3', $h2so4); + $sheet->setCellValue('A4', '5'); + $sheet->getCell('A4')->getStyle()->getFont()->setSuperScript(true); + $sheet->setCellValue('A5', '6'); + $sheet->getCell('A5')->getStyle()->getFont()->setSubScript(true); + + $writer = new Html($spreadsheet); + $html = $writer->generateHTMLAll(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('div'); + self::assertCount(1, $divs); + + $tabl = $divs[0]->getElementsByTagName('table'); + $tbod = $tabl[0]->getElementsByTagName('tbody'); + $rows = $tbod[0]->getElementsByTagName('tr'); + self::assertCount(5, $rows); + $tds = $rows[0]->getElementsByTagName('td'); + self::assertCount(1, $tds); + $spans = $tds[0]->getElementsByTagName('span'); + self::assertCount(2, $spans); + self::assertEquals('e=mc', $spans[0]->textContent); + $style = $spans[0]->getAttribute('style'); + self::assertEquals(1, preg_match('/color:#0000FF/', $style)); + $style = $spans[1]->getAttribute('style'); + self::assertEquals(1, preg_match('/color:#008000/', $style)); + $sups = $spans[1]->getElementsByTagName('sup'); + self::assertCount(1, $sups); + assert('2' == $sups[0]->textContent); + + $tds = $rows[1]->getElementsByTagName('td'); + assert(1 == count($tds)); + $spans = $tds[0]->getElementsByTagName('span'); + assert(3 == count($spans)); + assert('H' == $spans[0]->textContent); + $style = $spans[1]->getAttribute('style'); + assert(1 == preg_match('/color:#FF0000/', $style)); + $subs = $spans[1]->getElementsByTagName('sub'); + assert(1 == count($subs)); + assert('2' == $subs[0]->textContent); + assert('O' == $spans[2]->textContent); + + $tds = $rows[2]->getElementsByTagName('td'); + self::assertCount(1, $tds); + $spans = $tds[0]->getElementsByTagName('span'); + self::assertCount(4, $spans); + self::assertEquals('H', $spans[0]->textContent); + $subs = $spans[1]->getElementsByTagName('sub'); + self::assertCount(1, $subs); + self::assertEquals('2', $subs[0]->textContent); + self::assertEquals('SO', $spans[2]->textContent); + $subs = $spans[3]->getElementsByTagName('sub'); + self::assertCount(1, $subs); + self::assertEquals('4', $subs[0]->textContent); + + $tds = $rows[3]->getElementsByTagName('td'); + self::assertCount(1, $tds); + $spans = $tds[0]->getElementsByTagName('span'); + self::assertCount(0, $spans); + $sups = $tds[0]->getElementsByTagName('sup'); + self::assertCount(1, $sups); + self::assertEquals('5', $sups[0]->textContent); + + $tds = $rows[4]->getElementsByTagName('td'); + self::assertCount(1, $tds); + $spans = $tds[0]->getElementsByTagName('span'); + self::assertCount(0, $spans); + $subs = $tds[0]->getElementsByTagName('sub'); + self::assertCount(1, $subs); + self::assertEquals('6', $subs[0]->textContent); + + $this->writeAndReload($spreadsheet, 'Html'); + } +} diff --git a/tests/PhpSpreadsheetTests/Functional/HtmlCommentsTest.php b/tests/PhpSpreadsheetTests/Writer/Html/HtmlCommentsTest.php similarity index 92% rename from tests/PhpSpreadsheetTests/Functional/HtmlCommentsTest.php rename to tests/PhpSpreadsheetTests/Writer/Html/HtmlCommentsTest.php index 1b497277a6..637c6514cb 100644 --- a/tests/PhpSpreadsheetTests/Functional/HtmlCommentsTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/HtmlCommentsTest.php @@ -1,11 +1,12 @@ decsep = StringHelper::getDecimalSeparator(); + StringHelper::setDecimalSeparator('.'); + $this->thosep = StringHelper::getThousandsSeparator(); + StringHelper::setThousandsSeparator(','); + } + + protected function tearDown(): void + { + StringHelper::setDecimalSeparator($this->decsep); + StringHelper::setThousandsSeparator($this->thosep); + } + + public function testColorNumberFormat() + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('A1', -50); + $sheet->setCellValue('A2', 3000); + $sheet->setCellValue('A3', 0); + $sheet->setCellValue('A4', '
'); + $fmt = '[Blue]$#,##0;[Red]$#,##0;$#,##0'; + $sheet->getStyle('A1:A4')->getNumberFormat()->setFormatCode($fmt); + + $writer = new Html($spreadsheet); + $html = $writer->generateHTMLAll(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('div'); + + $tabl = $divs[0]->getElementsByTagName('table'); + $tbod = $tabl[0]->getElementsByTagName('tbody'); + $rows = $tbod[0]->getElementsByTagName('tr'); + self::assertCount(4, $rows); + + $tds = $rows[0]->getElementsByTagName('td'); + self::assertCount(1, $tds); + $spans = $tds[0]->getElementsByTagName('span'); + self::assertCount(1, $spans); + $style = $spans[0]->getAttribute('style'); + self::assertEquals(1, preg_match('/color:red/', $style)); + self::assertEquals('$50', $spans[0]->textContent); + + $tds = $rows[1]->getElementsByTagName('td'); + self::assertCount(1, $tds); + $spans = $tds[0]->getElementsByTagName('span'); + self::assertCount(1, $spans); + $style = $spans[0]->getAttribute('style'); + self::assertEquals(1, preg_match('/color:blue/', $style)); + self::assertEquals('$3,000', $spans[0]->textContent); + + $tds = $rows[2]->getElementsByTagName('td'); + self::assertCount(1, $tds); + $spans = $tds[0]->getElementsByTagName('span'); + self::assertCount(0, $spans); + self::assertEquals('$0', $tds[0]->textContent); + + $tds = $rows[3]->getElementsByTagName('td'); + self::assertCount(1, $tds); + $spans = $tds[0]->getElementsByTagName('span'); + self::assertCount(0, $spans); + self::assertEquals('
', $tds[0]->textContent); + + $this->writeAndReload($spreadsheet, 'Html'); + } + + public function testColorNumberFormatComplex() + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('A1', -50); + $sheet->setCellValue('A2', 3000.75); + $sheet->setCellValue('A3', 0); + $sheet->setCellValue('A4', 3000.25); + $fmt = '[Blue][>=3000.5]$#,##0.00;[Red][<0]$#,##0.00;$#,##0.00'; + $sheet->getStyle('A1:A4')->getNumberFormat()->setFormatCode($fmt); + + $writer = new Html($spreadsheet); + $html = $writer->generateHTMLAll(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('div'); + + $tabl = $divs[0]->getElementsByTagName('table'); + $tbod = $tabl[0]->getElementsByTagName('tbody'); + $rows = $tbod[0]->getElementsByTagName('tr'); + self::assertCount(4, $rows); + + $tds = $rows[0]->getElementsByTagName('td'); + self::assertCount(1, $tds); + $spans = $tds[0]->getElementsByTagName('span'); + self::assertCount(1, $spans); + $style = $spans[0]->getAttribute('style'); + self::assertEquals(1, preg_match('/color:red/', $style)); + self::assertEquals('$50.00', $spans[0]->textContent); + + $tds = $rows[1]->getElementsByTagName('td'); + self::assertCount(1, $tds); + $spans = $tds[0]->getElementsByTagName('span'); + self::assertCount(1, $spans); + $style = $spans[0]->getAttribute('style'); + self::assertEquals(1, preg_match('/color:blue/', $style)); + self::assertEquals('$3,000.75', $spans[0]->textContent); + + $tds = $rows[2]->getElementsByTagName('td'); + self::assertCount(1, $tds); + $spans = $tds[0]->getElementsByTagName('span'); + self::assertCount(0, $spans); + self::assertEquals('$0.00', $tds[0]->textContent); + + $tds = $rows[3]->getElementsByTagName('td'); + self::assertCount(1, $tds); + $spans = $tds[0]->getElementsByTagName('span'); + self::assertCount(0, $spans); + self::assertEquals('$3,000.25', $tds[0]->textContent); + + $this->writeAndReload($spreadsheet, 'Html'); + } + + /** + * @dataProvider providerNumberFormat + * + * @param mixed $expectedResult + * @param mixed $val + * @param mixed $fmt + */ + public function testFormatValueWithMask($expectedResult, $val, $fmt) + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->getCell('A1')->setValue($val)->getStyle()->getNumberFormat()->setFormatCode($fmt); + + $writer = new Html($spreadsheet); + $html = $writer->generateHTMLAll(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('div'); + + $tabl = $divs[0]->getElementsByTagName('table'); + $tbod = $tabl[0]->getElementsByTagName('tbody'); + $rows = $tbod[0]->getElementsByTagName('tr'); + + $tds = $rows[0]->getElementsByTagName('td'); + $nbsp = html_entity_decode(' '); + self::assertEquals($expectedResult, str_replace($nbsp, ' ', $tds[0]->textContent)); + + $this->writeAndReload($spreadsheet, 'Html'); + } + + public function providerNumberFormat() + { + return require __DIR__ . '/../../../data/Style/NumberFormat.php'; + } + + /** + * @dataProvider providerNumberFormatDates + * + * @param mixed $expectedResult + * @param mixed $val + * @param mixed $fmt + */ + public function testFormatValueWithMaskDate($expectedResult, $val, $fmt) + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->getCell('A1')->setValue($val)->getStyle()->getNumberFormat()->setFormatCode($fmt); + + $writer = new Html($spreadsheet); + $html = $writer->generateHTMLAll(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('div'); + + $tabl = $divs[0]->getElementsByTagName('table'); + $tbod = $tabl[0]->getElementsByTagName('tbody'); + $rows = $tbod[0]->getElementsByTagName('tr'); + + $tds = $rows[0]->getElementsByTagName('td'); + $nbsp = html_entity_decode(' '); + self::assertEquals($expectedResult, str_replace($nbsp, ' ', $tds[0]->textContent)); + + $this->writeAndReload($spreadsheet, 'Html'); + } + + public function providerNumberFormatDates() + { + return require __DIR__ . '/../../../data/Style/NumberFormatDates.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Writer/Html/ImagesRootTest.php b/tests/PhpSpreadsheetTests/Writer/Html/ImagesRootTest.php new file mode 100644 index 0000000000..f7716e33c2 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Html/ImagesRootTest.php @@ -0,0 +1,54 @@ +getActiveSheet(); + $drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing(); + $drawing->setName('Test'); + $drawing->setDescription('Test'); + $root = 'http://www.example.com'; + $newdir = __DIR__ . '/../../../data/Reader/HTML'; + $stub = 'image.jpg'; + $imagePath = "./$stub"; + $curdir = getcwd(); + chdir($newdir); + self::assertFileExists($imagePath); + $drawing->setPath($imagePath); + $desc = 'Test tag'; + $drawing->setDescription($desc); + $drawing->setHeight(36); + $drawing->setWorksheet($spreadsheet->getActiveSheet()); + $drawing->setCoordinates('A1'); + $sheet->setCellValue('A2', 'Image Above?'); + + $writer = new Html($spreadsheet); + $writer->setImagesRoot($root); + $html = $writer->generateHTMLAll(); + chdir($curdir); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('div'); + + $tabl = $divs[0]->getElementsByTagName('table'); + $tbod = $tabl[0]->getElementsByTagName('tbody'); + $rows = $tbod[0]->getElementsByTagName('tr'); + self::assertCount(2, $rows); + + $tds = $rows[0]->getElementsByTagName('td'); + self::assertCount(1, $tds); + $img = $tds[0]->getElementsByTagName('img'); + self::assertCount(1, $img); + self::assertEquals("$root/$stub", $img[0]->getAttribute('src')); + self::assertEquals($desc, $img[0]->getAttribute('alt')); + } +} diff --git a/tests/PhpSpreadsheetTests/Writer/Html/InvalidFileNameTest.php b/tests/PhpSpreadsheetTests/Writer/Html/InvalidFileNameTest.php new file mode 100644 index 0000000000..f536d2bdbd --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Html/InvalidFileNameTest.php @@ -0,0 +1,53 @@ +expectException(WriterException::class); + $spreadsheet = new Spreadsheet(); + $spreadsheet->getActiveSheet()->getCell('A1')->setValue('Cell 1'); + $writer = new Html($spreadsheet); + $writer->save(''); + } + + public function testEmptyFileNamePdf() + { + $this->expectException(WriterException::class); + $spreadsheet = new Spreadsheet(); + $spreadsheet->getActiveSheet()->getCell('A1')->setValue('Cell 1'); + $writer = new Mpdf($spreadsheet); + $writer->save(''); + } + + public function testEmptyTempdirNamePdf() + { + $this->expectException(WriterException::class); + $spreadsheet = new Spreadsheet(); + $spreadsheet->getActiveSheet()->getCell('A1')->setValue('Cell 1'); + $writer = new Mpdf($spreadsheet); + $writer->setFont('Helvetica'); + self::assertEquals('Helvetica', $writer->getFont()); + $writer->setPaperSize(PageSetup::PAPERSIZE_LEDGER); + self::assertEquals($writer->getPaperSize(), PageSetup::PAPERSIZE_LEDGER); + self::assertEquals(File::sysGetTempDir() . '/phpsppdf', $writer->getTempDir()); + $writer->setTempDir(''); + } + + public function testWinFileNames() + { + self::assertEquals('file:///C:/temp/filename.xlsx', Html::winFileToUrl('C:\\temp\filename.xlsx')); + self::assertEquals('/tmp/filename.xlsx', Html::winFileToUrl('/tmp/filename.xlsx')); + self::assertEquals('a:bfile', Html::winFileToUrl('a:bfile')); + } +} diff --git a/tests/PhpSpreadsheetTests/Writer/Html/RepeatedRowsTest.php b/tests/PhpSpreadsheetTests/Writer/Html/RepeatedRowsTest.php new file mode 100644 index 0000000000..e38e4b8e9a --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Html/RepeatedRowsTest.php @@ -0,0 +1,104 @@ +getActiveSheet(); + $sheet->getPageSetup()->setRowsToRepeatAtTop([1, 2]); + $sheet->setCellValue('A1', 'Repeat1'); + $sheet->setCellValue('A2', 'Repeat2'); + for ($row = 3; $row <= 100; ++$row) { + $sheet->setCellValue("A$row", $row); + } + + $writer = new Html($spreadsheet); + $html = $writer->generateHTMLall(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('div'); + $tbl = $divs->item(0)->getElementsByTagName('table'); + self::assertEquals('', $tbl->item(0)->getAttribute('style')); + $thd = $divs->item(0)->getElementsByTagName('thead'); + self::assertCount(1, $thd); + $trw = $thd->item(0)->getElementsByTagName('tr'); + self::assertCount(2, $trw); + $tbd = $divs->item(0)->getElementsByTagName('tbody'); + self::assertCount(1, $tbd); + $trw = $tbd->item(0)->getElementsByTagName('tr'); + self::assertCount(98, $trw); + + $this->writeAndReload($spreadsheet, 'Html'); + } + + public function testWriteNoRepeats() + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + //$sheet->getPageSetup()->setRowsToRepeatAtTop([1, 2]); + $sheet->setCellValue('A1', 'Repeat1'); + $sheet->setCellValue('A2', 'Repeat2'); + for ($row = 3; $row <= 100; ++$row) { + $sheet->setCellValue("A$row", $row); + } + + $writer = new Html($spreadsheet); + $html = $writer->generateHTMLall(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('div'); + $tbl = $divs->item(0)->getElementsByTagName('table'); + $thd = $tbl->item(0)->getElementsByTagName('thead'); + self::assertCount(0, $thd); + //$trw = $thd->item(0)->getElementsByTagName('tr'); + //self::assertCount(2, $trw); + $tbd = $divs->item(0)->getElementsByTagName('tbody'); + self::assertCount(1, $tbd); + $trw = $tbd->item(0)->getElementsByTagName('tr'); + self::assertCount(100, $trw); + + $this->writeAndReload($spreadsheet, 'Html'); + } + + public function testWriteRepeatsInline() + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->getPageSetup()->setRowsToRepeatAtTop([1, 2]); + $sheet->setCellValue('A1', 'Repeat1'); + $sheet->setCellValue('A2', 'Repeat2'); + for ($row = 3; $row <= 100; ++$row) { + $sheet->setCellValue("A$row", $row); + } + + $writer = new Html($spreadsheet); + self::assertFalse($writer->getUseInlineCss()); + $writer->setUseInlineCss(true); + $html = $writer->generateHTMLall(); + $dom = new \DOMDocument(); + $dom->loadHTML($html); + $body = $dom->getElementsByTagName('body')[0]; + $divs = $body->getElementsByTagName('div'); + $tbl = $divs->item(0)->getElementsByTagName('table'); + self::assertEquals('border-collapse:collapse', $tbl->item(0)->getAttribute('style')); + $thd = $divs->item(0)->getElementsByTagName('thead'); + self::assertCount(1, $thd); + $trw = $thd->item(0)->getElementsByTagName('tr'); + self::assertCount(2, $trw); + $tbd = $divs->item(0)->getElementsByTagName('tbody'); + self::assertCount(1, $tbd); + $trw = $tbd->item(0)->getElementsByTagName('tr'); + self::assertCount(98, $trw); + + $this->writeAndReload($spreadsheet, 'Html'); + } +} diff --git a/tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php b/tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php new file mode 100644 index 0000000000..63cdefb7d9 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php @@ -0,0 +1,111 @@ +getActiveSheet(); + $sheet->setCellValue('A1', 1); + $sheet->setCellValue('A2', 2); + $sheet->setCellValue('A3', 3); + $sheet->setCellValue('B1', 4); + $sheet->setCellValue('B2', 5); + $sheet->setCellValue('B3', 6); + $sheet->setCellValue('C1', 7); + $sheet->setCellValue('C2', 8); + $sheet->setCellValue('C3', 9); + $sheet->getColumnDimension('B')->setVisible(false); + $sheet->getRowDimension(2)->setVisible(false); + $writer = new Html($spreadsheet); + $html = $writer->generateHTMLAll(); + $reg = '/^\\s*table[.]sheet0 tr { display:none; visibility:hidden }\\s*$/m'; + $rowsrch = preg_match($reg, $html); + self::assertEquals($rowsrch, 0); + $reg = '/^\\s*table[.]sheet0 tr[.]row1 { display:none; visibility:hidden }\\s*$/m'; + $rowsrch = preg_match($reg, $html); + self::assertEquals($rowsrch, 1); + $reg = '/^\\s*table[.]sheet0 [.]column1 [{] display:none [}]\\s*$/m'; + $colsrch = preg_match($reg, $html); + self::assertEquals($colsrch, 1); + + $this->writeAndReload($spreadsheet, 'Html'); + } + + public function testVisibility2() + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('A1', 1); + $sheet->setCellValue('A2', 2); + $sheet->setCellValue('A3', 3); + $sheet->setCellValue('B1', 4); + $sheet->setCellValue('B2', 5); + $sheet->setCellValue('B3', 6); + $sheet->setCellValue('C1', 7); + $sheet->setCellValue('C2', 8); + $sheet->setCellValue('C3', 9); + $sheet->getDefaultRowDimension()->setVisible(false); + $sheet->getColumnDimension('B')->setVisible(false); + $sheet->getRowDimension(1)->setVisible(true); + $sheet->getRowDimension(3)->setVisible(true); + + $writer = new Html($spreadsheet); + $html = $writer->generateHTMLAll(); + $reg = '/^\\s*table[.]sheet0 tr { height:15pt; display:none; visibility:hidden }\\s*$/m'; + $rowsrch = preg_match($reg, $html); + self::assertEquals($rowsrch, 1); + $reg = '/^\\s*table[.]sheet0 tr[.]row1 { display:none; visibility:hidden }\\s*$/m'; + $rowsrch = preg_match($reg, $html); + self::assertEquals($rowsrch, 0); + $reg = '/^\\s*table[.]sheet0 [.]column1 [{] display:none [}]\\s*$/m'; + $colsrch = preg_match($reg, $html); + self::assertEquals($colsrch, 1); + + $this->writeAndReload($spreadsheet, 'Html'); + } + + public function testDefaultRowHeight() + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('A1', 1); + $sheet->getStyle('A1')->getFont()->setStrikethrough(true); + $sheet->setCellValue('A2', 2); + $sheet->setCellValue('A3', 3); + $sheet->getStyle('A3')->getFont()->setStrikethrough(true)->setUnderline(Font::UNDERLINE_SINGLE); + $sheet->setCellValue('B1', 4); + $sheet->setCellValue('B2', 5); + $sheet->setCellValue('B3', 6); + $sheet->setCellValue('C1', 7); + $sheet->setCellValue('C2', 8); + $sheet->setCellValue('C3', 9); + $sheet->getStyle('C3')->getFont()->setUnderline(Font::UNDERLINE_SINGLE); + $sheet->getDefaultRowDimension()->setRowHeight(20); + $sheet->getRowDimension(2)->setRowHeight(25); + + $writer = new Html($spreadsheet); + $html = $writer->generateHTMLAll(); + self::assertEquals(1, substr_count($html, 'height:20pt')); + self::assertEquals(1, substr_count($html, 'height:25pt')); + $rowsrch = preg_match('/^\\s*table[.]sheet0 tr [{] height:20pt [}]\\s*$/m', $html); + self::assertEquals(1, $rowsrch); + $rowsrch = preg_match('/^\\s*table[.]sheet0 tr[.]row1 [{] height:25pt [}]\\s*$/m', $html); + self::assertEquals(1, $rowsrch); + $rowsrch = preg_match('/^\\s*td[.]style1 [{].*text-decoration:line-through;.*[}]\\s*$/m', $html); + self::assertEquals(1, $rowsrch); + $rowsrch = preg_match('/^\\s*td[.]style2 [{].*text-decoration:underline line-through;.*[}]\\s*$/m', $html); + self::assertEquals(1, $rowsrch); + $rowsrch = preg_match('/^\\s*td[.]style3 [{].*text-decoration:underline;.*[}]\\s*$/m', $html); + self::assertEquals(1, $rowsrch); + + $this->writeAndReload($spreadsheet, 'Html'); + } +} diff --git a/tests/data/Style/NumberFormat.php b/tests/data/Style/NumberFormat.php index d9ab094094..5038d6da47 100644 --- a/tests/data/Style/NumberFormat.php +++ b/tests/data/Style/NumberFormat.php @@ -103,6 +103,11 @@ 12345.678900000001, '#,##0.000\ [$€-1]', ], + [ + '12,345.679 $', + 12345.678900000001, + '#,##0.000\ [$]', + ], [ '5.68', 5.6788999999999996, @@ -177,6 +182,21 @@ 5.25, '???/???', ], + [ + '0 3/4', + 0.75, + '0??/???', + ], + [ + '3/4', + 0.75, + '#??/???', + ], + [ + ' 3/4', + 0.75, + '? ??/???', + ], // Complex formats [ '(001) 2-3456-789', @@ -302,4 +322,24 @@ -2, '[Green]"Positive";[Red]"Negative";[Blue]"Zero"', ], + [ + '<=3500 red', + 3500, + '[Green][=17]"=17 green";[Red][<=3500]"<=3500 red";[Blue]"Zero"', + ], + [ + '=17 green', + 17, + '[Green][=17]"=17 green";[Red][<=3500]"<=3500 red";[Blue]"Zero"', + ], + [ + '<>25 green', + 17, + '[Green][<>25]"<>25 green";[Red]"else red"', + ], + [ + 'else red', + 25, + '[Green][<>25]"<>25 green";[Red]"else red"', + ], ]; From 38b360f91258b8ffc4dfae68ec40bfcd6adfb163 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 18 May 2020 12:49:46 +0900 Subject: [PATCH 047/659] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbc3909215..27d72197f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Fix return type in docblock for the Cells::get() [#1398](https://github.com/PHPOffice/PhpSpreadsheet/pull/1398) - Fix RATE, PRICE, XIRR, and XNPV Functions [#1456](https://github.com/PHPOffice/PhpSpreadsheet/pull/1456) - Save Excel 2010+ functions properly in XLSX [#1461](https://github.com/PHPOffice/PhpSpreadsheet/pull/1461) +- Several improvements in HTML writer [#1464](https://github.com/PHPOffice/PhpSpreadsheet/pull/1464) ### Changed From fcd9f10663c5be8e435fd0f92c077a8d8747ded1 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 18 May 2020 13:49:57 +0900 Subject: [PATCH 048/659] Update PHP-CS-Fixer rules --- .php_cs.dist | 117 ++++++++---- .../Autofilter/10_Autofilter_selection_1.php | 12 +- .../Autofilter/10_Autofilter_selection_2.php | 12 +- .../10_Autofilter_selection_display.php | 12 +- samples/Basic/22_Heavily_formatted.php | 24 +-- samples/Basic/23_Sharedstyles.php | 32 ++-- samples/Basic/25_In_memory_image.php | 6 +- samples/Basic/30_Template.php | 6 +- samples/Chart/33_Chart_create_area.php | 12 +- samples/Chart/33_Chart_create_bar_stacked.php | 12 +- samples/Chart/33_Chart_create_column.php | 12 +- samples/Chart/33_Chart_create_column_2.php | 28 +-- samples/Chart/33_Chart_create_composite.php | 28 +-- .../Chart/33_Chart_create_multiple_charts.php | 12 +- samples/Chart/33_Chart_create_pie.php | 12 +- .../33_Chart_create_pie_custom_colors.php | 12 +- samples/Chart/33_Chart_create_radar.php | 28 +-- samples/Chart/33_Chart_create_scatter.php | 12 +- samples/Chart/33_Chart_create_stock.php | 14 +- samples/Chart/34_Chart_update.php | 10 +- ...a_configurable_read_filter_(version_2).php | 2 +- ...ks_to_split_across_multiple_worksheets.php | 2 +- samples/templates/chartSpreadsheet.php | 12 +- samples/templates/sampleSpreadsheet.php | 72 +++---- .../Calculation/Calculation.php | 75 ++++---- src/PhpSpreadsheet/Calculation/DateTime.php | 10 +- .../Engine/CyclicReferenceStack.php | 4 +- .../Calculation/Engine/Logger.php | 12 +- .../Calculation/Engineering.php | 8 +- src/PhpSpreadsheet/Calculation/Exception.php | 2 +- src/PhpSpreadsheet/Calculation/Financial.php | 40 ++-- .../Calculation/FormulaParser.php | 2 +- .../Calculation/FormulaToken.php | 6 +- src/PhpSpreadsheet/Calculation/Functions.php | 2 +- src/PhpSpreadsheet/Calculation/LookupRef.php | 17 +- src/PhpSpreadsheet/Calculation/MathTrig.php | 26 ++- .../Calculation/Statistical.php | 69 ++++--- src/PhpSpreadsheet/Calculation/TextData.php | 4 +- .../Calculation/Token/Stack.php | 4 +- src/PhpSpreadsheet/Cell/Cell.php | 15 +- src/PhpSpreadsheet/Cell/Coordinate.php | 2 +- src/PhpSpreadsheet/Chart/Axis.php | 17 +- src/PhpSpreadsheet/Chart/Chart.php | 23 +-- src/PhpSpreadsheet/Chart/DataSeries.php | 2 +- src/PhpSpreadsheet/Chart/DataSeriesValues.php | 2 +- src/PhpSpreadsheet/Chart/GridLines.php | 11 +- src/PhpSpreadsheet/Chart/Layout.php | 2 - src/PhpSpreadsheet/Chart/Legend.php | 3 +- src/PhpSpreadsheet/Chart/PlotArea.php | 5 +- .../Chart/Renderer/IRenderer.php | 2 - src/PhpSpreadsheet/Chart/Renderer/JpGraph.php | 96 ++++++---- .../Chart/Renderer/Polyfill.php | 2 +- src/PhpSpreadsheet/Chart/Title.php | 3 +- src/PhpSpreadsheet/Collection/Cells.php | 14 +- src/PhpSpreadsheet/Comment.php | 2 - src/PhpSpreadsheet/Document/Properties.php | 8 +- src/PhpSpreadsheet/DocumentGenerator.php | 6 +- src/PhpSpreadsheet/HashTable.php | 8 +- src/PhpSpreadsheet/Helper/Html.php | 48 +++-- src/PhpSpreadsheet/Helper/Sample.php | 15 +- src/PhpSpreadsheet/IOFactory.php | 5 +- src/PhpSpreadsheet/NamedRange.php | 7 +- src/PhpSpreadsheet/Reader/BaseReader.php | 4 +- src/PhpSpreadsheet/Reader/Csv.php | 16 +- src/PhpSpreadsheet/Reader/Gnumeric.php | 5 +- src/PhpSpreadsheet/Reader/Html.php | 24 +-- src/PhpSpreadsheet/Reader/IReader.php | 2 - src/PhpSpreadsheet/Reader/Ods.php | 27 +-- src/PhpSpreadsheet/Reader/Ods/Properties.php | 11 +- .../Reader/Security/XmlScanner.php | 6 +- src/PhpSpreadsheet/Reader/Slk.php | 1 - src/PhpSpreadsheet/Reader/Xls.php | 176 +++++++++--------- src/PhpSpreadsheet/Reader/Xls/Escher.php | 44 ++--- src/PhpSpreadsheet/Reader/Xls/MD5.php | 6 +- src/PhpSpreadsheet/Reader/Xlsx.php | 36 ++-- src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php | 15 +- src/PhpSpreadsheet/Reader/Xlsx/Chart.php | 5 +- .../Reader/Xlsx/ColumnAndRowAttributes.php | 15 +- .../Reader/Xlsx/ConditionalStyles.php | 7 +- .../Reader/Xlsx/DataValidations.php | 5 +- src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php | 7 +- src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php | 15 +- src/PhpSpreadsheet/Reader/Xlsx/Properties.php | 9 +- .../Reader/Xlsx/SheetViewOptions.php | 17 +- src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php | 21 ++- src/PhpSpreadsheet/Reader/Xlsx/Styles.php | 27 +-- src/PhpSpreadsheet/Reader/Xml.php | 25 +-- src/PhpSpreadsheet/ReferenceHelper.php | 20 +- src/PhpSpreadsheet/RichText/RichText.php | 2 +- src/PhpSpreadsheet/RichText/Run.php | 2 +- src/PhpSpreadsheet/Settings.php | 10 +- src/PhpSpreadsheet/Shared/Date.php | 9 +- .../Shared/Escher/DgContainer.php | 4 +- .../Escher/DgContainer/SpgrContainer.php | 4 +- .../DgContainer/SpgrContainer/SpContainer.php | 24 +-- .../Shared/Escher/DggContainer.php | 12 +- .../Escher/DggContainer/BstoreContainer.php | 2 +- .../DggContainer/BstoreContainer/BSE.php | 6 +- .../DggContainer/BstoreContainer/BSE/Blip.php | 4 +- src/PhpSpreadsheet/Shared/File.php | 4 +- src/PhpSpreadsheet/Shared/Font.php | 5 +- .../Shared/JAMA/EigenvalueDecomposition.php | 20 +- src/PhpSpreadsheet/Shared/JAMA/Matrix.php | 33 +--- .../JAMA/SingularValueDecomposition.php | 14 +- src/PhpSpreadsheet/Shared/OLE.php | 10 +- .../Shared/OLE/ChainedBlockStream.php | 4 +- src/PhpSpreadsheet/Shared/OLE/PPS/File.php | 2 +- src/PhpSpreadsheet/Shared/OLE/PPS/Root.php | 32 ++-- src/PhpSpreadsheet/Shared/OLERead.php | 4 +- src/PhpSpreadsheet/Shared/StringHelper.php | 12 +- src/PhpSpreadsheet/Shared/Trend/BestFit.php | 6 +- .../Shared/Trend/ExponentialBestFit.php | 4 +- .../Shared/Trend/LinearBestFit.php | 2 +- .../Shared/Trend/LogarithmicBestFit.php | 2 +- .../Shared/Trend/PolynomialBestFit.php | 8 +- .../Shared/Trend/PowerBestFit.php | 6 +- src/PhpSpreadsheet/Shared/Xls.php | 10 +- src/PhpSpreadsheet/Spreadsheet.php | 67 +++---- src/PhpSpreadsheet/Style/Border.php | 2 - src/PhpSpreadsheet/Style/Conditional.php | 2 +- src/PhpSpreadsheet/Style/Fill.php | 4 - src/PhpSpreadsheet/Style/Font.php | 2 - src/PhpSpreadsheet/Style/NumberFormat.php | 86 ++++----- src/PhpSpreadsheet/Style/Style.php | 4 +- src/PhpSpreadsheet/Worksheet/AutoFilter.php | 4 +- .../Worksheet/AutoFilter/Column.php | 6 +- .../Worksheet/AutoFilter/Column/Rule.php | 4 +- src/PhpSpreadsheet/Worksheet/BaseDrawing.php | 9 +- src/PhpSpreadsheet/Worksheet/CellIterator.php | 8 +- src/PhpSpreadsheet/Worksheet/Column.php | 4 +- .../Worksheet/ColumnCellIterator.php | 10 +- .../Worksheet/ColumnIterator.php | 11 +- .../Worksheet/Drawing/Shadow.php | 2 +- src/PhpSpreadsheet/Worksheet/HeaderFooter.php | 1 - src/PhpSpreadsheet/Worksheet/Iterator.php | 8 +- .../Worksheet/MemoryDrawing.php | 2 +- src/PhpSpreadsheet/Worksheet/Row.php | 4 +- .../Worksheet/RowCellIterator.php | 10 +- src/PhpSpreadsheet/Worksheet/RowIterator.php | 11 +- src/PhpSpreadsheet/Worksheet/SheetView.php | 2 +- src/PhpSpreadsheet/Worksheet/Worksheet.php | 31 +-- src/PhpSpreadsheet/Writer/Csv.php | 4 +- src/PhpSpreadsheet/Writer/Html.php | 33 ++-- src/PhpSpreadsheet/Writer/IWriter.php | 2 - src/PhpSpreadsheet/Writer/Ods.php | 4 +- .../Writer/Ods/Cell/Comment.php | 2 +- src/PhpSpreadsheet/Writer/Ods/Content.php | 30 +-- src/PhpSpreadsheet/Writer/Ods/Meta.php | 2 +- src/PhpSpreadsheet/Writer/Ods/Mimetype.php | 2 +- src/PhpSpreadsheet/Writer/Ods/Settings.php | 2 +- src/PhpSpreadsheet/Writer/Ods/Styles.php | 2 +- src/PhpSpreadsheet/Writer/Ods/Thumbnails.php | 2 +- src/PhpSpreadsheet/Writer/Ods/WriterPart.php | 2 - src/PhpSpreadsheet/Writer/Pdf/Dompdf.php | 2 +- src/PhpSpreadsheet/Writer/Pdf/Mpdf.php | 2 +- src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php | 2 +- src/PhpSpreadsheet/Writer/Xls.php | 10 +- src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php | 6 +- src/PhpSpreadsheet/Writer/Xls/Font.php | 4 +- src/PhpSpreadsheet/Writer/Xls/Parser.php | 50 ++--- src/PhpSpreadsheet/Writer/Xls/Workbook.php | 33 ++-- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 114 ++++++------ src/PhpSpreadsheet/Writer/Xls/Xf.php | 20 +- src/PhpSpreadsheet/Writer/Xlsx.php | 4 +- src/PhpSpreadsheet/Writer/Xlsx/Chart.php | 35 ++-- src/PhpSpreadsheet/Writer/Xlsx/Comments.php | 8 +- .../Writer/Xlsx/ContentTypes.php | 5 +- src/PhpSpreadsheet/Writer/Xlsx/DocProps.php | 6 - src/PhpSpreadsheet/Writer/Xlsx/Drawing.php | 16 +- src/PhpSpreadsheet/Writer/Xlsx/Rels.php | 12 +- src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php | 2 - src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php | 2 - .../Writer/Xlsx/StringTable.php | 4 +- src/PhpSpreadsheet/Writer/Xlsx/Style.php | 32 +--- src/PhpSpreadsheet/Writer/Xlsx/Theme.php | 2 - src/PhpSpreadsheet/Writer/Xlsx/Workbook.php | 36 ++-- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 52 +++--- src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php | 2 - .../Calculation/CalculationTest.php | 54 +++--- .../DefinedNameConfusedForCellTest.php | 2 +- .../Calculation/FinancialTest.php | 74 ++++---- .../Calculation/FormulaAsStringTest.php | 2 +- .../Functions/DateTime/DateDifTest.php | 4 +- .../Functions/DateTime/DateTest.php | 26 +-- .../Functions/DateTime/DateValueTest.php | 18 +- .../Functions/DateTime/DayTest.php | 6 +- .../Functions/DateTime/Days360Test.php | 4 +- .../Functions/DateTime/DaysTest.php | 4 +- .../Functions/DateTime/EDateTest.php | 18 +- .../Functions/DateTime/EoMonthTest.php | 18 +- .../Functions/DateTime/HourTest.php | 4 +- .../Functions/DateTime/IsoWeekNumTest.php | 4 +- .../Functions/DateTime/MinuteTest.php | 4 +- .../Functions/DateTime/MonthTest.php | 4 +- .../Functions/DateTime/NetworkDaysTest.php | 4 +- .../Functions/DateTime/SecondTest.php | 4 +- .../Functions/DateTime/TimeTest.php | 16 +- .../Functions/DateTime/TimeValueTest.php | 18 +- .../Functions/DateTime/WeekDayTest.php | 4 +- .../Functions/DateTime/WeekNumTest.php | 4 +- .../Functions/DateTime/WorkDayTest.php | 4 +- .../Functions/DateTime/YearFracTest.php | 4 +- .../Functions/DateTime/YearTest.php | 4 +- .../Functions/Engineering/BesselITest.php | 4 +- .../Functions/Engineering/BesselJTest.php | 4 +- .../Functions/Engineering/BesselKTest.php | 4 +- .../Functions/Engineering/BesselYTest.php | 4 +- .../Functions/Engineering/Bin2DecTest.php | 4 +- .../Functions/Engineering/Bin2HexTest.php | 4 +- .../Functions/Engineering/Bin2OctTest.php | 4 +- .../Functions/Engineering/BitAndTest.php | 4 +- .../Functions/Engineering/BitLShiftTest.php | 4 +- .../Functions/Engineering/BitOrTest.php | 4 +- .../Functions/Engineering/BitRShiftTest.php | 4 +- .../Functions/Engineering/BitXorTest.php | 4 +- .../Functions/Engineering/ComplexTest.php | 4 +- .../Functions/Engineering/ConvertUoMTest.php | 20 +- .../Functions/Engineering/Dec2BinTest.php | 4 +- .../Functions/Engineering/Dec2HexTest.php | 4 +- .../Functions/Engineering/Dec2OctTest.php | 4 +- .../Functions/Engineering/DeltaTest.php | 4 +- .../Functions/Engineering/ErfCTest.php | 6 +- .../Functions/Engineering/ErfPreciseTest.php | 6 +- .../Functions/Engineering/ErfTest.php | 6 +- .../Functions/Engineering/GeStepTest.php | 4 +- .../Functions/Engineering/Hex2BinTest.php | 4 +- .../Functions/Engineering/Hex2DecTest.php | 4 +- .../Functions/Engineering/Hex2OctTest.php | 4 +- .../Functions/Engineering/ImAbsTest.php | 4 +- .../Functions/Engineering/ImArgumentTest.php | 4 +- .../Functions/Engineering/ImConjugateTest.php | 4 +- .../Functions/Engineering/ImCosTest.php | 4 +- .../Functions/Engineering/ImCoshTest.php | 4 +- .../Functions/Engineering/ImCotTest.php | 4 +- .../Functions/Engineering/ImCscTest.php | 4 +- .../Functions/Engineering/ImCschTest.php | 4 +- .../Functions/Engineering/ImDivTest.php | 4 +- .../Functions/Engineering/ImExpTest.php | 4 +- .../Functions/Engineering/ImLnTest.php | 4 +- .../Functions/Engineering/ImLog10Test.php | 4 +- .../Functions/Engineering/ImLog2Test.php | 4 +- .../Functions/Engineering/ImPowerTest.php | 4 +- .../Functions/Engineering/ImProductTest.php | 4 +- .../Functions/Engineering/ImRealTest.php | 4 +- .../Functions/Engineering/ImSecTest.php | 4 +- .../Functions/Engineering/ImSechTest.php | 4 +- .../Functions/Engineering/ImSinTest.php | 4 +- .../Functions/Engineering/ImSinhTest.php | 4 +- .../Functions/Engineering/ImSqrtTest.php | 4 +- .../Functions/Engineering/ImSubTest.php | 4 +- .../Functions/Engineering/ImSumTest.php | 4 +- .../Functions/Engineering/ImTanTest.php | 4 +- .../Functions/Engineering/ImaginaryTest.php | 4 +- .../Functions/Engineering/Oct2BinTest.php | 4 +- .../Functions/Engineering/Oct2DecTest.php | 4 +- .../Functions/Engineering/Oct2HexTest.php | 4 +- .../Engineering/ParseComplexTest.php | 14 +- .../Functions/Financial/AccrintMTest.php | 2 +- .../Functions/Financial/AccrintTest.php | 4 +- .../Calculation/Functions/Logical/AndTest.php | 4 +- .../Functions/Logical/FalseTest.php | 4 +- .../Functions/Logical/IfErrorTest.php | 4 +- .../Functions/Logical/IfNaTest.php | 4 +- .../Calculation/Functions/Logical/IfTest.php | 4 +- .../Calculation/Functions/Logical/NotTest.php | 4 +- .../Calculation/Functions/Logical/OrTest.php | 4 +- .../Functions/Logical/SwitchTest.php | 4 +- .../Functions/Logical/TrueTest.php | 4 +- .../Calculation/Functions/Logical/XorTest.php | 4 +- .../Functions/LookupRef/ChooseTest.php | 4 +- .../Functions/LookupRef/ColumnsTest.php | 4 +- .../Functions/LookupRef/HLookupTest.php | 4 +- .../Functions/LookupRef/IndexTest.php | 4 +- .../Functions/LookupRef/LookupTest.php | 4 +- .../Functions/LookupRef/MatchTest.php | 4 +- .../Functions/LookupRef/RowsTest.php | 4 +- .../Functions/LookupRef/VLookupTest.php | 4 +- .../Functions/MathTrig/AcotTest.php | 4 +- .../Functions/MathTrig/AcothTest.php | 4 +- .../Functions/MathTrig/ArabicTest.php | 4 +- .../Functions/MathTrig/Atan2Test.php | 4 +- .../Functions/MathTrig/BaseTest.php | 4 +- .../Functions/MathTrig/CeilingTest.php | 4 +- .../Functions/MathTrig/CombinTest.php | 4 +- .../Functions/MathTrig/CotTest.php | 4 +- .../Functions/MathTrig/CothTest.php | 4 +- .../Functions/MathTrig/CscTest.php | 4 +- .../Functions/MathTrig/CschTest.php | 4 +- .../Functions/MathTrig/EvenTest.php | 4 +- .../Functions/MathTrig/FactDoubleTest.php | 4 +- .../Functions/MathTrig/FactTest.php | 4 +- .../Functions/MathTrig/FloorMathTest.php | 4 +- .../Functions/MathTrig/FloorPreciseTest.php | 4 +- .../Functions/MathTrig/FloorTest.php | 4 +- .../Functions/MathTrig/GcdTest.php | 4 +- .../Functions/MathTrig/IntTest.php | 4 +- .../Functions/MathTrig/LcmTest.php | 4 +- .../Functions/MathTrig/LogTest.php | 4 +- .../Functions/MathTrig/MInverseTest.php | 4 +- .../Functions/MathTrig/MMultTest.php | 4 +- .../Functions/MathTrig/MRoundTest.php | 4 +- .../Functions/MathTrig/MdeTermTest.php | 4 +- .../Functions/MathTrig/ModTest.php | 4 +- .../Functions/MathTrig/MultinomialTest.php | 4 +- .../Functions/MathTrig/OddTest.php | 4 +- .../Functions/MathTrig/PowerTest.php | 4 +- .../Functions/MathTrig/ProductTest.php | 4 +- .../Functions/MathTrig/QuotientTest.php | 4 +- .../Functions/MathTrig/RomanTest.php | 4 +- .../Functions/MathTrig/RoundDownTest.php | 4 +- .../Functions/MathTrig/RoundUpTest.php | 4 +- .../Functions/MathTrig/SecTest.php | 4 +- .../Functions/MathTrig/SechTest.php | 4 +- .../Functions/MathTrig/SeriesSumTest.php | 4 +- .../Functions/MathTrig/SignTest.php | 4 +- .../Functions/MathTrig/SqrtPiTest.php | 4 +- .../Functions/MathTrig/SubTotalTest.php | 24 +-- .../Functions/MathTrig/SumIfTest.php | 4 +- .../Functions/MathTrig/SumIfsTest.php | 4 +- .../Functions/MathTrig/SumProductTest.php | 4 +- .../Functions/MathTrig/SumSqTest.php | 4 +- .../Functions/MathTrig/SumX2MY2Test.php | 4 +- .../Functions/MathTrig/SumX2PY2Test.php | 4 +- .../Functions/MathTrig/SumXMY2Test.php | 4 +- .../Functions/MathTrig/TruncTest.php | 4 +- .../Functions/Statistical/AveDevTest.php | 4 +- .../Functions/Statistical/AverageATest.php | 4 +- .../Functions/Statistical/AverageIfTest.php | 4 +- .../Functions/Statistical/AverageTest.php | 4 +- .../Functions/Statistical/BetaDistTest.php | 4 +- .../Functions/Statistical/BetaInvTest.php | 4 +- .../Functions/Statistical/BinomDistTest.php | 4 +- .../Functions/Statistical/ChiDistTest.php | 4 +- .../Functions/Statistical/ChiInvTest.php | 4 +- .../Functions/Statistical/ConfidenceTest.php | 4 +- .../Functions/Statistical/CorrelTest.php | 4 +- .../Functions/Statistical/CountATest.php | 4 +- .../Functions/Statistical/CountBlankTest.php | 4 +- .../Functions/Statistical/CountIfTest.php | 4 +- .../Functions/Statistical/CountIfsTest.php | 4 +- .../Functions/Statistical/CountTest.php | 16 +- .../Functions/Statistical/CovarTest.php | 4 +- .../Functions/Statistical/ExponDistTest.php | 4 +- .../Functions/Statistical/FisherInvTest.php | 4 +- .../Functions/Statistical/FisherTest.php | 4 +- .../Functions/Statistical/ForecastTest.php | 4 +- .../Functions/Statistical/GammaDistTest.php | 4 +- .../Functions/Statistical/GammaInvTest.php | 4 +- .../Functions/Statistical/GammaLnTest.php | 4 +- .../Functions/Statistical/GeoMeanTest.php | 4 +- .../Functions/Statistical/HarMeanTest.php | 4 +- .../Functions/Statistical/InterceptTest.php | 4 +- .../Functions/Statistical/MaxIfsTest.php | 4 +- .../Functions/Statistical/MedianTest.php | 4 +- .../Functions/Statistical/MinIfsTest.php | 4 +- .../Functions/Statistical/ModeTest.php | 1 - .../Functions/Statistical/PermutTest.php | 4 +- .../Functions/Statistical/RsqTest.php | 4 +- .../Functions/Statistical/SlopeTest.php | 4 +- .../Functions/Statistical/SteyxTest.php | 4 +- .../Functions/TextData/CharTest.php | 4 +- .../Functions/TextData/CleanTest.php | 4 +- .../Functions/TextData/CodeTest.php | 4 +- .../Functions/TextData/ConcatenateTest.php | 4 +- .../Functions/TextData/DollarTest.php | 4 +- .../Functions/TextData/ExactTest.php | 4 +- .../Functions/TextData/FindTest.php | 4 +- .../Functions/TextData/FixedTest.php | 4 +- .../Functions/TextData/LeftTest.php | 4 +- .../Functions/TextData/LenTest.php | 4 +- .../Functions/TextData/LowerTest.php | 4 +- .../Functions/TextData/MidTest.php | 4 +- .../Functions/TextData/NumberValueTest.php | 5 +- .../Functions/TextData/ProperTest.php | 4 +- .../Functions/TextData/ReplaceTest.php | 4 +- .../Functions/TextData/RightTest.php | 4 +- .../Functions/TextData/SearchTest.php | 4 +- .../Functions/TextData/SubstituteTest.php | 4 +- .../Calculation/Functions/TextData/TTest.php | 4 +- .../Functions/TextData/TextJoinTest.php | 5 +- .../Functions/TextData/TextTest.php | 4 +- .../Functions/TextData/TrimTest.php | 4 +- .../Functions/TextData/UpperTest.php | 4 +- .../Functions/TextData/ValueTest.php | 4 +- .../Calculation/FunctionsTest.php | 82 ++++---- .../Calculation/LookupRefTest.php | 16 +- .../Cell/AdvancedValueBinderTest.php | 22 +-- tests/PhpSpreadsheetTests/Cell/CellTest.php | 7 +- .../Cell/CoordinateTest.php | 61 +++--- .../PhpSpreadsheetTests/Cell/DataTypeTest.php | 4 +- .../Cell/DataValidationTest.php | 2 +- .../Cell/DataValidatorTest.php | 6 +- .../Cell/DefaultValueBinderTest.php | 12 +- .../Cell/HyperlinkTest.php | 12 +- .../Chart/DataSeriesValuesTest.php | 16 +- .../PhpSpreadsheetTests/Chart/LayoutTest.php | 4 +- .../PhpSpreadsheetTests/Chart/LegendTest.php | 18 +- .../Collection/CellsTest.php | 22 +-- .../Custom/ComplexAssert.php | 2 +- .../DocumentGeneratorTest.php | 6 - .../Functional/AbstractFunctional.php | 4 +- .../Functional/ActiveSheetTest.php | 2 +- .../Functional/ColumnWidthTest.php | 4 +- .../Functional/CommentsTest.php | 2 +- .../Functional/ConditionalStopIfTrueTest.php | 2 +- .../Functional/DrawingImageHyperlinkTest.php | 2 +- .../Functional/EnclosureTest.php | 2 +- .../Functional/FreezePaneTest.php | 8 +- .../Functional/MergedCellsTest.php | 2 +- .../Functional/PrintAreaTest.php | 4 +- .../Functional/ReadBlankCellsTest.php | 17 +- .../Functional/ReadFilterTest.php | 10 +- .../Functional/SelectedCellsTest.php | 2 +- .../Functional/StreamTest.php | 2 - .../TypeAttributePreservationTest.php | 3 +- .../Functional/WorkbookViewAttributesTest.php | 50 ++--- tests/PhpSpreadsheetTests/Helper/HtmlTest.php | 2 +- .../PhpSpreadsheetTests/Helper/SampleTest.php | 4 +- tests/PhpSpreadsheetTests/IOFactoryTest.php | 27 +-- .../Reader/CondNumFmtTest.php | 2 +- .../Reader/CsvContiguousFilter.php | 4 +- .../Reader/CsvContiguousTest.php | 4 +- tests/PhpSpreadsheetTests/Reader/CsvTest.php | 26 +-- tests/PhpSpreadsheetTests/Reader/HtmlTest.php | 42 ++--- tests/PhpSpreadsheetTests/Reader/OdsTest.php | 20 +- .../Reader/Security/XmlScannerTest.php | 27 +-- tests/PhpSpreadsheetTests/Reader/XlsTest.php | 2 +- .../Reader/Xlsx/AutoFilterTest.php | 9 +- .../PhpSpreadsheetTests/Reader/Xlsx2Test.php | 6 +- tests/PhpSpreadsheetTests/Reader/XlsxTest.php | 92 ++++----- tests/PhpSpreadsheetTests/Reader/XmlTest.php | 6 +- .../ReferenceHelperTest.php | 8 +- tests/PhpSpreadsheetTests/SettingsTest.php | 4 +- .../Shared/CodePageTest.php | 10 +- tests/PhpSpreadsheetTests/Shared/DateTest.php | 20 +- tests/PhpSpreadsheetTests/Shared/FileTest.php | 4 +- tests/PhpSpreadsheetTests/Shared/FontTest.php | 12 +- .../Shared/OLEReadTest.php | 2 +- .../Shared/PasswordHasherTest.php | 2 +- .../Shared/StringHelperTest.php | 20 +- .../Shared/TimeZoneTest.php | 4 +- tests/PhpSpreadsheetTests/SpreadsheetTest.php | 4 +- .../Style/BorderRangeTest.php | 4 +- .../PhpSpreadsheetTests/Style/BorderTest.php | 2 +- tests/PhpSpreadsheetTests/Style/ColorTest.php | 8 +- .../Style/NumberFormatTest.php | 6 +- .../Worksheet/AutoFilter/Column/RuleTest.php | 18 +- .../Worksheet/AutoFilter/ColumnTest.php | 34 ++-- .../Worksheet/AutoFilterTest.php | 50 ++--- .../Worksheet/ColumnCellIteratorTest.php | 18 +- .../Worksheet/ColumnDimensionTest.php | 8 +- .../Worksheet/ColumnIteratorTest.php | 14 +- .../Worksheet/ColumnTest.php | 10 +- .../Worksheet/DrawingTest.php | 2 +- .../Worksheet/IteratorTest.php | 2 +- .../Worksheet/RowCellIteratorTest.php | 18 +- .../Worksheet/RowIteratorTest.php | 14 +- .../PhpSpreadsheetTests/Worksheet/RowTest.php | 10 +- .../Worksheet/WorksheetTest.php | 31 +-- .../Writer/Csv/CsvWriteTest.php | 6 +- .../Writer/Html/AllOrOneSheetTest.php | 25 +-- .../Writer/Html/GridlinesTest.php | 13 +- .../Writer/Html/HtmlCommentsTest.php | 2 +- .../Writer/Html/HtmlNumberFormatTest.php | 17 +- .../Writer/Html/ImagesRootTest.php | 5 +- .../Writer/Html/InvalidFileNameTest.php | 8 +- .../Writer/Html/RepeatedRowsTest.php | 13 +- .../Writer/Html/VisibilityTest.php | 6 +- .../Writer/Ods/ContentTest.php | 4 +- .../Writer/Xls/FormulaErrTest.php | 2 +- .../Writer/Xls/WorkbookTest.php | 10 +- .../Writer/Xlsx/FloatsRetainedTest.php | 4 +- .../Writer/Xlsx/LocaleFloatsTest.php | 8 +- .../Writer/Xlsx/UnparsedDataTest.php | 50 ++--- tests/data/Calculation/Calculation.php | 4 +- tests/data/Calculation/DateTime/DATE.php | 2 +- tests/data/Calculation/Financial/XIRR.php | 26 +-- tests/data/Calculation/Financial/XNPV.php | 2 +- tests/data/Calculation/Logical/SWITCH.php | 52 +++--- tests/data/Calculation/LookupRef/CHOOSE.php | 24 +-- tests/data/Calculation/LookupRef/HLOOKUP.php | 8 +- tests/data/Calculation/LookupRef/LOOKUP.php | 25 +-- tests/data/Calculation/LookupRef/VLOOKUP.php | 8 +- tests/data/Calculation/MathTrig/ARABIC.php | 12 +- tests/data/Calculation/MathTrig/FLOORMATH.php | 12 +- tests/data/Calculation/MathTrig/MDETERM.php | 76 ++++---- tests/data/Calculation/MathTrig/MINVERSE.php | 100 +++++----- tests/data/Calculation/MathTrig/MMULT.php | 94 +++++----- tests/data/Calculation/MathTrig/SUMIF.php | 14 +- tests/data/Calculation/Statistical/AVEDEV.php | 2 +- .../data/Calculation/Statistical/AVERAGE.php | 2 +- .../Calculation/Statistical/AVERAGEIF.php | 14 +- .../Calculation/Statistical/BasicCOUNT.php | 2 +- tests/data/Calculation/Statistical/COUNTA.php | 4 +- tests/data/Calculation/Statistical/FISHER.php | 2 +- tests/data/Calculation/Statistical/SLOPE.php | 4 +- 496 files changed, 2634 insertions(+), 2866 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 2321692488..28c859009d 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -1,11 +1,8 @@ exclude(['vendor', 'tests/data/Calculation']) - ->in('samples') - ->in('src') - ->in('tests/PhpSpreadsheetTests') - ; + ->exclude('vendor') + ->in(__DIR__); return PhpCsFixer\Config::create() ->setRiskyAllowed(true) @@ -13,21 +10,27 @@ return PhpCsFixer\Config::create() ->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer' . preg_replace('~\W~', '-', __DIR__)) ->setRules([ 'align_multiline_comment' => true, + 'array_indentation' => true, 'array_syntax' => ['syntax' => 'short'], 'backtick_to_shell_exec' => true, 'binary_operator_spaces' => true, 'blank_line_after_namespace' => true, 'blank_line_after_opening_tag' => true, + 'blank_line_before_return' => false, // Deprecated 'blank_line_before_statement' => true, 'braces' => true, 'cast_spaces' => true, 'class_attributes_separation' => ['elements' => ['method', 'property']], // const are often grouped with other related const 'class_definition' => true, - 'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE + 'class_keyword_remove' => false, // ::class keyword gives us better support in IDE 'combine_consecutive_issets' => true, 'combine_consecutive_unsets' => true, + 'combine_nested_dirname' => true, + 'comment_to_phpdoc' => true, 'compact_nullable_typehint' => true, 'concat_space' => ['spacing' => 'one'], + 'constant_case' => true, + 'date_time_immutable' => false, // Break our unit tests 'declare_equal_normalize' => true, 'declare_strict_types' => false, // Too early to adopt strict types 'dir_constant' => true, @@ -38,39 +41,57 @@ return PhpCsFixer\Config::create() 'elseif' => true, 'encoding' => true, 'ereg_to_preg' => true, + 'error_suppression' => true, 'escape_implicit_backslashes' => true, 'explicit_indirect_variable' => false, // I feel it makes the code actually harder to read 'explicit_string_variable' => false, // I feel it makes the code actually harder to read + 'final_class' => false, // We need non-final classes 'final_internal_class' => true, + 'final_public_method_for_abstract_class' => false, // We need non-final methods + 'final_static_access' => true, + 'fopen_flag_order' => true, + 'fopen_flags' => true, 'full_opening_tag' => true, + 'fully_qualified_strict_types' => true, 'function_declaration' => true, 'function_to_constant' => true, 'function_typehint_space' => true, 'general_phpdoc_annotation_remove' => false, // No use for that - 'hash_to_slash_comment' => true, + 'global_namespace_import' => true, + 'hash_to_slash_comment' => false, // Deprecated 'header_comment' => false, // We don't use common header in all our files + 'heredoc_indentation' => false, // Requires PHP >= 7.3 'heredoc_to_nowdoc' => false, // Not sure about this one + 'implode_call' => true, 'include' => true, 'increment_style' => true, 'indentation_type' => true, - 'is_null' => ['use_yoda_style' => false], - 'linebreak_after_opening_tag' => true, + 'is_null' => true, 'line_ending' => true, + 'linebreak_after_opening_tag' => true, 'list_syntax' => ['syntax' => 'short'], + 'logical_operators' => true, 'lowercase_cast' => true, - 'lowercase_constants' => true, + 'lowercase_constants' => false, // Deprecated 'lowercase_keywords' => true, + 'lowercase_static_reference' => true, 'magic_constant_casing' => true, + 'magic_method_casing' => true, 'mb_str_functions' => false, // No, too dangerous to change that 'method_argument_space' => true, 'method_chaining_indentation' => true, - 'method_separation' => true, + 'method_separation' => false, // Deprecated 'modernize_types_casting' => true, 'multiline_comment_opening_closing' => true, + 'multiline_whitespace_before_semicolons' => true, + 'native_constant_invocation' => false, // Micro optimization that look messy 'native_function_casing' => true, - 'native_function_invocation' => false, // This is risky and seems to be micro-optimization that make code uglier so not worth it, at least for now + 'native_function_invocation' => false, // I suppose this would be best, but I am still unconvinced about the visual aspect of it + 'native_function_type_declaration_casing' => true, 'new_with_braces' => true, 'no_alias_functions' => true, + 'no_alternative_syntax' => true, + 'no_binary_string' => true, 'no_blank_lines_after_class_opening' => true, 'no_blank_lines_after_phpdoc' => true, 'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace @@ -80,16 +101,15 @@ return PhpCsFixer\Config::create() 'no_empty_phpdoc' => true, 'no_empty_statement' => true, 'no_extra_blank_lines' => true, + 'no_extra_consecutive_blank_lines' => false, // Deprecated 'no_homoglyph_names' => true, 'no_leading_import_slash' => true, 'no_leading_namespace_whitespace' => true, 'no_mixed_echo_print' => true, 'no_multiline_whitespace_around_double_arrow' => true, - 'no_multiline_whitespace_before_semicolons' => true, - 'non_printable_character' => true, + 'no_multiline_whitespace_before_semicolons' => false, // Deprecated 'no_null_property_initialization' => true, 'no_php4_constructor' => true, - 'normalize_index_brace' => true, 'no_short_bool_cast' => true, 'no_short_echo_tag' => true, 'no_singleline_whitespace_before_semicolons' => true, @@ -97,29 +117,55 @@ return PhpCsFixer\Config::create() 'no_spaces_around_offset' => true, 'no_spaces_inside_parenthesis' => true, 'no_superfluous_elseif' => false, // Might be risky on a huge code base - 'not_operator_with_space' => false, // No we prefer to keep '!' without spaces - 'not_operator_with_successor_space' => false, // idem + 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true], 'no_trailing_comma_in_list_call' => true, 'no_trailing_comma_in_singleline_array' => true, - 'no_trailing_whitespace_in_comment' => true, 'no_trailing_whitespace' => true, + 'no_trailing_whitespace_in_comment' => true, 'no_unneeded_control_parentheses' => true, 'no_unneeded_curly_braces' => true, 'no_unneeded_final_method' => true, 'no_unreachable_default_argument_value' => true, + 'no_unset_cast' => true, + 'no_unset_on_property' => true, 'no_unused_imports' => true, 'no_useless_else' => true, 'no_useless_return' => true, 'no_whitespace_before_comma_in_array' => true, 'no_whitespace_in_blank_line' => true, + 'non_printable_character' => true, + 'normalize_index_brace' => true, + 'not_operator_with_space' => false, // No we prefer to keep '!' without spaces + 'not_operator_with_successor_space' => false, // idem + 'nullable_type_declaration_for_default_null_value' => true, 'object_operator_without_whitespace' => true, 'ordered_class_elements' => false, // We prefer to keep some freedom 'ordered_imports' => true, + 'ordered_interfaces' => true, + 'php_unit_construct' => true, + 'php_unit_dedicate_assert' => true, + 'php_unit_dedicate_assert_internal_type' => true, + 'php_unit_expectation' => true, + 'php_unit_fqcn_annotation' => true, + 'php_unit_internal_class' => false, // Because tests are excluded from package + 'php_unit_method_casing' => true, + 'php_unit_mock' => true, + 'php_unit_mock_short_will_return' => true, + 'php_unit_namespaced' => true, + 'php_unit_no_expectation_annotation' => true, + 'php_unit_ordered_covers' => true, + 'php_unit_set_up_tear_down_visibility' => true, + 'php_unit_size_class' => false, // That seems extra work to maintain for little benefits + 'php_unit_strict' => false, // We sometime actually need assertEquals + 'php_unit_test_annotation' => true, + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], + 'php_unit_test_class_requires_covers' => false, // We don't care as much as we should about coverage 'phpdoc_add_missing_param_annotation' => true, 'phpdoc_align' => false, // Waste of time 'phpdoc_annotation_without_dot' => true, 'phpdoc_indent' => true, 'phpdoc_inline_tag' => true, + 'phpdoc_line_span' => false, // Unfortunately our old comments turn even uglier with this 'phpdoc_no_access' => true, 'phpdoc_no_alias_tag' => true, 'phpdoc_no_empty_return' => true, @@ -132,43 +178,46 @@ return PhpCsFixer\Config::create() 'phpdoc_single_line_var_spacing' => true, 'phpdoc_summary' => true, 'phpdoc_to_comment' => true, + 'phpdoc_to_param_type' => false, // Because experimental, but interesting for one shot use + 'phpdoc_to_return_type' => false, // idem 'phpdoc_trim' => true, - 'phpdoc_types_order' => true, + 'phpdoc_trim_consecutive_blank_line_separation' => true, 'phpdoc_types' => true, + 'phpdoc_types_order' => true, + 'phpdoc_var_annotation_correct_order' => true, 'phpdoc_var_without_name' => true, - 'php_unit_construct' => true, - 'php_unit_dedicate_assert' => true, - 'php_unit_expectation' => true, - 'php_unit_fqcn_annotation' => true, - 'php_unit_mock' => true, - 'php_unit_namespaced' => true, - 'php_unit_no_expectation_annotation' => true, - 'php_unit_strict' => false, // We sometime actually need assertEquals - 'php_unit_test_annotation' => true, - 'php_unit_test_class_requires_covers' => false, // We don't care as much as we should about coverage - 'pow_to_exponentiation' => false, + 'pow_to_exponentiation' => true, + 'pre_increment' => false, // Deprecated 'protected_to_private' => true, 'psr0' => true, 'psr4' => true, - 'random_api_migration' => false, // This breaks our unit tests + 'random_api_migration' => true, + 'return_assignment' => false, // Sometimes useful for clarity or debug 'return_type_declaration' => true, 'self_accessor' => true, + 'self_static_accessor' => true, 'semicolon_after_instruction' => false, // Buggy in `samples/index.php` + 'set_type_to_cast' => true, 'short_scalar_cast' => true, - 'silenced_deprecation_error' => true, - 'simplified_null_return' => false, // While technically correct we prefer to be explicit when returning null + 'silenced_deprecation_error' => false, // Deprecated + 'simple_to_complex_string_variable' => false, // Would differ from TypeScript without obvious advantages + 'simplified_null_return' => false, // Even if technically correct we prefer to be explicit 'single_blank_line_at_eof' => true, 'single_blank_line_before_namespace' => true, 'single_class_element_per_statement' => true, 'single_import_per_statement' => true, 'single_line_after_imports' => true, 'single_line_comment_style' => true, + 'single_line_throw' => false, // I don't see any reason for having a special case for Exception 'single_quote' => true, + 'single_trait_insert_per_statement' => true, 'space_after_semicolon' => true, + 'standardize_increment' => true, 'standardize_not_equals' => true, 'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()` 'strict_comparison' => false, // No, too dangerous to change that 'strict_param' => false, // No, too dangerous to change that + 'string_line_ending' => true, 'switch_case_semicolon_to_colon' => true, 'switch_case_space' => true, 'ternary_operator_spaces' => true, @@ -177,7 +226,7 @@ return PhpCsFixer\Config::create() 'trim_array_spaces' => true, 'unary_operator_spaces' => true, 'visibility_required' => true, - 'void_return' => false, // Cannot use that with PHP 5.6 + 'void_return' => true, 'whitespace_after_comma_in_array' => true, 'yoda_style' => false, ]); diff --git a/samples/Autofilter/10_Autofilter_selection_1.php b/samples/Autofilter/10_Autofilter_selection_1.php index 464b8c1860..556ef61cdc 100644 --- a/samples/Autofilter/10_Autofilter_selection_1.php +++ b/samples/Autofilter/10_Autofilter_selection_1.php @@ -59,18 +59,18 @@ $period, $i ); - $value = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); + $value = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4)); $salesValue = $invoiceValue = null; - $incomeOrExpenditure = rand(-1, 1); + $incomeOrExpenditure = mt_rand(-1, 1); if ($incomeOrExpenditure == -1) { - $expenditure = rand(-500, -1000) * (1 + (rand(-1, 1) / 4)); + $expenditure = mt_rand(-1000, -500) * (1 + (mt_rand(-1, 1) / 4)); $income = null; } elseif ($incomeOrExpenditure == 1) { - $expenditure = rand(-500, -1000) * (1 + (rand(-1, 1) / 4)); - $income = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); + $expenditure = mt_rand(-1000, -500) * (1 + (mt_rand(-1, 1) / 4)); + $income = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4)); } else { $expenditure = null; - $income = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); + $income = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4)); } $dataArray = [$year, $period, diff --git a/samples/Autofilter/10_Autofilter_selection_2.php b/samples/Autofilter/10_Autofilter_selection_2.php index 1c55a0cf7f..4bae0abaf5 100644 --- a/samples/Autofilter/10_Autofilter_selection_2.php +++ b/samples/Autofilter/10_Autofilter_selection_2.php @@ -59,18 +59,18 @@ $period, $i ); - $value = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); + $value = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4)); $salesValue = $invoiceValue = null; - $incomeOrExpenditure = rand(-1, 1); + $incomeOrExpenditure = mt_rand(-1, 1); if ($incomeOrExpenditure == -1) { - $expenditure = rand(-500, -1000) * (1 + (rand(-1, 1) / 4)); + $expenditure = mt_rand(-1000, -500) * (1 + (mt_rand(-1, 1) / 4)); $income = null; } elseif ($incomeOrExpenditure == 1) { - $expenditure = rand(-500, -1000) * (1 + (rand(-1, 1) / 4)); - $income = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); + $expenditure = mt_rand(-1000, -500) * (1 + (mt_rand(-1, 1) / 4)); + $income = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4)); } else { $expenditure = null; - $income = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); + $income = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4)); } $dataArray = [$year, $period, diff --git a/samples/Autofilter/10_Autofilter_selection_display.php b/samples/Autofilter/10_Autofilter_selection_display.php index 55211552f3..4810348c58 100644 --- a/samples/Autofilter/10_Autofilter_selection_display.php +++ b/samples/Autofilter/10_Autofilter_selection_display.php @@ -59,18 +59,18 @@ $period, $i ); - $value = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); + $value = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4)); $salesValue = $invoiceValue = null; - $incomeOrExpenditure = rand(-1, 1); + $incomeOrExpenditure = mt_rand(-1, 1); if ($incomeOrExpenditure == -1) { - $expenditure = rand(-500, -1000) * (1 + (rand(-1, 1) / 4)); + $expenditure = mt_rand(-1000, -500) * (1 + (mt_rand(-1, 1) / 4)); $income = null; } elseif ($incomeOrExpenditure == 1) { - $expenditure = rand(-500, -1000) * (1 + (rand(-1, 1) / 4)); - $income = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); + $expenditure = mt_rand(-1000, -500) * (1 + (mt_rand(-1, 1) / 4)); + $income = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4)); } else { $expenditure = null; - $income = rand(500, 1000) * (1 + (rand(-1, 1) / 4)); + $income = mt_rand(500, 1000) * (1 + (mt_rand(-1, 1) / 4)); } $dataArray = [$year, $period, diff --git a/samples/Basic/22_Heavily_formatted.php b/samples/Basic/22_Heavily_formatted.php index d7ba861bc8..aadb5b9291 100644 --- a/samples/Basic/22_Heavily_formatted.php +++ b/samples/Basic/22_Heavily_formatted.php @@ -26,22 +26,22 @@ $spreadsheet->getActiveSheet()->getStyle('A1:T100')->applyFromArray( ['fill' => [ - 'fillType' => Fill::FILL_SOLID, - 'color' => ['argb' => 'FFCCFFCC'], - ], - 'borders' => [ - 'bottom' => ['borderStyle' => Border::BORDER_THIN], - 'right' => ['borderStyle' => Border::BORDER_MEDIUM], - ], - ] + 'fillType' => Fill::FILL_SOLID, + 'color' => ['argb' => 'FFCCFFCC'], + ], + 'borders' => [ + 'bottom' => ['borderStyle' => Border::BORDER_THIN], + 'right' => ['borderStyle' => Border::BORDER_MEDIUM], + ], + ] ); $spreadsheet->getActiveSheet()->getStyle('C5:R95')->applyFromArray( ['fill' => [ - 'fillType' => Fill::FILL_SOLID, - 'color' => ['argb' => 'FFFFFF00'], - ], - ] + 'fillType' => Fill::FILL_SOLID, + 'color' => ['argb' => 'FFFFFF00'], + ], + ] ); // Save diff --git a/samples/Basic/23_Sharedstyles.php b/samples/Basic/23_Sharedstyles.php index b5398883fb..8e75a4880c 100644 --- a/samples/Basic/23_Sharedstyles.php +++ b/samples/Basic/23_Sharedstyles.php @@ -30,26 +30,26 @@ $sharedStyle1->applyFromArray( ['fill' => [ - 'fillType' => Fill::FILL_SOLID, - 'color' => ['argb' => 'FFCCFFCC'], - ], - 'borders' => [ - 'bottom' => ['borderStyle' => Border::BORDER_THIN], - 'right' => ['borderStyle' => Border::BORDER_MEDIUM], - ], - ] + 'fillType' => Fill::FILL_SOLID, + 'color' => ['argb' => 'FFCCFFCC'], + ], + 'borders' => [ + 'bottom' => ['borderStyle' => Border::BORDER_THIN], + 'right' => ['borderStyle' => Border::BORDER_MEDIUM], + ], + ] ); $sharedStyle2->applyFromArray( ['fill' => [ - 'fillType' => Fill::FILL_SOLID, - 'color' => ['argb' => 'FFFFFF00'], - ], - 'borders' => [ - 'bottom' => ['borderStyle' => Border::BORDER_THIN], - 'right' => ['borderStyle' => Border::BORDER_MEDIUM], - ], - ] + 'fillType' => Fill::FILL_SOLID, + 'color' => ['argb' => 'FFFFFF00'], + ], + 'borders' => [ + 'bottom' => ['borderStyle' => Border::BORDER_THIN], + 'right' => ['borderStyle' => Border::BORDER_MEDIUM], + ], + ] ); $spreadsheet->getActiveSheet()->duplicateStyle($sharedStyle1, 'A1:T100'); diff --git a/samples/Basic/25_In_memory_image.php b/samples/Basic/25_In_memory_image.php index 5985a0a076..af02c64abb 100644 --- a/samples/Basic/25_In_memory_image.php +++ b/samples/Basic/25_In_memory_image.php @@ -21,7 +21,11 @@ // Generate an image $helper->log('Generate an image'); -$gdImage = @imagecreatetruecolor(120, 20) or die('Cannot Initialize new GD image stream'); +$gdImage = @imagecreatetruecolor(120, 20); +if (!$gdImage) { + die('Cannot Initialize new GD image stream'); +} + $textColor = imagecolorallocate($gdImage, 255, 255, 255); imagestring($gdImage, 1, 5, 5, 'Created with PhpSpreadsheet', $textColor); diff --git a/samples/Basic/30_Template.php b/samples/Basic/30_Template.php index b70c18b610..409acb668a 100644 --- a/samples/Basic/30_Template.php +++ b/samples/Basic/30_Template.php @@ -11,9 +11,9 @@ $helper->log('Add new data to the template'); $data = [['title' => 'Excel for dummies', - 'price' => 17.99, - 'quantity' => 2, - ], + 'price' => 17.99, + 'quantity' => 2, +], ['title' => 'PHP for dummies', 'price' => 15.99, 'quantity' => 1, diff --git a/samples/Chart/33_Chart_create_area.php b/samples/Chart/33_Chart_create_area.php index 860c16a6b7..57db90fcc9 100644 --- a/samples/Chart/33_Chart_create_area.php +++ b/samples/Chart/33_Chart_create_area.php @@ -15,12 +15,12 @@ $worksheet = $spreadsheet->getActiveSheet(); $worksheet->fromArray( [ - ['', 2010, 2011, 2012], - ['Q1', 12, 15, 21], - ['Q2', 56, 73, 86], - ['Q3', 52, 61, 69], - ['Q4', 30, 32, 0], - ] + ['', 2010, 2011, 2012], + ['Q1', 12, 15, 21], + ['Q2', 56, 73, 86], + ['Q3', 52, 61, 69], + ['Q4', 30, 32, 0], + ] ); // Set the Labels for each data series we want to plot diff --git a/samples/Chart/33_Chart_create_bar_stacked.php b/samples/Chart/33_Chart_create_bar_stacked.php index 0aa211a954..0c87224ec0 100644 --- a/samples/Chart/33_Chart_create_bar_stacked.php +++ b/samples/Chart/33_Chart_create_bar_stacked.php @@ -15,12 +15,12 @@ $worksheet = $spreadsheet->getActiveSheet(); $worksheet->fromArray( [ - ['', 2010, 2011, 2012], - ['Q1', 12, 15, 21], - ['Q2', 56, 73, 86], - ['Q3', 52, 61, 69], - ['Q4', 30, 32, 0], - ] + ['', 2010, 2011, 2012], + ['Q1', 12, 15, 21], + ['Q2', 56, 73, 86], + ['Q3', 52, 61, 69], + ['Q4', 30, 32, 0], + ] ); // Set the Labels for each data series we want to plot diff --git a/samples/Chart/33_Chart_create_column.php b/samples/Chart/33_Chart_create_column.php index 694082a46e..5af0908c00 100644 --- a/samples/Chart/33_Chart_create_column.php +++ b/samples/Chart/33_Chart_create_column.php @@ -15,12 +15,12 @@ $worksheet = $spreadsheet->getActiveSheet(); $worksheet->fromArray( [ - ['', 2010, 2011, 2012], - ['Q1', 12, 15, 21], - ['Q2', 56, 73, 86], - ['Q3', 52, 61, 69], - ['Q4', 30, 32, 0], - ] + ['', 2010, 2011, 2012], + ['Q1', 12, 15, 21], + ['Q2', 56, 73, 86], + ['Q3', 52, 61, 69], + ['Q4', 30, 32, 0], + ] ); // Set the Labels for each data series we want to plot diff --git a/samples/Chart/33_Chart_create_column_2.php b/samples/Chart/33_Chart_create_column_2.php index f5a529b9be..a62b490683 100644 --- a/samples/Chart/33_Chart_create_column_2.php +++ b/samples/Chart/33_Chart_create_column_2.php @@ -15,20 +15,20 @@ $worksheet = $spreadsheet->getActiveSheet(); $worksheet->fromArray( [ - ['', '', 'Budget', 'Forecast', 'Actual'], - ['2010', 'Q1', 47, 44, 43], - ['', 'Q2', 56, 53, 50], - ['', 'Q3', 52, 46, 45], - ['', 'Q4', 45, 40, 40], - ['2011', 'Q1', 51, 42, 46], - ['', 'Q2', 53, 58, 56], - ['', 'Q3', 64, 66, 69], - ['', 'Q4', 54, 55, 56], - ['2012', 'Q1', 49, 52, 58], - ['', 'Q2', 68, 73, 86], - ['', 'Q3', 72, 78, 0], - ['', 'Q4', 50, 60, 0], - ] + ['', '', 'Budget', 'Forecast', 'Actual'], + ['2010', 'Q1', 47, 44, 43], + ['', 'Q2', 56, 53, 50], + ['', 'Q3', 52, 46, 45], + ['', 'Q4', 45, 40, 40], + ['2011', 'Q1', 51, 42, 46], + ['', 'Q2', 53, 58, 56], + ['', 'Q3', 64, 66, 69], + ['', 'Q4', 54, 55, 56], + ['2012', 'Q1', 49, 52, 58], + ['', 'Q2', 68, 73, 86], + ['', 'Q3', 72, 78, 0], + ['', 'Q4', 50, 60, 0], + ] ); // Set the Labels for each data series we want to plot diff --git a/samples/Chart/33_Chart_create_composite.php b/samples/Chart/33_Chart_create_composite.php index dfeacae3ae..ce42d2fc71 100644 --- a/samples/Chart/33_Chart_create_composite.php +++ b/samples/Chart/33_Chart_create_composite.php @@ -15,20 +15,20 @@ $worksheet = $spreadsheet->getActiveSheet(); $worksheet->fromArray( [ - ['', 'Rainfall (mm)', 'Temperature (°F)', 'Humidity (%)'], - ['Jan', 78, 52, 61], - ['Feb', 64, 54, 62], - ['Mar', 62, 57, 63], - ['Apr', 21, 62, 59], - ['May', 11, 75, 60], - ['Jun', 1, 75, 57], - ['Jul', 1, 79, 56], - ['Aug', 1, 79, 59], - ['Sep', 10, 75, 60], - ['Oct', 40, 68, 63], - ['Nov', 69, 62, 64], - ['Dec', 89, 57, 66], - ] + ['', 'Rainfall (mm)', 'Temperature (°F)', 'Humidity (%)'], + ['Jan', 78, 52, 61], + ['Feb', 64, 54, 62], + ['Mar', 62, 57, 63], + ['Apr', 21, 62, 59], + ['May', 11, 75, 60], + ['Jun', 1, 75, 57], + ['Jul', 1, 79, 56], + ['Aug', 1, 79, 59], + ['Sep', 10, 75, 60], + ['Oct', 40, 68, 63], + ['Nov', 69, 62, 64], + ['Dec', 89, 57, 66], + ] ); // Set the Labels for each data series we want to plot diff --git a/samples/Chart/33_Chart_create_multiple_charts.php b/samples/Chart/33_Chart_create_multiple_charts.php index c25328a814..608ffc53e0 100644 --- a/samples/Chart/33_Chart_create_multiple_charts.php +++ b/samples/Chart/33_Chart_create_multiple_charts.php @@ -15,12 +15,12 @@ $worksheet = $spreadsheet->getActiveSheet(); $worksheet->fromArray( [ - ['', 2010, 2011, 2012], - ['Q1', 12, 15, 21], - ['Q2', 56, 73, 86], - ['Q3', 52, 61, 69], - ['Q4', 30, 32, 0], - ] + ['', 2010, 2011, 2012], + ['Q1', 12, 15, 21], + ['Q2', 56, 73, 86], + ['Q3', 52, 61, 69], + ['Q4', 30, 32, 0], + ] ); // Set the Labels for each data series we want to plot diff --git a/samples/Chart/33_Chart_create_pie.php b/samples/Chart/33_Chart_create_pie.php index 0df4114361..5480a18ab3 100644 --- a/samples/Chart/33_Chart_create_pie.php +++ b/samples/Chart/33_Chart_create_pie.php @@ -16,12 +16,12 @@ $worksheet = $spreadsheet->getActiveSheet(); $worksheet->fromArray( [ - ['', 2010, 2011, 2012], - ['Q1', 12, 15, 21], - ['Q2', 56, 73, 86], - ['Q3', 52, 61, 69], - ['Q4', 30, 32, 0], - ] + ['', 2010, 2011, 2012], + ['Q1', 12, 15, 21], + ['Q2', 56, 73, 86], + ['Q3', 52, 61, 69], + ['Q4', 30, 32, 0], + ] ); // Set the Labels for each data series we want to plot diff --git a/samples/Chart/33_Chart_create_pie_custom_colors.php b/samples/Chart/33_Chart_create_pie_custom_colors.php index 137e6e75c0..ca5397a16b 100644 --- a/samples/Chart/33_Chart_create_pie_custom_colors.php +++ b/samples/Chart/33_Chart_create_pie_custom_colors.php @@ -16,12 +16,12 @@ $worksheet = $spreadsheet->getActiveSheet(); $worksheet->fromArray( [ - ['', 2010, 2011, 2012], - ['Q1', 12, 15, 21], - ['Q2', 56, 73, 86], - ['Q3', 52, 61, 69], - ['Q4', 30, 32, 0], - ] + ['', 2010, 2011, 2012], + ['Q1', 12, 15, 21], + ['Q2', 56, 73, 86], + ['Q3', 52, 61, 69], + ['Q4', 30, 32, 0], + ] ); // Custom colors for dataSeries (gray, blue, red, orange) diff --git a/samples/Chart/33_Chart_create_radar.php b/samples/Chart/33_Chart_create_radar.php index 1c5c435f38..eba4dc3912 100644 --- a/samples/Chart/33_Chart_create_radar.php +++ b/samples/Chart/33_Chart_create_radar.php @@ -16,20 +16,20 @@ $worksheet = $spreadsheet->getActiveSheet(); $worksheet->fromArray( [ - ['', 2010, 2011, 2012], - ['Jan', 47, 45, 71], - ['Feb', 56, 73, 86], - ['Mar', 52, 61, 69], - ['Apr', 40, 52, 60], - ['May', 42, 55, 71], - ['Jun', 58, 63, 76], - ['Jul', 53, 61, 89], - ['Aug', 46, 69, 85], - ['Sep', 62, 75, 81], - ['Oct', 51, 70, 96], - ['Nov', 55, 66, 89], - ['Dec', 68, 62, 0], - ] + ['', 2010, 2011, 2012], + ['Jan', 47, 45, 71], + ['Feb', 56, 73, 86], + ['Mar', 52, 61, 69], + ['Apr', 40, 52, 60], + ['May', 42, 55, 71], + ['Jun', 58, 63, 76], + ['Jul', 53, 61, 89], + ['Aug', 46, 69, 85], + ['Sep', 62, 75, 81], + ['Oct', 51, 70, 96], + ['Nov', 55, 66, 89], + ['Dec', 68, 62, 0], + ] ); // Set the Labels for each data series we want to plot diff --git a/samples/Chart/33_Chart_create_scatter.php b/samples/Chart/33_Chart_create_scatter.php index 02fa866d21..c67e4e9530 100644 --- a/samples/Chart/33_Chart_create_scatter.php +++ b/samples/Chart/33_Chart_create_scatter.php @@ -15,12 +15,12 @@ $worksheet = $spreadsheet->getActiveSheet(); $worksheet->fromArray( [ - ['', 2010, 2011, 2012], - ['Q1', 12, 15, 21], - ['Q2', 56, 73, 86], - ['Q3', 52, 61, 69], - ['Q4', 30, 32, 0], - ] + ['', 2010, 2011, 2012], + ['Q1', 12, 15, 21], + ['Q2', 56, 73, 86], + ['Q3', 52, 61, 69], + ['Q4', 30, 32, 0], + ] ); // Set the Labels for each data series we want to plot diff --git a/samples/Chart/33_Chart_create_stock.php b/samples/Chart/33_Chart_create_stock.php index 4e8ffe8e5e..5868678427 100644 --- a/samples/Chart/33_Chart_create_stock.php +++ b/samples/Chart/33_Chart_create_stock.php @@ -16,13 +16,13 @@ $worksheet = $spreadsheet->getActiveSheet(); $worksheet->fromArray( [ - ['Counts', 'Max', 'Min', 'Min Threshold', 'Max Threshold'], - [10, 10, 5, 0, 50], - [30, 20, 10, 0, 50], - [20, 30, 15, 0, 50], - [40, 10, 0, 0, 50], - [100, 40, 5, 0, 50], - ], + ['Counts', 'Max', 'Min', 'Min Threshold', 'Max Threshold'], + [10, 10, 5, 0, 50], + [30, 20, 10, 0, 50], + [20, 30, 15, 0, 50], + [40, 10, 0, 0, 50], + [100, 40, 5, 0, 50], + ], null, 'A1', true diff --git a/samples/Chart/34_Chart_update.php b/samples/Chart/34_Chart_update.php index 638d2e0adf..a428792776 100644 --- a/samples/Chart/34_Chart_update.php +++ b/samples/Chart/34_Chart_update.php @@ -20,11 +20,11 @@ $worksheet = $spreadsheet->getActiveSheet(); $worksheet->fromArray( [ - [50 - 12, 50 - 15, 50 - 21], - [50 - 56, 50 - 73, 50 - 86], - [50 - 52, 50 - 61, 50 - 69], - [50 - 30, 50 - 32, 50], - ], + [50 - 12, 50 - 15, 50 - 21], + [50 - 56, 50 - 73, 50 - 86], + [50 - 52, 50 - 61, 50 - 69], + [50 - 30, 50 - 32, 50], + ], null, 'B2' ); diff --git a/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php b/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php index 1f39ec4d30..61f624b2be 100644 --- a/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php +++ b/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php @@ -23,7 +23,7 @@ class ChunkReadFilter implements IReadFilter * @param mixed $startRow * @param mixed $chunkSize */ - public function setRows($startRow, $chunkSize) + public function setRows($startRow, $chunkSize): void { $this->startRow = $startRow; $this->endRow = $startRow + $chunkSize; diff --git a/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php b/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php index efe6858270..02d3d939b1 100644 --- a/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php +++ b/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php @@ -24,7 +24,7 @@ class ChunkReadFilter implements IReadFilter * @param mixed $startRow * @param mixed $chunkSize */ - public function setRows($startRow, $chunkSize) + public function setRows($startRow, $chunkSize): void { $this->startRow = $startRow; $this->endRow = $startRow + $chunkSize; diff --git a/samples/templates/chartSpreadsheet.php b/samples/templates/chartSpreadsheet.php index 44d7b54356..2ad61d326d 100644 --- a/samples/templates/chartSpreadsheet.php +++ b/samples/templates/chartSpreadsheet.php @@ -12,12 +12,12 @@ $worksheet = $spreadsheet->getActiveSheet(); $worksheet->fromArray( [ - ['', 2010, 2011, 2012], - ['Q1', 12, 15, 21], - ['Q2', 56, 73, 86], - ['Q3', 52, 61, 69], - ['Q4', 30, 32, 0], - ] + ['', 2010, 2011, 2012], + ['Q1', 12, 15, 21], + ['Q2', 56, 73, 86], + ['Q3', 52, 61, 69], + ['Q4', 30, 32, 0], + ] ); // Set the Labels for each data series we want to plot diff --git a/samples/templates/sampleSpreadsheet.php b/samples/templates/sampleSpreadsheet.php index c668f447fe..6d9568be65 100644 --- a/samples/templates/sampleSpreadsheet.php +++ b/samples/templates/sampleSpreadsheet.php @@ -184,59 +184,59 @@ $helper->log('Set style for header row using alternative method'); $spreadsheet->getActiveSheet()->getStyle('A3:E3')->applyFromArray( [ - 'font' => [ - 'bold' => true, - ], - 'alignment' => [ - 'horizontal' => Alignment::HORIZONTAL_RIGHT, + 'font' => [ + 'bold' => true, + ], + 'alignment' => [ + 'horizontal' => Alignment::HORIZONTAL_RIGHT, + ], + 'borders' => [ + 'top' => [ + 'borderStyle' => Border::BORDER_THIN, ], - 'borders' => [ - 'top' => [ - 'borderStyle' => Border::BORDER_THIN, - ], + ], + 'fill' => [ + 'fillType' => Fill::FILL_GRADIENT_LINEAR, + 'rotation' => 90, + 'startColor' => [ + 'argb' => 'FFA0A0A0', ], - 'fill' => [ - 'fillType' => Fill::FILL_GRADIENT_LINEAR, - 'rotation' => 90, - 'startColor' => [ - 'argb' => 'FFA0A0A0', - ], - 'endColor' => [ - 'argb' => 'FFFFFFFF', - ], + 'endColor' => [ + 'argb' => 'FFFFFFFF', ], - ] + ], + ] ); $spreadsheet->getActiveSheet()->getStyle('A3')->applyFromArray( [ - 'alignment' => [ - 'horizontal' => Alignment::HORIZONTAL_LEFT, - ], - 'borders' => [ - 'left' => [ - 'borderStyle' => Border::BORDER_THIN, - ], + 'alignment' => [ + 'horizontal' => Alignment::HORIZONTAL_LEFT, + ], + 'borders' => [ + 'left' => [ + 'borderStyle' => Border::BORDER_THIN, ], - ] + ], + ] ); $spreadsheet->getActiveSheet()->getStyle('B3')->applyFromArray( [ - 'alignment' => [ - 'horizontal' => Alignment::HORIZONTAL_LEFT, - ], - ] + 'alignment' => [ + 'horizontal' => Alignment::HORIZONTAL_LEFT, + ], + ] ); $spreadsheet->getActiveSheet()->getStyle('E3')->applyFromArray( [ - 'borders' => [ - 'right' => [ - 'borderStyle' => Border::BORDER_THIN, - ], + 'borders' => [ + 'right' => [ + 'borderStyle' => Border::BORDER_THIN, ], - ] + ], + ] ); // Unprotect a cell diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 447ae588f2..0be9ab6f6e 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -11,6 +11,7 @@ use PhpOffice\PhpSpreadsheet\Shared; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; +use ReflectionMethod; class Calculation { @@ -2263,16 +2264,16 @@ class Calculation ], ]; - public function __construct(Spreadsheet $spreadsheet = null) + public function __construct(?Spreadsheet $spreadsheet = null) { - $this->delta = 1 * pow(10, 0 - ini_get('precision')); + $this->delta = 1 * 10 ** (0 - ini_get('precision')); $this->spreadsheet = $spreadsheet; $this->cyclicReferenceStack = new CyclicReferenceStack(); $this->debugLog = new Logger($this->cyclicReferenceStack); } - private static function loadLocales() + private static function loadLocales(): void { $localeFileDirectory = __DIR__ . '/locale/'; foreach (glob($localeFileDirectory . '*', GLOB_ONLYDIR) as $filename) { @@ -2291,7 +2292,7 @@ private static function loadLocales() * * @return Calculation */ - public static function getInstance(Spreadsheet $spreadsheet = null) + public static function getInstance(?Spreadsheet $spreadsheet = null) { if ($spreadsheet !== null) { $instance = $spreadsheet->getCalculationEngine(); @@ -2311,7 +2312,7 @@ public static function getInstance(Spreadsheet $spreadsheet = null) * Flush the calculation cache for any existing instance of this class * but only if a Calculation instance exists. */ - public function flushInstance() + public function flushInstance(): void { $this->clearCalculationCache(); $this->clearBranchStore(); @@ -2400,7 +2401,7 @@ public function getCalculationCacheEnabled() * * @param bool $pValue */ - public function setCalculationCacheEnabled($pValue) + public function setCalculationCacheEnabled($pValue): void { $this->calculationCacheEnabled = $pValue; $this->clearCalculationCache(); @@ -2409,7 +2410,7 @@ public function setCalculationCacheEnabled($pValue) /** * Enable calculation cache. */ - public function enableCalculationCache() + public function enableCalculationCache(): void { $this->setCalculationCacheEnabled(true); } @@ -2417,7 +2418,7 @@ public function enableCalculationCache() /** * Disable calculation cache. */ - public function disableCalculationCache() + public function disableCalculationCache(): void { $this->setCalculationCacheEnabled(false); } @@ -2425,7 +2426,7 @@ public function disableCalculationCache() /** * Clear calculation cache. */ - public function clearCalculationCache() + public function clearCalculationCache(): void { $this->calculationCache = []; } @@ -2435,7 +2436,7 @@ public function clearCalculationCache() * * @param string $worksheetName */ - public function clearCalculationCacheForWorksheet($worksheetName) + public function clearCalculationCacheForWorksheet($worksheetName): void { if (isset($this->calculationCache[$worksheetName])) { unset($this->calculationCache[$worksheetName]); @@ -2448,7 +2449,7 @@ public function clearCalculationCacheForWorksheet($worksheetName) * @param string $fromWorksheetName * @param string $toWorksheetName */ - public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksheetName) + public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksheetName): void { if (isset($this->calculationCache[$fromWorksheetName])) { $this->calculationCache[$toWorksheetName] = &$this->calculationCache[$fromWorksheetName]; @@ -2459,25 +2460,24 @@ public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksh /** * Enable/disable calculation cache. * - * @param bool $pValue * @param mixed $enabled */ - public function setBranchPruningEnabled($enabled) + public function setBranchPruningEnabled($enabled): void { $this->branchPruningEnabled = $enabled; } - public function enableBranchPruning() + public function enableBranchPruning(): void { $this->setBranchPruningEnabled(true); } - public function disableBranchPruning() + public function disableBranchPruning(): void { $this->setBranchPruningEnabled(false); } - public function clearBranchStore() + public function clearBranchStore(): void { $this->branchStoreKeyCounter = 0; } @@ -2779,7 +2779,7 @@ public static function unwrapResult($value) * * @return mixed */ - public function calculate(Cell $pCell = null) + public function calculate(?Cell $pCell = null) { try { return $this->calculateCellValue($pCell); @@ -2796,7 +2796,7 @@ public function calculate(Cell $pCell = null) * * @return mixed */ - public function calculateCellValue(Cell $pCell = null, $resetLog = true) + public function calculateCellValue(?Cell $pCell = null, $resetLog = true) { if ($pCell === null) { return null; @@ -2898,7 +2898,7 @@ public function parseFormula($formula) * * @return mixed */ - public function calculateFormula($formula, $cellID = null, Cell $pCell = null) + public function calculateFormula($formula, $cellID = null, ?Cell $pCell = null) { // Initialise the logging settings $this->formulaError = null; @@ -2957,7 +2957,7 @@ public function getValueFromCache($cellReference, &$cellValue) * @param string $cellReference * @param mixed $cellValue */ - public function saveValueToCache($cellReference, $cellValue) + public function saveValueToCache($cellReference, $cellValue): void { if ($this->calculationCacheEnabled) { $this->calculationCache[$cellReference] = $cellValue; @@ -2973,7 +2973,7 @@ public function saveValueToCache($cellReference, $cellValue) * * @return mixed */ - public function _calculateFormulaValue($formula, $cellID = null, Cell $pCell = null) + public function _calculateFormulaValue($formula, $cellID = null, ?Cell $pCell = null) { $cellValue = null; @@ -3119,7 +3119,7 @@ public static function getMatrixDimensions(array &$matrix) * @param int $matrix2Rows Row size of second matrix operand * @param int $matrix2Columns Column size of second matrix operand */ - private static function resizeMatricesShrink(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns) + private static function resizeMatricesShrink(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns): void { if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { if ($matrix2Rows < $matrix1Rows) { @@ -3162,7 +3162,7 @@ private static function resizeMatricesShrink(&$matrix1, &$matrix2, $matrix1Rows, * @param int $matrix2Rows Row size of second matrix operand * @param int $matrix2Columns Column size of second matrix operand */ - private static function resizeMatricesExtend(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns) + private static function resizeMatricesExtend(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns): void { if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { if ($matrix2Columns < $matrix1Columns) { @@ -3371,11 +3371,10 @@ private static function mkMatrix(...$args) /** * @param string $formula - * @param null|\PhpOffice\PhpSpreadsheet\Cell\Cell $pCell * * @return bool */ - private function _parseFormula($formula, Cell $pCell = null) + private function _parseFormula($formula, ?Cell $pCell = null) { if (($formula = $this->convertMatrixReferences(trim($formula))) === false) { return false; @@ -3469,7 +3468,7 @@ private function _parseFormula($formula, Cell $pCell = null) ++$index; // Drop the redundant plus symbol } elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal return $this->raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression - } elseif ((isset(self::$operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack? + } elseif ((isset(self::$operators[$opCharacter]) || $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack? while ($stack->count() > 0 && ($o2 = $stack->last()) && isset(self::$operators[$o2['value']]) && @@ -3495,7 +3494,7 @@ private function _parseFormula($formula, Cell $pCell = null) // Branch pruning we decrease the depth whether is it a function // call or a parenthesis if (!empty($pendingStoreKey)) { - $parenthesisDepthMap[$pendingStoreKey] -= 1; + --$parenthesisDepthMap[$pendingStoreKey]; } if (is_array($d) && preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $d['value'], $matches)) { // Did this parenthesis just close a function? @@ -3509,7 +3508,7 @@ private function _parseFormula($formula, Cell $pCell = null) } $expectingThenMap[$pendingStoreKey] = false; $expectingElseMap[$pendingStoreKey] = false; - $parenthesisDepthMap[$pendingStoreKey] -= 1; + --$parenthesisDepthMap[$pendingStoreKey]; array_pop($pendingStoreKeysStack); unset($pendingStoreKey); } @@ -3615,7 +3614,7 @@ private function _parseFormula($formula, Cell $pCell = null) ++$index; } elseif ($opCharacter == '(' && !$expectingOperator) { if (!empty($pendingStoreKey)) { // Branch pruning: we go deeper - $parenthesisDepthMap[$pendingStoreKey] += 1; + ++$parenthesisDepthMap[$pendingStoreKey]; } $stack->push('Brace', '(', null, $currentCondition, $currentOnlyIf, $currentOnlyIf); ++$index; @@ -3641,7 +3640,7 @@ private function _parseFormula($formula, Cell $pCell = null) $parenthesisDepthMap[$pendingStoreKey] = 0; } else { // this is not an if but we go deeper if (!empty($pendingStoreKey) && array_key_exists($pendingStoreKey, $parenthesisDepthMap)) { - $parenthesisDepthMap[$pendingStoreKey] += 1; + ++$parenthesisDepthMap[$pendingStoreKey]; } } @@ -3818,11 +3817,10 @@ private static function dataTestReference(&$operandData) /** * @param mixed $tokens * @param null|string $cellID - * @param null|Cell $pCell * * @return bool */ - private function processTokenStack($tokens, $cellID = null, Cell $pCell = null) + private function processTokenStack($tokens, $cellID = null, ?Cell $pCell = null) { if ($tokens == false) { return false; @@ -4361,7 +4359,6 @@ private function validateBinaryOperand(&$operand, &$stack) * @param mixed $operand1 * @param mixed $operand2 * @param string $operation - * @param Stack $stack * @param bool $recursingArrays * * @return mixed @@ -4583,7 +4580,7 @@ private function executeNumericBinaryOperation($operand1, $operand2, $operation, break; // Power case '^': - $result = pow($operand1, $operand2); + $result = $operand1 ** $operand2; break; } @@ -4620,7 +4617,7 @@ protected function raiseFormulaError($errorMessage) * * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned. */ - public function extractCellRange(&$pRange = 'A1', Worksheet $pSheet = null, $resetLog = true) + public function extractCellRange(&$pRange = 'A1', ?Worksheet $pSheet = null, $resetLog = true) { // Return value $returnValue = []; @@ -4673,7 +4670,7 @@ public function extractCellRange(&$pRange = 'A1', Worksheet $pSheet = null, $res * * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned. */ - public function extractNamedRange(&$pRange = 'A1', Worksheet $pSheet = null, $resetLog = true) + public function extractNamedRange(&$pRange = 'A1', ?Worksheet $pSheet = null, $resetLog = true) { // Return value $returnValue = []; @@ -4773,21 +4770,19 @@ public function getImplementedFunctionNames() /** * Add cell reference if needed while making sure that it is the last argument. * - * @param array $args * @param bool $passCellReference * @param array|string $functionCall - * @param null|Cell $pCell * * @return array */ - private function addCellReference(array $args, $passCellReference, $functionCall, Cell $pCell = null) + private function addCellReference(array $args, $passCellReference, $functionCall, ?Cell $pCell = null) { if ($passCellReference) { if (is_array($functionCall)) { $className = $functionCall[0]; $methodName = $functionCall[1]; - $reflectionMethod = new \ReflectionMethod($className, $methodName); + $reflectionMethod = new ReflectionMethod($className, $methodName); $argumentCount = count($reflectionMethod->getParameters()); while (count($args) < $argumentCount - 1) { $args[] = null; diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index 9e1e4cf593..a57be297a1 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; +use DateTimeImmutable; +use DateTimeInterface; use PhpOffice\PhpSpreadsheet\Shared\Date; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; @@ -66,7 +68,7 @@ private static function dateDiff360($startDay, $startMonth, $startYear, $endDay, public static function getDateValue($dateValue) { if (!is_numeric($dateValue)) { - if ((is_object($dateValue)) && ($dateValue instanceof \DateTimeInterface)) { + if ((is_object($dateValue)) && ($dateValue instanceof DateTimeInterface)) { $dateValue = Date::PHPToExcel($dateValue); } else { $saveReturnDateType = Functions::getReturnDateType(); @@ -768,9 +770,9 @@ public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') * * @category Date/Time Functions * - * @param \DateTimeImmutable|float|int|string $endDate Excel date serial value (float), + * @param DateTimeImmutable|float|int|string $endDate Excel date serial value (float), * PHP date timestamp (integer), PHP DateTime object, or a standard date string - * @param \DateTimeImmutable|float|int|string $startDate Excel date serial value (float), + * @param DateTimeImmutable|float|int|string $startDate Excel date serial value (float), * PHP date timestamp (integer), PHP DateTime object, or a standard date string * * @return int|string Number of days between start date and end date or an error @@ -1301,7 +1303,7 @@ public static function WEEKDAY($dateValue = 1, $style = 1) self::DOW_SATURDAY, self::DOW_SUNDAY, self::STARTWEEK_MONDAY_ISO => self::STARTWEEK_MONDAY_ISO, - ]; + ]; /** * WEEKNUM. diff --git a/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php b/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php index 5a54d83ac0..b688e05634 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php +++ b/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php @@ -26,7 +26,7 @@ public function count() * * @param mixed $value */ - public function push($value) + public function push($value): void { $this->stack[$value] = $value; } @@ -56,7 +56,7 @@ public function onStack($value) /** * Clear the stack. */ - public function clear() + public function clear(): void { $this->stack = []; } diff --git a/src/PhpSpreadsheet/Calculation/Engine/Logger.php b/src/PhpSpreadsheet/Calculation/Engine/Logger.php index 6793dade78..d69ea56d18 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/Logger.php +++ b/src/PhpSpreadsheet/Calculation/Engine/Logger.php @@ -39,8 +39,6 @@ class Logger /** * Instantiate a Calculation engine logger. - * - * @param CyclicReferenceStack $stack */ public function __construct(CyclicReferenceStack $stack) { @@ -52,7 +50,7 @@ public function __construct(CyclicReferenceStack $stack) * * @param bool $pValue */ - public function setWriteDebugLog($pValue) + public function setWriteDebugLog($pValue): void { $this->writeDebugLog = $pValue; } @@ -72,7 +70,7 @@ public function getWriteDebugLog() * * @param bool $pValue */ - public function setEchoDebugLog($pValue) + public function setEchoDebugLog($pValue): void { $this->echoDebugLog = $pValue; } @@ -90,11 +88,11 @@ public function getEchoDebugLog() /** * Write an entry to the calculation engine debug log. */ - public function writeDebugLog(...$args) + public function writeDebugLog(...$args): void { // Only write the debug log if logging is enabled if ($this->writeDebugLog) { - $message = implode($args); + $message = implode('', $args); $cellReference = implode(' -> ', $this->cellStack->showStack()); if ($this->echoDebugLog) { echo $cellReference, @@ -111,7 +109,7 @@ public function writeDebugLog(...$args) /** * Clear the calculation engine debug log. */ - public function clearLog() + public function clearLog(): void { $this->debugLog = []; } diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php index 1a79ff71e7..aad35eecd2 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -799,7 +799,7 @@ public static function BESSELI($x, $ord) } if (abs($x) <= 30) { - $fResult = $fTerm = pow($x / 2, $ord) / MathTrig::FACT($ord); + $fResult = $fTerm = ($x / 2) ** $ord / MathTrig::FACT($ord); $ordK = 1; $fSqrX = ($x * $x) / 4; do { @@ -854,7 +854,7 @@ public static function BESSELJ($x, $ord) $fResult = 0; if (abs($x) <= 30) { - $fResult = $fTerm = pow($x / 2, $ord) / MathTrig::FACT($ord); + $fResult = $fTerm = ($x / 2) ** $ord / MathTrig::FACT($ord); $ordK = 1; $fSqrX = ($x * $x) / -4; do { @@ -2357,7 +2357,7 @@ private static function validateBitwiseArgument($value) } elseif (is_numeric($value)) { if ($value == (int) ($value)) { $value = (int) ($value); - if (($value > pow(2, 48) - 1) || ($value < 0)) { + if (($value > 2 ** 48 - 1) || ($value < 0)) { throw new Exception(Functions::NAN()); } @@ -2477,7 +2477,7 @@ public static function BITLSHIFT($number, $shiftAmount) $shiftAmount = Functions::flattenSingleValue($shiftAmount); $result = $number << $shiftAmount; - if ($result > pow(2, 48) - 1) { + if ($result > 2 ** 48 - 1) { return Functions::NAN(); } diff --git a/src/PhpSpreadsheet/Calculation/Exception.php b/src/PhpSpreadsheet/Calculation/Exception.php index fccf0af70f..87c7d222be 100644 --- a/src/PhpSpreadsheet/Calculation/Exception.php +++ b/src/PhpSpreadsheet/Calculation/Exception.php @@ -15,7 +15,7 @@ class Exception extends PhpSpreadsheetException * @param mixed $line * @param mixed $context */ - public static function errorHandlerCallback($code, $string, $file, $line, $context) + public static function errorHandlerCallback($code, $string, $file, $line, $context): void { $e = new self($string, $code); $e->line = $line; diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php index 1a49ac1cd9..624f035ac3 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -851,7 +851,7 @@ public static function DB($cost, $salvage, $life, $period, $month = 12) return Functions::NAN(); } // Set Fixed Depreciation Rate - $fixedDepreciationRate = 1 - pow(($salvage / $cost), (1 / $life)); + $fixedDepreciationRate = 1 - ($salvage / $cost) ** (1 / $life); $fixedDepreciationRate = round($fixedDepreciationRate, 3); // Loop through each period calculating the depreciation @@ -917,7 +917,7 @@ public static function DDB($cost, $salvage, $life, $period, $factor = 2.0) return Functions::NAN(); } // Set Fixed Depreciation Rate - $fixedDepreciationRate = 1 - pow(($salvage / $cost), (1 / $life)); + $fixedDepreciationRate = 1 - ($salvage / $cost) ** (1 / $life); $fixedDepreciationRate = round($fixedDepreciationRate, 3); // Loop through each period calculating the depreciation @@ -1021,7 +1021,7 @@ public static function DOLLARDE($fractional_dollar = null, $fraction = 0) $dollars = floor($fractional_dollar); $cents = fmod($fractional_dollar, 1); $cents /= $fraction; - $cents *= pow(10, ceil(log10($fraction))); + $cents *= 10 ** ceil(log10($fraction)); return $dollars + $cents; } @@ -1059,7 +1059,7 @@ public static function DOLLARFR($decimal_dollar = null, $fraction = 0) $dollars = floor($decimal_dollar); $cents = fmod($decimal_dollar, 1); $cents *= $fraction; - $cents *= pow(10, -ceil(log10($fraction))); + $cents *= 10 ** (-ceil(log10($fraction))); return $dollars + $cents; } @@ -1090,7 +1090,7 @@ public static function EFFECT($nominal_rate = 0, $npery = 0) return Functions::NAN(); } - return pow((1 + $nominal_rate / $npery), $npery) - 1; + return (1 + $nominal_rate / $npery) ** $npery - 1; } /** @@ -1131,7 +1131,7 @@ public static function FV($rate = 0, $nper = 0, $pmt = 0, $pv = 0, $type = 0) // Calculate if ($rate !== null && $rate != 0) { - return -$pv * pow(1 + $rate, $nper) - $pmt * (1 + $rate * $type) * (pow(1 + $rate, $nper) - 1) / $rate; + return -$pv * (1 + $rate) ** $nper - $pmt * (1 + $rate * $type) * ((1 + $rate) ** $nper - 1) / $rate; } return -$pv - $pmt * $nper; @@ -1400,9 +1400,9 @@ public static function MIRR($values, $finance_rate, $reinvestment_rate) $npv_pos = $npv_neg = 0.0; foreach ($values as $i => $v) { if ($v >= 0) { - $npv_pos += $v / pow($rr, $i); + $npv_pos += $v / $rr ** $i; } else { - $npv_neg += $v / pow($fr, $i); + $npv_neg += $v / $fr ** $i; } } @@ -1410,8 +1410,8 @@ public static function MIRR($values, $finance_rate, $reinvestment_rate) return Functions::VALUE(); } - $mirr = pow((-$npv_pos * pow($rr, $n)) - / ($npv_neg * ($rr)), (1.0 / ($n - 1))) - 1.0; + $mirr = ((-$npv_pos * $rr ** $n) + / ($npv_neg * ($rr))) ** (1.0 / ($n - 1)) - 1.0; return is_finite($mirr) ? $mirr : Functions::VALUE(); } @@ -1437,7 +1437,7 @@ public static function NOMINAL($effect_rate = 0, $npery = 0) } // Calculate - return $npery * (pow($effect_rate + 1, 1 / $npery) - 1); + return $npery * (($effect_rate + 1) ** (1 / $npery) - 1); } /** @@ -1502,7 +1502,7 @@ public static function NPV(...$args) for ($i = 1; $i <= $countArgs; ++$i) { // Is it a numeric value? if (is_numeric($aArgs[$i - 1])) { - $returnValue += $aArgs[$i - 1] / pow(1 + $rate, $i); + $returnValue += $aArgs[$i - 1] / (1 + $rate) ** $i; } } @@ -1565,7 +1565,7 @@ public static function PMT($rate = 0, $nper = 0, $pv = 0, $fv = 0, $type = 0) // Calculate if ($rate !== null && $rate != 0) { - return (-$fv - $pv * pow(1 + $rate, $nper)) / (1 + $rate * $type) / ((pow(1 + $rate, $nper) - 1) / $rate); + return (-$fv - $pv * (1 + $rate) ** $nper) / (1 + $rate * $type) / (((1 + $rate) ** $nper - 1) / $rate); } return (-$pv - $fv) / $nper; @@ -1672,9 +1672,9 @@ public static function PRICE($settlement, $maturity, $rate, $yield, $redemption, $rfp = 100 * ($rate / $frequency); $de = $dsc / $e; - $result = $redemption / pow($baseYF, (--$n + $de)); + $result = $redemption / $baseYF ** (--$n + $de); for ($k = 0; $k <= $n; ++$k) { - $result += $rfp / (pow($baseYF, ($k + $de))); + $result += $rfp / ($baseYF ** ($k + $de)); } $result -= $rfp * ($a / $e); @@ -1820,7 +1820,7 @@ public static function PV($rate = 0, $nper = 0, $pmt = 0, $fv = 0, $type = 0) // Calculate if ($rate !== null && $rate != 0) { - return (-$pmt * (1 + $rate * $type) * ((pow(1 + $rate, $nper) - 1) / $rate) - $fv) / pow(1 + $rate, $nper); + return (-$pmt * (1 + $rate * $type) * (((1 + $rate) ** $nper - 1) / $rate) - $fv) / (1 + $rate) ** $nper; } return -$fv - $pmt * $nper; @@ -1889,8 +1889,8 @@ private static function rateNextGuess($rate, $nper, $pmt, $pv, $fv, $type) if ($rate == 0) { return Functions::NAN(); } - $tt1 = pow($rate + 1, $nper); - $tt2 = pow($rate + 1, $nper - 1); + $tt1 = ($rate + 1) ** $nper; + $tt2 = ($rate + 1) ** ($nper - 1); $numerator = $fv + $tt1 * $pv + $pmt * ($tt1 - 1) * ($rate * $type + 1) / $rate; $denominator = $nper * $tt2 * $pv - $pmt * ($tt1 - 1) * ($rate * $type + 1) / ($rate * $rate) + $nper * $pmt * $tt2 * ($rate * $type + 1) / $rate @@ -1971,7 +1971,7 @@ public static function RRI($nper = 0, $pv = 0, $fv = 0) return Functions::NAN(); } - return pow($fv / $pv, 1 / $nper) - 1; + return ($fv / $pv) ** (1 / $nper) - 1; } /** @@ -2377,7 +2377,7 @@ private static function xnpvOrdered($rate, $values, $dates, $ordered = true) if (!is_numeric($dif)) { return $dif; } - $xnpv += $values[$i] / pow(1 + $rate, $dif / 365); + $xnpv += $values[$i] / (1 + $rate) ** ($dif / 365); } return is_finite($xnpv) ? $xnpv : Functions::VALUE(); diff --git a/src/PhpSpreadsheet/Calculation/FormulaParser.php b/src/PhpSpreadsheet/Calculation/FormulaParser.php index 38c725c2de..f6c88b2650 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaParser.php +++ b/src/PhpSpreadsheet/Calculation/FormulaParser.php @@ -125,7 +125,7 @@ public function getTokens() /** * Parse to tokens. */ - private function parseToTokens() + private function parseToTokens(): void { // No attempt is made to verify formulas; assumes formulas are derived from Excel, where // they can only exist if valid; stack overflows/underflows sunk as nulls without exceptions. diff --git a/src/PhpSpreadsheet/Calculation/FormulaToken.php b/src/PhpSpreadsheet/Calculation/FormulaToken.php index 66618d4a0c..4d225de2d5 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaToken.php +++ b/src/PhpSpreadsheet/Calculation/FormulaToken.php @@ -103,7 +103,7 @@ public function getValue() * * @param string $value */ - public function setValue($value) + public function setValue($value): void { $this->value = $value; } @@ -123,7 +123,7 @@ public function getTokenType() * * @param string $value */ - public function setTokenType($value) + public function setTokenType($value): void { $this->tokenType = $value; } @@ -143,7 +143,7 @@ public function getTokenSubType() * * @param string $value */ - public function setTokenSubType($value) + public function setTokenSubType($value): void { $this->tokenSubType = $value; } diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index 1862b008a1..af872dd707 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -660,7 +660,7 @@ public static function flattenSingleValue($value = '') * * @return bool|string */ - public static function isFormula($cellReference = '', Cell $pCell = null) + public static function isFormula($cellReference = '', ?Cell $pCell = null) { if ($pCell === null) { return self::REF(); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index 48434300b2..2d196aef51 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -238,7 +238,7 @@ public static function ROWS($cellAddress = null) * * @return mixed The value of $displayName (or $linkURL if $displayName was blank) */ - public static function HYPERLINK($linkURL = '', $displayName = null, Cell $pCell = null) + public static function HYPERLINK($linkURL = '', $displayName = null, ?Cell $pCell = null) { $linkURL = ($linkURL === null) ? '' : Functions::flattenSingleValue($linkURL); $displayName = ($displayName === null) ? '' : Functions::flattenSingleValue($displayName); @@ -275,7 +275,7 @@ public static function HYPERLINK($linkURL = '', $displayName = null, Cell $pCell * * @todo Support for the optional a1 parameter introduced in Excel 2010 */ - public static function INDIRECT($cellAddress = null, Cell $pCell = null) + public static function INDIRECT($cellAddress = null, ?Cell $pCell = null) { $cellAddress = Functions::flattenSingleValue($cellAddress); if ($cellAddress === null || $cellAddress === '') { @@ -339,11 +339,10 @@ public static function INDIRECT($cellAddress = null, Cell $pCell = null) * starting reference). * @param mixed $height The height, in number of rows, that you want the returned reference to be. Height must be a positive number. * @param mixed $width The width, in number of columns, that you want the returned reference to be. Width must be a positive number. - * @param null|Cell $pCell * * @return string A reference to a cell or range of cells */ - public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null, Cell $pCell = null) + public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null, ?Cell $pCell = null) { $rows = Functions::flattenSingleValue($rows); $columns = Functions::flattenSingleValue($columns); @@ -419,14 +418,6 @@ public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $hei * Excel Function: * =CHOOSE(index_num, value1, [value2], ...) * - * @param mixed $index_num Specifies which value argument is selected. - * Index_num must be a number between 1 and 254, or a formula or reference to a cell containing a number - * between 1 and 254. - * @param mixed $value1 ... Value1 is required, subsequent values are optional. - * Between 1 to 254 value arguments from which CHOOSE selects a value or an action to perform based on - * index_num. The arguments can be numbers, cell references, defined names, formulas, functions, or - * text. - * * @return mixed The selected value */ public static function CHOOSE(...$chooseArgs) @@ -945,7 +936,7 @@ public static function LOOKUP($lookup_value, $lookup_vector, $result_vector = nu * * @return string */ - public static function FORMULATEXT($cellReference = '', Cell $pCell = null) + public static function FORMULATEXT($cellReference = '', ?Cell $pCell = null) { if ($pCell === null) { return Functions::REF(); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index f94c8fcc5e..3db3fb8d05 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -2,6 +2,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; +use Exception; use Matrix\Exception as MatrixException; use Matrix\Matrix; @@ -68,7 +69,7 @@ public static function ARABIC($roman) try { $arabic = self::calculateArabic(str_split($roman)); - } catch (\Exception $e) { + } catch (Exception $e) { return Functions::VALUE(); // Invalid character detected } @@ -82,7 +83,6 @@ public static function ARABIC($roman) /** * Recursively calculate the arabic value of a roman numeral. * - * @param array $roman * @param int $sum * @param int $subtract * @@ -102,7 +102,7 @@ protected static function calculateArabic(array $roman, &$sum = 0, $subtract = 0 $numeral = array_shift($roman); if (!isset($lookup[$numeral])) { - throw new \Exception('Invalid character detected'); + throw new Exception('Invalid character detected'); } $arabic = $lookup[$numeral]; @@ -618,7 +618,7 @@ public static function LCM(...$args) $myCountedFactors = array_count_values($myFactors); $myPoweredFactors = []; foreach ($myCountedFactors as $myCountedFactor => $myCountedPower) { - $myPoweredFactors[$myCountedFactor] = pow($myCountedFactor, $myCountedPower); + $myPoweredFactors[$myCountedFactor] = $myCountedFactor ** $myCountedPower; } foreach ($myPoweredFactors as $myPoweredValue => $myPoweredFactor) { if (isset($allPoweredFactors[$myPoweredValue])) { @@ -986,7 +986,7 @@ public static function POWER($x = 0, $y = 2) } // Return - $result = pow($x, $y); + $result = $x ** $y; return (!is_nan($result) && !is_infinite($result)) ? $result : Functions::NAN(); } @@ -1139,10 +1139,10 @@ public static function ROUNDUP($number, $digits) if ((is_numeric($number)) && (is_numeric($digits))) { if ($number < 0.0) { - return round($number - 0.5 * pow(0.1, $digits), $digits, PHP_ROUND_HALF_DOWN); + return round($number - 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_DOWN); } - return round($number + 0.5 * pow(0.1, $digits), $digits, PHP_ROUND_HALF_DOWN); + return round($number + 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_DOWN); } return Functions::VALUE(); @@ -1165,10 +1165,10 @@ public static function ROUNDDOWN($number, $digits) if ((is_numeric($number)) && (is_numeric($digits))) { if ($number < 0.0) { - return round($number + 0.5 * pow(0.1, $digits), $digits, PHP_ROUND_HALF_UP); + return round($number + 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_UP); } - return round($number - 0.5 * pow(0.1, $digits), $digits, PHP_ROUND_HALF_UP); + return round($number - 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_UP); } return Functions::VALUE(); @@ -1179,9 +1179,6 @@ public static function ROUNDDOWN($number, $digits) * * Returns the sum of a power series * - * @param float $x Input value to the power series - * @param float $n Initial power to which you want to raise $x - * @param float $m Step by which to increase $n for each term in the series * @param array of mixed Data Series * * @return float|string The result, or a string containing an error @@ -1203,7 +1200,7 @@ public static function SERIESSUM(...$args) foreach ($aArgs as $arg) { // Is it a numeric value? if ((is_numeric($arg)) && (!is_string($arg))) { - $returnValue += $arg * pow($x, $n + ($m * $i++)); + $returnValue += $arg * $x ** ($n + ($m * $i++)); } else { return Functions::VALUE(); } @@ -1445,7 +1442,6 @@ public static function SUMIF($aArgs, $condition, $sumArgs = []) * @category Mathematical and Trigonometric Functions * * @param mixed $args Data values - * @param string $condition the criteria that defines which cells will be summed * * @return float */ @@ -1663,7 +1659,7 @@ public static function TRUNC($value = 0, $digits = 0) $digits = floor($digits); // Truncate - $adjust = pow(10, $digits); + $adjust = 10 ** $digits; if (($digits > 0) && (rtrim((int) ((abs($value) - abs((int) $value)) * $adjust), '0') < $adjust / 10)) { return $value; diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php index 2b7fd8c92d..675f88efc5 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -397,10 +397,10 @@ private static function incompleteGamma($a, $x) for ($i = 1; $i <= $n; ++$i) { $divisor *= ($a + $i); } - $summer += (pow($x, $n) / $divisor); + $summer += ($x ** $n / $divisor); } - return pow($x, $a) * exp(0 - $x) * $summer; + return $x ** $a * exp(0 - $x) * $summer; } // @@ -874,13 +874,13 @@ public static function BINOMDIST($value, $trials, $probability, $cumulative) if ($cumulative) { $summer = 0; for ($i = 0; $i <= $value; ++$i) { - $summer += MathTrig::COMBIN($trials, $i) * pow($probability, $i) * pow(1 - $probability, $trials - $i); + $summer += MathTrig::COMBIN($trials, $i) * $probability ** $i * (1 - $probability) ** ($trials - $i); } return $summer; } - return MathTrig::COMBIN($trials, $value) * pow($probability, $value) * pow(1 - $probability, $trials - $value); + return MathTrig::COMBIN($trials, $value) * $probability ** $value * (1 - $probability) ** ($trials - $value); } } @@ -1320,7 +1320,7 @@ public static function CRITBINOM($trials, $probability, $alpha) $t = sqrt(log(1 / ($alpha * $alpha))); $trialsApprox = 0 - ($t + (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t)); } else { - $t = sqrt(log(1 / pow(1 - $alpha, 2))); + $t = sqrt(log(1 / (1 - $alpha) ** 2)); $trialsApprox = $t - (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t); } @@ -1441,9 +1441,9 @@ public static function DEVSQ(...$args) } if ((is_numeric($arg)) && (!is_string($arg))) { if ($returnValue === null) { - $returnValue = pow(($arg - $aMean), 2); + $returnValue = ($arg - $aMean) ** 2; } else { - $returnValue += pow(($arg - $aMean), 2); + $returnValue += ($arg - $aMean) ** 2; } ++$aCount; } @@ -1603,7 +1603,7 @@ public static function GAMMADIST($value, $a, $b, $cumulative) return self::incompleteGamma($a, $value / $b) / self::gamma($a); } - return (1 / (pow($b, $a) * self::gamma($a))) * pow($value, $a - 1) * exp(0 - ($value / $b)); + return (1 / ($b ** $a * self::gamma($a))) * $value ** ($a - 1) * exp(0 - ($value / $b)); } } @@ -1721,7 +1721,7 @@ public static function GEOMEAN(...$args) if (is_numeric($aMean) && ($aMean > 0)) { $aCount = self::COUNT($aArgs); if (self::MIN($aArgs) > 0) { - return pow($aMean, (1 / $aCount)); + return $aMean ** (1 / $aCount); } } @@ -1900,7 +1900,7 @@ public static function KURT(...$args) } else { // Is it a numeric value? if ((is_numeric($arg)) && (!is_string($arg))) { - $summer += pow((($arg - $mean) / $stdDev), 4); + $summer += (($arg - $mean) / $stdDev) ** 4; ++$count; } } @@ -1908,7 +1908,7 @@ public static function KURT(...$args) // Return if ($count > 3) { - return $summer * ($count * ($count + 1) / (($count - 1) * ($count - 2) * ($count - 3))) - (3 * pow($count - 1, 2) / (($count - 2) * ($count - 3))); + return $summer * ($count * ($count + 1) / (($count - 1) * ($count - 2) * ($count - 3))) - (3 * ($count - 1) ** 2 / (($count - 2) * ($count - 3))); } } @@ -1927,7 +1927,6 @@ public static function KURT(...$args) * @category Statistical Functions * * @param mixed $args Data values - * @param int $entry Position (ordered from the largest) in the array or range of data to return * * @return float|string The result, or a string containing an error */ @@ -2013,9 +2012,9 @@ public static function LINEST($yValues, $xValues = null, $const = true, $stats = } return [ - $bestFitLinear->getSlope(), - $bestFitLinear->getIntersect(), - ]; + $bestFitLinear->getSlope(), + $bestFitLinear->getIntersect(), + ]; } /** @@ -2078,9 +2077,9 @@ public static function LOGEST($yValues, $xValues = null, $const = true, $stats = } return [ - $bestFitExponential->getSlope(), - $bestFitExponential->getIntersect(), - ]; + $bestFitExponential->getSlope(), + $bestFitExponential->getIntersect(), + ]; } /** @@ -2579,7 +2578,7 @@ public static function NEGBINOMDIST($failures, $successes, $probability) } } - return (MathTrig::COMBIN($failures + $successes - 1, $successes - 1)) * (pow($probability, $successes)) * (pow(1 - $probability, $failures)); + return (MathTrig::COMBIN($failures + $successes - 1, $successes - 1)) * ($probability ** $successes) * ((1 - $probability) ** $failures); } return Functions::VALUE(); @@ -2614,7 +2613,7 @@ public static function NORMDIST($value, $mean, $stdDev, $cumulative) return 0.5 * (1 + Engineering::erfVal(($value - $mean) / ($stdDev * sqrt(2)))); } - return (1 / (self::SQRT2PI * $stdDev)) * exp(0 - (pow($value - $mean, 2) / (2 * ($stdDev * $stdDev)))); + return (1 / (self::SQRT2PI * $stdDev)) * exp(0 - (($value - $mean) ** 2 / (2 * ($stdDev * $stdDev)))); } } @@ -2695,7 +2694,6 @@ public static function NORMSINV($value) * @category Statistical Functions * * @param mixed $args Data values - * @param float $entry Percentile value in the range 0..1, inclusive. * * @return float|string The result, or a string containing an error */ @@ -2841,13 +2839,13 @@ public static function POISSON($value, $mean, $cumulative) $summer = 0; $floor = floor($value); for ($i = 0; $i <= $floor; ++$i) { - $summer += pow($mean, $i) / MathTrig::FACT($i); + $summer += $mean ** $i / MathTrig::FACT($i); } return exp(0 - $mean) * $summer; } - return (exp(0 - $mean) * pow($mean, $value)) / MathTrig::FACT($value); + return (exp(0 - $mean) * $mean ** $value) / MathTrig::FACT($value); } } @@ -2865,7 +2863,6 @@ public static function POISSON($value, $mean, $cumulative) * @category Statistical Functions * * @param mixed $args Data values - * @param int $entry Quartile value in the range 1..3, inclusive. * * @return float|string The result, or a string containing an error */ @@ -2979,7 +2976,7 @@ public static function SKEW(...$args) } else { // Is it a numeric value? if ((is_numeric($arg)) && (!is_string($arg))) { - $summer += pow((($arg - $mean) / $stdDev), 3); + $summer += (($arg - $mean) / $stdDev) ** 3; ++$count; } } @@ -3033,7 +3030,6 @@ public static function SLOPE($yValues, $xValues) * @category Statistical Functions * * @param mixed $args Data values - * @param int $entry Position (ordered from the smallest) in the array or range of data to return * * @return float|string The result, or a string containing an error */ @@ -3126,9 +3122,9 @@ public static function STDEV(...$args) // Is it a numeric value? if ((is_numeric($arg)) && (!is_string($arg))) { if ($returnValue === null) { - $returnValue = pow(($arg - $aMean), 2); + $returnValue = ($arg - $aMean) ** 2; } else { - $returnValue += pow(($arg - $aMean), 2); + $returnValue += ($arg - $aMean) ** 2; } ++$aCount; } @@ -3178,9 +3174,9 @@ public static function STDEVA(...$args) $arg = 0; } if ($returnValue === null) { - $returnValue = pow(($arg - $aMean), 2); + $returnValue = ($arg - $aMean) ** 2; } else { - $returnValue += pow(($arg - $aMean), 2); + $returnValue += ($arg - $aMean) ** 2; } ++$aCount; } @@ -3226,9 +3222,9 @@ public static function STDEVP(...$args) // Is it a numeric value? if ((is_numeric($arg)) && (!is_string($arg))) { if ($returnValue === null) { - $returnValue = pow(($arg - $aMean), 2); + $returnValue = ($arg - $aMean) ** 2; } else { - $returnValue += pow(($arg - $aMean), 2); + $returnValue += ($arg - $aMean) ** 2; } ++$aCount; } @@ -3277,9 +3273,9 @@ public static function STDEVPA(...$args) $arg = 0; } if ($returnValue === null) { - $returnValue = pow(($arg - $aMean), 2); + $returnValue = ($arg - $aMean) ** 2; } else { - $returnValue += pow(($arg - $aMean), 2); + $returnValue += ($arg - $aMean) ** 2; } ++$aCount; } @@ -3491,7 +3487,6 @@ public static function TREND($yValues, $xValues = [], $newValues = [], $const = * @category Statistical Functions * * @param mixed $args Data values - * @param float $discard Percentage to discard * * @return float|string */ @@ -3746,10 +3741,10 @@ public static function WEIBULL($value, $alpha, $beta, $cumulative) } if ((is_numeric($cumulative)) || (is_bool($cumulative))) { if ($cumulative) { - return 1 - exp(0 - pow($value / $beta, $alpha)); + return 1 - exp(0 - ($value / $beta) ** $alpha); } - return ($alpha / pow($beta, $alpha)) * pow($value, $alpha - 1) * exp(0 - pow($value / $beta, $alpha)); + return ($alpha / $beta ** $alpha) * $value ** ($alpha - 1) * exp(0 - ($value / $beta) ** $alpha); } } diff --git a/src/PhpSpreadsheet/Calculation/TextData.php b/src/PhpSpreadsheet/Calculation/TextData.php index bbb03926ca..8f4b7d87b4 100644 --- a/src/PhpSpreadsheet/Calculation/TextData.php +++ b/src/PhpSpreadsheet/Calculation/TextData.php @@ -167,7 +167,7 @@ public static function DOLLAR($value = 0, $decimals = 2) if ($decimals > 0) { $mask .= '.' . str_repeat('0', $decimals); } else { - $round = pow(10, abs($decimals)); + $round = 10 ** abs($decimals); if ($value < 0) { $round = 0 - $round; } @@ -623,7 +623,7 @@ public static function NUMBERVALUE($value = '', $decimalSeparator = null, $group $percentageAdjustment = strlen($value) - strlen($percentageString); if ($percentageAdjustment) { $value = (float) $percentageString; - $value /= pow(10, $percentageAdjustment * 2); + $value /= 10 ** ($percentageAdjustment * 2); } } diff --git a/src/PhpSpreadsheet/Calculation/Token/Stack.php b/src/PhpSpreadsheet/Calculation/Token/Stack.php index 341a017979..941e1ad764 100644 --- a/src/PhpSpreadsheet/Calculation/Token/Stack.php +++ b/src/PhpSpreadsheet/Calculation/Token/Stack.php @@ -49,7 +49,7 @@ public function push( $storeKey = null, $onlyIf = null, $onlyIfNot = null - ) { + ): void { $stackItem = $this->getStackItem($type, $value, $reference, $storeKey, $onlyIf, $onlyIfNot); $this->stack[$this->count++] = $stackItem; @@ -124,7 +124,7 @@ public function last($n = 1) /** * Clear the stack. */ - public function clear() + public function clear(): void { $this->stack = []; $this->count = 0; diff --git a/src/PhpSpreadsheet/Cell/Cell.php b/src/PhpSpreadsheet/Cell/Cell.php index 30be33535d..0bca2fc03e 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -76,12 +76,12 @@ public function updateInCollection() return $this; } - public function detach() + public function detach(): void { $this->parent = null; } - public function attach(Cells $parent) + public function attach(Cells $parent): void { $this->parent = $parent; } @@ -91,7 +91,6 @@ public function attach(Cells $parent) * * @param mixed $pValue * @param string $pDataType - * @param Worksheet $pSheet */ public function __construct($pValue, $pDataType, Worksheet $pSheet) { @@ -386,7 +385,7 @@ public function getDataValidation() * * @return Cell */ - public function setDataValidation(DataValidation $pDataValidation = null) + public function setDataValidation(?DataValidation $pDataValidation = null) { if (!isset($this->parent)) { throw new Exception('Cannot set data validation for cell that is not bound to a worksheet'); @@ -444,7 +443,7 @@ public function getHyperlink() * * @return Cell */ - public function setHyperlink(Hyperlink $pHyperlink = null) + public function setHyperlink(?Hyperlink $pHyperlink = null) { if (!isset($this->parent)) { throw new Exception('Cannot set hyperlink for cell that is not bound to a worksheet'); @@ -532,8 +531,6 @@ public function getStyle() /** * Re-bind parent. * - * @param Worksheet $parent - * * @return Cell */ public function rebindParent(Worksheet $parent) @@ -600,10 +597,8 @@ public static function getValueBinder() /** * Set value binder to use. - * - * @param IValueBinder $binder */ - public static function setValueBinder(IValueBinder $binder) + public static function setValueBinder(IValueBinder $binder): void { self::$valueBinder = $binder; } diff --git a/src/PhpSpreadsheet/Cell/Coordinate.php b/src/PhpSpreadsheet/Cell/Coordinate.php index 70fed25a01..8c67991371 100644 --- a/src/PhpSpreadsheet/Cell/Coordinate.php +++ b/src/PhpSpreadsheet/Cell/Coordinate.php @@ -503,7 +503,7 @@ private static function getCellBlocksFromRangeString($pRange) * @param int $currentRow * @param int $endRow */ - private static function validateRange($cellBlock, $startColumnIndex, $endColumnIndex, $currentRow, $endRow) + private static function validateRange($cellBlock, $startColumnIndex, $endColumnIndex, $currentRow, $endRow): void { if ($startColumnIndex >= $endColumnIndex || $currentRow > $endRow) { throw new Exception('Invalid range: "' . $cellBlock . '"'); diff --git a/src/PhpSpreadsheet/Chart/Axis.php b/src/PhpSpreadsheet/Chart/Axis.php index 66242e3409..7995c3b3fe 100644 --- a/src/PhpSpreadsheet/Chart/Axis.php +++ b/src/PhpSpreadsheet/Chart/Axis.php @@ -178,7 +178,7 @@ public function getAxisNumberSourceLinked() * @param string $major_unit * @param string $minor_unit */ - public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = null, $horizontal_crosses = null, $axis_orientation = null, $major_tmt = null, $minor_tmt = null, $minimum = null, $maximum = null, $major_unit = null, $minor_unit = null) + public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = null, $horizontal_crosses = null, $axis_orientation = null, $major_tmt = null, $minor_tmt = null, $minimum = null, $maximum = null, $major_unit = null, $minor_unit = null): void { $this->axisOptions['axis_labels'] = (string) $axis_labels; ($horizontal_crosses_value !== null) ? $this->axisOptions['horizontal_crosses_value'] = (string) $horizontal_crosses_value : null; @@ -210,7 +210,7 @@ public function getAxisOptionsProperty($property) * * @param string $orientation */ - public function setAxisOrientation($orientation) + public function setAxisOrientation($orientation): void { $this->axisOptions['orientation'] = (string) $orientation; } @@ -222,7 +222,7 @@ public function setAxisOrientation($orientation) * @param int $alpha * @param string $type */ - public function setFillParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB) + public function setFillParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB): void { $this->fillProperties = $this->setColorProperties($color, $alpha, $type); } @@ -234,7 +234,7 @@ public function setFillParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_ * @param int $alpha * @param string $type */ - public function setLineParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB) + public function setLineParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB): void { $this->lineProperties = $this->setColorProperties($color, $alpha, $type); } @@ -276,7 +276,7 @@ public function getLineProperty($property) * @param string $end_arrow_type * @param string $end_arrow_size */ - public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null) + public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null): void { ($line_width !== null) ? $this->lineStyleProperties['width'] = $this->getExcelPointsWidth((float) $line_width) : null; ($compound_type !== null) ? $this->lineStyleProperties['compound'] = (string) $compound_type : null; @@ -336,7 +336,7 @@ public function getLineStyleArrowLength($arrow) * @param int $sh_angle * @param float $sh_distance */ - public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null) + public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null): void { $this->setShadowPresetsProperties((int) $sh_presets) ->setShadowColor( @@ -367,7 +367,6 @@ private function setShadowPresetsProperties($shadow_presets) /** * Set Shadow Properties from Mapped Values. * - * @param array $properties_map * @param mixed &$reference * * @return $this @@ -479,7 +478,7 @@ public function getShadowProperty($elements) * @param int $color_alpha * @param string $color_type */ - public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null) + public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null): void { $this->setGlowSize($size) ->setGlowColor( @@ -538,7 +537,7 @@ private function setGlowColor($color, $alpha, $type) * * @param float $size */ - public function setSoftEdges($size) + public function setSoftEdges($size): void { if ($size !== null) { $softEdges['size'] = (string) $this->getExcelPointsWidth($size); diff --git a/src/PhpSpreadsheet/Chart/Chart.php b/src/PhpSpreadsheet/Chart/Chart.php index 7064160eb7..20eb2aee7b 100644 --- a/src/PhpSpreadsheet/Chart/Chart.php +++ b/src/PhpSpreadsheet/Chart/Chart.php @@ -144,19 +144,10 @@ class Chart * Create a new Chart. * * @param mixed $name - * @param null|Title $title - * @param null|Legend $legend - * @param null|PlotArea $plotArea * @param mixed $plotVisibleOnly * @param string $displayBlanksAs - * @param null|Title $xAxisLabel - * @param null|Title $yAxisLabel - * @param null|Axis $xAxis - * @param null|Axis $yAxis - * @param null|GridLines $majorGridlines - * @param null|GridLines $minorGridlines */ - public function __construct($name, Title $title = null, Legend $legend = null, PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = DataSeries::EMPTY_AS_GAP, Title $xAxisLabel = null, Title $yAxisLabel = null, Axis $xAxis = null, Axis $yAxis = null, GridLines $majorGridlines = null, GridLines $minorGridlines = null) + public function __construct($name, ?Title $title = null, ?Legend $legend = null, ?PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = DataSeries::EMPTY_AS_GAP, ?Title $xAxisLabel = null, ?Title $yAxisLabel = null, ?Axis $xAxis = null, ?Axis $yAxis = null, ?GridLines $majorGridlines = null, ?GridLines $minorGridlines = null) { $this->name = $name; $this->title = $title; @@ -199,7 +190,7 @@ public function getWorksheet() * * @return $this */ - public function setWorksheet(Worksheet $pValue = null) + public function setWorksheet(?Worksheet $pValue = null) { $this->worksheet = $pValue; @@ -219,8 +210,6 @@ public function getTitle() /** * Set Title. * - * @param Title $title - * * @return $this */ public function setTitle(Title $title) @@ -243,8 +232,6 @@ public function getLegend() /** * Set Legend. * - * @param Legend $legend - * * @return $this */ public function setLegend(Legend $legend) @@ -267,8 +254,6 @@ public function getXAxisLabel() /** * Set X-Axis Label. * - * @param Title $label - * * @return $this */ public function setXAxisLabel(Title $label) @@ -291,8 +276,6 @@ public function getYAxisLabel() /** * Set Y-Axis Label. * - * @param Title $label - * * @return $this */ public function setYAxisLabel(Title $label) @@ -645,7 +628,7 @@ public function getBottomRightYOffset() return $this->bottomRightYOffset; } - public function refresh() + public function refresh(): void { if ($this->worksheet !== null) { $this->plotArea->refresh($this->worksheet); diff --git a/src/PhpSpreadsheet/Chart/DataSeries.php b/src/PhpSpreadsheet/Chart/DataSeries.php index 79f4e8d16b..3a44b33529 100644 --- a/src/PhpSpreadsheet/Chart/DataSeries.php +++ b/src/PhpSpreadsheet/Chart/DataSeries.php @@ -373,7 +373,7 @@ public function setSmoothLine($smoothLine) return $this; } - public function refresh(Worksheet $worksheet) + public function refresh(Worksheet $worksheet): void { foreach ($this->plotValues as $plotValues) { if ($plotValues !== null) { diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index e15f5da5f5..c1bd973a46 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -352,7 +352,7 @@ public function setDataValues($dataValues) return $this; } - public function refresh(Worksheet $worksheet, $flatten = true) + public function refresh(Worksheet $worksheet, $flatten = true): void { if ($this->dataSource !== null) { $calcEngine = Calculation::getInstance($worksheet->getParent()); diff --git a/src/PhpSpreadsheet/Chart/GridLines.php b/src/PhpSpreadsheet/Chart/GridLines.php index b07fcae595..2e424bc246 100644 --- a/src/PhpSpreadsheet/Chart/GridLines.php +++ b/src/PhpSpreadsheet/Chart/GridLines.php @@ -107,7 +107,7 @@ private function activateObject() * @param int $alpha * @param string $type */ - public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD) + public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD): void { $this->activateObject() ->lineProperties['color'] = $this->setColorProperties( @@ -130,7 +130,7 @@ public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_C * @param string $end_arrow_type * @param string $end_arrow_size */ - public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null) + public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null): void { $this->activateObject(); ($line_width !== null) @@ -194,7 +194,7 @@ public function getLineStyleProperty($elements) * @param int $color_alpha * @param string $color_type */ - public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null) + public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null): void { $this ->activateObject() @@ -286,7 +286,7 @@ public function getLineStyleArrowParameters($arrow_selector, $property_selector) * @param int $sh_angle * @param float $sh_distance */ - public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null) + public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null): void { $this->activateObject() ->setShadowPresetsProperties((int) $sh_presets) @@ -318,7 +318,6 @@ private function setShadowPresetsProperties($shadow_presets) /** * Set Shadow Properties Values. * - * @param array $properties_map * @param mixed &$reference * * @return $this @@ -435,7 +434,7 @@ public function getShadowProperty($elements) * * @param float $size */ - public function setSoftEdgesSize($size) + public function setSoftEdgesSize($size): void { if ($size !== null) { $this->activateObject(); diff --git a/src/PhpSpreadsheet/Chart/Layout.php b/src/PhpSpreadsheet/Chart/Layout.php index 3e989c6d58..51c8995b06 100644 --- a/src/PhpSpreadsheet/Chart/Layout.php +++ b/src/PhpSpreadsheet/Chart/Layout.php @@ -110,8 +110,6 @@ class Layout /** * Create a new Layout. - * - * @param array $layout */ public function __construct(array $layout = []) { diff --git a/src/PhpSpreadsheet/Chart/Legend.php b/src/PhpSpreadsheet/Chart/Legend.php index d077626510..fc0ed1407c 100644 --- a/src/PhpSpreadsheet/Chart/Legend.php +++ b/src/PhpSpreadsheet/Chart/Legend.php @@ -52,10 +52,9 @@ class Legend * Create a new Legend. * * @param string $position - * @param null|Layout $layout * @param bool $overlay */ - public function __construct($position = self::POSITION_RIGHT, Layout $layout = null, $overlay = false) + public function __construct($position = self::POSITION_RIGHT, ?Layout $layout = null, $overlay = false) { $this->setPosition($position); $this->layout = $layout; diff --git a/src/PhpSpreadsheet/Chart/PlotArea.php b/src/PhpSpreadsheet/Chart/PlotArea.php index 9da4aa3297..954777cf2f 100644 --- a/src/PhpSpreadsheet/Chart/PlotArea.php +++ b/src/PhpSpreadsheet/Chart/PlotArea.php @@ -23,10 +23,9 @@ class PlotArea /** * Create a new PlotArea. * - * @param null|Layout $layout * @param DataSeries[] $plotSeries */ - public function __construct(Layout $layout = null, array $plotSeries = []) + public function __construct(?Layout $layout = null, array $plotSeries = []) { $this->layout = $layout; $this->plotSeries = $plotSeries; @@ -103,7 +102,7 @@ public function setPlotSeries(array $plotSeries) return $this; } - public function refresh(Worksheet $worksheet) + public function refresh(Worksheet $worksheet): void { foreach ($this->plotSeries as $plotSeries) { $plotSeries->refresh($worksheet); diff --git a/src/PhpSpreadsheet/Chart/Renderer/IRenderer.php b/src/PhpSpreadsheet/Chart/Renderer/IRenderer.php index c6fcfbfc93..3032f6ba25 100644 --- a/src/PhpSpreadsheet/Chart/Renderer/IRenderer.php +++ b/src/PhpSpreadsheet/Chart/Renderer/IRenderer.php @@ -8,8 +8,6 @@ interface IRenderer { /** * IRenderer constructor. - * - * @param \PhpOffice\PhpSpreadsheet\Chart\Chart $chart */ public function __construct(Chart $chart); diff --git a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php index 9dcab049d2..bd931c66c5 100644 --- a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php +++ b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php @@ -2,8 +2,24 @@ namespace PhpOffice\PhpSpreadsheet\Chart\Renderer; +use AccBarPlot; +use AccLinePlot; +use BarPlot; +use ContourPlot; +use Graph; +use GroupBarPlot; +use LinePlot; use PhpOffice\PhpSpreadsheet\Chart\Chart; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; +use PieGraph; +use PiePlot; +use PiePlot3D; +use PiePlotC; +use RadarGraph; +use RadarPlot; +use ScatterPlot; +use Spline; +use StockPlot; require_once __DIR__ . '/Polyfill.php'; @@ -33,8 +49,6 @@ class JpGraph implements IRenderer /** * Create a new jpgraph. - * - * @param Chart $chart */ public function __construct(Chart $chart) { @@ -43,7 +57,7 @@ public function __construct(Chart $chart) $this->chart = $chart; } - private static function init() + private static function init(): void { static $loaded = false; if ($loaded) { @@ -179,7 +193,7 @@ private function getCaption($captionElement) return $caption; } - private function renderTitle() + private function renderTitle(): void { $title = $this->getCaption($this->chart->getTitle()); if ($title !== null) { @@ -187,7 +201,7 @@ private function renderTitle() } } - private function renderLegend() + private function renderLegend(): void { $legend = $this->chart->getLegend(); if ($legend !== null) { @@ -220,9 +234,9 @@ private function renderLegend() } } - private function renderCartesianPlotArea($type = 'textlin') + private function renderCartesianPlotArea($type = 'textlin'): void { - $this->graph = new \Graph(self::$width, self::$height); + $this->graph = new Graph(self::$width, self::$height); $this->graph->SetScale($type); $this->renderTitle(); @@ -257,22 +271,22 @@ private function renderCartesianPlotArea($type = 'textlin') } } - private function renderPiePlotArea() + private function renderPiePlotArea(): void { - $this->graph = new \PieGraph(self::$width, self::$height); + $this->graph = new PieGraph(self::$width, self::$height); $this->renderTitle(); } - private function renderRadarPlotArea() + private function renderRadarPlotArea(): void { - $this->graph = new \RadarGraph(self::$width, self::$height); + $this->graph = new RadarGraph(self::$width, self::$height); $this->graph->SetScale('lin'); $this->renderTitle(); } - private function renderPlotLine($groupID, $filled = false, $combination = false, $dimensions = '2d') + private function renderPlotLine($groupID, $filled = false, $combination = false, $dimensions = '2d'): void { $grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); @@ -308,7 +322,7 @@ private function renderPlotLine($groupID, $filled = false, $combination = false, ++$testCurrentIndex; } - $seriesPlot = new \LinePlot($dataValues); + $seriesPlot = new LinePlot($dataValues); if ($combination) { $seriesPlot->SetBarCenter(); } @@ -330,12 +344,12 @@ private function renderPlotLine($groupID, $filled = false, $combination = false, if ($grouping == 'standard') { $groupPlot = $seriesPlots; } else { - $groupPlot = new \AccLinePlot($seriesPlots); + $groupPlot = new AccLinePlot($seriesPlots); } $this->graph->Add($groupPlot); } - private function renderPlotBar($groupID, $dimensions = '2d') + private function renderPlotBar($groupID, $dimensions = '2d'): void { $rotation = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection(); // Rotate for bar rather than column chart @@ -385,7 +399,7 @@ private function renderPlotBar($groupID, $dimensions = '2d') if ($rotation == 'bar') { $dataValues = array_reverse($dataValues); } - $seriesPlot = new \BarPlot($dataValues); + $seriesPlot = new BarPlot($dataValues); $seriesPlot->SetColor('black'); $seriesPlot->SetFillColor(self::$colourSet[self::$plotColour++]); if ($dimensions == '3d') { @@ -406,11 +420,11 @@ private function renderPlotBar($groupID, $dimensions = '2d') } if ($grouping == 'clustered') { - $groupPlot = new \GroupBarPlot($seriesPlots); + $groupPlot = new GroupBarPlot($seriesPlots); } elseif ($grouping == 'standard') { - $groupPlot = new \GroupBarPlot($seriesPlots); + $groupPlot = new GroupBarPlot($seriesPlots); } else { - $groupPlot = new \AccBarPlot($seriesPlots); + $groupPlot = new AccBarPlot($seriesPlots); if ($dimensions == '3d') { $groupPlot->SetShadow(); } @@ -419,7 +433,7 @@ private function renderPlotBar($groupID, $dimensions = '2d') $this->graph->Add($groupPlot); } - private function renderPlotScatter($groupID, $bubble) + private function renderPlotScatter($groupID, $bubble): void { $grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); $scatterStyle = $bubbleSize = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); @@ -436,14 +450,14 @@ private function renderPlotScatter($groupID, $bubble) $dataValuesY[$k] = $k; } - $seriesPlot = new \ScatterPlot($dataValuesX, $dataValuesY); + $seriesPlot = new ScatterPlot($dataValuesX, $dataValuesY); if ($scatterStyle == 'lineMarker') { $seriesPlot->SetLinkPoints(); $seriesPlot->link->SetColor(self::$colourSet[self::$plotColour]); } elseif ($scatterStyle == 'smoothMarker') { - $spline = new \Spline($dataValuesY, $dataValuesX); + $spline = new Spline($dataValuesY, $dataValuesX); [$splineDataY, $splineDataX] = $spline->Get(count($dataValuesX) * self::$width / 20); - $lplot = new \LinePlot($splineDataX, $splineDataY); + $lplot = new LinePlot($splineDataX, $splineDataY); $lplot->SetColor(self::$colourSet[self::$plotColour]); $this->graph->Add($lplot); @@ -464,7 +478,7 @@ private function renderPlotScatter($groupID, $bubble) } } - private function renderPlotRadar($groupID) + private function renderPlotRadar($groupID): void { $radarStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); @@ -488,7 +502,7 @@ private function renderPlotRadar($groupID) $this->graph->SetTitles(array_reverse($dataValues)); - $seriesPlot = new \RadarPlot(array_reverse($dataValuesX)); + $seriesPlot = new RadarPlot(array_reverse($dataValuesX)); $dataLabel = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue(); $seriesPlot->SetColor(self::$colourSet[self::$plotColour++]); @@ -502,7 +516,7 @@ private function renderPlotRadar($groupID) } } - private function renderPlotContour($groupID) + private function renderPlotContour($groupID): void { $contourStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); @@ -517,12 +531,12 @@ private function renderPlotContour($groupID) $dataValues[$i] = $dataValuesX; } - $seriesPlot = new \ContourPlot($dataValues); + $seriesPlot = new ContourPlot($dataValues); $this->graph->Add($seriesPlot); } - private function renderPlotStock($groupID) + private function renderPlotStock($groupID): void { $seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); $plotOrder = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder(); @@ -556,13 +570,13 @@ private function renderPlotStock($groupID) $this->graph->xaxis->SetTickLabels($datasetLabels); } - $seriesPlot = new \StockPlot($dataValuesPlot); + $seriesPlot = new StockPlot($dataValuesPlot); $seriesPlot->SetWidth(20); $this->graph->Add($seriesPlot); } - private function renderAreaChart($groupCount, $dimensions = '2d') + private function renderAreaChart($groupCount, $dimensions = '2d'): void { $this->renderCartesianPlotArea(); @@ -571,7 +585,7 @@ private function renderAreaChart($groupCount, $dimensions = '2d') } } - private function renderLineChart($groupCount, $dimensions = '2d') + private function renderLineChart($groupCount, $dimensions = '2d'): void { $this->renderCartesianPlotArea(); @@ -580,7 +594,7 @@ private function renderLineChart($groupCount, $dimensions = '2d') } } - private function renderBarChart($groupCount, $dimensions = '2d') + private function renderBarChart($groupCount, $dimensions = '2d'): void { $this->renderCartesianPlotArea(); @@ -589,7 +603,7 @@ private function renderBarChart($groupCount, $dimensions = '2d') } } - private function renderScatterChart($groupCount) + private function renderScatterChart($groupCount): void { $this->renderCartesianPlotArea('linlin'); @@ -598,7 +612,7 @@ private function renderScatterChart($groupCount) } } - private function renderBubbleChart($groupCount) + private function renderBubbleChart($groupCount): void { $this->renderCartesianPlotArea('linlin'); @@ -607,7 +621,7 @@ private function renderBubbleChart($groupCount) } } - private function renderPieChart($groupCount, $dimensions = '2d', $doughnut = false, $multiplePlots = false) + private function renderPieChart($groupCount, $dimensions = '2d', $doughnut = false, $multiplePlots = false): void { $this->renderPiePlotArea(); @@ -643,12 +657,12 @@ private function renderPieChart($groupCount, $dimensions = '2d', $doughnut = fal } if ($dimensions == '3d') { - $seriesPlot = new \PiePlot3D($dataValues); + $seriesPlot = new PiePlot3D($dataValues); } else { if ($doughnut) { - $seriesPlot = new \PiePlotC($dataValues); + $seriesPlot = new PiePlotC($dataValues); } else { - $seriesPlot = new \PiePlot($dataValues); + $seriesPlot = new PiePlot($dataValues); } } @@ -679,7 +693,7 @@ private function renderPieChart($groupCount, $dimensions = '2d', $doughnut = fal } } - private function renderRadarChart($groupCount) + private function renderRadarChart($groupCount): void { $this->renderRadarPlotArea(); @@ -688,7 +702,7 @@ private function renderRadarChart($groupCount) } } - private function renderStockChart($groupCount) + private function renderStockChart($groupCount): void { $this->renderCartesianPlotArea('intint'); @@ -697,7 +711,7 @@ private function renderStockChart($groupCount) } } - private function renderContourChart($groupCount, $dimensions) + private function renderContourChart($groupCount, $dimensions): void { $this->renderCartesianPlotArea('intint'); diff --git a/src/PhpSpreadsheet/Chart/Renderer/Polyfill.php b/src/PhpSpreadsheet/Chart/Renderer/Polyfill.php index 7fa383944c..5e233abdbb 100644 --- a/src/PhpSpreadsheet/Chart/Renderer/Polyfill.php +++ b/src/PhpSpreadsheet/Chart/Renderer/Polyfill.php @@ -2,7 +2,7 @@ // This is a dirty workaround to output JpGraph charts even when antialiasing is not available if (!function_exists('imageantialias')) { - function imageantialias(...$args) + function imageantialias(...$args): void { // Do nothing } diff --git a/src/PhpSpreadsheet/Chart/Title.php b/src/PhpSpreadsheet/Chart/Title.php index 650bcdc152..af9fa088bc 100644 --- a/src/PhpSpreadsheet/Chart/Title.php +++ b/src/PhpSpreadsheet/Chart/Title.php @@ -22,9 +22,8 @@ class Title * Create a new Title. * * @param null|mixed $caption - * @param null|Layout $layout */ - public function __construct($caption = null, Layout $layout = null) + public function __construct($caption = null, ?Layout $layout = null) { $this->caption = $caption; $this->layout = $layout; diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php index b9017e0e14..48f34f41d2 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -2,6 +2,7 @@ namespace PhpOffice\PhpSpreadsheet\Collection; +use Generator; use PhpOffice\PhpSpreadsheet\Cell\Cell; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; @@ -61,7 +62,6 @@ class Cells * Initialise this new cell collection. * * @param Worksheet $parent The worksheet for this cell collection - * @param CacheInterface $cache */ public function __construct(Worksheet $parent, CacheInterface $cache) { @@ -117,7 +117,7 @@ public function update(Cell $cell) * * @param string $pCoord Coordinate of the cell to delete */ - public function delete($pCoord) + public function delete($pCoord): void { if ($pCoord === $this->currentCoordinate && $this->currentCell !== null) { $this->currentCell->detach(); @@ -346,7 +346,7 @@ public function cloneCellCollection(Worksheet $parent) * * @param string $row Row number to remove */ - public function removeRow($row) + public function removeRow($row): void { foreach ($this->getCoordinates() as $coord) { $c = ''; @@ -364,7 +364,7 @@ public function removeRow($row) * * @param string $column Column ID to remove */ - public function removeColumn($column) + public function removeColumn($column): void { foreach ($this->getCoordinates() as $coord) { $c = ''; @@ -381,7 +381,7 @@ public function removeColumn($column) * Store cell data in cache for the current cell object if it's "dirty", * and the 'nullify' the current cell object. */ - private function storeCurrentCell() + private function storeCurrentCell(): void { if ($this->currentCellIsDirty && !empty($this->currentCoordinate)) { $this->currentCell->detach(); @@ -459,7 +459,7 @@ public function get($pCoord) /** * Clear the cell collection and disconnect from our parent. */ - public function unsetWorksheetCells() + public function unsetWorksheetCells(): void { if ($this->currentCell !== null) { $this->currentCell->detach(); @@ -487,7 +487,7 @@ public function __destruct() /** * Returns all known cache keys. * - * @return \Generator|string[] + * @return Generator|string[] */ private function getAllCacheKeys() { diff --git a/src/PhpSpreadsheet/Comment.php b/src/PhpSpreadsheet/Comment.php index 8041ddaf3e..31f7664053 100644 --- a/src/PhpSpreadsheet/Comment.php +++ b/src/PhpSpreadsheet/Comment.php @@ -118,8 +118,6 @@ public function getText() /** * Set Rich text comment. * - * @param RichText $pValue - * * @return $this */ public function setText(RichText $pValue) diff --git a/src/PhpSpreadsheet/Document/Properties.php b/src/PhpSpreadsheet/Document/Properties.php index 58fd2ef60c..cbaae2db83 100644 --- a/src/PhpSpreadsheet/Document/Properties.php +++ b/src/PhpSpreadsheet/Document/Properties.php @@ -458,10 +458,10 @@ public function getCustomPropertyType($propertyName) public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null) { if (($propertyType === null) || (!in_array($propertyType, [self::PROPERTY_TYPE_INTEGER, - self::PROPERTY_TYPE_FLOAT, - self::PROPERTY_TYPE_STRING, - self::PROPERTY_TYPE_DATE, - self::PROPERTY_TYPE_BOOLEAN, ]))) { + self::PROPERTY_TYPE_FLOAT, + self::PROPERTY_TYPE_STRING, + self::PROPERTY_TYPE_DATE, + self::PROPERTY_TYPE_BOOLEAN, ]))) { if ($propertyValue === null) { $propertyType = self::PROPERTY_TYPE_STRING; } elseif (is_float($propertyValue)) { diff --git a/src/PhpSpreadsheet/DocumentGenerator.php b/src/PhpSpreadsheet/DocumentGenerator.php index 8baba6e53a..5e06af97f4 100644 --- a/src/PhpSpreadsheet/DocumentGenerator.php +++ b/src/PhpSpreadsheet/DocumentGenerator.php @@ -11,8 +11,6 @@ class DocumentGenerator { /** * @param array[] $phpSpreadsheetFunctions - * - * @return string */ public static function generateFunctionListByCategory(array $phpSpreadsheetFunctions): string { @@ -40,7 +38,7 @@ private static function getCategories(): array return (new ReflectionClass(Category::class))->getConstants(); } - private static function tableRow(array $lengths, array $values = null): string + private static function tableRow(array $lengths, ?array $values = null): string { $result = ''; foreach (array_map(null, $lengths, $values ?? []) as $i => [$length, $value]) { @@ -73,8 +71,6 @@ private static function getPhpSpreadsheetFunctionText($functionCall): string /** * @param array[] $phpSpreadsheetFunctions - * - * @return string */ public static function generateFunctionListByName(array $phpSpreadsheetFunctions): string { diff --git a/src/PhpSpreadsheet/HashTable.php b/src/PhpSpreadsheet/HashTable.php index 4d1e7b4d88..90ea806bd8 100644 --- a/src/PhpSpreadsheet/HashTable.php +++ b/src/PhpSpreadsheet/HashTable.php @@ -36,7 +36,7 @@ public function __construct($pSource = null) * * @param IComparable[] $pSource Source array to create HashTable from */ - public function addFromSource(array $pSource = null) + public function addFromSource(?array $pSource = null): void { // Check if an array was passed if ($pSource == null) { @@ -53,7 +53,7 @@ public function addFromSource(array $pSource = null) * * @param IComparable $pSource Item to add */ - public function add(IComparable $pSource) + public function add(IComparable $pSource): void { $hash = $pSource->getHashCode(); if (!isset($this->items[$hash])) { @@ -67,7 +67,7 @@ public function add(IComparable $pSource) * * @param IComparable $pSource Item to remove */ - public function remove(IComparable $pSource) + public function remove(IComparable $pSource): void { $hash = $pSource->getHashCode(); if (isset($this->items[$hash])) { @@ -90,7 +90,7 @@ public function remove(IComparable $pSource) /** * Clear HashTable. */ - public function clear() + public function clear(): void { $this->items = []; $this->keyMap = []; diff --git a/src/PhpSpreadsheet/Helper/Html.php b/src/PhpSpreadsheet/Helper/Html.php index eaf73028fa..252e14a51d 100644 --- a/src/PhpSpreadsheet/Helper/Html.php +++ b/src/PhpSpreadsheet/Helper/Html.php @@ -593,7 +593,7 @@ class Html */ protected $richTextObject; - protected function initialise() + protected function initialise(): void { $this->face = $this->size = $this->color = null; $this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false; @@ -632,7 +632,7 @@ public function toRichTextObject($html) return $this->richTextObject; } - protected function cleanWhitespace() + protected function cleanWhitespace(): void { foreach ($this->richTextObject->getRichTextElements() as $key => $element) { $text = $element->getText(); @@ -646,7 +646,7 @@ protected function cleanWhitespace() } } - protected function buildTextRun() + protected function buildTextRun(): void { $text = $this->stringData; if (trim($text) === '') { @@ -691,7 +691,7 @@ protected function rgbToColour($rgb) $value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT); } - return implode($values[0]); + return implode('', $values[0]); } protected function colourNameLookup($rgb) @@ -699,7 +699,7 @@ protected function colourNameLookup($rgb) return self::$colourMap[$rgb]; } - protected function startFontTag($tag) + protected function startFontTag($tag): void { foreach ($tag->attributes as $attribute) { $attributeName = strtolower($attribute->name); @@ -719,77 +719,77 @@ protected function startFontTag($tag) } } - protected function endFontTag() + protected function endFontTag(): void { $this->face = $this->size = $this->color = null; } - protected function startBoldTag() + protected function startBoldTag(): void { $this->bold = true; } - protected function endBoldTag() + protected function endBoldTag(): void { $this->bold = false; } - protected function startItalicTag() + protected function startItalicTag(): void { $this->italic = true; } - protected function endItalicTag() + protected function endItalicTag(): void { $this->italic = false; } - protected function startUnderlineTag() + protected function startUnderlineTag(): void { $this->underline = true; } - protected function endUnderlineTag() + protected function endUnderlineTag(): void { $this->underline = false; } - protected function startSubscriptTag() + protected function startSubscriptTag(): void { $this->subscript = true; } - protected function endSubscriptTag() + protected function endSubscriptTag(): void { $this->subscript = false; } - protected function startSuperscriptTag() + protected function startSuperscriptTag(): void { $this->superscript = true; } - protected function endSuperscriptTag() + protected function endSuperscriptTag(): void { $this->superscript = false; } - protected function startStrikethruTag() + protected function startStrikethruTag(): void { $this->strikethrough = true; } - protected function endStrikethruTag() + protected function endStrikethruTag(): void { $this->strikethrough = false; } - protected function breakTag() + protected function breakTag(): void { $this->stringData .= "\n"; } - protected function parseTextNode(DOMText $textNode) + protected function parseTextNode(DOMText $textNode): void { $domText = preg_replace( '/\s+/u', @@ -801,11 +801,9 @@ protected function parseTextNode(DOMText $textNode) } /** - * @param DOMElement $element * @param string $callbackTag - * @param array $callbacks */ - protected function handleCallback(DOMElement $element, $callbackTag, array $callbacks) + protected function handleCallback(DOMElement $element, $callbackTag, array $callbacks): void { if (isset($callbacks[$callbackTag])) { $elementHandler = $callbacks[$callbackTag]; @@ -815,7 +813,7 @@ protected function handleCallback(DOMElement $element, $callbackTag, array $call } } - protected function parseElementNode(DOMElement $element) + protected function parseElementNode(DOMElement $element): void { $callbackTag = strtolower($element->nodeName); $this->stack[] = $callbackTag; @@ -828,7 +826,7 @@ protected function parseElementNode(DOMElement $element) $this->handleCallback($element, $callbackTag, $this->endTagCallbacks); } - protected function parseElements(DOMNode $element) + protected function parseElements(DOMNode $element): void { foreach ($element->childNodes as $child) { if ($child instanceof DOMText) { diff --git a/src/PhpSpreadsheet/Helper/Sample.php b/src/PhpSpreadsheet/Helper/Sample.php index e199c807c0..a91b195e24 100644 --- a/src/PhpSpreadsheet/Helper/Sample.php +++ b/src/PhpSpreadsheet/Helper/Sample.php @@ -11,6 +11,7 @@ use RecursiveRegexIterator; use ReflectionClass; use RegexIterator; +use RuntimeException; /** * Helper class to be used in sample code. @@ -106,11 +107,10 @@ public function getSamples() /** * Write documents. * - * @param Spreadsheet $spreadsheet * @param string $filename * @param string[] $writers */ - public function write(Spreadsheet $spreadsheet, $filename, array $writers = ['Xlsx', 'Xls']) + public function write(Spreadsheet $spreadsheet, $filename, array $writers = ['Xlsx', 'Xls']): void { // Set active sheet index to the first sheet, so Excel opens this as the first sheet $spreadsheet->setActiveSheetIndex(0); @@ -142,7 +142,7 @@ private function getTemporaryFolder() $tempFolder = sys_get_temp_dir() . '/phpspreadsheet'; if (!is_dir($tempFolder)) { if (!mkdir($tempFolder) && !is_dir($tempFolder)) { - throw new \RuntimeException(sprintf('Directory "%s" was not created', $tempFolder)); + throw new RuntimeException(sprintf('Directory "%s" was not created', $tempFolder)); } } @@ -179,7 +179,7 @@ public function getTemporaryFilename($extension = 'xlsx') return $temporaryFilename . '.' . $extension; } - public function log($message) + public function log($message): void { $eol = $this->isCli() ? PHP_EOL : '
'; echo date('H:i:s ') . $message . $eol; @@ -188,7 +188,7 @@ public function log($message) /** * Log ending notes. */ - public function logEndingNotes() + public function logEndingNotes(): void { // Do not show execution time for index $this->log('Peak memory usage: ' . (memory_get_peak_usage(true) / 1024 / 1024) . 'MB'); @@ -197,11 +197,10 @@ public function logEndingNotes() /** * Log a line about the write operation. * - * @param IWriter $writer * @param string $path * @param float $callStartTime */ - public function logWrite(IWriter $writer, $path, $callStartTime) + public function logWrite(IWriter $writer, $path, $callStartTime): void { $callEndTime = microtime(true); $callTime = $callEndTime - $callStartTime; @@ -219,7 +218,7 @@ public function logWrite(IWriter $writer, $path, $callStartTime) * @param string $path * @param float $callStartTime */ - public function logRead($format, $path, $callStartTime) + public function logRead($format, $path, $callStartTime): void { $callEndTime = microtime(true); $callTime = $callEndTime - $callStartTime; diff --git a/src/PhpSpreadsheet/IOFactory.php b/src/PhpSpreadsheet/IOFactory.php index 38c0f221f4..ab04e9698e 100644 --- a/src/PhpSpreadsheet/IOFactory.php +++ b/src/PhpSpreadsheet/IOFactory.php @@ -37,7 +37,6 @@ abstract class IOFactory /** * Create Writer\IWriter. * - * @param Spreadsheet $spreadsheet * @param string $writerType Example: Xlsx * * @return Writer\IWriter @@ -192,7 +191,7 @@ private static function getReaderTypeFromExtension($filename) * @param string $writerType * @param string $writerClass */ - public static function registerWriter($writerType, $writerClass) + public static function registerWriter($writerType, $writerClass): void { if (!is_a($writerClass, Writer\IWriter::class, true)) { throw new Writer\Exception('Registered writers must implement ' . Writer\IWriter::class); @@ -207,7 +206,7 @@ public static function registerWriter($writerType, $writerClass) * @param string $readerType * @param string $readerClass */ - public static function registerReader($readerType, $readerClass) + public static function registerReader($readerType, $readerClass): void { if (!is_a($readerClass, Reader\IReader::class, true)) { throw new Reader\Exception('Registered readers must implement ' . Reader\IReader::class); diff --git a/src/PhpSpreadsheet/NamedRange.php b/src/PhpSpreadsheet/NamedRange.php index 576f17d738..94fe819020 100644 --- a/src/PhpSpreadsheet/NamedRange.php +++ b/src/PhpSpreadsheet/NamedRange.php @@ -45,7 +45,6 @@ class NamedRange * Create a new NamedRange. * * @param string $pName - * @param Worksheet $pWorksheet * @param string $pRange * @param bool $pLocalOnly * @param null|Worksheet $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope. @@ -123,7 +122,7 @@ public function getWorksheet() * * @return $this */ - public function setWorksheet(Worksheet $value = null) + public function setWorksheet(?Worksheet $value = null) { if ($value !== null) { $this->worksheet = $value; @@ -196,11 +195,9 @@ public function getScope() /** * Set scope. * - * @param null|Worksheet $value - * * @return $this */ - public function setScope(Worksheet $value = null) + public function setScope(?Worksheet $value = null) { $this->scope = $value; $this->localOnly = $value != null; diff --git a/src/PhpSpreadsheet/Reader/BaseReader.php b/src/PhpSpreadsheet/Reader/BaseReader.php index 35466e7325..77a6421b9c 100644 --- a/src/PhpSpreadsheet/Reader/BaseReader.php +++ b/src/PhpSpreadsheet/Reader/BaseReader.php @@ -145,12 +145,12 @@ public function getSecurityScanner() * * @param string $pFilename */ - protected function openFile($pFilename) + protected function openFile($pFilename): void { File::assertFile($pFilename); // Open file - $this->fileHandle = fopen($pFilename, 'r'); + $this->fileHandle = fopen($pFilename, 'rb'); if ($this->fileHandle === false) { throw new Exception('Could not open file ' . $pFilename . ' for reading.'); } diff --git a/src/PhpSpreadsheet/Reader/Csv.php b/src/PhpSpreadsheet/Reader/Csv.php index 2e485109ce..db2b50b928 100644 --- a/src/PhpSpreadsheet/Reader/Csv.php +++ b/src/PhpSpreadsheet/Reader/Csv.php @@ -2,6 +2,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader; +use InvalidArgumentException; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Spreadsheet; @@ -85,7 +86,7 @@ public function getInputEncoding() /** * Move filepointer past any BOM marker. */ - protected function skipBOM() + protected function skipBOM(): void { rewind($this->fileHandle); @@ -101,7 +102,7 @@ protected function skipBOM() /** * Identify any separator that is explicitly set in the file. */ - protected function checkSeparator() + protected function checkSeparator(): void { $line = fgets($this->fileHandle); if ($line === false) { @@ -120,7 +121,7 @@ protected function checkSeparator() /** * Infer the separator if it isn't explicitly set in the file or specified by the user. */ - protected function inferSeparator() + protected function inferSeparator(): void { if ($this->delimiter !== null) { return; @@ -178,7 +179,7 @@ protected function inferSeparator() $meanSquareDeviations[$delimiter] = array_reduce( $series, function ($sum, $value) use ($median) { - return $sum + pow($value - $median, 2); + return $sum + ($value - $median) ** 2; } ) / count($series); } @@ -292,7 +293,7 @@ public function load($pFilename) return $this->loadIntoExisting($pFilename, $spreadsheet); } - private function openFileOrMemory($pFilename) + private function openFileOrMemory($pFilename): void { // Open file $fhandle = $this->canRead($pFilename); @@ -303,7 +304,7 @@ private function openFileOrMemory($pFilename) if ($this->inputEncoding !== 'UTF-8') { fclose($this->fileHandle); $entireFile = file_get_contents($pFilename); - $this->fileHandle = fopen('php://memory', 'r+'); + $this->fileHandle = fopen('php://memory', 'r+b'); $data = StringHelper::convertEncoding($entireFile, 'UTF-8', $this->inputEncoding); fwrite($this->fileHandle, $data); rewind($this->fileHandle); @@ -314,7 +315,6 @@ private function openFileOrMemory($pFilename) * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * * @param string $pFilename - * @param Spreadsheet $spreadsheet * * @return Spreadsheet */ @@ -508,7 +508,7 @@ public function canRead($pFilename) // Check if file exists try { $this->openFile($pFilename); - } catch (\InvalidArgumentException $e) { + } catch (InvalidArgumentException $e) { return false; } diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index 83ff293cde..f97680291f 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -58,7 +58,7 @@ public function canRead($pFilename) } // Read signature data (first 3 bytes) - $fh = fopen($pFilename, 'r'); + $fh = fopen($pFilename, 'rb'); $data = fread($fh, 2); fclose($fh); @@ -182,7 +182,6 @@ public function load($pFilename) * Loads from file into Spreadsheet instance. * * @param string $pFilename - * @param Spreadsheet $spreadsheet * * @return Spreadsheet */ @@ -473,7 +472,7 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) $endColumn = ($styleAttributes['endCol'] > $maxCol) ? $maxCol : (int) $styleAttributes['endCol']; $endColumn = Coordinate::stringFromColumnIndex($endColumn + 1); $endRow = ($styleAttributes['endRow'] > $maxRow) ? $maxRow : $styleAttributes['endRow']; - $endRow += 1; + ++$endRow; $cellRange = $startColumn . $startRow . ':' . $endColumn . $endRow; $styleAttributes = $styleRegion->Style->attributes(); diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 86263a2040..5e12a2fb8c 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -270,7 +270,7 @@ protected function releaseTableStartColumn() return array_pop($this->nestedColumn); } - protected function flushCell(Worksheet $sheet, $column, $row, &$cellContent) + protected function flushCell(Worksheet $sheet, $column, $row, &$cellContent): void { if (is_string($cellContent)) { // Simple String content @@ -290,13 +290,11 @@ protected function flushCell(Worksheet $sheet, $column, $row, &$cellContent) } /** - * @param DOMNode $element - * @param Worksheet $sheet * @param int $row * @param string $column * @param string $cellContent */ - protected function processDomElement(DOMNode $element, Worksheet $sheet, &$row, &$column, &$cellContent) + protected function processDomElement(DOMNode $element, Worksheet $sheet, &$row, &$column, &$cellContent): void { foreach ($element->childNodes as $child) { if ($child instanceof DOMText) { @@ -577,7 +575,6 @@ protected function processDomElement(DOMNode $element, Worksheet $sheet, &$row, * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * * @param string $pFilename - * @param Spreadsheet $spreadsheet * * @return Spreadsheet */ @@ -603,9 +600,6 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) * Spreadsheet from content. * * @param string $content - * @param null|Spreadsheet $spreadsheet - * - * @return Spreadsheet */ public function loadFromString($content, ?Spreadsheet $spreadsheet = null): Spreadsheet { @@ -622,11 +616,6 @@ public function loadFromString($content, ?Spreadsheet $spreadsheet = null): Spre /** * Loads PhpSpreadsheet from DOMDocument into PhpSpreadsheet instance. - * - * @param DOMDocument $document - * @param Spreadsheet $spreadsheet - * - * @return Spreadsheet */ private function loadDocument(DOMDocument $document, Spreadsheet $spreadsheet): Spreadsheet { @@ -687,7 +676,7 @@ public function setSheetIndex($pValue) * @param string $column * @param array $attributeArray */ - private function applyInlineStyle(&$sheet, $row, $column, $attributeArray) + private function applyInlineStyle(&$sheet, $row, $column, $attributeArray): void { if (!isset($attributeArray['style'])) { return; @@ -852,12 +841,10 @@ public function getStyleColor($value) } /** - * @param Worksheet $sheet * @param string $column * @param int $row - * @param array $attributes */ - private function insertImage(Worksheet $sheet, $column, $row, array $attributes) + private function insertImage(Worksheet $sheet, $column, $row, array $attributes): void { if (!isset($attributes['src'])) { return; @@ -941,11 +928,10 @@ public function getBorderStyle($style) } /** - * @param Style $cellStyle * @param string $styleValue * @param string $type */ - private function setBorderStyle(Style $cellStyle, $styleValue, $type) + private function setBorderStyle(Style $cellStyle, $styleValue, $type): void { [, $borderStyle, $color] = explode(' ', $styleValue); diff --git a/src/PhpSpreadsheet/Reader/IReader.php b/src/PhpSpreadsheet/Reader/IReader.php index 3f5a7e49e9..a8bd360659 100644 --- a/src/PhpSpreadsheet/Reader/IReader.php +++ b/src/PhpSpreadsheet/Reader/IReader.php @@ -118,8 +118,6 @@ public function getReadFilter(); /** * Set read filter. * - * @param IReadFilter $pValue - * * @return IReader */ public function setReadFilter(IReadFilter $pValue); diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index 41fd34a8d9..d638d1fb23 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -4,6 +4,10 @@ use DateTime; use DateTimeZone; +use DOMAttr; +use DOMDocument; +use DOMElement; +use DOMNode; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Cell\DataType; @@ -242,7 +246,6 @@ public function load($pFilename) * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * * @param string $pFilename - * @param Spreadsheet $spreadsheet * * @return Spreadsheet */ @@ -251,7 +254,7 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) File::assertFile($pFilename); $timezoneObj = new DateTimeZone('Europe/London'); - $GMT = new \DateTimeZone('UTC'); + $GMT = new DateTimeZone('UTC'); $zip = new ZipArchive(); if (!$zip->open($pFilename)) { @@ -275,7 +278,7 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) // Content - $dom = new \DOMDocument('1.01', 'UTF-8'); + $dom = new DOMDocument('1.01', 'UTF-8'); $dom->loadXML( $this->securityScanner->scan($zip->getFromName('content.xml')), Settings::getLibXmlLoaderOptions() @@ -291,12 +294,12 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) ->getElementsByTagNameNS($officeNs, 'spreadsheet'); foreach ($spreadsheets as $workbookData) { - /** @var \DOMElement $workbookData */ + /** @var DOMElement $workbookData */ $tables = $workbookData->getElementsByTagNameNS($tableNs, 'table'); $worksheetID = 0; foreach ($tables as $worksheetDataSet) { - /** @var \DOMElement $worksheetDataSet */ + /** @var DOMElement $worksheetDataSet */ $worksheetName = $worksheetDataSet->getAttributeNS($tableNs, 'name'); // Check loadSheetsOnly @@ -322,7 +325,7 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) // Go through every child of table element $rowID = 1; foreach ($worksheetDataSet->childNodes as $childNode) { - /** @var \DOMElement $childNode */ + /** @var DOMElement $childNode */ // Filter elements which are not under the "table" ns if ($childNode->namespaceURI != $tableNs) { @@ -395,11 +398,11 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) // Content - /** @var \DOMElement[] $paragraphs */ + /** @var DOMElement[] $paragraphs */ $paragraphs = []; foreach ($cellData->childNodes as $item) { - /** @var \DOMElement $item */ + /** @var DOMElement $item */ // Filter text:p elements if ($item->nodeName == 'text:p') { @@ -649,22 +652,20 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) /** * Recursively scan element. * - * @param \DOMNode $element - * * @return string */ - protected function scanElementForText(\DOMNode $element) + protected function scanElementForText(DOMNode $element) { $str = ''; foreach ($element->childNodes as $child) { - /** @var \DOMNode $child */ + /** @var DOMNode $child */ if ($child->nodeType == XML_TEXT_NODE) { $str .= $child->nodeValue; } elseif ($child->nodeType == XML_ELEMENT_NODE && $child->nodeName == 'text:s') { // It's a space // Multiple spaces? - /** @var \DOMAttr $cAttr */ + /** @var DOMAttr $cAttr */ $cAttr = $child->attributes->getNamedItem('c'); if ($cAttr) { $multiplier = (int) $cAttr->nodeValue; diff --git a/src/PhpSpreadsheet/Reader/Ods/Properties.php b/src/PhpSpreadsheet/Reader/Ods/Properties.php index c5c7caf843..c0b309a966 100644 --- a/src/PhpSpreadsheet/Reader/Ods/Properties.php +++ b/src/PhpSpreadsheet/Reader/Ods/Properties.php @@ -4,6 +4,7 @@ use PhpOffice\PhpSpreadsheet\Document\Properties as DocumentProperties; use PhpOffice\PhpSpreadsheet\Spreadsheet; +use SimpleXMLElement; class Properties { @@ -14,7 +15,7 @@ public function __construct(Spreadsheet $spreadsheet) $this->spreadsheet = $spreadsheet; } - public function load(\SimpleXMLElement $xml, $namespacesMeta) + public function load(SimpleXMLElement $xml, $namespacesMeta): void { $docProps = $this->spreadsheet->getProperties(); $officeProperty = $xml->children($namespacesMeta['office']); @@ -35,7 +36,7 @@ public function load(\SimpleXMLElement $xml, $namespacesMeta) } } - private function setCoreProperties(DocumentProperties $docProps, \SimpleXMLElement $officePropertyDC) + private function setCoreProperties(DocumentProperties $docProps, SimpleXMLElement $officePropertyDC): void { foreach ($officePropertyDC as $propertyName => $propertyValue) { $propertyValue = (string) $propertyValue; @@ -73,10 +74,10 @@ private function setCoreProperties(DocumentProperties $docProps, \SimpleXMLEleme private function setMetaProperties( $namespacesMeta, - \SimpleXMLElement $propertyValue, + SimpleXMLElement $propertyValue, $propertyName, DocumentProperties $docProps - ) { + ): void { $propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']); $propertyValue = (string) $propertyValue; switch ($propertyName) { @@ -100,7 +101,7 @@ private function setMetaProperties( } } - private function setUserDefinedProperty($propertyValueAttributes, $propertyValue, DocumentProperties $docProps) + private function setUserDefinedProperty($propertyValueAttributes, $propertyValue, DocumentProperties $docProps): void { $propertyValueName = ''; $propertyValueType = DocumentProperties::PROPERTY_TYPE_STRING; diff --git a/src/PhpSpreadsheet/Reader/Security/XmlScanner.php b/src/PhpSpreadsheet/Reader/Security/XmlScanner.php index 33e21f9d1c..55bba632ff 100644 --- a/src/PhpSpreadsheet/Reader/Security/XmlScanner.php +++ b/src/PhpSpreadsheet/Reader/Security/XmlScanner.php @@ -61,7 +61,7 @@ public static function threadSafeLibxmlDisableEntityLoaderAvailability() return false; } - private function disableEntityLoaderCheck() + private function disableEntityLoaderCheck(): void { if (Settings::getLibXmlDisableEntityLoader()) { $libxmlDisableEntityLoaderValue = libxml_disable_entity_loader(true); @@ -72,7 +72,7 @@ private function disableEntityLoaderCheck() } } - public static function shutdown() + public static function shutdown(): void { if (self::$libxmlDisableEntityLoaderValue !== null) { libxml_disable_entity_loader(self::$libxmlDisableEntityLoaderValue); @@ -85,7 +85,7 @@ public function __destruct() self::shutdown(); } - public function setAdditionalCallback(callable $callback) + public function setAdditionalCallback(callable $callback): void { $this->callback = $callback; } diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index 278abd582a..f40eba7460 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -190,7 +190,6 @@ public function load($pFilename) * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * * @param string $pFilename - * @param Spreadsheet $spreadsheet * * @return Spreadsheet */ diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index ec5879a9ef..b206f8ac36 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -1248,10 +1248,10 @@ public function load($pFilename) [$firstColumn, $firstRow] = Coordinate::coordinateFromString($coordinateStrings[0]); [$lastColumn, $lastRow] = Coordinate::coordinateFromString($coordinateStrings[1]); - if ($firstColumn == 'A' and $lastColumn == 'IV') { + if ($firstColumn == 'A' && $lastColumn == 'IV') { // then we have repeating rows $docSheet->getPageSetup()->setRowsToRepeatAtTop([$firstRow, $lastRow]); - } elseif ($firstRow == 1 and $lastRow == 65536) { + } elseif ($firstRow == 1 && $lastRow == 65536) { // then we have repeating columns $docSheet->getPageSetup()->setColumnsToRepeatAtLeft([$firstColumn, $lastColumn]); } @@ -1348,7 +1348,7 @@ private function readRecordData($data, $pos, $len) * * @param string $pFilename */ - private function loadOLE($pFilename) + private function loadOLE($pFilename): void { // OLE reader $ole = new OLERead(); @@ -1365,7 +1365,7 @@ private function loadOLE($pFilename) /** * Read summary information. */ - private function readSummaryInformation() + private function readSummaryInformation(): void { if (!isset($this->summaryInformation)) { return; @@ -1512,7 +1512,7 @@ private function readSummaryInformation() /** * Read additional document summary information. */ - private function readDocumentSummaryInformation() + private function readDocumentSummaryInformation(): void { if (!isset($this->documentSummaryInformation)) { return; @@ -1650,7 +1650,7 @@ private function readDocumentSummaryInformation() /** * Reads a general type of BIFF record. Does nothing except for moving stream pointer forward to next record. */ - private function readDefault() + private function readDefault(): void { $length = self::getUInt2d($this->data, $this->pos + 2); @@ -1662,7 +1662,7 @@ private function readDefault() * The NOTE record specifies a comment associated with a particular cell. In Excel 95 (BIFF7) and earlier versions, * this record stores a note (cell note). This feature was significantly enhanced in Excel 97. */ - private function readNote() + private function readNote(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -1715,7 +1715,7 @@ private function readNote() /** * The TEXT Object record contains the text associated with a cell annotation. */ - private function readTextObject() + private function readTextObject(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -1762,7 +1762,7 @@ private function readTextObject() /** * Read BOF. */ - private function readBof() + private function readBof(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = substr($this->data, $this->pos + 4, $length); @@ -1813,7 +1813,7 @@ private function readBof() * are based on the source of Spreadsheet-ParseExcel: * https://metacpan.org/release/Spreadsheet-ParseExcel */ - private function readFilepass() + private function readFilepass(): void { $length = self::getUInt2d($this->data, $this->pos + 2); @@ -1963,7 +1963,7 @@ private function verifyPassword($password, $docid, $salt_data, $hashedsalt_data, * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readCodepage() + private function readCodepage(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -1989,7 +1989,7 @@ private function readCodepage() * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readDateMode() + private function readDateMode(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -2007,7 +2007,7 @@ private function readDateMode() /** * Read a FONT record. */ - private function readFont() + private function readFont(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -2115,7 +2115,7 @@ private function readFont() * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readFormat() + private function readFormat(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -2152,7 +2152,7 @@ private function readFormat() * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readXf() + private function readXf(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -2449,7 +2449,7 @@ private function readXf() } } - private function readXfExt() + private function readXfExt(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -2498,7 +2498,7 @@ private function readXfExt() if (isset($this->mapCellXfIndex[$ixfe])) { $fill = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFill(); $fill->getStartColor()->setRGB($rgb); - unset($fill->startcolorIndex); // normal color index does not apply, discard + $fill->startcolorIndex = null; // normal color index does not apply, discard } } @@ -2514,7 +2514,7 @@ private function readXfExt() if (isset($this->mapCellXfIndex[$ixfe])) { $fill = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFill(); $fill->getEndColor()->setRGB($rgb); - unset($fill->endcolorIndex); // normal color index does not apply, discard + $fill->endcolorIndex = null; // normal color index does not apply, discard } } @@ -2530,7 +2530,7 @@ private function readXfExt() if (isset($this->mapCellXfIndex[$ixfe])) { $top = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getTop(); $top->getColor()->setRGB($rgb); - unset($top->colorIndex); // normal color index does not apply, discard + $top->colorIndex = null; // normal color index does not apply, discard } } @@ -2546,7 +2546,7 @@ private function readXfExt() if (isset($this->mapCellXfIndex[$ixfe])) { $bottom = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getBottom(); $bottom->getColor()->setRGB($rgb); - unset($bottom->colorIndex); // normal color index does not apply, discard + $bottom->colorIndex = null; // normal color index does not apply, discard } } @@ -2562,7 +2562,7 @@ private function readXfExt() if (isset($this->mapCellXfIndex[$ixfe])) { $left = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getLeft(); $left->getColor()->setRGB($rgb); - unset($left->colorIndex); // normal color index does not apply, discard + $left->colorIndex = null; // normal color index does not apply, discard } } @@ -2578,7 +2578,7 @@ private function readXfExt() if (isset($this->mapCellXfIndex[$ixfe])) { $right = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getRight(); $right->getColor()->setRGB($rgb); - unset($right->colorIndex); // normal color index does not apply, discard + $right->colorIndex = null; // normal color index does not apply, discard } } @@ -2594,7 +2594,7 @@ private function readXfExt() if (isset($this->mapCellXfIndex[$ixfe])) { $diagonal = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getDiagonal(); $diagonal->getColor()->setRGB($rgb); - unset($diagonal->colorIndex); // normal color index does not apply, discard + $diagonal->colorIndex = null; // normal color index does not apply, discard } } @@ -2610,7 +2610,7 @@ private function readXfExt() if (isset($this->mapCellXfIndex[$ixfe])) { $font = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFont(); $font->getColor()->setRGB($rgb); - unset($font->colorIndex); // normal color index does not apply, discard + $font->colorIndex = null; // normal color index does not apply, discard } } @@ -2625,7 +2625,7 @@ private function readXfExt() /** * Read STYLE record. */ - private function readStyle() + private function readStyle(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -2662,7 +2662,7 @@ private function readStyle() /** * Read PALETTE record. */ - private function readPalette() + private function readPalette(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -2694,7 +2694,7 @@ private function readPalette() * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readSheet() + private function readSheet(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -2749,7 +2749,7 @@ private function readSheet() /** * Read EXTERNALBOOK record. */ - private function readExternalBook() + private function readExternalBook(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -2811,7 +2811,7 @@ private function readExternalBook() /** * Read EXTERNNAME record. */ - private function readExternName() + private function readExternName(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -2845,7 +2845,7 @@ private function readExternName() /** * Read EXTERNSHEET record. */ - private function readExternSheet() + private function readExternSheet(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -2881,7 +2881,7 @@ private function readExternSheet() * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readDefinedName() + private function readDefinedName(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -2935,7 +2935,7 @@ private function readDefinedName() /** * Read MSODRAWINGGROUP record. */ - private function readMsoDrawingGroup() + private function readMsoDrawingGroup(): void { $length = self::getUInt2d($this->data, $this->pos + 2); @@ -2957,7 +2957,7 @@ private function readMsoDrawingGroup() * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readSst() + private function readSst(): void { // offset within (spliced) record data $pos = 0; @@ -3138,7 +3138,7 @@ private function readSst() /** * Read PRINTGRIDLINES record. */ - private function readPrintGridlines() + private function readPrintGridlines(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3156,7 +3156,7 @@ private function readPrintGridlines() /** * Read DEFAULTROWHEIGHT record. */ - private function readDefaultRowHeight() + private function readDefaultRowHeight(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3173,7 +3173,7 @@ private function readDefaultRowHeight() /** * Read SHEETPR record. */ - private function readSheetPr() + private function readSheetPr(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3199,7 +3199,7 @@ private function readSheetPr() /** * Read HORIZONTALPAGEBREAKS record. */ - private function readHorizontalPageBreaks() + private function readHorizontalPageBreaks(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3226,7 +3226,7 @@ private function readHorizontalPageBreaks() /** * Read VERTICALPAGEBREAKS record. */ - private function readVerticalPageBreaks() + private function readVerticalPageBreaks(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3253,7 +3253,7 @@ private function readVerticalPageBreaks() /** * Read HEADER record. */ - private function readHeader() + private function readHeader(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3280,7 +3280,7 @@ private function readHeader() /** * Read FOOTER record. */ - private function readFooter() + private function readFooter(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3306,7 +3306,7 @@ private function readFooter() /** * Read HCENTER record. */ - private function readHcenter() + private function readHcenter(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3325,7 +3325,7 @@ private function readHcenter() /** * Read VCENTER record. */ - private function readVcenter() + private function readVcenter(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3344,7 +3344,7 @@ private function readVcenter() /** * Read LEFTMARGIN record. */ - private function readLeftMargin() + private function readLeftMargin(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3361,7 +3361,7 @@ private function readLeftMargin() /** * Read RIGHTMARGIN record. */ - private function readRightMargin() + private function readRightMargin(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3378,7 +3378,7 @@ private function readRightMargin() /** * Read TOPMARGIN record. */ - private function readTopMargin() + private function readTopMargin(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3395,7 +3395,7 @@ private function readTopMargin() /** * Read BOTTOMMARGIN record. */ - private function readBottomMargin() + private function readBottomMargin(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3412,7 +3412,7 @@ private function readBottomMargin() /** * Read PAGESETUP record. */ - private function readPageSetup() + private function readPageSetup(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3475,7 +3475,7 @@ private function readPageSetup() * PROTECT - Sheet protection (BIFF2 through BIFF8) * if this record is omitted, then it also means no sheet protection. */ - private function readProtect() + private function readProtect(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3497,7 +3497,7 @@ private function readProtect() /** * SCENPROTECT. */ - private function readScenProtect() + private function readScenProtect(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3520,7 +3520,7 @@ private function readScenProtect() /** * OBJECTPROTECT. */ - private function readObjectProtect() + private function readObjectProtect(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3543,7 +3543,7 @@ private function readObjectProtect() /** * PASSWORD - Sheet protection (hashed) password (BIFF2 through BIFF8). */ - private function readPassword() + private function readPassword(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3561,7 +3561,7 @@ private function readPassword() /** * Read DEFCOLWIDTH record. */ - private function readDefColWidth() + private function readDefColWidth(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3579,7 +3579,7 @@ private function readDefColWidth() /** * Read COLINFO record. */ - private function readColInfo() + private function readColInfo(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3637,7 +3637,7 @@ private function readColInfo() * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readRow() + private function readRow(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3706,7 +3706,7 @@ private function readRow() * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readRk() + private function readRk(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3750,7 +3750,7 @@ private function readRk() * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readLabelSst() + private function readLabelSst(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3834,7 +3834,7 @@ private function readLabelSst() * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readMulRk() + private function readMulRk(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3887,7 +3887,7 @@ private function readMulRk() * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readNumber() + private function readNumber(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -3928,7 +3928,7 @@ private function readNumber() * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readFormula() + private function readFormula(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4054,7 +4054,7 @@ private function readFormula() * which usually contains relative references. * These will be used to construct the formula in each shared formula part after the sheet is read. */ - private function readSharedFmla() + private function readSharedFmla(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4112,7 +4112,7 @@ private function readString() * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readBoolErr() + private function readBoolErr(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4171,7 +4171,7 @@ private function readBoolErr() * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readMulBlank() + private function readMulBlank(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4212,7 +4212,7 @@ private function readMulBlank() * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readLabel() + private function readLabel(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4256,7 +4256,7 @@ private function readLabel() /** * Read BLANK record. */ - private function readBlank() + private function readBlank(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4286,7 +4286,7 @@ private function readBlank() /** * Read MSODRAWING record. */ - private function readMsoDrawing() + private function readMsoDrawing(): void { $length = self::getUInt2d($this->data, $this->pos + 2); @@ -4300,7 +4300,7 @@ private function readMsoDrawing() /** * Read OBJ record. */ - private function readObj() + private function readObj(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4340,7 +4340,7 @@ private function readObj() /** * Read WINDOW2 record. */ - private function readWindow2() + private function readWindow2(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4411,7 +4411,7 @@ private function readWindow2() /** * Read PLV Record(Created by Excel2007 or upper). */ - private function readPageLayoutView() + private function readPageLayoutView(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4448,7 +4448,7 @@ private function readPageLayoutView() /** * Read SCL record. */ - private function readScl() + private function readScl(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4469,7 +4469,7 @@ private function readScl() /** * Read PANE record. */ - private function readPane() + private function readPane(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4503,7 +4503,7 @@ private function readPane() /** * Read SELECTION record. There is one such record for each pane in the sheet. */ - private function readSelection() + private function readSelection(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4580,7 +4580,7 @@ private function includeCellRangeFiltered($cellRangeAddress) * -- "OpenOffice.org's Documentation of the Microsoft * Excel File Format" */ - private function readMergedCells() + private function readMergedCells(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4602,7 +4602,7 @@ private function readMergedCells() /** * Read HYPERLINK record. */ - private function readHyperLink() + private function readHyperLink(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4775,7 +4775,7 @@ private function readHyperLink() /** * Read DATAVALIDATIONS record. */ - private function readDataValidations() + private function readDataValidations(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4787,7 +4787,7 @@ private function readDataValidations() /** * Read DATAVALIDATION record. */ - private function readDataValidation() + private function readDataValidation(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -4997,7 +4997,7 @@ private function readDataValidation() /** * Read SHEETLAYOUT record. Stores sheet tab color information. */ - private function readSheetLayout() + private function readSheetLayout(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -5037,7 +5037,7 @@ private function readSheetLayout() /** * Read SHEETPROTECTION record (FEATHEADR). */ - private function readSheetProtection() + private function readSheetProtection(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -5137,7 +5137,7 @@ private function readSheetProtection() * Reading of this record is based on Microsoft Office Excel 97-2000 Binary File Format Specification, * where it is referred to as FEAT record. */ - private function readRangeProtection() + private function readRangeProtection(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -5199,7 +5199,7 @@ private function readRangeProtection() * When MSODRAWING data on a sheet exceeds 8224 bytes, CONTINUE records are used instead. Undocumented. * In this case, we must treat the CONTINUE record as a MSODRAWING record. */ - private function readContinue() + private function readContinue(): void { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -5319,7 +5319,7 @@ private function getFormulaFromData($formulaData, $additionalData = '', $baseCel // start parsing the formula data $tokens = []; - while (strlen($formulaData) > 0 and $token = $this->getNextToken($formulaData, $baseCell)) { + while (strlen($formulaData) > 0 && $token = $this->getNextToken($formulaData, $baseCell)) { $tokens[] = $token; $formulaData = substr($formulaData, $token['size']); } @@ -7203,7 +7203,7 @@ private function readBIFF5CellRangeAddressFixed($subData) $fc = Coordinate::stringFromColumnIndex($fc + 1); $lc = Coordinate::stringFromColumnIndex($lc + 1); - if ($fr == $lr and $fc == $lc) { + if ($fr == $lr && $fc == $lc) { return "$fc$fr"; } @@ -7242,7 +7242,7 @@ private function readBIFF8CellRangeAddressFixed($subData) $fc = Coordinate::stringFromColumnIndex($fc + 1); $lc = Coordinate::stringFromColumnIndex($lc + 1); - if ($fr == $lr and $fc == $lc) { + if ($fr == $lr && $fc == $lc) { return "$fc$fr"; } @@ -7463,7 +7463,7 @@ private function readSheetRangeByRefIndex($index) switch ($type) { case 'internal': // check if we have a deleted 3d reference - if ($this->ref[$index]['firstSheetIndex'] == 0xFFFF or $this->ref[$index]['lastSheetIndex'] == 0xFFFF) { + if ($this->ref[$index]['firstSheetIndex'] == 0xFFFF || $this->ref[$index]['lastSheetIndex'] == 0xFFFF) { throw new Exception('Deleted sheet reference'); } @@ -7688,7 +7688,7 @@ private static function readUnicodeStringShort($subData) $string = self::readUnicodeString(substr($subData, 1), $characterCount); // add 1 for the string length - $string['size'] += 1; + ++$string['size']; return $string; } @@ -7781,13 +7781,13 @@ private static function extractNumber($data) $mantissa = (0x100000 | ($rknumhigh & 0x000fffff)); $mantissalow1 = ($rknumlow & 0x80000000) >> 31; $mantissalow2 = ($rknumlow & 0x7fffffff); - $value = $mantissa / pow(2, (20 - $exp)); + $value = $mantissa / 2 ** (20 - $exp); if ($mantissalow1 != 0) { - $value += 1 / pow(2, (21 - $exp)); + $value += 1 / 2 ** (21 - $exp); } - $value += $mantissalow2 / pow(2, (52 - $exp)); + $value += $mantissalow2 / 2 ** (52 - $exp); if ($sign) { $value *= -1; } @@ -7813,7 +7813,7 @@ private static function getIEEE754($rknum) $sign = ($rknum & 0x80000000) >> 31; $exp = ($rknum & 0x7ff00000) >> 20; $mantissa = (0x100000 | ($rknum & 0x000ffffc)); - $value = $mantissa / pow(2, (20 - ($exp - 1023))); + $value = $mantissa / 2 ** (20 - ($exp - 1023)); if ($sign) { $value = -1 * $value; } diff --git a/src/PhpSpreadsheet/Reader/Xls/Escher.php b/src/PhpSpreadsheet/Reader/Xls/Escher.php index 858d6bbbac..306fc8f1f7 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Escher.php +++ b/src/PhpSpreadsheet/Reader/Xls/Escher.php @@ -178,7 +178,7 @@ public function load($data) /** * Read a generic record. */ - private function readDefault() + private function readDefault(): void { // offset 0; size: 2; recVer and recInstance $verInstance = Xls::getUInt2d($this->data, $this->pos); @@ -199,7 +199,7 @@ private function readDefault() /** * Read DggContainer record (Drawing Group Container). */ - private function readDggContainer() + private function readDggContainer(): void { $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -217,7 +217,7 @@ private function readDggContainer() /** * Read Dgg record (Drawing Group). */ - private function readDgg() + private function readDgg(): void { $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -229,7 +229,7 @@ private function readDgg() /** * Read BstoreContainer record (Blip Store Container). */ - private function readBstoreContainer() + private function readBstoreContainer(): void { $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -247,7 +247,7 @@ private function readBstoreContainer() /** * Read BSE record. */ - private function readBSE() + private function readBSE(): void { // offset: 0; size: 2; recVer and recInstance @@ -313,7 +313,7 @@ private function readBSE() /** * Read BlipJPEG record. Holds raw JPEG image data. */ - private function readBlipJPEG() + private function readBlipJPEG(): void { // offset: 0; size: 2; recVer and recInstance @@ -340,7 +340,7 @@ private function readBlipJPEG() // offset: var; size: 1; tag $tag = ord($recordData[$pos]); - $pos += 1; + ++$pos; // offset: var; size: var; the raw image data $data = substr($recordData, $pos); @@ -354,7 +354,7 @@ private function readBlipJPEG() /** * Read BlipPNG record. Holds raw PNG image data. */ - private function readBlipPNG() + private function readBlipPNG(): void { // offset: 0; size: 2; recVer and recInstance @@ -381,7 +381,7 @@ private function readBlipPNG() // offset: var; size: 1; tag $tag = ord($recordData[$pos]); - $pos += 1; + ++$pos; // offset: var; size: var; the raw image data $data = substr($recordData, $pos); @@ -395,7 +395,7 @@ private function readBlipPNG() /** * Read OPT record. This record may occur within DggContainer record or SpContainer. */ - private function readOPT() + private function readOPT(): void { // offset: 0; size: 2; recVer and recInstance @@ -414,7 +414,7 @@ private function readOPT() /** * Read TertiaryOPT record. */ - private function readTertiaryOPT() + private function readTertiaryOPT(): void { // offset: 0; size: 2; recVer and recInstance @@ -431,7 +431,7 @@ private function readTertiaryOPT() /** * Read SplitMenuColors record. */ - private function readSplitMenuColors() + private function readSplitMenuColors(): void { $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -443,7 +443,7 @@ private function readSplitMenuColors() /** * Read DgContainer record (Drawing Container). */ - private function readDgContainer() + private function readDgContainer(): void { $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -461,7 +461,7 @@ private function readDgContainer() /** * Read Dg record (Drawing). */ - private function readDg() + private function readDg(): void { $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -473,7 +473,7 @@ private function readDg() /** * Read SpgrContainer record (Shape Group Container). */ - private function readSpgrContainer() + private function readSpgrContainer(): void { // context is either context DgContainer or SpgrContainer @@ -501,7 +501,7 @@ private function readSpgrContainer() /** * Read SpContainer record (Shape Container). */ - private function readSpContainer() + private function readSpContainer(): void { $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -521,7 +521,7 @@ private function readSpContainer() /** * Read Spgr record (Shape Group). */ - private function readSpgr() + private function readSpgr(): void { $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -533,7 +533,7 @@ private function readSpgr() /** * Read Sp record (Shape). */ - private function readSp() + private function readSp(): void { // offset: 0; size: 2; recVer and recInstance @@ -550,7 +550,7 @@ private function readSp() /** * Read ClientTextbox record. */ - private function readClientTextbox() + private function readClientTextbox(): void { // offset: 0; size: 2; recVer and recInstance @@ -567,7 +567,7 @@ private function readClientTextbox() /** * Read ClientAnchor record. This record holds information about where the shape is anchored in worksheet. */ - private function readClientAnchor() + private function readClientAnchor(): void { $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -621,7 +621,7 @@ private function readClientAnchor() /** * Read ClientData record. */ - private function readClientData() + private function readClientData(): void { $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -636,7 +636,7 @@ private function readClientData() * @param string $data Binary data * @param int $n Number of properties */ - private function readOfficeArtRGFOPTE($data, $n) + private function readOfficeArtRGFOPTE($data, $n): void { $splicedComplexData = substr($data, 6 * $n); diff --git a/src/PhpSpreadsheet/Reader/Xls/MD5.php b/src/PhpSpreadsheet/Reader/Xls/MD5.php index 6a10e591ec..c0417ba693 100644 --- a/src/PhpSpreadsheet/Reader/Xls/MD5.php +++ b/src/PhpSpreadsheet/Reader/Xls/MD5.php @@ -24,7 +24,7 @@ public function __construct() /** * Reset the MD5 stream context. */ - public function reset() + public function reset(): void { $this->a = 0x67452301; $this->b = 0xEFCDAB89; @@ -56,7 +56,7 @@ public function getContext() * * @param string $data Data to add */ - public function add($data) + public function add($data): void { $words = array_values(unpack('V16', $data)); @@ -168,7 +168,7 @@ private static function i($X, $Y, $Z) return $Y ^ ($X | (~$Z)); // Y XOR (X OR NOT Z) } - private static function step($func, &$A, $B, $C, $D, $M, $s, $t) + private static function step($func, &$A, $B, $C, $D, $M, $s, $t): void { $A = ($A + call_user_func($func, $B, $C, $D) + $M + $t) & 0xffffffff; $A = self::rotate($A, $s); diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 40814c64fd..77035a39b4 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -35,6 +35,8 @@ use PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use SimpleXMLElement; +use stdClass; +use Throwable; use XMLReader; use ZipArchive; @@ -256,7 +258,7 @@ private static function castToString($c) return isset($c->v) ? (string) $c->v : null; } - private function castToFormula($c, $r, &$cellDataType, &$value, &$calculatedValue, &$sharedFormulas, $castBaseType) + private function castToFormula($c, $r, &$cellDataType, &$value, &$calculatedValue, &$sharedFormulas, $castBaseType): void { $cellDataType = 'f'; $value = "={$c->f}"; @@ -282,7 +284,6 @@ private function castToFormula($c, $r, &$cellDataType, &$value, &$calculatedValu } /** - * @param ZipArchive $archive * @param string $fileName * * @return string @@ -658,7 +659,7 @@ public function load($pFilename) $coordinates = Coordinate::coordinateFromString($r); if (!$this->getReadFilter()->readCell($coordinates[0], (int) $coordinates[1], $docSheet->getTitle())) { - $rowIndex += 1; + ++$rowIndex; continue; } @@ -744,9 +745,9 @@ public function load($pFilename) (int) ($c['s']) : 0); } } - $rowIndex += 1; + ++$rowIndex; } - $cIndex += 1; + ++$cIndex; } } @@ -891,7 +892,7 @@ public function load($pFilename) Settings::getLibXmlLoaderOptions() ); $vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); - } catch (\Throwable $ex) { + } catch (Throwable $ex) { //Ignore unparsable vmlDrawings. Later they will be moved from $unparsedVmlDrawings to $unparsedLoadedData continue; } @@ -1115,7 +1116,7 @@ public function load($pFilename) $xfrm = $oneCellAnchor->pic->spPr->children('http://schemas.openxmlformats.org/drawingml/2006/main')->xfrm; /** @var SimpleXMLElement $outerShdw */ $outerShdw = $oneCellAnchor->pic->spPr->children('http://schemas.openxmlformats.org/drawingml/2006/main')->effectLst->outerShdw; - /** @var \SimpleXMLElement $hlinkClick */ + /** @var SimpleXMLElement $hlinkClick */ $hlinkClick = $oneCellAnchor->pic->nvPicPr->cNvPr->children('http://schemas.openxmlformats.org/drawingml/2006/main')->hlinkClick; $objDrawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing(); @@ -1556,10 +1557,9 @@ private static function readColor($color, $background = false) } /** - * @param Style $docStyle - * @param SimpleXMLElement|\stdClass $style + * @param SimpleXMLElement|stdClass $style */ - private static function readStyle(Style $docStyle, $style) + private static function readStyle(Style $docStyle, $style): void { $docStyle->getNumberFormat()->setFormatCode($style->numFmt); @@ -1684,10 +1684,9 @@ private static function readStyle(Style $docStyle, $style) } /** - * @param Border $docBorder * @param SimpleXMLElement $eleBorder */ - private static function readBorder(Border $docBorder, $eleBorder) + private static function readBorder(Border $docBorder, $eleBorder): void { if (isset($eleBorder['style'])) { $docBorder->setBorderStyle((string) $eleBorder['style']); @@ -1760,11 +1759,10 @@ private function parseRichText($is) } /** - * @param Spreadsheet $excel * @param mixed $customUITarget * @param mixed $zip */ - private function readRibbon(Spreadsheet $excel, $customUITarget, $zip) + private function readRibbon(Spreadsheet $excel, $customUITarget, $zip): void { $baseDir = dirname($customUITarget); $nameCustomUI = basename($customUITarget); @@ -1866,10 +1864,10 @@ private static function boolean($value) /** * @param \PhpOffice\PhpSpreadsheet\Worksheet\Drawing $objDrawing - * @param \SimpleXMLElement $cellAnchor + * @param SimpleXMLElement $cellAnchor * @param array $hyperlinks */ - private function readHyperLinkDrawing($objDrawing, $cellAnchor, $hyperlinks) + private function readHyperLinkDrawing($objDrawing, $cellAnchor, $hyperlinks): void { $hlinkClick = $cellAnchor->pic->nvPicPr->cNvPr->children('http://schemas.openxmlformats.org/drawingml/2006/main')->hlinkClick; @@ -1885,7 +1883,7 @@ private function readHyperLinkDrawing($objDrawing, $cellAnchor, $hyperlinks) $objDrawing->setHyperlink($hyperlink); } - private function readProtection(Spreadsheet $excel, SimpleXMLElement $xmlWorkbook) + private function readProtection(Spreadsheet $excel, SimpleXMLElement $xmlWorkbook): void { if (!$xmlWorkbook->workbookProtection) { return; @@ -1912,7 +1910,7 @@ private function readProtection(Spreadsheet $excel, SimpleXMLElement $xmlWorkboo } } - private function readFormControlProperties(Spreadsheet $excel, ZipArchive $zip, $dir, $fileWorksheet, $docSheet, array &$unparsedLoadedData) + private function readFormControlProperties(Spreadsheet $excel, ZipArchive $zip, $dir, $fileWorksheet, $docSheet, array &$unparsedLoadedData): void { if (!$zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) { return; @@ -1944,7 +1942,7 @@ private function readFormControlProperties(Spreadsheet $excel, ZipArchive $zip, unset($unparsedCtrlProps); } - private function readPrinterSettings(Spreadsheet $excel, ZipArchive $zip, $dir, $fileWorksheet, $docSheet, array &$unparsedLoadedData) + private function readPrinterSettings(Spreadsheet $excel, ZipArchive $zip, $dir, $fileWorksheet, $docSheet, array &$unparsedLoadedData): void { if (!$zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) { return; diff --git a/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php b/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php index 69d5f69e0a..f52bfd41a8 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php @@ -5,6 +5,7 @@ use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column; use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; +use SimpleXMLElement; class AutoFilter { @@ -12,13 +13,13 @@ class AutoFilter private $worksheetXml; - public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXml) + public function __construct(Worksheet $workSheet, SimpleXMLElement $worksheetXml) { $this->worksheet = $workSheet; $this->worksheetXml = $worksheetXml; } - public function load() + public function load(): void { // Remove all "$" in the auto filter range $autoFilterRange = preg_replace('/\$/', '', $this->worksheetXml->autoFilter['ref']); @@ -27,7 +28,7 @@ public function load() } } - private function readAutoFilter($autoFilterRange, $xmlSheet) + private function readAutoFilter($autoFilterRange, $xmlSheet): void { $autoFilter = $this->worksheet->getAutoFilter(); $autoFilter->setRange($autoFilterRange); @@ -62,7 +63,7 @@ private function readAutoFilter($autoFilterRange, $xmlSheet) } } - private function readDateRangeAutoFilter(\SimpleXMLElement $filters, Column $column) + private function readDateRangeAutoFilter(SimpleXMLElement $filters, Column $column): void { foreach ($filters->dateGroupItem as $dateGroupItem) { // Operator is undefined, but always treated as EQUAL @@ -81,7 +82,7 @@ private function readDateRangeAutoFilter(\SimpleXMLElement $filters, Column $col } } - private function readCustomAutoFilter(\SimpleXMLElement $filterColumn, Column $column) + private function readCustomAutoFilter(SimpleXMLElement $filterColumn, Column $column): void { if ($filterColumn->customFilters) { $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER); @@ -100,7 +101,7 @@ private function readCustomAutoFilter(\SimpleXMLElement $filterColumn, Column $c } } - private function readDynamicAutoFilter(\SimpleXMLElement $filterColumn, Column $column) + private function readDynamicAutoFilter(SimpleXMLElement $filterColumn, Column $column): void { if ($filterColumn->dynamicFilter) { $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER); @@ -122,7 +123,7 @@ private function readDynamicAutoFilter(\SimpleXMLElement $filterColumn, Column $ } } - private function readTopTenAutoFilter(\SimpleXMLElement $filterColumn, Column $column) + private function readTopTenAutoFilter(SimpleXMLElement $filterColumn, Column $column): void { if ($filterColumn->top10) { $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER); diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php index 2b920d705c..c9a230c215 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php @@ -17,7 +17,6 @@ class Chart { /** - * @param SimpleXMLElement $component * @param string $name * @param string $format * @@ -51,7 +50,6 @@ private static function readColor($color, $background = false) } /** - * @param SimpleXMLElement $chartElements * @param string $chartName * * @return \PhpOffice\PhpSpreadsheet\Chart\Chart @@ -529,10 +527,9 @@ private static function readChartAttributes($chartDetail) } /** - * @param Layout $plotArea * @param mixed $plotAttributes */ - private static function setChartAttributes(Layout $plotArea, $plotAttributes) + private static function setChartAttributes(Layout $plotArea, $plotAttributes): void { foreach ($plotAttributes as $plotAttributeKey => $plotAttributeValue) { switch ($plotAttributeKey) { diff --git a/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php b/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php index e901d99048..339c0584c4 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php @@ -5,6 +5,7 @@ use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Reader\IReadFilter; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; +use SimpleXMLElement; class ColumnAndRowAttributes extends BaseParserClass { @@ -12,7 +13,7 @@ class ColumnAndRowAttributes extends BaseParserClass private $worksheetXml; - public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXml = null) + public function __construct(Worksheet $workSheet, ?SimpleXMLElement $worksheetXml = null) { $this->worksheet = $workSheet; $this->worksheetXml = $worksheetXml; @@ -25,7 +26,7 @@ public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXm * @param array $columnAttributes array of attributes (indexes are attribute name, values are value) * 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'width', ... ? */ - private function setColumnAttributes($columnAddress, array $columnAttributes) + private function setColumnAttributes($columnAddress, array $columnAttributes): void { if (isset($columnAttributes['xfIndex'])) { $this->worksheet->getColumnDimension($columnAddress)->setXfIndex($columnAttributes['xfIndex']); @@ -51,7 +52,7 @@ private function setColumnAttributes($columnAddress, array $columnAttributes) * @param array $rowAttributes array of attributes (indexes are attribute name, values are value) * 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'rowHeight', ... ? */ - private function setRowAttributes($rowNumber, array $rowAttributes) + private function setRowAttributes($rowNumber, array $rowAttributes): void { if (isset($rowAttributes['xfIndex'])) { $this->worksheet->getRowDimension($rowNumber)->setXfIndex($rowAttributes['xfIndex']); @@ -74,7 +75,7 @@ private function setRowAttributes($rowNumber, array $rowAttributes) * @param IReadFilter $readFilter * @param bool $readDataOnly */ - public function load(IReadFilter $readFilter = null, $readDataOnly = false) + public function load(?IReadFilter $readFilter = null, $readDataOnly = false): void { if ($this->worksheetXml === null) { return; @@ -125,7 +126,7 @@ private function isFilteredColumn(IReadFilter $readFilter, $columnCoordinate, ar return false; } - private function readColumnAttributes(\SimpleXMLElement $worksheetCols, $readDataOnly) + private function readColumnAttributes(SimpleXMLElement $worksheetCols, $readDataOnly) { $columnAttributes = []; @@ -145,7 +146,7 @@ private function readColumnAttributes(\SimpleXMLElement $worksheetCols, $readDat return $columnAttributes; } - private function readColumnRangeAttributes(\SimpleXMLElement $column, $readDataOnly) + private function readColumnRangeAttributes(SimpleXMLElement $column, $readDataOnly) { $columnAttributes = []; @@ -177,7 +178,7 @@ private function isFilteredRow(IReadFilter $readFilter, $rowCoordinate, array $c return false; } - private function readRowAttributes(\SimpleXMLElement $worksheetRow, $readDataOnly) + private function readRowAttributes(SimpleXMLElement $worksheetRow, $readDataOnly) { $rowAttributes = []; diff --git a/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php b/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php index 722b77952a..668bfd1887 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php @@ -4,6 +4,7 @@ use PhpOffice\PhpSpreadsheet\Style\Conditional; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; +use SimpleXMLElement; class ConditionalStyles { @@ -13,14 +14,14 @@ class ConditionalStyles private $dxfs; - public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXml, array $dxfs = []) + public function __construct(Worksheet $workSheet, SimpleXMLElement $worksheetXml, array $dxfs = []) { $this->worksheet = $workSheet; $this->worksheetXml = $worksheetXml; $this->dxfs = $dxfs; } - public function load() + public function load(): void { $this->setConditionalStyles( $this->worksheet, @@ -48,7 +49,7 @@ private function readConditionalStyles($xmlSheet) return $conditionals; } - private function setConditionalStyles(Worksheet $worksheet, array $conditionals) + private function setConditionalStyles(Worksheet $worksheet, array $conditionals): void { foreach ($conditionals as $ref => $cfRules) { ksort($cfRules); diff --git a/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php b/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php index 4bb4412920..41a8c9fb57 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php @@ -4,6 +4,7 @@ use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; +use SimpleXMLElement; class DataValidations { @@ -11,13 +12,13 @@ class DataValidations private $worksheetXml; - public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXml) + public function __construct(Worksheet $workSheet, SimpleXMLElement $worksheetXml) { $this->worksheet = $workSheet; $this->worksheetXml = $worksheetXml; } - public function load() + public function load(): void { foreach ($this->worksheetXml->dataValidations->dataValidation as $dataValidation) { // Uppercase coordinate diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php b/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php index 400b272528..9e6aeaf788 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php @@ -4,6 +4,7 @@ use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; +use SimpleXMLElement; class Hyperlinks { @@ -16,7 +17,7 @@ public function __construct(Worksheet $workSheet) $this->worksheet = $workSheet; } - public function readHyperlinks(\SimpleXMLElement $relsWorksheet) + public function readHyperlinks(SimpleXMLElement $relsWorksheet): void { foreach ($relsWorksheet->Relationship as $element) { if ($element['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink') { @@ -25,14 +26,14 @@ public function readHyperlinks(\SimpleXMLElement $relsWorksheet) } } - public function setHyperlinks(\SimpleXMLElement $worksheetXml) + public function setHyperlinks(SimpleXMLElement $worksheetXml): void { foreach ($worksheetXml->hyperlink as $hyperlink) { $this->setHyperlink($hyperlink, $this->worksheet); } } - private function setHyperlink(\SimpleXMLElement $hyperlink, Worksheet $worksheet) + private function setHyperlink(SimpleXMLElement $hyperlink, Worksheet $worksheet): void { // Link url $linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); diff --git a/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php b/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php index 6f286769c0..bfb7a1f5f5 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php @@ -4,6 +4,7 @@ use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; +use SimpleXMLElement; class PageSetup extends BaseParserClass { @@ -11,7 +12,7 @@ class PageSetup extends BaseParserClass private $worksheetXml; - public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXml = null) + public function __construct(Worksheet $workSheet, ?SimpleXMLElement $worksheetXml = null) { $this->worksheet = $workSheet; $this->worksheetXml = $worksheetXml; @@ -31,7 +32,7 @@ public function load(array $unparsedLoadedData) return $unparsedLoadedData; } - private function margins(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) + private function margins(SimpleXMLElement $xmlSheet, Worksheet $worksheet): void { if ($xmlSheet->pageMargins) { $docPageMargins = $worksheet->getPageMargins(); @@ -44,7 +45,7 @@ private function margins(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) } } - private function pageSetup(\SimpleXMLElement $xmlSheet, Worksheet $worksheet, array $unparsedLoadedData) + private function pageSetup(SimpleXMLElement $xmlSheet, Worksheet $worksheet, array $unparsedLoadedData) { if ($xmlSheet->pageSetup) { $docPageSetup = $worksheet->getPageSetup(); @@ -78,7 +79,7 @@ private function pageSetup(\SimpleXMLElement $xmlSheet, Worksheet $worksheet, ar return $unparsedLoadedData; } - private function headerFooter(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) + private function headerFooter(SimpleXMLElement $xmlSheet, Worksheet $worksheet): void { if ($xmlSheet->headerFooter) { $docHeaderFooter = $worksheet->getHeaderFooter(); @@ -117,7 +118,7 @@ private function headerFooter(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) } } - private function pageBreaks(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) + private function pageBreaks(SimpleXMLElement $xmlSheet, Worksheet $worksheet): void { if ($xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk) { $this->rowBreaks($xmlSheet, $worksheet); @@ -127,7 +128,7 @@ private function pageBreaks(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) } } - private function rowBreaks(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) + private function rowBreaks(SimpleXMLElement $xmlSheet, Worksheet $worksheet): void { foreach ($xmlSheet->rowBreaks->brk as $brk) { if ($brk['man']) { @@ -136,7 +137,7 @@ private function rowBreaks(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) } } - private function columnBreaks(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) + private function columnBreaks(SimpleXMLElement $xmlSheet, Worksheet $worksheet): void { foreach ($xmlSheet->colBreaks->brk as $brk) { if ($brk['man']) { diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Properties.php b/src/PhpSpreadsheet/Reader/Xlsx/Properties.php index bf8e57d807..b6f3c61fc3 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Properties.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Properties.php @@ -5,6 +5,7 @@ use PhpOffice\PhpSpreadsheet\Document\Properties as DocumentProperties; use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner; use PhpOffice\PhpSpreadsheet\Settings; +use SimpleXMLElement; class Properties { @@ -27,7 +28,7 @@ private function extractPropertyData($propertyData) ); } - public function readCoreProperties($propertyData) + public function readCoreProperties($propertyData): void { $xmlCore = $this->extractPropertyData($propertyData); @@ -48,7 +49,7 @@ public function readCoreProperties($propertyData) } } - public function readExtendedProperties($propertyData) + public function readExtendedProperties($propertyData): void { $xmlCore = $this->extractPropertyData($propertyData); @@ -62,13 +63,13 @@ public function readExtendedProperties($propertyData) } } - public function readCustomProperties($propertyData) + public function readCustomProperties($propertyData): void { $xmlCore = $this->extractPropertyData($propertyData); if (is_object($xmlCore)) { foreach ($xmlCore as $xmlProperty) { - /** @var \SimpleXMLElement $xmlProperty */ + /** @var SimpleXMLElement $xmlProperty */ $cellDataOfficeAttributes = $xmlProperty->attributes(); if (isset($cellDataOfficeAttributes['name'])) { $propertyName = (string) $cellDataOfficeAttributes['name']; diff --git a/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php b/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php index eb61a5d306..b3bee8991c 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php @@ -3,6 +3,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; +use SimpleXMLElement; class SheetViewOptions extends BaseParserClass { @@ -10,7 +11,7 @@ class SheetViewOptions extends BaseParserClass private $worksheetXml; - public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXml = null) + public function __construct(Worksheet $workSheet, ?SimpleXMLElement $worksheetXml = null) { $this->worksheet = $workSheet; $this->worksheetXml = $worksheetXml; @@ -19,7 +20,7 @@ public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXm /** * @param bool $readDataOnly */ - public function load($readDataOnly = false) + public function load($readDataOnly = false): void { if ($this->worksheetXml === null) { return; @@ -41,21 +42,21 @@ public function load($readDataOnly = false) } } - private function tabColor(\SimpleXMLElement $sheetPr) + private function tabColor(SimpleXMLElement $sheetPr): void { if (isset($sheetPr->tabColor, $sheetPr->tabColor['rgb'])) { $this->worksheet->getTabColor()->setARGB((string) $sheetPr->tabColor['rgb']); } } - private function codeName(\SimpleXMLElement $sheetPr) + private function codeName(SimpleXMLElement $sheetPr): void { if (isset($sheetPr['codeName'])) { $this->worksheet->setCodeName((string) $sheetPr['codeName'], false); } } - private function outlines(\SimpleXMLElement $sheetPr) + private function outlines(SimpleXMLElement $sheetPr): void { if (isset($sheetPr->outlinePr)) { if (isset($sheetPr->outlinePr['summaryRight']) && @@ -74,7 +75,7 @@ private function outlines(\SimpleXMLElement $sheetPr) } } - private function pageSetup(\SimpleXMLElement $sheetPr) + private function pageSetup(SimpleXMLElement $sheetPr): void { if (isset($sheetPr->pageSetUpPr)) { if (isset($sheetPr->pageSetUpPr['fitToPage']) && @@ -86,7 +87,7 @@ private function pageSetup(\SimpleXMLElement $sheetPr) } } - private function sheetFormat(\SimpleXMLElement $sheetFormatPr) + private function sheetFormat(SimpleXMLElement $sheetFormatPr): void { if (isset($sheetFormatPr['customHeight']) && self::boolean((string) $sheetFormatPr['customHeight']) && @@ -106,7 +107,7 @@ private function sheetFormat(\SimpleXMLElement $sheetFormatPr) } } - private function printOptions(\SimpleXMLElement $printOptions) + private function printOptions(SimpleXMLElement $printOptions): void { if (self::boolean((string) $printOptions['gridLinesSet'])) { $this->worksheet->setShowGridlines(true); diff --git a/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php b/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php index 88c01ead37..f6c4792906 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php @@ -4,6 +4,7 @@ use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; +use SimpleXMLElement; class SheetViews extends BaseParserClass { @@ -11,13 +12,13 @@ class SheetViews extends BaseParserClass private $worksheet; - public function __construct(\SimpleXMLElement $sheetViewXml, Worksheet $workSheet) + public function __construct(SimpleXMLElement $sheetViewXml, Worksheet $workSheet) { $this->sheetViewXml = $sheetViewXml; $this->worksheet = $workSheet; } - public function load() + public function load(): void { $this->zoomScale(); $this->view(); @@ -34,7 +35,7 @@ public function load() } } - private function zoomScale() + private function zoomScale(): void { if (isset($this->sheetViewXml['zoomScale'])) { $zoomScale = (int) ($this->sheetViewXml['zoomScale']); @@ -59,14 +60,14 @@ private function zoomScale() } } - private function view() + private function view(): void { if (isset($this->sheetViewXml['view'])) { $this->worksheet->getSheetView()->setView((string) $this->sheetViewXml['view']); } } - private function gridLines() + private function gridLines(): void { if (isset($this->sheetViewXml['showGridLines'])) { $this->worksheet->setShowGridLines( @@ -75,7 +76,7 @@ private function gridLines() } } - private function headers() + private function headers(): void { if (isset($this->sheetViewXml['showRowColHeaders'])) { $this->worksheet->setShowRowColHeaders( @@ -84,7 +85,7 @@ private function headers() } } - private function direction() + private function direction(): void { if (isset($this->sheetViewXml['rightToLeft'])) { $this->worksheet->setRightToLeft( @@ -93,7 +94,7 @@ private function direction() } } - private function showZeros() + private function showZeros(): void { if (isset($this->sheetViewXml['showZeros'])) { $this->worksheet->getSheetView()->setShowZeros( @@ -102,7 +103,7 @@ private function showZeros() } } - private function pane() + private function pane(): void { $xSplit = 0; $ySplit = 0; @@ -126,7 +127,7 @@ private function pane() ); } - private function selection() + private function selection(): void { $sqref = (string) $this->sheetViewXml->selection['sqref']; $sqref = explode(' ', $sqref); diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Styles.php b/src/PhpSpreadsheet/Reader/Xlsx/Styles.php index 40106258c4..43de87875e 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Styles.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Styles.php @@ -11,6 +11,7 @@ use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Style\Protection; use PhpOffice\PhpSpreadsheet\Style\Style; +use SimpleXMLElement; class Styles extends BaseParserClass { @@ -27,19 +28,19 @@ class Styles extends BaseParserClass private $styleXml; - public function __construct(\SimpleXMLElement $styleXml) + public function __construct(SimpleXMLElement $styleXml) { $this->styleXml = $styleXml; } - public function setStyleBaseData(Theme $theme = null, $styles = [], $cellStyles = []) + public function setStyleBaseData(?Theme $theme = null, $styles = [], $cellStyles = []): void { self::$theme = $theme; $this->styles = $styles; $this->cellStyles = $cellStyles; } - private static function readFontStyle(Font $fontStyle, \SimpleXMLElement $fontStyleXml) + private static function readFontStyle(Font $fontStyle, SimpleXMLElement $fontStyleXml): void { $fontStyle->setName((string) $fontStyleXml->name['val']); $fontStyle->setSize((float) $fontStyleXml->sz['val']); @@ -72,7 +73,7 @@ private static function readFontStyle(Font $fontStyle, \SimpleXMLElement $fontSt } } - private static function readNumberFormat(NumberFormat $numfmtStyle, \SimpleXMLElement $numfmtStyleXml) + private static function readNumberFormat(NumberFormat $numfmtStyle, SimpleXMLElement $numfmtStyleXml): void { if ($numfmtStyleXml->count() === 0) { return; @@ -83,10 +84,10 @@ private static function readNumberFormat(NumberFormat $numfmtStyle, \SimpleXMLEl } } - private static function readFillStyle(Fill $fillStyle, \SimpleXMLElement $fillStyleXml) + private static function readFillStyle(Fill $fillStyle, SimpleXMLElement $fillStyleXml): void { if ($fillStyleXml->gradientFill) { - /** @var \SimpleXMLElement $gradientFill */ + /** @var SimpleXMLElement $gradientFill */ $gradientFill = $fillStyleXml->gradientFill[0]; if (!empty($gradientFill['type'])) { $fillStyle->setFillType((string) $gradientFill['type']); @@ -109,7 +110,7 @@ private static function readFillStyle(Fill $fillStyle, \SimpleXMLElement $fillSt } } - private static function readBorderStyle(Borders $borderStyle, \SimpleXMLElement $borderStyleXml) + private static function readBorderStyle(Borders $borderStyle, SimpleXMLElement $borderStyleXml): void { $diagonalUp = self::boolean((string) $borderStyleXml['diagonalUp']); $diagonalDown = self::boolean((string) $borderStyleXml['diagonalDown']); @@ -130,7 +131,7 @@ private static function readBorderStyle(Borders $borderStyle, \SimpleXMLElement self::readBorder($borderStyle->getDiagonal(), $borderStyleXml->diagonal); } - private static function readBorder(Border $border, \SimpleXMLElement $borderXml) + private static function readBorder(Border $border, SimpleXMLElement $borderXml): void { if (isset($borderXml['style'])) { $border->setBorderStyle((string) $borderXml['style']); @@ -140,7 +141,7 @@ private static function readBorder(Border $border, \SimpleXMLElement $borderXml) } } - private static function readAlignmentStyle(Alignment $alignment, \SimpleXMLElement $alignmentXml) + private static function readAlignmentStyle(Alignment $alignment, SimpleXMLElement $alignmentXml): void { $alignment->setHorizontal((string) $alignmentXml->alignment['horizontal']); $alignment->setVertical((string) $alignmentXml->alignment['vertical']); @@ -159,9 +160,9 @@ private static function readAlignmentStyle(Alignment $alignment, \SimpleXMLEleme $alignment->setReadOrder((int) ((string) $alignmentXml->alignment['readingOrder']) > 0 ? (int) ((string) $alignmentXml->alignment['readingOrder']) : 0); } - private function readStyle(Style $docStyle, $style) + private function readStyle(Style $docStyle, $style): void { - if ($style->numFmt instanceof \SimpleXMLElement) { + if ($style->numFmt instanceof SimpleXMLElement) { self::readNumberFormat($docStyle->getNumberFormat(), $style->numFmt); } else { $docStyle->getNumberFormat()->setFormatCode($style->numFmt); @@ -195,7 +196,7 @@ private function readStyle(Style $docStyle, $style) } } - private function readProtectionLocked(Style $docStyle, $style) + private function readProtectionLocked(Style $docStyle, $style): void { if (isset($style->protection['locked'])) { if (self::boolean((string) $style->protection['locked'])) { @@ -206,7 +207,7 @@ private function readProtectionLocked(Style $docStyle, $style) } } - private function readProtectionHidden(Style $docStyle, $style) + private function readProtectionHidden(Style $docStyle, $style): void { if (isset($style->protection['hidden'])) { if (self::boolean((string) $style->protection['hidden'])) { diff --git a/src/PhpSpreadsheet/Reader/Xml.php b/src/PhpSpreadsheet/Reader/Xml.php index 03099e3e47..15fb34ad91 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -101,7 +101,7 @@ public function canRead($pFilename) * * @param string $pFilename * - * @return false|\SimpleXMLElement + * @return false|SimpleXMLElement */ public function trySimpleXMLLoadString($pFilename) { @@ -288,7 +288,6 @@ protected static function hex2str($hex) * Loads from file into Spreadsheet instance. * * @param string $pFilename - * @param Spreadsheet $spreadsheet * * @return Spreadsheet */ @@ -653,11 +652,7 @@ protected function parseRichText($is) return $value; } - /** - * @param SimpleXMLElement $xml - * @param array $namespaces - */ - private function parseStyles(SimpleXMLElement $xml, array $namespaces) + private function parseStyles(SimpleXMLElement $xml, array $namespaces): void { if (!isset($xml->Styles)) { return; @@ -697,9 +692,8 @@ private function parseStyles(SimpleXMLElement $xml, array $namespaces) /** * @param string $styleID - * @param SimpleXMLElement $styleAttributes */ - private function parseStyleAlignment($styleID, SimpleXMLElement $styleAttributes) + private function parseStyleAlignment($styleID, SimpleXMLElement $styleAttributes): void { $verticalAlignmentStyles = [ Alignment::VERTICAL_BOTTOM, @@ -741,10 +735,8 @@ private function parseStyleAlignment($styleID, SimpleXMLElement $styleAttributes /** * @param $styleID - * @param SimpleXMLElement $styleData - * @param array $namespaces */ - private function parseStyleBorders($styleID, SimpleXMLElement $styleData, array $namespaces) + private function parseStyleBorders($styleID, SimpleXMLElement $styleData, array $namespaces): void { foreach ($styleData->Border as $borderStyle) { $borderAttributes = $borderStyle->attributes($namespaces['ss']); @@ -778,9 +770,8 @@ private function parseStyleBorders($styleID, SimpleXMLElement $styleData, array /** * @param $styleID - * @param SimpleXMLElement $styleAttributes */ - private function parseStyleFont($styleID, SimpleXMLElement $styleAttributes) + private function parseStyleFont($styleID, SimpleXMLElement $styleAttributes): void { $underlineStyles = [ Font::UNDERLINE_NONE, @@ -825,9 +816,8 @@ private function parseStyleFont($styleID, SimpleXMLElement $styleAttributes) /** * @param $styleID - * @param SimpleXMLElement $styleAttributes */ - private function parseStyleInterior($styleID, SimpleXMLElement $styleAttributes) + private function parseStyleInterior($styleID, SimpleXMLElement $styleAttributes): void { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { switch ($styleAttributeKey) { @@ -845,9 +835,8 @@ private function parseStyleInterior($styleID, SimpleXMLElement $styleAttributes) /** * @param $styleID - * @param SimpleXMLElement $styleAttributes */ - private function parseStyleNumberFormat($styleID, SimpleXMLElement $styleAttributes) + private function parseStyleNumberFormat($styleID, SimpleXMLElement $styleAttributes): void { $fromFormats = ['\-', '\ ']; $toFormats = ['-', ' ']; diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index 6d65573054..0b0f6dd3c6 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -152,7 +152,7 @@ private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNum * @param int $beforeRow Number of the row we're inserting/deleting before * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function adjustPageBreaks(Worksheet $pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustPageBreaks(Worksheet $pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void { $aBreaks = $pSheet->getBreaks(); ($pNumCols > 0 || $pNumRows > 0) ? @@ -185,7 +185,7 @@ protected function adjustPageBreaks(Worksheet $pSheet, $pBefore, $beforeColumnIn * @param int $beforeRow Number of the row we're inserting/deleting before * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void { $aComments = $pSheet->getComments(); $aNewComments = []; // the new array of all comments @@ -212,7 +212,7 @@ protected function adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCo * @param int $beforeRow Number of the row we're inserting/deleting before * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void { $aHyperlinkCollection = $pSheet->getHyperlinkCollection(); ($pNumCols > 0 || $pNumRows > 0) ? @@ -237,7 +237,7 @@ protected function adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNum * @param int $beforeRow Number of the row we're inserting/deleting before * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void { $aDataValidationCollection = $pSheet->getDataValidationCollection(); ($pNumCols > 0 || $pNumRows > 0) ? @@ -262,7 +262,7 @@ protected function adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, * @param int $beforeRow Number of the row we're inserting/deleting before * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void { $aMergeCells = $pSheet->getMergeCells(); $aNewMergeCells = []; // the new array of all merge cells @@ -283,7 +283,7 @@ protected function adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNum * @param int $beforeRow Number of the row we're inserting/deleting before * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void { $aProtectedCells = $pSheet->getProtectedCells(); ($pNumCols > 0 || $pNumRows > 0) ? @@ -307,7 +307,7 @@ protected function adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $ * @param int $beforeRow Number of the row we're inserting/deleting before * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void { $aColumnDimensions = array_reverse($pSheet->getColumnDimensions(), true); if (!empty($aColumnDimensions)) { @@ -332,7 +332,7 @@ protected function adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, * @param int $beforeRow Number of the row we're inserting/deleting before * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) + protected function adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows): void { $aRowDimensions = array_reverse($pSheet->getRowDimensions(), true); if (!empty($aRowDimensions)) { @@ -364,7 +364,7 @@ protected function adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $p * @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion) * @param Worksheet $pSheet The worksheet that we're editing */ - public function insertNewBefore($pBefore, $pNumCols, $pNumRows, Worksheet $pSheet) + public function insertNewBefore($pBefore, $pNumCols, $pNumRows, Worksheet $pSheet): void { $remove = ($pNumCols < 0 || $pNumRows < 0); $allCoordinates = $pSheet->getCoordinates(); @@ -789,7 +789,7 @@ public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCo * @param string $oldName Old name (name to replace) * @param string $newName New name */ - public function updateNamedFormulas(Spreadsheet $spreadsheet, $oldName = '', $newName = '') + public function updateNamedFormulas(Spreadsheet $spreadsheet, $oldName = '', $newName = ''): void { if ($oldName == '') { return; diff --git a/src/PhpSpreadsheet/RichText/RichText.php b/src/PhpSpreadsheet/RichText/RichText.php index 4fa5f2bdf9..104177bd29 100644 --- a/src/PhpSpreadsheet/RichText/RichText.php +++ b/src/PhpSpreadsheet/RichText/RichText.php @@ -20,7 +20,7 @@ class RichText implements IComparable * * @param Cell $pCell */ - public function __construct(Cell $pCell = null) + public function __construct(?Cell $pCell = null) { // Initialise variables $this->richTextElements = []; diff --git a/src/PhpSpreadsheet/RichText/Run.php b/src/PhpSpreadsheet/RichText/Run.php index aa4a8e462d..592d0e36b6 100644 --- a/src/PhpSpreadsheet/RichText/Run.php +++ b/src/PhpSpreadsheet/RichText/Run.php @@ -42,7 +42,7 @@ public function getFont() * * @return $this */ - public function setFont(Font $pFont = null) + public function setFont(?Font $pFont = null) { $this->font = $pFont; diff --git a/src/PhpSpreadsheet/Settings.php b/src/PhpSpreadsheet/Settings.php index 56f778e57b..4e0c91ef48 100644 --- a/src/PhpSpreadsheet/Settings.php +++ b/src/PhpSpreadsheet/Settings.php @@ -60,7 +60,7 @@ public static function setLocale($locale) * @param string $rendererClass Class name of the chart renderer * eg: PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph */ - public static function setChartRenderer($rendererClass) + public static function setChartRenderer($rendererClass): void { if (!is_a($rendererClass, IRenderer::class, true)) { throw new Exception('Chart renderer must implement ' . IRenderer::class); @@ -85,7 +85,7 @@ public static function getChartRenderer() * * @param int $options Default options for libxml loader */ - public static function setLibXmlLoaderOptions($options) + public static function setLibXmlLoaderOptions($options): void { if ($options === null && defined('LIBXML_DTDLOAD')) { $options = LIBXML_DTDLOAD | LIBXML_DTDATTR; @@ -120,7 +120,7 @@ public static function getLibXmlLoaderOptions() * * @param bool $state */ - public static function setLibXmlDisableEntityLoader($state) + public static function setLibXmlDisableEntityLoader($state): void { self::$libXmlDisableEntityLoader = (bool) $state; } @@ -137,10 +137,8 @@ public static function getLibXmlDisableEntityLoader() /** * Sets the implementation of cache that should be used for cell collection. - * - * @param CacheInterface $cache */ - public static function setCache(CacheInterface $cache) + public static function setCache(CacheInterface $cache): void { self::$cache = $cache; } diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index 8be255c5e5..fd49c1ecad 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -4,6 +4,7 @@ use DateTimeInterface; use DateTimeZone; +use Exception; use PhpOffice\PhpSpreadsheet\Calculation\DateTime; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Cell\Cell; @@ -57,7 +58,7 @@ class Date /** * Default timezone to use for DateTime objects. * - * @var null|\DateTimeZone + * @var null|DateTimeZone */ protected static $defaultTimeZone; @@ -139,7 +140,7 @@ protected static function validateTimeZone($timeZone) return new DateTimeZone($timeZone); } - throw new \Exception('Invalid timezone'); + throw new Exception('Invalid timezone'); } /** @@ -311,8 +312,6 @@ public static function formattedPHPToExcel($year, $month, $day, $hours = 0, $min /** * Is a given cell a date/time? * - * @param Cell $pCell - * * @return bool */ public static function isDateTime(Cell $pCell) @@ -328,8 +327,6 @@ public static function isDateTime(Cell $pCell) /** * Is a given number format a date/time? * - * @param NumberFormat $pFormat - * * @return bool */ public static function isDateTimeFormat(NumberFormat $pFormat) diff --git a/src/PhpSpreadsheet/Shared/Escher/DgContainer.php b/src/PhpSpreadsheet/Shared/Escher/DgContainer.php index e9d387daa4..b0d75d7833 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DgContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer.php @@ -25,7 +25,7 @@ public function getDgId() return $this->dgId; } - public function setDgId($value) + public function setDgId($value): void { $this->dgId = $value; } @@ -35,7 +35,7 @@ public function getLastSpId() return $this->lastSpId; } - public function setLastSpId($value) + public function setLastSpId($value): void { $this->lastSpId = $value; } diff --git a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php index 7e2c34608a..1da877262f 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php @@ -23,7 +23,7 @@ class SpgrContainer * * @param \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer $parent */ - public function setParent($parent) + public function setParent($parent): void { $this->parent = $parent; } @@ -43,7 +43,7 @@ public function getParent() * * @param mixed $child */ - public function addChild($child) + public function addChild($child): void { $this->children[] = $child; $child->setParent($this); diff --git a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php index bbf51df186..8a81ff5797 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php @@ -95,7 +95,7 @@ class SpContainer * * @param SpgrContainer $parent */ - public function setParent($parent) + public function setParent($parent): void { $this->parent = $parent; } @@ -115,7 +115,7 @@ public function getParent() * * @param bool $value */ - public function setSpgr($value) + public function setSpgr($value): void { $this->spgr = $value; } @@ -135,7 +135,7 @@ public function getSpgr() * * @param int $value */ - public function setSpType($value) + public function setSpType($value): void { $this->spType = $value; } @@ -155,7 +155,7 @@ public function getSpType() * * @param int $value */ - public function setSpFlag($value) + public function setSpFlag($value): void { $this->spFlag = $value; } @@ -175,7 +175,7 @@ public function getSpFlag() * * @param int $value */ - public function setSpId($value) + public function setSpId($value): void { $this->spId = $value; } @@ -196,7 +196,7 @@ public function getSpId() * @param int $property The number specifies the option * @param mixed $value */ - public function setOPT($property, $value) + public function setOPT($property, $value): void { $this->OPT[$property] = $value; } @@ -232,7 +232,7 @@ public function getOPTCollection() * * @param string $value eg: 'A1' */ - public function setStartCoordinates($value) + public function setStartCoordinates($value): void { $this->startCoordinates = $value; } @@ -252,7 +252,7 @@ public function getStartCoordinates() * * @param int $startOffsetX */ - public function setStartOffsetX($startOffsetX) + public function setStartOffsetX($startOffsetX): void { $this->startOffsetX = $startOffsetX; } @@ -272,7 +272,7 @@ public function getStartOffsetX() * * @param int $startOffsetY */ - public function setStartOffsetY($startOffsetY) + public function setStartOffsetY($startOffsetY): void { $this->startOffsetY = $startOffsetY; } @@ -292,7 +292,7 @@ public function getStartOffsetY() * * @param string $value eg: 'A1' */ - public function setEndCoordinates($value) + public function setEndCoordinates($value): void { $this->endCoordinates = $value; } @@ -312,7 +312,7 @@ public function getEndCoordinates() * * @param int $endOffsetX */ - public function setEndOffsetX($endOffsetX) + public function setEndOffsetX($endOffsetX): void { $this->endOffsetX = $endOffsetX; } @@ -332,7 +332,7 @@ public function getEndOffsetX() * * @param int $endOffsetY */ - public function setEndOffsetY($endOffsetY) + public function setEndOffsetY($endOffsetY): void { $this->endOffsetY = $endOffsetY; } diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer.php index 96da32131e..1bd15b9edd 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer.php @@ -61,7 +61,7 @@ public function getSpIdMax() * * @param int $value */ - public function setSpIdMax($value) + public function setSpIdMax($value): void { $this->spIdMax = $value; } @@ -81,7 +81,7 @@ public function getCDgSaved() * * @param int $value */ - public function setCDgSaved($value) + public function setCDgSaved($value): void { $this->cDgSaved = $value; } @@ -101,7 +101,7 @@ public function getCSpSaved() * * @param int $value */ - public function setCSpSaved($value) + public function setCSpSaved($value): void { $this->cSpSaved = $value; } @@ -121,7 +121,7 @@ public function getBstoreContainer() * * @param DggContainer\BstoreContainer $bstoreContainer */ - public function setBstoreContainer($bstoreContainer) + public function setBstoreContainer($bstoreContainer): void { $this->bstoreContainer = $bstoreContainer; } @@ -132,7 +132,7 @@ public function setBstoreContainer($bstoreContainer) * @param int $property The number specifies the option * @param mixed $value */ - public function setOPT($property, $value) + public function setOPT($property, $value): void { $this->OPT[$property] = $value; } @@ -168,7 +168,7 @@ public function getIDCLs() * * @param array $pValue */ - public function setIDCLs($pValue) + public function setIDCLs($pValue): void { $this->IDCLs = $pValue; } diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php index 9d1e68ec77..b07786ff65 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php @@ -16,7 +16,7 @@ class BstoreContainer * * @param BstoreContainer\BSE $BSE */ - public function addBSE($BSE) + public function addBSE($BSE): void { $this->BSECollection[] = $BSE; $BSE->setParent($this); diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php index f83bdc7ee3..e885146577 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php @@ -41,7 +41,7 @@ class BSE * * @param \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer $parent */ - public function setParent($parent) + public function setParent($parent): void { $this->parent = $parent; } @@ -61,7 +61,7 @@ public function getBlip() * * @param BSE\Blip $blip */ - public function setBlip($blip) + public function setBlip($blip): void { $this->blip = $blip; $blip->setParent($this); @@ -82,7 +82,7 @@ public function getBlipType() * * @param int $blipType */ - public function setBlipType($blipType) + public function setBlipType($blipType): void { $this->blipType = $blipType; } diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php index 88bc117a16..500d7eaf3e 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php @@ -33,7 +33,7 @@ public function getData() * * @param string $data */ - public function setData($data) + public function setData($data): void { $this->data = $data; } @@ -43,7 +43,7 @@ public function setData($data) * * @param \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE $parent */ - public function setParent($parent) + public function setParent($parent): void { $this->parent = $parent; } diff --git a/src/PhpSpreadsheet/Shared/File.php b/src/PhpSpreadsheet/Shared/File.php index 6b1fe6f563..7525df8a6b 100644 --- a/src/PhpSpreadsheet/Shared/File.php +++ b/src/PhpSpreadsheet/Shared/File.php @@ -19,7 +19,7 @@ class File * * @param bool $useUploadTempDir Use File Upload Temporary directory (true or false) */ - public static function setUseUploadTempDirectory($useUploadTempDir) + public static function setUseUploadTempDirectory($useUploadTempDir): void { self::$useUploadTempDirectory = (bool) $useUploadTempDir; } @@ -129,7 +129,7 @@ public static function sysGetTempDir() * * @param string $filename */ - public static function assertFile($filename) + public static function assertFile($filename): void { if (!is_file($filename)) { throw new InvalidArgumentException('File "' . $filename . '" does not exist.'); diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index 89d91be74d..ca94529cb1 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -198,7 +198,7 @@ public static function getAutoSizeMethod() * * @param string $pValue */ - public static function setTrueTypeFontPath($pValue) + public static function setTrueTypeFontPath($pValue): void { self::$trueTypeFontPath = $pValue; } @@ -223,7 +223,7 @@ public static function getTrueTypeFontPath() * * @return int Column width */ - public static function calculateColumnWidth(\PhpOffice\PhpSpreadsheet\Style\Font $font, $cellText = '', $rotation = 0, \PhpOffice\PhpSpreadsheet\Style\Font $defaultFont = null) + public static function calculateColumnWidth(\PhpOffice\PhpSpreadsheet\Style\Font $font, $cellText = '', $rotation = 0, ?\PhpOffice\PhpSpreadsheet\Style\Font $defaultFont = null) { // If it is rich text, use plain text if ($cellText instanceof RichText) { @@ -303,7 +303,6 @@ public static function getTextWidthPixelsExact($text, \PhpOffice\PhpSpreadsheet\ * Get approximate width in pixels for a string of text in a certain font at a certain rotation angle. * * @param string $columnText - * @param \PhpOffice\PhpSpreadsheet\Style\Font $font * @param int $rotation * * @return int Text width in pixels (no padding added) diff --git a/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php index ba59e0e5ad..f6fbccb8a0 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php +++ b/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php @@ -73,7 +73,7 @@ class EigenvalueDecomposition /** * Symmetric Householder reduction to tridiagonal form. */ - private function tred2() + private function tred2(): void { // This is derived from the Algol procedures tred2 by // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for @@ -96,7 +96,7 @@ private function tred2() // Generate Householder vector. for ($k = 0; $k < $i; ++$k) { $this->d[$k] /= $scale; - $h += pow($this->d[$k], 2); + $h += $this->d[$k] ** 2; } $f = $this->d[$i_]; $g = sqrt($h); @@ -180,7 +180,7 @@ private function tred2() * Auto. Comp., Vol.ii-Linear Algebra, and the corresponding * Fortran subroutine in EISPACK. */ - private function tql2() + private function tql2(): void { for ($i = 1; $i < $this->n; ++$i) { $this->e[$i - 1] = $this->e[$i]; @@ -188,7 +188,7 @@ private function tql2() $this->e[$this->n - 1] = 0.0; $f = 0.0; $tst1 = 0.0; - $eps = pow(2.0, -52.0); + $eps = 2.0 ** (-52.0); for ($l = 0; $l < $this->n; ++$l) { // Find small subdiagonal element @@ -206,7 +206,7 @@ private function tql2() $iter = 0; do { // Could check iteration count here. - $iter += 1; + ++$iter; // Compute implicit shift $g = $this->d[$l]; $p = ($this->d[$l + 1] - $g) / (2.0 * $this->e[$l]); @@ -287,7 +287,7 @@ private function tql2() * Vol.ii-Linear Algebra, and the corresponding * Fortran subroutines in EISPACK. */ - private function orthes() + private function orthes(): void { $low = 0; $high = $this->n - 1; @@ -372,7 +372,7 @@ private function orthes() * @param mixed $yr * @param mixed $yi */ - private function cdiv($xr, $xi, $yr, $yi) + private function cdiv($xr, $xi, $yr, $yi): void { if (abs($yr) > abs($yi)) { $r = $yi / $yr; @@ -395,21 +395,21 @@ private function cdiv($xr, $xi, $yr, $yi) * Vol.ii-Linear Algebra, and the corresponding * Fortran subroutine in EISPACK. */ - private function hqr2() + private function hqr2(): void { // Initialize $nn = $this->n; $n = $nn - 1; $low = 0; $high = $nn - 1; - $eps = pow(2.0, -52.0); + $eps = 2.0 ** (-52.0); $exshift = 0.0; $p = $q = $r = $s = $z = 0; // Store roots isolated by balanc and compute matrix norm $norm = 0.0; for ($i = 0; $i < $nn; ++$i) { - if (($i < $low) or ($i > $high)) { + if (($i < $low) || ($i > $high)) { $this->d[$i] = $this->H[$i][$i]; $this->e[$i] = 0.0; } diff --git a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php index a67b6c2de5..a5cb6de0f6 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php +++ b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php @@ -159,11 +159,6 @@ public function get($i = null, $j = null) * * Get a submatrix * - * @param int $i0 Initial row index - * @param int $iF Final row index - * @param int $j0 Initial column index - * @param int $jF Final column index - * * @return Matrix Submatrix */ public function getMatrix(...$args) @@ -477,8 +472,6 @@ public function uminus() * * A + B * - * @param mixed $B Matrix/Array - * * @return Matrix Sum */ public function plus(...$args) @@ -522,8 +515,6 @@ public function plus(...$args) * * A = A + B * - * @param mixed $B Matrix/Array - * * @return $this */ public function plusEquals(...$args) @@ -581,8 +572,6 @@ public function plusEquals(...$args) * * A - B * - * @param mixed $B Matrix/Array - * * @return Matrix Sum */ public function minus(...$args) @@ -626,8 +615,6 @@ public function minus(...$args) * * A = A - B * - * @param mixed $B Matrix/Array - * * @return $this */ public function minusEquals(...$args) @@ -686,8 +673,6 @@ public function minusEquals(...$args) * Element-by-element multiplication * Cij = Aij * Bij * - * @param mixed $B Matrix/Array - * * @return Matrix Matrix Cij */ public function arrayTimes(...$args) @@ -732,8 +717,6 @@ public function arrayTimes(...$args) * Element-by-element multiplication * Aij = Aij * Bij * - * @param mixed $B Matrix/Array - * * @return $this */ public function arrayTimesEquals(...$args) @@ -792,8 +775,6 @@ public function arrayTimesEquals(...$args) * Element-by-element right division * A / B * - * @param Matrix $B Matrix B - * * @return Matrix Division result */ public function arrayRightDivide(...$args) @@ -857,8 +838,6 @@ public function arrayRightDivide(...$args) * Element-by-element right division * Aij = Aij / Bij * - * @param mixed $B Matrix/Array - * * @return Matrix Matrix Aij */ public function arrayRightDivideEquals(...$args) @@ -903,8 +882,6 @@ public function arrayRightDivideEquals(...$args) * Element-by-element Left division * A / B * - * @param Matrix $B Matrix B - * * @return Matrix Division result */ public function arrayLeftDivide(...$args) @@ -949,8 +926,6 @@ public function arrayLeftDivide(...$args) * Element-by-element Left division * Aij = Aij / Bij * - * @param mixed $B Matrix/Array - * * @return Matrix Matrix Aij */ public function arrayLeftDivideEquals(...$args) @@ -994,8 +969,6 @@ public function arrayLeftDivideEquals(...$args) * * Matrix multiplication * - * @param mixed $n Matrix/Array/Scalar - * * @return Matrix Product */ public function times(...$args) @@ -1089,8 +1062,6 @@ public function times(...$args) * * A = A ^ B * - * @param mixed $B Matrix/Array - * * @return $this */ public function power(...$args) @@ -1130,7 +1101,7 @@ public function power(...$args) $validValues &= StringHelper::convertToNumberIfFraction($value); } if ($validValues) { - $this->A[$i][$j] = pow($this->A[$i][$j], $value); + $this->A[$i][$j] = $this->A[$i][$j] ** $value; } else { $this->A[$i][$j] = Functions::NAN(); } @@ -1148,8 +1119,6 @@ public function power(...$args) * * A = A & B * - * @param mixed $B Matrix/Array - * * @return $this */ public function concat(...$args) diff --git a/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php index 3ca95619c8..b997fb7cc1 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php +++ b/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php @@ -117,7 +117,7 @@ public function __construct($Arg) } } - if ($wantu and ($k < $nct)) { + if ($wantu && ($k < $nct)) { // Place the transformation in U for subsequent back // multiplication. for ($i = $k; $i < $this->m; ++$i) { @@ -143,7 +143,7 @@ public function __construct($Arg) $e[$k + 1] += 1.0; } $e[$k] = -$e[$k]; - if (($k + 1 < $this->m) and ($e[$k] != 0.0)) { + if (($k + 1 < $this->m) && ($e[$k] != 0.0)) { // Apply the transformation. for ($i = $k + 1; $i < $this->m; ++$i) { $work[$i] = 0.0; @@ -221,7 +221,7 @@ public function __construct($Arg) // If required, generate V. if ($wantv) { for ($k = $this->n - 1; $k >= 0; --$k) { - if (($k < $nrt) and ($e[$k] != 0.0)) { + if (($k < $nrt) && ($e[$k] != 0.0)) { for ($j = $k + 1; $j < $nu; ++$j) { $t = 0; for ($i = $k + 1; $i < $this->n; ++$i) { @@ -243,7 +243,7 @@ public function __construct($Arg) // Main iteration loop for the singular values. $pp = $p - 1; $iter = 0; - $eps = pow(2.0, -52.0); + $eps = 2.0 ** (-52.0); while ($p > 0) { // Here is where a test for too many iterations would go. @@ -415,14 +415,14 @@ public function __construct($Arg) $t = $this->s[$k]; $this->s[$k] = $this->s[$k + 1]; $this->s[$k + 1] = $t; - if ($wantv and ($k < $this->n - 1)) { + if ($wantv && ($k < $this->n - 1)) { for ($i = 0; $i < $this->n; ++$i) { $t = $this->V[$i][$k + 1]; $this->V[$i][$k + 1] = $this->V[$i][$k]; $this->V[$i][$k] = $t; } } - if ($wantu and ($k < $this->m - 1)) { + if ($wantu && ($k < $this->m - 1)) { for ($i = 0; $i < $this->m; ++$i) { $t = $this->U[$i][$k + 1]; $this->U[$i][$k + 1] = $this->U[$i][$k]; @@ -513,7 +513,7 @@ public function cond() */ public function rank() { - $eps = pow(2.0, -52.0); + $eps = 2.0 ** (-52.0); $tol = max($this->m, $this->n) * $this->s[0] * $eps; $r = 0; $iMax = count($this->s); diff --git a/src/PhpSpreadsheet/Shared/OLE.php b/src/PhpSpreadsheet/Shared/OLE.php index 81ebaa34ed..27c72acd0e 100644 --- a/src/PhpSpreadsheet/Shared/OLE.php +++ b/src/PhpSpreadsheet/Shared/OLE.php @@ -117,7 +117,7 @@ class OLE */ public function read($file) { - $fh = fopen($file, 'r'); + $fh = fopen($file, 'rb'); if (!$fh) { throw new ReaderException("Can't open file $file"); } @@ -133,8 +133,8 @@ public function read($file) throw new ReaderException('Only Little-Endian encoding is supported.'); } // Size of blocks and short blocks in bytes - $this->bigBlockSize = pow(2, self::_readInt2($fh)); - $this->smallBlockSize = pow(2, self::_readInt2($fh)); + $this->bigBlockSize = 2 ** self::_readInt2($fh); + $this->smallBlockSize = 2 ** self::_readInt2($fh); // Skip UID, revision number and version number fseek($fh, 44); @@ -239,7 +239,7 @@ public function getStream($blockIdOrPps) $path .= '&blockId=' . $blockIdOrPps; } - return fopen($path, 'r'); + return fopen($path, 'rb'); } /** @@ -502,7 +502,7 @@ public static function localDateToOLE($date) } // factor used for separating numbers into 4 bytes parts - $factor = pow(2, 32); + $factor = 2 ** 32; // days from 1-1-1601 until the beggining of UNIX era $days = 134774; diff --git a/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php b/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php index e6ba72428f..ecaa97ed35 100644 --- a/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php +++ b/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php @@ -101,7 +101,7 @@ public function stream_open($path, $mode, $options, &$openedPath) // @codingStan /** * Implements support for fclose(). */ - public function stream_close() // @codingStandardsIgnoreLine + public function stream_close(): void // @codingStandardsIgnoreLine { $this->ole = null; unset($GLOBALS['_OLE_INSTANCES']); @@ -179,7 +179,7 @@ public function stream_stat() // @codingStandardsIgnoreLine { return [ 'size' => strlen($this->data), - ]; + ]; } // Methods used by stream_wrapper_register() that are not implemented: diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/File.php b/src/PhpSpreadsheet/Shared/OLE/PPS/File.php index 68f50a5c8c..b7425af43f 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/File.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/File.php @@ -59,7 +59,7 @@ public function init() * * @param string $data The data to append */ - public function append($data) + public function append($data): void { $this->_data .= $data; } diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php index 472483ebaa..0d70df6d29 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php @@ -73,14 +73,12 @@ public function save($fileHandle) $this->fileHandle = $fileHandle; // Initial Setting for saving - $this->bigBlockSize = pow( - 2, + $this->bigBlockSize = 2 ** ( (isset($this->bigBlockSize)) ? self::adjust2($this->bigBlockSize) : 9 - ); - $this->smallBlockSize = pow( - 2, + ); + $this->smallBlockSize = 2 ** ( (isset($this->smallBlockSize)) ? self::adjust2($this->smallBlockSize) : 6 - ); + ); // Make an array of PPS's (for Save) $aList = []; @@ -122,7 +120,7 @@ public function _calcSize(&$raList) $raList[$i]->Size = $raList[$i]->getDataLen(); if ($raList[$i]->Size < OLE::OLE_DATA_SIZE_SMALL) { $iSBcnt += floor($raList[$i]->Size / $this->smallBlockSize) - + (($raList[$i]->Size % $this->smallBlockSize) ? 1 : 0); + + (($raList[$i]->Size % $this->smallBlockSize) ? 1 : 0); } else { $iBBcnt += (floor($raList[$i]->Size / $this->bigBlockSize) + (($raList[$i]->Size % $this->bigBlockSize) ? 1 : 0)); @@ -133,7 +131,7 @@ public function _calcSize(&$raList) $iSlCnt = floor($this->bigBlockSize / OLE::OLE_LONG_INT_SIZE); $iSBDcnt = floor($iSBcnt / $iSlCnt) + (($iSBcnt % $iSlCnt) ? 1 : 0); $iBBcnt += (floor($iSmallLen / $this->bigBlockSize) + - (($iSmallLen % $this->bigBlockSize) ? 1 : 0)); + (($iSmallLen % $this->bigBlockSize) ? 1 : 0)); $iCnt = count($raList); $iBdCnt = $this->bigBlockSize / OLE::OLE_PPS_SIZE; $iPPScnt = (floor($iCnt / $iBdCnt) + (($iCnt % $iBdCnt) ? 1 : 0)); @@ -146,9 +144,9 @@ public function _calcSize(&$raList) * * @param int $i2 The argument * - * @see save() - * * @return float + * + * @see save() */ private static function adjust2($i2) { @@ -164,7 +162,7 @@ private static function adjust2($i2) * @param int $iBBcnt * @param int $iPPScnt */ - public function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt) + public function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt): void { $FILE = $this->fileHandle; @@ -243,7 +241,7 @@ public function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt) * @param int $iStBlk * @param array &$raList Reference to array of PPS's */ - public function _saveBigData($iStBlk, &$raList) + public function _saveBigData($iStBlk, &$raList): void { $FILE = $this->fileHandle; @@ -261,8 +259,8 @@ public function _saveBigData($iStBlk, &$raList) // Set For PPS $raList[$i]->startBlock = $iStBlk; $iStBlk += - (floor($raList[$i]->Size / $this->bigBlockSize) + - (($raList[$i]->Size % $this->bigBlockSize) ? 1 : 0)); + (floor($raList[$i]->Size / $this->bigBlockSize) + + (($raList[$i]->Size % $this->bigBlockSize) ? 1 : 0)); } } } @@ -290,7 +288,7 @@ public function _makeSmallData(&$raList) } if ($raList[$i]->Size < OLE::OLE_DATA_SIZE_SMALL) { $iSmbCnt = floor($raList[$i]->Size / $this->smallBlockSize) - + (($raList[$i]->Size % $this->smallBlockSize) ? 1 : 0); + + (($raList[$i]->Size % $this->smallBlockSize) ? 1 : 0); // Add to SBD $jB = $iSmbCnt - 1; for ($j = 0; $j < $jB; ++$j) { @@ -325,7 +323,7 @@ public function _makeSmallData(&$raList) * * @param array $raList Reference to an array with all PPS's */ - public function _savePps(&$raList) + public function _savePps(&$raList): void { // Save each PPS WK $iC = count($raList); @@ -347,7 +345,7 @@ public function _savePps(&$raList) * @param int $iBsize * @param int $iPpsCnt */ - public function _saveBbd($iSbdSize, $iBsize, $iPpsCnt) + public function _saveBbd($iSbdSize, $iBsize, $iPpsCnt): void { $FILE = $this->fileHandle; // Calculate Basic Setting diff --git a/src/PhpSpreadsheet/Shared/OLERead.php b/src/PhpSpreadsheet/Shared/OLERead.php index 3526c7e69c..b6d5422c40 100644 --- a/src/PhpSpreadsheet/Shared/OLERead.php +++ b/src/PhpSpreadsheet/Shared/OLERead.php @@ -95,7 +95,7 @@ class OLERead * * @param $pFilename string Filename */ - public function read($pFilename) + public function read($pFilename): void { File::assertFile($pFilename); @@ -258,7 +258,7 @@ private function _readData($bl) /** * Read entries in the directory stream. */ - private function readPropertySets() + private function readPropertySets(): void { $offset = 0; diff --git a/src/PhpSpreadsheet/Shared/StringHelper.php b/src/PhpSpreadsheet/Shared/StringHelper.php index d949203bab..9ae324132d 100644 --- a/src/PhpSpreadsheet/Shared/StringHelper.php +++ b/src/PhpSpreadsheet/Shared/StringHelper.php @@ -63,7 +63,7 @@ class StringHelper /** * Build control characters array. */ - private static function buildControlCharacters() + private static function buildControlCharacters(): void { for ($i = 0; $i <= 31; ++$i) { if ($i != 9 && $i != 10 && $i != 13) { @@ -77,7 +77,7 @@ private static function buildControlCharacters() /** * Build SYLK characters array. */ - private static function buildSYLKCharacters() + private static function buildSYLKCharacters(): void { self::$SYLKCharacters = [ "\x1B 0" => chr(0), @@ -272,7 +272,7 @@ public static function getIsIconvEnabled() return self::$isIconvEnabled; } - private static function buildCharacterSets() + private static function buildCharacterSets(): void { if (empty(self::$controlCharacters)) { self::buildControlCharacters(); @@ -603,7 +603,7 @@ public static function getDecimalSeparator() * * @param string $pValue Character for decimal separator */ - public static function setDecimalSeparator($pValue) + public static function setDecimalSeparator($pValue): void { self::$decimalSeparator = $pValue; } @@ -636,7 +636,7 @@ public static function getThousandsSeparator() * * @param string $pValue Character for thousands separator */ - public static function setThousandsSeparator($pValue) + public static function setThousandsSeparator($pValue): void { self::$thousandsSeparator = $pValue; } @@ -674,7 +674,7 @@ public static function getCurrencyCode() * * @param string $pValue Character for currency code */ - public static function setCurrencyCode($pValue) + public static function setCurrencyCode($pValue): void { self::$currencyCode = $pValue; } diff --git a/src/PhpSpreadsheet/Shared/Trend/BestFit.php b/src/PhpSpreadsheet/Shared/Trend/BestFit.php index d8e63d5e28..c94997226b 100644 --- a/src/PhpSpreadsheet/Shared/Trend/BestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/BestFit.php @@ -341,7 +341,7 @@ public function getYBestFitValues() return $this->yBestFitValues; } - protected function calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const) + protected function calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const): void { $SSres = $SScov = $SScor = $SStot = $SSsex = 0.0; foreach ($this->xValues as $xKey => $xValue) { @@ -377,7 +377,7 @@ protected function calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $this->SSRegression = $this->goodnessOfFit * $SStot; $this->covariance = $SScov / $this->valueCount; - $this->correlation = ($this->valueCount * $sumXY - $sumX * $sumY) / sqrt(($this->valueCount * $sumX2 - pow($sumX, 2)) * ($this->valueCount * $sumY2 - pow($sumY, 2))); + $this->correlation = ($this->valueCount * $sumXY - $sumX * $sumY) / sqrt(($this->valueCount * $sumX2 - $sumX ** 2) * ($this->valueCount * $sumY2 - $sumY ** 2)); $this->slopeSE = $this->stdevOfResiduals / sqrt($SSsex); $this->intersectSE = $this->stdevOfResiduals * sqrt(1 / ($this->valueCount - ($sumX * $sumX) / $sumX2)); if ($this->SSResiduals != 0.0) { @@ -400,7 +400,7 @@ protected function calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, * @param float[] $xValues * @param bool $const */ - protected function leastSquareFit(array $yValues, array $xValues, $const) + protected function leastSquareFit(array $yValues, array $xValues, $const): void { // calculate sums $x_sum = array_sum($xValues); diff --git a/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php b/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php index 5b57f4b71f..82866dee80 100644 --- a/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php @@ -21,7 +21,7 @@ class ExponentialBestFit extends BestFit */ public function getValueOfYForX($xValue) { - return $this->getIntersect() * pow($this->getSlope(), ($xValue - $this->xOffset)); + return $this->getIntersect() * $this->getSlope() ** ($xValue - $this->xOffset); } /** @@ -90,7 +90,7 @@ public function getIntersect($dp = 0) * @param float[] $xValues The set of X-values for this regression * @param bool $const */ - private function exponentialRegression($yValues, $xValues, $const) + private function exponentialRegression($yValues, $xValues, $const): void { foreach ($yValues as &$value) { if ($value < 0.0) { diff --git a/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php b/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php index 217f096477..26a562c551 100644 --- a/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php @@ -58,7 +58,7 @@ public function getEquation($dp = 0) * @param float[] $xValues The set of X-values for this regression * @param bool $const */ - private function linearRegression($yValues, $xValues, $const) + private function linearRegression($yValues, $xValues, $const): void { $this->leastSquareFit($yValues, $xValues, $const); } diff --git a/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php b/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php index 96ca2ed879..c469067d47 100644 --- a/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php @@ -58,7 +58,7 @@ public function getEquation($dp = 0) * @param float[] $xValues The set of X-values for this regression * @param bool $const */ - private function logarithmicRegression($yValues, $xValues, $const) + private function logarithmicRegression($yValues, $xValues, $const): void { foreach ($xValues as &$value) { if ($value < 0.0) { diff --git a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php index a1510491f7..d959eddb75 100644 --- a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php @@ -44,7 +44,7 @@ public function getValueOfYForX($xValue) $slope = $this->getSlope(); foreach ($slope as $key => $value) { if ($value != 0.0) { - $retVal += $value * pow($xValue, $key + 1); + $retVal += $value * $xValue ** ($key + 1); } } @@ -121,7 +121,7 @@ public function getCoefficients($dp = 0) * @param float[] $yValues The set of Y-values for this regression * @param float[] $xValues The set of X-values for this regression */ - private function polynomialRegression($order, $yValues, $xValues) + private function polynomialRegression($order, $yValues, $xValues): void { // calculate sums $x_sum = array_sum($xValues); @@ -144,7 +144,7 @@ private function polynomialRegression($order, $yValues, $xValues) $B = []; for ($i = 0; $i < $this->valueCount; ++$i) { for ($j = 0; $j <= $order; ++$j) { - $A[$i][$j] = pow($xValues[$i], $j); + $A[$i][$j] = $xValues[$i] ** $j; } } for ($i = 0; $i < $this->valueCount; ++$i) { @@ -157,7 +157,7 @@ private function polynomialRegression($order, $yValues, $xValues) $coefficients = []; for ($i = 0; $i < $C->getRowDimension(); ++$i) { $r = $C->get($i, 0); - if (abs($r) <= pow(10, -9)) { + if (abs($r) <= 10 ** (-9)) { $r = 0; } $coefficients[] = $r; diff --git a/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php b/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php index 4eefec8265..c53eab6381 100644 --- a/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php @@ -21,7 +21,7 @@ class PowerBestFit extends BestFit */ public function getValueOfYForX($xValue) { - return $this->getIntersect() * pow(($xValue - $this->xOffset), $this->getSlope()); + return $this->getIntersect() * ($xValue - $this->xOffset) ** $this->getSlope(); } /** @@ -33,7 +33,7 @@ public function getValueOfYForX($xValue) */ public function getValueOfXForY($yValue) { - return pow((($yValue + $this->yOffset) / $this->getIntersect()), (1 / $this->getSlope())); + return (($yValue + $this->yOffset) / $this->getIntersect()) ** (1 / $this->getSlope()); } /** @@ -74,7 +74,7 @@ public function getIntersect($dp = 0) * @param float[] $xValues The set of X-values for this regression * @param bool $const */ - private function powerRegression($yValues, $xValues, $const) + private function powerRegression($yValues, $xValues, $const): void { foreach ($xValues as &$value) { if ($value < 0.0) { diff --git a/src/PhpSpreadsheet/Shared/Xls.php b/src/PhpSpreadsheet/Shared/Xls.php index b8ce5e2daa..c9eaf378b6 100644 --- a/src/PhpSpreadsheet/Shared/Xls.php +++ b/src/PhpSpreadsheet/Shared/Xls.php @@ -25,7 +25,7 @@ public static function sizeCol($sheet, $col = 'A') $columnDimensions = $sheet->getColumnDimensions(); // first find the true column width in pixels (uncollapsed and unhidden) - if (isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1) { + if (isset($columnDimensions[$col]) && $columnDimensions[$col]->getWidth() != -1) { // then we have column dimension with explicit width $columnDimension = $columnDimensions[$col]; $width = $columnDimension->getWidth(); @@ -41,7 +41,7 @@ public static function sizeCol($sheet, $col = 'A') } // now find the effective column width in pixels - if (isset($columnDimensions[$col]) and !$columnDimensions[$col]->getVisible()) { + if (isset($columnDimensions[$col]) && !$columnDimensions[$col]->getVisible()) { $effectivePixelWidth = 0; } else { $effectivePixelWidth = $pixelWidth; @@ -68,7 +68,7 @@ public static function sizeRow($sheet, $row = 1) $rowDimensions = $sheet->getRowDimensions(); // first find the true row height in pixels (uncollapsed and unhidden) - if (isset($rowDimensions[$row]) and $rowDimensions[$row]->getRowHeight() != -1) { + if (isset($rowDimensions[$row]) && $rowDimensions[$row]->getRowHeight() != -1) { // then we have a row dimension $rowDimension = $rowDimensions[$row]; $rowHeight = $rowDimension->getRowHeight(); @@ -85,7 +85,7 @@ public static function sizeRow($sheet, $row = 1) } // now find the effective row height in pixels - if (isset($rowDimensions[$row]) and !$rowDimensions[$row]->getVisible()) { + if (isset($rowDimensions[$row]) && !$rowDimensions[$row]->getVisible()) { $effectivePixelRowHeight = 0; } else { $effectivePixelRowHeight = $pixelRowHeight; @@ -98,7 +98,6 @@ public static function sizeRow($sheet, $row = 1) * Get the horizontal distance in pixels between two anchors * The distanceX is found as sum of all the spanning columns widths minus correction for the two offsets. * - * @param Worksheet $sheet * @param string $startColumn * @param int $startOffsetX Offset within start cell measured in 1/1024 of the cell width * @param string $endColumn @@ -130,7 +129,6 @@ public static function getDistanceX(Worksheet $sheet, $startColumn = 'A', $start * Get the vertical distance in pixels between two anchors * The distanceY is found as sum of all the spanning rows minus two offsets. * - * @param Worksheet $sheet * @param int $startRow (1-based) * @param int $startOffsetY Offset within start cell measured in 1/256 of the cell height * @param int $endRow (1-based) diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index 6023c61668..322d5f7c04 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -210,7 +210,7 @@ public function hasMacros() * * @param bool $hasMacros true|false */ - public function setHasMacros($hasMacros) + public function setHasMacros($hasMacros): void { $this->hasMacros = (bool) $hasMacros; } @@ -220,7 +220,7 @@ public function setHasMacros($hasMacros) * * @param string $macroCode string|null */ - public function setMacrosCode($macroCode) + public function setMacrosCode($macroCode): void { $this->macrosCode = $macroCode; $this->setHasMacros($macroCode !== null); @@ -241,7 +241,7 @@ public function getMacrosCode() * * @param null|string $certificate */ - public function setMacrosCertificate($certificate) + public function setMacrosCertificate($certificate): void { $this->macrosCertificate = $certificate; } @@ -269,7 +269,7 @@ public function getMacrosCertificate() /** * Remove all macros, certificate from spreadsheet. */ - public function discardMacros() + public function discardMacros(): void { $this->hasMacros = false; $this->macrosCode = null; @@ -282,7 +282,7 @@ public function discardMacros() * @param null|mixed $target * @param null|mixed $xmlData */ - public function setRibbonXMLData($target, $xmlData) + public function setRibbonXMLData($target, $xmlData): void { if ($target !== null && $xmlData !== null) { $this->ribbonXMLData = ['target' => $target, 'data' => $xmlData]; @@ -327,7 +327,7 @@ public function getRibbonXMLData($what = 'all') //we need some constants here... * @param null|mixed $BinObjectsNames * @param null|mixed $BinObjectsData */ - public function setRibbonBinObjects($BinObjectsNames, $BinObjectsData) + public function setRibbonBinObjects($BinObjectsNames, $BinObjectsData): void { if ($BinObjectsNames !== null && $BinObjectsData !== null) { $this->ribbonBinObjects = ['names' => $BinObjectsNames, 'data' => $BinObjectsData]; @@ -354,10 +354,8 @@ public function getUnparsedLoadedData() * It has to be minimized when the library start to support currently unparsed data. * * @internal - * - * @param array $unparsedLoadedData */ - public function setUnparsedLoadedData(array $unparsedLoadedData) + public function setUnparsedLoadedData(array $unparsedLoadedData): void { $this->unparsedLoadedData = $unparsedLoadedData; } @@ -507,7 +505,7 @@ public function __destruct() * Disconnect all worksheets from this PhpSpreadsheet workbook object, * typically so that the PhpSpreadsheet object can be unset. */ - public function disconnectWorksheets() + public function disconnectWorksheets(): void { $worksheet = null; foreach ($this->workSheetCollection as $k => &$worksheet) { @@ -540,10 +538,8 @@ public function getProperties() /** * Set properties. - * - * @param Document\Properties $pValue */ - public function setProperties(Document\Properties $pValue) + public function setProperties(Document\Properties $pValue): void { $this->properties = $pValue; } @@ -560,10 +556,8 @@ public function getSecurity() /** * Set security. - * - * @param Document\Security $pValue */ - public function setSecurity(Document\Security $pValue) + public function setSecurity(Document\Security $pValue): void { $this->security = $pValue; } @@ -608,7 +602,6 @@ public function sheetNameExists($pSheetName) /** * Add sheet. * - * @param Worksheet $pSheet * @param null|int $iSheetIndex Index where sheet should go (0,1,..., or null for last) * * @return Worksheet @@ -653,7 +646,7 @@ public function addSheet(Worksheet $pSheet, $iSheetIndex = null) * * @param int $pIndex Active sheet index */ - public function removeSheetByIndex($pIndex) + public function removeSheetByIndex($pIndex): void { $numSheets = count($this->workSheetCollection); if ($pIndex > $numSheets - 1) { @@ -722,8 +715,6 @@ public function getSheetByName($pName) /** * Get index for sheet. * - * @param Worksheet $pSheet - * * @return int index */ public function getIndex(Worksheet $pSheet) @@ -885,8 +876,6 @@ public function getNamedRanges() /** * Add named range. * - * @param NamedRange $namedRange - * * @return bool */ public function addNamedRange(NamedRange $namedRange) @@ -910,7 +899,7 @@ public function addNamedRange(NamedRange $namedRange) * * @return null|NamedRange */ - public function getNamedRange($namedRange, Worksheet $pSheet = null) + public function getNamedRange($namedRange, ?Worksheet $pSheet = null) { $returnValue = null; @@ -937,7 +926,7 @@ public function getNamedRange($namedRange, Worksheet $pSheet = null) * * @return $this */ - public function removeNamedRange($namedRange, Worksheet $pSheet = null) + public function removeNamedRange($namedRange, ?Worksheet $pSheet = null) { if ($pSheet === null) { if (isset($this->namedRanges[$namedRange])) { @@ -1060,10 +1049,8 @@ public function getDefaultStyle() /** * Add a cellXf to the workbook. - * - * @param Style $style */ - public function addCellXf(Style $style) + public function addCellXf(Style $style): void { $this->cellXfCollection[] = $style; $style->setIndex(count($this->cellXfCollection) - 1); @@ -1074,7 +1061,7 @@ public function addCellXf(Style $style) * * @param int $pIndex Index to cellXf */ - public function removeCellXfByIndex($pIndex) + public function removeCellXfByIndex($pIndex): void { if ($pIndex > count($this->cellXfCollection) - 1) { throw new Exception('CellXf index is out of bounds.'); @@ -1151,10 +1138,8 @@ public function getCellStyleXfByHashCode($pValue) /** * Add a cellStyleXf to the workbook. - * - * @param Style $pStyle */ - public function addCellStyleXf(Style $pStyle) + public function addCellStyleXf(Style $pStyle): void { $this->cellStyleXfCollection[] = $pStyle; $pStyle->setIndex(count($this->cellStyleXfCollection) - 1); @@ -1165,7 +1150,7 @@ public function addCellStyleXf(Style $pStyle) * * @param int $pIndex Index to cellXf */ - public function removeCellStyleXfByIndex($pIndex) + public function removeCellStyleXfByIndex($pIndex): void { if ($pIndex > count($this->cellStyleXfCollection) - 1) { throw new Exception('CellStyleXf index is out of bounds.'); @@ -1177,7 +1162,7 @@ public function removeCellStyleXfByIndex($pIndex) * Eliminate all unneeded cellXf and afterwards update the xfIndex for all cells * and columns in the workbook. */ - public function garbageCollect() + public function garbageCollect(): void { // how many references are there to each cellXf ? $countReferencesCellXf = []; @@ -1278,7 +1263,7 @@ public function getShowHorizontalScroll() * * @param bool $showHorizontalScroll True if horizonal scroll bar is visible */ - public function setShowHorizontalScroll($showHorizontalScroll) + public function setShowHorizontalScroll($showHorizontalScroll): void { $this->showHorizontalScroll = (bool) $showHorizontalScroll; } @@ -1298,7 +1283,7 @@ public function getShowVerticalScroll() * * @param bool $showVerticalScroll True if vertical scroll bar is visible */ - public function setShowVerticalScroll($showVerticalScroll) + public function setShowVerticalScroll($showVerticalScroll): void { $this->showVerticalScroll = (bool) $showVerticalScroll; } @@ -1318,7 +1303,7 @@ public function getShowSheetTabs() * * @param bool $showSheetTabs True if sheet tabs are visible */ - public function setShowSheetTabs($showSheetTabs) + public function setShowSheetTabs($showSheetTabs): void { $this->showSheetTabs = (bool) $showSheetTabs; } @@ -1338,7 +1323,7 @@ public function getMinimized() * * @param bool $minimized true if workbook window is minimized */ - public function setMinimized($minimized) + public function setMinimized($minimized): void { $this->minimized = (bool) $minimized; } @@ -1360,7 +1345,7 @@ public function getAutoFilterDateGrouping() * * @param bool $autoFilterDateGrouping true if workbook window is minimized */ - public function setAutoFilterDateGrouping($autoFilterDateGrouping) + public function setAutoFilterDateGrouping($autoFilterDateGrouping): void { $this->autoFilterDateGrouping = (bool) $autoFilterDateGrouping; } @@ -1380,7 +1365,7 @@ public function getFirstSheetIndex() * * @param int $firstSheetIndex First sheet in book view */ - public function setFirstSheetIndex($firstSheetIndex) + public function setFirstSheetIndex($firstSheetIndex): void { if ($firstSheetIndex >= 0) { $this->firstSheetIndex = (int) $firstSheetIndex; @@ -1417,7 +1402,7 @@ public function getVisibility() * * @param string $visibility visibility status of the workbook */ - public function setVisibility($visibility) + public function setVisibility($visibility): void { if ($visibility === null) { $visibility = self::VISIBILITY_VISIBLE; @@ -1447,7 +1432,7 @@ public function getTabRatio() * * @param int $tabRatio Ratio between the tabs bar and the horizontal scroll bar */ - public function setTabRatio($tabRatio) + public function setTabRatio($tabRatio): void { if ($tabRatio >= 0 || $tabRatio <= 1000) { $this->tabRatio = (int) $tabRatio; diff --git a/src/PhpSpreadsheet/Style/Border.php b/src/PhpSpreadsheet/Style/Border.php index 2e076a9267..78ad8b2639 100644 --- a/src/PhpSpreadsheet/Style/Border.php +++ b/src/PhpSpreadsheet/Style/Border.php @@ -194,8 +194,6 @@ public function getColor() /** * Set Border Color. * - * @param Color $pValue - * * @return $this */ public function setColor(Color $pValue) diff --git a/src/PhpSpreadsheet/Style/Conditional.php b/src/PhpSpreadsheet/Style/Conditional.php index 2b096a34aa..35ec479ba5 100644 --- a/src/PhpSpreadsheet/Style/Conditional.php +++ b/src/PhpSpreadsheet/Style/Conditional.php @@ -234,7 +234,7 @@ public function getStyle() * * @return $this */ - public function setStyle(Style $pValue = null) + public function setStyle(?Style $pValue = null) { $this->style = $pValue; diff --git a/src/PhpSpreadsheet/Style/Fill.php b/src/PhpSpreadsheet/Style/Fill.php index 789a9801d5..c6baeed032 100644 --- a/src/PhpSpreadsheet/Style/Fill.php +++ b/src/PhpSpreadsheet/Style/Fill.php @@ -244,8 +244,6 @@ public function getStartColor() /** * Set Start Color. * - * @param Color $pValue - * * @return $this */ public function setStartColor(Color $pValue) @@ -276,8 +274,6 @@ public function getEndColor() /** * Set End Color. * - * @param Color $pValue - * * @return $this */ public function setEndColor(Color $pValue) diff --git a/src/PhpSpreadsheet/Style/Font.php b/src/PhpSpreadsheet/Style/Font.php index 5ab58dcae6..eee7df0448 100644 --- a/src/PhpSpreadsheet/Style/Font.php +++ b/src/PhpSpreadsheet/Style/Font.php @@ -504,8 +504,6 @@ public function getColor() /** * Set Color. * - * @param Color $pValue - * * @return $this */ public function setColor(Color $pValue) diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index 1f4a6c0c74..259acabf8c 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -228,7 +228,7 @@ public function setBuiltInFormatCode($pValue) /** * Fill built-in format codes. */ - private static function fillBuiltInFormatCodes() + private static function fillBuiltInFormatCodes(): void { // [MS-OI29500: Microsoft Office Implementation Information for ISO/IEC-29500 Standard Compliance] // 18.8.30. numFmt (Number Format) @@ -395,43 +395,43 @@ public function getHashCode() * @var array */ private static $dateFormatReplacements = [ - // first remove escapes related to non-format characters - '\\' => '', - // 12-hour suffix - 'am/pm' => 'A', - // 4-digit year - 'e' => 'Y', - 'yyyy' => 'Y', - // 2-digit year - 'yy' => 'y', - // first letter of month - no php equivalent - 'mmmmm' => 'M', - // full month name - 'mmmm' => 'F', - // short month name - 'mmm' => 'M', - // mm is minutes if time, but can also be month w/leading zero - // so we try to identify times be the inclusion of a : separator in the mask - // It isn't perfect, but the best way I know how - ':mm' => ':i', - 'mm:' => 'i:', - // month leading zero - 'mm' => 'm', - // month no leading zero - 'm' => 'n', - // full day of week name - 'dddd' => 'l', - // short day of week name - 'ddd' => 'D', - // days leading zero - 'dd' => 'd', - // days no leading zero - 'd' => 'j', - // seconds - 'ss' => 's', - // fractional seconds - no php equivalent - '.s' => '', - ]; + // first remove escapes related to non-format characters + '\\' => '', + // 12-hour suffix + 'am/pm' => 'A', + // 4-digit year + 'e' => 'Y', + 'yyyy' => 'Y', + // 2-digit year + 'yy' => 'y', + // first letter of month - no php equivalent + 'mmmmm' => 'M', + // full month name + 'mmmm' => 'F', + // short month name + 'mmm' => 'M', + // mm is minutes if time, but can also be month w/leading zero + // so we try to identify times be the inclusion of a : separator in the mask + // It isn't perfect, but the best way I know how + ':mm' => ':i', + 'mm:' => 'i:', + // month leading zero + 'mm' => 'm', + // month no leading zero + 'm' => 'n', + // full day of week name + 'dddd' => 'l', + // short day of week name + 'ddd' => 'D', + // days leading zero + 'dd' => 'd', + // days no leading zero + 'd' => 'j', + // seconds + 'ss' => 's', + // fractional seconds - no php equivalent + '.s' => '', + ]; /** * Search/replace values to convert Excel date/time format masks hours to PHP format masks (24 hr clock). @@ -463,7 +463,7 @@ private static function escapeQuotesCallback($matches) return '\\' . implode('\\', str_split($matches[1])); } - private static function formatAsDate(&$value, &$format) + private static function formatAsDate(&$value, &$format): void { // strip off first part containing e.g. [$-F800] or [$USD-409] // general syntax: [$-] @@ -505,7 +505,7 @@ private static function formatAsDate(&$value, &$format) $value = $dateObj->format($format); } - private static function formatAsPercentage(&$value, &$format) + private static function formatAsPercentage(&$value, &$format): void { if ($format === self::FORMAT_PERCENTAGE) { $value = round((100 * $value), 0) . '%'; @@ -523,14 +523,14 @@ private static function formatAsPercentage(&$value, &$format) } } - private static function formatAsFraction(&$value, &$format) + private static function formatAsFraction(&$value, &$format): void { $sign = ($value < 0) ? '-' : ''; $integerPart = floor(abs($value)); $decimalPart = trim(fmod(abs($value), 1), '0.'); $decimalLength = strlen($decimalPart); - $decimalDivisor = pow(10, $decimalLength); + $decimalDivisor = 10 ** $decimalLength; $GCD = MathTrig::GCD($decimalPart, $decimalDivisor); @@ -686,7 +686,7 @@ private static function formatAsNumber($value, $format) $scale = 1; // same as no scale $matches = []; if (preg_match('/(#|0)(,+)/', $format, $matches)) { - $scale = pow(1000, strlen($matches[2])); + $scale = 1000 ** strlen($matches[2]); // strip the commas $format = preg_replace('/0,+/', '0', $format); diff --git a/src/PhpSpreadsheet/Style/Style.php b/src/PhpSpreadsheet/Style/Style.php index a37d99b5f5..533a7c3861 100644 --- a/src/PhpSpreadsheet/Style/Style.php +++ b/src/PhpSpreadsheet/Style/Style.php @@ -483,8 +483,6 @@ public function getFont() /** * Set font. * - * @param Font $font - * * @return $this */ public function setFont(Font $font) @@ -634,7 +632,7 @@ public function getIndex() * * @param int $pValue */ - public function setIndex($pValue) + public function setIndex($pValue): void { $this->index = $pValue; } diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index e6cd40e32c..c085b59604 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -38,7 +38,7 @@ class AutoFilter * @param string $pRange Cell range (i.e. A1:E10) * @param Worksheet $pSheet */ - public function __construct($pRange = '', Worksheet $pSheet = null) + public function __construct($pRange = '', ?Worksheet $pSheet = null) { $this->range = $pRange; $this->workSheet = $pSheet; @@ -61,7 +61,7 @@ public function getParent() * * @return $this */ - public function setParent(Worksheet $pSheet = null) + public function setParent(?Worksheet $pSheet = null) { $this->workSheet = $pSheet; diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php index a36740a3ef..09584a7aaa 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php @@ -94,7 +94,7 @@ class Column * @param string $pColumn Column (e.g. A) * @param AutoFilter $pParent Autofilter for this column */ - public function __construct($pColumn, AutoFilter $pParent = null) + public function __construct($pColumn, ?AutoFilter $pParent = null) { $this->columnIndex = $pColumn; $this->parent = $pParent; @@ -147,7 +147,7 @@ public function getParent() * * @return $this */ - public function setParent(AutoFilter $pParent = null) + public function setParent(?AutoFilter $pParent = null) { $this->parent = $pParent; @@ -308,8 +308,6 @@ public function createRule() /** * Add a new AutoFilter Column Rule to the ruleset. * - * @param Column\Rule $pRule - * * @return $this */ public function addRule(Column\Rule $pRule) diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php index 28286cee19..c0a15a7c49 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php @@ -240,7 +240,7 @@ class Rule * * @param Column $pParent */ - public function __construct(Column $pParent = null) + public function __construct(?Column $pParent = null) { $this->parent = $pParent; } @@ -416,7 +416,7 @@ public function getParent() * * @return $this */ - public function setParent(Column $pParent = null) + public function setParent(?Column $pParent = null) { $this->parent = $pParent; diff --git a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php index bcea3435b4..1b145a814e 100644 --- a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php @@ -205,7 +205,7 @@ public function getWorksheet() * * @return $this */ - public function setWorksheet(Worksheet $pValue = null, $pOverrideOld = false) + public function setWorksheet(?Worksheet $pValue = null, $pOverrideOld = false) { if ($this->worksheet === null) { // Add drawing to \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet @@ -471,7 +471,7 @@ public function getShadow() * * @return $this */ - public function setShadow(Drawing\Shadow $pValue = null) + public function setShadow(?Drawing\Shadow $pValue = null) { $this->shadow = $pValue; @@ -517,10 +517,7 @@ public function __clone() } } - /** - * @param null|Hyperlink $pHyperlink - */ - public function setHyperlink(Hyperlink $pHyperlink = null) + public function setHyperlink(?Hyperlink $pHyperlink = null): void { $this->hyperlink = $pHyperlink; } diff --git a/src/PhpSpreadsheet/Worksheet/CellIterator.php b/src/PhpSpreadsheet/Worksheet/CellIterator.php index 472609a369..45f76cab37 100644 --- a/src/PhpSpreadsheet/Worksheet/CellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/CellIterator.php @@ -2,7 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; -abstract class CellIterator implements \Iterator +use Iterator; + +abstract class CellIterator implements Iterator { /** * Worksheet to iterate. @@ -23,7 +25,7 @@ abstract class CellIterator implements \Iterator */ public function __destruct() { - unset($this->worksheet); + $this->worksheet = null; } /** @@ -46,7 +48,7 @@ abstract protected function adjustForExistingOnlyRange(); * * @param bool $value */ - public function setIterateOnlyExistingCells($value) + public function setIterateOnlyExistingCells($value): void { $this->onlyExistingCells = (bool) $value; diff --git a/src/PhpSpreadsheet/Worksheet/Column.php b/src/PhpSpreadsheet/Worksheet/Column.php index 098967f726..410e80735a 100644 --- a/src/PhpSpreadsheet/Worksheet/Column.php +++ b/src/PhpSpreadsheet/Worksheet/Column.php @@ -24,7 +24,7 @@ class Column * @param Worksheet $parent * @param string $columnIndex */ - public function __construct(Worksheet $parent = null, $columnIndex = 'A') + public function __construct(?Worksheet $parent = null, $columnIndex = 'A') { // Set parent and column index $this->parent = $parent; @@ -36,7 +36,7 @@ public function __construct(Worksheet $parent = null, $columnIndex = 'A') */ public function __destruct() { - unset($this->parent); + $this->parent = null; } /** diff --git a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php index 184f488803..ec16fbe5ec 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php @@ -43,7 +43,7 @@ class ColumnCellIterator extends CellIterator * @param int $startRow The row number at which to start iterating * @param int $endRow Optionally, the row number at which to stop iterating */ - public function __construct(Worksheet $subject = null, $columnIndex = 'A', $startRow = 1, $endRow = null) + public function __construct(?Worksheet $subject = null, $columnIndex = 'A', $startRow = 1, $endRow = null) { // Set subject $this->worksheet = $subject; @@ -105,7 +105,7 @@ public function seek($row = 1) /** * Rewind the iterator to the starting row. */ - public function rewind() + public function rewind(): void { $this->currentRow = $this->startRow; } @@ -133,7 +133,7 @@ public function key() /** * Set the iterator to its next value. */ - public function next() + public function next(): void { do { ++$this->currentRow; @@ -145,7 +145,7 @@ public function next() /** * Set the iterator to its previous value. */ - public function prev() + public function prev(): void { do { --$this->currentRow; @@ -167,7 +167,7 @@ public function valid() /** * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary. */ - protected function adjustForExistingOnlyRange() + protected function adjustForExistingOnlyRange(): void { if ($this->onlyExistingCells) { while ((!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->startRow)) && diff --git a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php index 0aff48599a..d0bb20cc96 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php @@ -2,11 +2,12 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use Iterator; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Exception; use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; -class ColumnIterator implements \Iterator +class ColumnIterator implements Iterator { /** * Worksheet to iterate. @@ -56,7 +57,7 @@ public function __construct(Worksheet $worksheet, $startColumn = 'A', $endColumn */ public function __destruct() { - unset($this->worksheet); + $this->worksheet = null; } /** @@ -118,7 +119,7 @@ public function seek($column = 'A') /** * Rewind the iterator to the starting column. */ - public function rewind() + public function rewind(): void { $this->currentColumnIndex = $this->startColumnIndex; } @@ -146,7 +147,7 @@ public function key() /** * Set the iterator to its next value. */ - public function next() + public function next(): void { ++$this->currentColumnIndex; } @@ -154,7 +155,7 @@ public function next() /** * Set the iterator to its previous value. */ - public function prev() + public function prev(): void { --$this->currentColumnIndex; } diff --git a/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php b/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php index c7594dae92..01ffed94d2 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php @@ -222,7 +222,7 @@ public function getColor() * * @return $this */ - public function setColor(Color $pValue = null) + public function setColor(?Color $pValue = null) { $this->color = $pValue; diff --git a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php index be19abbd27..cc37e7f5df 100644 --- a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php +++ b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php @@ -400,7 +400,6 @@ public function setAlignWithMargins($pValue) /** * Add header/footer image. * - * @param HeaderFooterDrawing $image * @param string $location * * @return $this diff --git a/src/PhpSpreadsheet/Worksheet/Iterator.php b/src/PhpSpreadsheet/Worksheet/Iterator.php index d8797a3473..6cfed37a47 100644 --- a/src/PhpSpreadsheet/Worksheet/Iterator.php +++ b/src/PhpSpreadsheet/Worksheet/Iterator.php @@ -22,8 +22,6 @@ class Iterator implements \Iterator /** * Create a new worksheet iterator. - * - * @param Spreadsheet $subject */ public function __construct(Spreadsheet $subject) { @@ -36,13 +34,13 @@ public function __construct(Spreadsheet $subject) */ public function __destruct() { - unset($this->subject); + $this->subject = null; } /** * Rewind iterator. */ - public function rewind() + public function rewind(): void { $this->position = 0; } @@ -70,7 +68,7 @@ public function key() /** * Next value. */ - public function next() + public function next(): void { ++$this->position; } diff --git a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php index f0935585da..22e09099d4 100644 --- a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php @@ -53,7 +53,7 @@ public function __construct() $this->imageResource = null; $this->renderingFunction = self::RENDERING_DEFAULT; $this->mimeType = self::MIMETYPE_DEFAULT; - $this->uniqueName = md5(rand(0, 9999) . time() . rand(0, 9999)); + $this->uniqueName = md5(mt_rand(0, 9999) . time() . mt_rand(0, 9999)); // Initialize parent parent::__construct(); diff --git a/src/PhpSpreadsheet/Worksheet/Row.php b/src/PhpSpreadsheet/Worksheet/Row.php index 2a379d2cd3..4f48a34618 100644 --- a/src/PhpSpreadsheet/Worksheet/Row.php +++ b/src/PhpSpreadsheet/Worksheet/Row.php @@ -24,7 +24,7 @@ class Row * @param Worksheet $worksheet * @param int $rowIndex */ - public function __construct(Worksheet $worksheet = null, $rowIndex = 1) + public function __construct(?Worksheet $worksheet = null, $rowIndex = 1) { // Set parent and row index $this->worksheet = $worksheet; @@ -36,7 +36,7 @@ public function __construct(Worksheet $worksheet = null, $rowIndex = 1) */ public function __destruct() { - unset($this->worksheet); + $this->worksheet = null; } /** diff --git a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php index 09a5b0a149..f5576dc797 100644 --- a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php @@ -43,7 +43,7 @@ class RowCellIterator extends CellIterator * @param string $startColumn The column address at which to start iterating * @param string $endColumn Optionally, the column address at which to stop iterating */ - public function __construct(Worksheet $worksheet = null, $rowIndex = 1, $startColumn = 'A', $endColumn = null) + public function __construct(?Worksheet $worksheet = null, $rowIndex = 1, $startColumn = 'A', $endColumn = null) { // Set subject and row index $this->worksheet = $worksheet; @@ -107,7 +107,7 @@ public function seek($column = 'A') /** * Rewind the iterator to the starting column. */ - public function rewind() + public function rewind(): void { $this->currentColumnIndex = $this->startColumnIndex; } @@ -135,7 +135,7 @@ public function key() /** * Set the iterator to its next value. */ - public function next() + public function next(): void { do { ++$this->currentColumnIndex; @@ -145,7 +145,7 @@ public function next() /** * Set the iterator to its previous value. */ - public function prev() + public function prev(): void { do { --$this->currentColumnIndex; @@ -175,7 +175,7 @@ public function getCurrentColumnIndex() /** * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary. */ - protected function adjustForExistingOnlyRange() + protected function adjustForExistingOnlyRange(): void { if ($this->onlyExistingCells) { while ((!$this->worksheet->cellExistsByColumnAndRow($this->startColumnIndex, $this->rowIndex)) && ($this->startColumnIndex <= $this->endColumnIndex)) { diff --git a/src/PhpSpreadsheet/Worksheet/RowIterator.php b/src/PhpSpreadsheet/Worksheet/RowIterator.php index 62cede7b25..4254253313 100644 --- a/src/PhpSpreadsheet/Worksheet/RowIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowIterator.php @@ -2,9 +2,10 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use Iterator; use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; -class RowIterator implements \Iterator +class RowIterator implements Iterator { /** * Worksheet to iterate. @@ -54,7 +55,7 @@ public function __construct(Worksheet $subject, $startRow = 1, $endRow = null) */ public function __destruct() { - unset($this->subject); + $this->subject = null; } /** @@ -113,7 +114,7 @@ public function seek($row = 1) /** * Rewind the iterator to the starting row. */ - public function rewind() + public function rewind(): void { $this->position = $this->startRow; } @@ -141,7 +142,7 @@ public function key() /** * Set the iterator to its next value. */ - public function next() + public function next(): void { ++$this->position; } @@ -149,7 +150,7 @@ public function next() /** * Set the iterator to its previous value. */ - public function prev() + public function prev(): void { --$this->position; } diff --git a/src/PhpSpreadsheet/Worksheet/SheetView.php b/src/PhpSpreadsheet/Worksheet/SheetView.php index e19ff80805..2f7d3812be 100644 --- a/src/PhpSpreadsheet/Worksheet/SheetView.php +++ b/src/PhpSpreadsheet/Worksheet/SheetView.php @@ -126,7 +126,7 @@ public function setZoomScaleNormal($pValue) * * @param bool $pValue */ - public function setShowZeros($pValue) + public function setShowZeros($pValue): void { $this->showZeros = $pValue; } diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index e8a61b78ae..1ed77e0560 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -344,7 +344,7 @@ class Worksheet implements IComparable * @param Spreadsheet $parent * @param string $pTitle */ - public function __construct(Spreadsheet $parent = null, $pTitle = 'Worksheet') + public function __construct(?Spreadsheet $parent = null, $pTitle = 'Worksheet') { // Set parent and title $this->parent = $parent; @@ -363,9 +363,9 @@ public function __construct(Spreadsheet $parent = null, $pTitle = 'Worksheet') // Set sheet view $this->sheetView = new SheetView(); // Drawing collection - $this->drawingCollection = new \ArrayObject(); + $this->drawingCollection = new ArrayObject(); // Chart collection - $this->chartCollection = new \ArrayObject(); + $this->chartCollection = new ArrayObject(); // Protection $this->protection = new Protection(); // Default row dimension @@ -379,7 +379,7 @@ public function __construct(Spreadsheet $parent = null, $pTitle = 'Worksheet') * Disconnect all cells from this Worksheet object, * typically so that the worksheet object can be unset. */ - public function disconnectCells() + public function disconnectCells(): void { if ($this->cellCollection !== null) { $this->cellCollection->unsetWorksheetCells(); @@ -552,7 +552,6 @@ public function getChartCollection() /** * Add chart. * - * @param Chart $pChart * @param null|int $iChartIndex Index where chart should go (0,1,..., or null for last) * * @return Chart @@ -791,8 +790,6 @@ public function getParent() /** * Re-bind parent. * - * @param Spreadsheet $parent - * * @return $this */ public function rebindParent(Spreadsheet $parent) @@ -931,8 +928,6 @@ public function getPageSetup() /** * Set page setup. * - * @param PageSetup $pValue - * * @return $this */ public function setPageSetup(PageSetup $pValue) @@ -955,8 +950,6 @@ public function getPageMargins() /** * Set page margins. * - * @param PageMargins $pValue - * * @return $this */ public function setPageMargins(PageMargins $pValue) @@ -979,8 +972,6 @@ public function getHeaderFooter() /** * Set page header/footer. * - * @param HeaderFooter $pValue - * * @return $this */ public function setHeaderFooter(HeaderFooter $pValue) @@ -1003,8 +994,6 @@ public function getSheetView() /** * Set sheet view. * - * @param SheetView $pValue - * * @return $this */ public function setSheetView(SheetView $pValue) @@ -1027,8 +1016,6 @@ public function getProtection() /** * Set Protection. * - * @param Protection $pValue - * * @return $this */ public function setProtection(Protection $pValue) @@ -1771,8 +1758,6 @@ public function getMergeCells() * Set merge cells array for the entire sheet. Use instead mergeCells() to merge * a single cell range. * - * @param array $pValue - * * @return $this */ public function setMergeCells(array $pValue) @@ -2733,11 +2718,10 @@ public function getHyperlink($pCellCoordinate) * Set hyperlink. * * @param string $pCellCoordinate Cell coordinate to insert hyperlink, eg: 'A1' - * @param null|Hyperlink $pHyperlink * * @return $this */ - public function setHyperlink($pCellCoordinate, Hyperlink $pHyperlink = null) + public function setHyperlink($pCellCoordinate, ?Hyperlink $pHyperlink = null) { if ($pHyperlink === null) { unset($this->hyperlinkCollection[$pCellCoordinate]); @@ -2794,11 +2778,10 @@ public function getDataValidation($pCellCoordinate) * Set data validation. * * @param string $pCellCoordinate Cell coordinate to insert data validation, eg: 'A1' - * @param null|DataValidation $pDataValidation * * @return $this */ - public function setDataValidation($pCellCoordinate, DataValidation $pDataValidation = null) + public function setDataValidation($pCellCoordinate, ?DataValidation $pDataValidation = null) { if ($pDataValidation === null) { unset($this->dataValidationCollection[$pCellCoordinate]); @@ -2889,7 +2872,7 @@ public function getTabColor() public function resetTabColor() { $this->tabColor = null; - unset($this->tabColor); + $this->tabColor = null; return $this; } diff --git a/src/PhpSpreadsheet/Writer/Csv.php b/src/PhpSpreadsheet/Writer/Csv.php index 4344a5bd7c..414bdf906f 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -79,7 +79,7 @@ public function __construct(Spreadsheet $spreadsheet) * * @param resource|string $pFilename */ - public function save($pFilename) + public function save($pFilename): void { // Fetch sheet $sheet = $this->spreadsheet->getSheet($this->sheetIndex); @@ -302,7 +302,7 @@ public function setSheetIndex($pValue) * @param resource $pFileHandle PHP filehandle * @param array $pValues Array containing values in a row */ - private function writeLine($pFileHandle, array $pValues) + private function writeLine($pFileHandle, array $pValues): void { // No leading delimiter $writeDelimiter = false; diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index bb5098069a..65b04c7d69 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -133,8 +133,6 @@ class Html extends BaseWriter /** * Create a new HTML. - * - * @param Spreadsheet $spreadsheet */ public function __construct(Spreadsheet $spreadsheet) { @@ -147,7 +145,7 @@ public function __construct(Spreadsheet $spreadsheet) * * @param resource|string $pFilename */ - public function save($pFilename) + public function save($pFilename): void { // Open file $this->openFileHandle($pFilename); @@ -204,7 +202,7 @@ public function generateHtmlAll() Alignment::VERTICAL_TOP => 'top', Alignment::VERTICAL_CENTER => 'middle', Alignment::VERTICAL_JUSTIFY => 'middle', - ]; + ]; /** * Map VAlign. @@ -224,7 +222,7 @@ private function mapVAlign($vAlign) Alignment::HORIZONTAL_CENTER => 'center', Alignment::HORIZONTAL_CENTER_CONTINUOUS => 'center', Alignment::HORIZONTAL_JUSTIFY => 'justify', - ]; + ]; /** * Map HAlign. @@ -251,7 +249,7 @@ private function mapHAlign($hAlign) Border::BORDER_MEDIUMDASHDOTDOT => '2px dotted', Border::BORDER_SLANTDASHDOT => '2px dashed', Border::BORDER_THICK => '3px solid', - ]; + ]; /** * Map border style. @@ -805,7 +803,7 @@ public function generateStyles($generateSurroundingHTML = true) return $html; } - private function buildCssRowHeights(Worksheet $sheet, array &$css, int $sheetIndex) + private function buildCssRowHeights(Worksheet $sheet, array &$css, int $sheetIndex): void { // Calculate row heights foreach ($sheet->getRowDimensions() as $rowDimension) { @@ -825,7 +823,7 @@ private function buildCssRowHeights(Worksheet $sheet, array &$css, int $sheetInd } } - private function buildCssPerSheet(Worksheet $sheet, array &$css) + private function buildCssPerSheet(Worksheet $sheet, array &$css): void { // Calculate hash code $sheetIndex = $sheet->getParent()->getIndex($sheet); @@ -975,8 +973,6 @@ public function buildCSS($generateSurroundingHTML = true) /** * Create CSS style. * - * @param Style $pStyle - * * @return array */ private function createCSSStyle(Style $pStyle) @@ -1018,8 +1014,6 @@ private function createCSSStyleAlignment(Alignment $pStyle) /** * Create CSS style (\PhpOffice\PhpSpreadsheet\Style\Font). * - * @param Font $pStyle - * * @return array */ private function createCSSStyleFont(Font $pStyle) @@ -1138,7 +1132,7 @@ private function generateTableTagInline($pSheet, $id) return $html; } - private function generateTableTag($pSheet, $id, &$html, $sheetIndex) + private function generateTableTag($pSheet, $id, &$html, $sheetIndex): void { if (!$this->useInlineCss) { $gridlines = $pSheet->getShowGridlines() ? ' gridlines' : ''; @@ -1266,7 +1260,7 @@ private function generateRowCellCss($pSheet, $cellAddress, $pRow, $colNum) return [$cell, $cssClass, $coordinate]; } - private function generateRowCellDataValueRich($cell, &$cellData) + private function generateRowCellDataValueRich($cell, &$cellData): void { // Loop through rich text elements $elements = $cell->getValue()->getRichTextElements(); @@ -1299,7 +1293,7 @@ private function generateRowCellDataValueRich($cell, &$cellData) } } - private function generateRowCellDataValue($pSheet, $cell, &$cellData) + private function generateRowCellDataValue($pSheet, $cell, &$cellData): void { if ($cell->getValue() instanceof RichText) { $this->generateRowCellDataValueRich($cell, $cellData); @@ -1386,7 +1380,7 @@ private function generateRowSpans($html, $rowSpan, $colSpan) return $html; } - private function generateRowWriteCell(&$html, $pSheet, $coordinate, $cellType, $cellData, $colSpan, $rowSpan, $cssClass, $colNum, $sheetIndex, $pRow) + private function generateRowWriteCell(&$html, $pSheet, $coordinate, $cellType, $cellData, $colSpan, $rowSpan, $cssClass, $colNum, $sheetIndex, $pRow): void { // Image? $htmlx = $this->writeImageInCell($pSheet, $coordinate); @@ -1519,8 +1513,6 @@ private function generateRow(Worksheet $pSheet, array $pValues, $pRow, $cellType /** * Takes array where of CSS properties / values and converts to CSS string. * - * @param array $pValue - * * @return string */ private function assembleCSS(array $pValue = []) @@ -1672,7 +1664,7 @@ public function formatColor($pValue, $pFormat) /** * Calculate information about HTML colspan and rowspan which is not always the same as Excel's. */ - private function calculateSpans() + private function calculateSpans(): void { if ($this->spansAreCalculated) { return; @@ -1735,7 +1727,7 @@ private function calculateSpans() $this->spansAreCalculated = true; } - private function calculateSpansOmitRows($sheet, $sheetIndex, $candidateSpannedRow) + private function calculateSpansOmitRows($sheet, $sheetIndex, $candidateSpannedRow): void { // Identify which rows should be omitted in HTML. These are the rows where all the cells // participate in a merge and the where base cells are somewhere above. @@ -1772,7 +1764,6 @@ private function calculateSpansOmitRows($sheet, $sheetIndex, $candidateSpannedRo * * @see https://github.com/LibreOffice/core/blob/9fc9bf3240f8c62ad7859947ab8a033ac1fe93fa/sc/source/filter/html/htmlexp.cxx#L1073-L1092 * - * @param Worksheet $pSheet * @param string $coordinate * * @return string diff --git a/src/PhpSpreadsheet/Writer/IWriter.php b/src/PhpSpreadsheet/Writer/IWriter.php index 2732953713..5129d65583 100644 --- a/src/PhpSpreadsheet/Writer/IWriter.php +++ b/src/PhpSpreadsheet/Writer/IWriter.php @@ -8,8 +8,6 @@ interface IWriter { /** * IWriter constructor. - * - * @param Spreadsheet $spreadsheet */ public function __construct(Spreadsheet $spreadsheet); diff --git a/src/PhpSpreadsheet/Writer/Ods.php b/src/PhpSpreadsheet/Writer/Ods.php index e3a0ca9888..36f3e9caf8 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -34,8 +34,6 @@ class Ods extends BaseWriter /** * Create a new Ods. - * - * @param Spreadsheet $spreadsheet */ public function __construct(Spreadsheet $spreadsheet) { @@ -77,7 +75,7 @@ public function getWriterPart($pPartName) * * @param resource|string $pFilename */ - public function save($pFilename) + public function save($pFilename): void { if (!$this->spreadSheet) { throw new WriterException('PhpSpreadsheet object unassigned.'); diff --git a/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php b/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php index 2f543be51b..880a8554f1 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php +++ b/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php @@ -13,7 +13,7 @@ */ class Comment { - public static function write(XMLWriter $objWriter, Cell $cell) + public static function write(XMLWriter $objWriter, Cell $cell): void { $comments = $cell->getWorksheet()->getComments(); if (!isset($comments[$cell->getCoordinate()])) { diff --git a/src/PhpSpreadsheet/Writer/Ods/Content.php b/src/PhpSpreadsheet/Writer/Ods/Content.php index cbf303bd8d..cb6c66282d 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Content.php +++ b/src/PhpSpreadsheet/Writer/Ods/Content.php @@ -106,13 +106,10 @@ public function write() /** * Write sheets. - * - * @param XMLWriter $objWriter */ - private function writeSheets(XMLWriter $objWriter) + private function writeSheets(XMLWriter $objWriter): void { - $spreadsheet = $this->getParentWriter()->getSpreadsheet(); // @var $spreadsheet Spreadsheet - + $spreadsheet = $this->getParentWriter()->getSpreadsheet(); /** @var Spreadsheet $spreadsheet */ $sheetCount = $spreadsheet->getSheetCount(); for ($i = 0; $i < $sheetCount; ++$i) { $objWriter->startElement('table:table'); @@ -128,11 +125,8 @@ private function writeSheets(XMLWriter $objWriter) /** * Write rows of the specified sheet. - * - * @param XMLWriter $objWriter - * @param Worksheet $sheet */ - private function writeRows(XMLWriter $objWriter, Worksheet $sheet) + private function writeRows(XMLWriter $objWriter, Worksheet $sheet): void { $numberRowsRepeated = self::NUMBER_ROWS_REPEATED_MAX; $span_row = 0; @@ -164,11 +158,8 @@ private function writeRows(XMLWriter $objWriter, Worksheet $sheet) /** * Write cells of the specified row. - * - * @param XMLWriter $objWriter - * @param Row $row */ - private function writeCells(XMLWriter $objWriter, Row $row) + private function writeCells(XMLWriter $objWriter, Row $row): void { $numberColsRepeated = self::NUMBER_COLS_REPEATED_MAX; $prevColumn = -1; @@ -254,11 +245,10 @@ private function writeCells(XMLWriter $objWriter, Row $row) /** * Write span. * - * @param XMLWriter $objWriter * @param int $curColumn * @param int $prevColumn */ - private function writeCellSpan(XMLWriter $objWriter, $curColumn, $prevColumn) + private function writeCellSpan(XMLWriter $objWriter, $curColumn, $prevColumn): void { $diff = $curColumn - $prevColumn - 1; if (1 === $diff) { @@ -272,11 +262,8 @@ private function writeCellSpan(XMLWriter $objWriter, $curColumn, $prevColumn) /** * Write XF cell styles. - * - * @param XMLWriter $writer - * @param Spreadsheet $spreadsheet */ - private function writeXfStyles(XMLWriter $writer, Spreadsheet $spreadsheet) + private function writeXfStyles(XMLWriter $writer, Spreadsheet $spreadsheet): void { foreach ($spreadsheet->getCellXfCollection() as $style) { $writer->startElement('style:style'); @@ -366,11 +353,8 @@ private function writeXfStyles(XMLWriter $writer, Spreadsheet $spreadsheet) /** * Write attributes for merged cell. - * - * @param XMLWriter $objWriter - * @param Cell $cell */ - private function writeCellMerge(XMLWriter $objWriter, Cell $cell) + private function writeCellMerge(XMLWriter $objWriter, Cell $cell): void { if (!$cell->isMergeRangeValueCell()) { return; diff --git a/src/PhpSpreadsheet/Writer/Ods/Meta.php b/src/PhpSpreadsheet/Writer/Ods/Meta.php index eb2ebf9edc..365221f77d 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Meta.php +++ b/src/PhpSpreadsheet/Writer/Ods/Meta.php @@ -14,7 +14,7 @@ class Meta extends WriterPart * * @return string XML Output */ - public function write(Spreadsheet $spreadsheet = null) + public function write(?Spreadsheet $spreadsheet = null) { if (!$spreadsheet) { $spreadsheet = $this->getParentWriter()->getSpreadsheet(); diff --git a/src/PhpSpreadsheet/Writer/Ods/Mimetype.php b/src/PhpSpreadsheet/Writer/Ods/Mimetype.php index d0fed2b379..4aac368525 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Mimetype.php +++ b/src/PhpSpreadsheet/Writer/Ods/Mimetype.php @@ -13,7 +13,7 @@ class Mimetype extends WriterPart * * @return string XML Output */ - public function write(Spreadsheet $spreadsheet = null) + public function write(?Spreadsheet $spreadsheet = null) { return 'application/vnd.oasis.opendocument.spreadsheet'; } diff --git a/src/PhpSpreadsheet/Writer/Ods/Settings.php b/src/PhpSpreadsheet/Writer/Ods/Settings.php index 11d13341f9..d458e8c2bd 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Settings.php +++ b/src/PhpSpreadsheet/Writer/Ods/Settings.php @@ -14,7 +14,7 @@ class Settings extends WriterPart * * @return string XML Output */ - public function write(Spreadsheet $spreadsheet = null) + public function write(?Spreadsheet $spreadsheet = null) { $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { diff --git a/src/PhpSpreadsheet/Writer/Ods/Styles.php b/src/PhpSpreadsheet/Writer/Ods/Styles.php index cd71566f54..7ba7eba735 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Styles.php +++ b/src/PhpSpreadsheet/Writer/Ods/Styles.php @@ -14,7 +14,7 @@ class Styles extends WriterPart * * @return string XML Output */ - public function write(Spreadsheet $spreadsheet = null) + public function write(?Spreadsheet $spreadsheet = null) { $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { diff --git a/src/PhpSpreadsheet/Writer/Ods/Thumbnails.php b/src/PhpSpreadsheet/Writer/Ods/Thumbnails.php index a29a14adbe..dfab0654c6 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Thumbnails.php +++ b/src/PhpSpreadsheet/Writer/Ods/Thumbnails.php @@ -13,7 +13,7 @@ class Thumbnails extends WriterPart * * @return string XML Output */ - public function writeThumbnail(Spreadsheet $spreadsheet = null) + public function writeThumbnail(?Spreadsheet $spreadsheet = null) { return ''; } diff --git a/src/PhpSpreadsheet/Writer/Ods/WriterPart.php b/src/PhpSpreadsheet/Writer/Ods/WriterPart.php index 3e2f968416..1982c4506b 100644 --- a/src/PhpSpreadsheet/Writer/Ods/WriterPart.php +++ b/src/PhpSpreadsheet/Writer/Ods/WriterPart.php @@ -25,8 +25,6 @@ public function getParentWriter() /** * Set parent Ods writer. - * - * @param Ods $writer */ public function __construct(Ods $writer) { diff --git a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php index 3ecaff682d..9ae2ccee35 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php @@ -22,7 +22,7 @@ protected function createExternalWriterInstance() * * @param string $pFilename Name of the file to save as */ - public function save($pFilename) + public function save($pFilename): void { $fileHandle = parent::prepareForSave($pFilename); diff --git a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php index 4424157555..75e0010d5f 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php @@ -24,7 +24,7 @@ protected function createExternalWriterInstance($config) * * @param string $pFilename Name of the file to save as */ - public function save($pFilename) + public function save($pFilename): void { $fileHandle = parent::prepareForSave($pFilename); diff --git a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php index 3dc172a2e2..7530b1efe0 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php @@ -38,7 +38,7 @@ protected function createExternalWriterInstance($orientation, $unit, $paperSize) * * @param string $pFilename Name of the file to save as */ - public function save($pFilename) + public function save($pFilename): void { $fileHandle = parent::prepareForSave($pFilename); diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index 06611789c8..cf87d5beee 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -117,7 +117,7 @@ public function __construct(Spreadsheet $spreadsheet) * * @param resource|string $pFilename */ - public function save($pFilename) + public function save($pFilename): void { // garbage collect $this->spreadsheet->garbageCollect(); @@ -230,7 +230,7 @@ public function save($pFilename) /** * Build the Worksheet Escher objects. */ - private function buildWorksheetEschers() + private function buildWorksheetEschers(): void { // 1-based index to BstoreContainer $blipIndex = 0; @@ -392,7 +392,7 @@ private function buildWorksheetEschers() /** * Build the Escher object corresponding to the MSODRAWINGGROUP record. */ - private function buildWorkbookEscher() + private function buildWorkbookEscher(): void { $escher = null; @@ -716,7 +716,7 @@ private function writeDocumentSummaryInformation() } elseif ($dataProp['type']['data'] == 0x1E) { // null-terminated string prepended by dword string length // Null-terminated string $dataProp['data']['data'] .= chr(0); - $dataProp['data']['length'] += 1; + ++$dataProp['data']['length']; // Complete the string with null string for being a %4 $dataProp['data']['length'] = $dataProp['data']['length'] + ((4 - $dataProp['data']['length'] % 4) == 4 ? 0 : (4 - $dataProp['data']['length'] % 4)); $dataProp['data']['data'] = str_pad($dataProp['data']['data'], $dataProp['data']['length'], chr(0), STR_PAD_RIGHT); @@ -912,7 +912,7 @@ private function writeSummaryInformation() } elseif ($dataProp['type']['data'] == 0x1E) { // null-terminated string prepended by dword string length // Null-terminated string $dataProp['data']['data'] .= chr(0); - $dataProp['data']['length'] += 1; + ++$dataProp['data']['length']; // Complete the string with null string for being a %4 $dataProp['data']['length'] = $dataProp['data']['length'] + ((4 - $dataProp['data']['length'] % 4) == 4 ? 0 : (4 - $dataProp['data']['length'] % 4)); $dataProp['data']['data'] = str_pad($dataProp['data']['data'], $dataProp['data']['length'], chr(0), STR_PAD_RIGHT); diff --git a/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php b/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php index 3b2eb9af27..84e27d0d81 100644 --- a/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php +++ b/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php @@ -109,7 +109,7 @@ public static function getByteOrder() * * @param string $data binary data to append */ - protected function append($data) + protected function append($data): void { if (strlen($data) - 4 > $this->limit) { $data = $this->addContinue($data); @@ -142,7 +142,7 @@ public function writeData($data) * @param int $type type of BIFF file to write: 0x0005 Workbook, * 0x0010 Worksheet */ - protected function storeBof($type) + protected function storeBof($type): void { $record = 0x0809; // Record identifier (BIFF5-BIFF8) $length = 0x0010; @@ -163,7 +163,7 @@ protected function storeBof($type) /** * Writes Excel EOF record to indicate the end of a BIFF stream. */ - protected function storeEof() + protected function storeEof(): void { $record = 0x000A; // Record identifier $length = 0x0000; // Number of bytes to follow diff --git a/src/PhpSpreadsheet/Writer/Xls/Font.php b/src/PhpSpreadsheet/Writer/Xls/Font.php index df37dcb56c..9cb31ead08 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Font.php +++ b/src/PhpSpreadsheet/Writer/Xls/Font.php @@ -22,8 +22,6 @@ class Font /** * Constructor. - * - * @param \PhpOffice\PhpSpreadsheet\Style\Font $font */ public function __construct(\PhpOffice\PhpSpreadsheet\Style\Font $font) { @@ -36,7 +34,7 @@ public function __construct(\PhpOffice\PhpSpreadsheet\Style\Font $font) * * @param int $colorIndex */ - public function setColorIndex($colorIndex) + public function setColorIndex($colorIndex): void { $this->colorIndex = $colorIndex; } diff --git a/src/PhpSpreadsheet/Writer/Xls/Parser.php b/src/PhpSpreadsheet/Writer/Xls/Parser.php index 5982062845..5e3316ab43 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Parser.php +++ b/src/PhpSpreadsheet/Writer/Xls/Parser.php @@ -516,7 +516,7 @@ private function convert($token) } elseif (isset($this->ptg[$token])) { return pack('C', $this->ptg[$token]); // match error codes - } elseif (preg_match('/^#[A-Z0\\/]{3,5}[!?]{1}$/', $token) or $token == '#N/A') { + } elseif (preg_match('/^#[A-Z0\\/]{3,5}[!?]{1}$/', $token) || $token == '#N/A') { return $this->convertError($token); // commented so argument number can be processed correctly. See toReversePolish(). /*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/", $token)) @@ -542,7 +542,7 @@ private function convert($token) private function convertNumber($num) { // Integer in the range 0..2**16-1 - if ((preg_match('/^\\d+$/', $num)) and ($num <= 65535)) { + if ((preg_match('/^\\d+$/', $num)) && ($num <= 65535)) { return pack('Cv', $this->ptg['ptgInt'], $num); } @@ -828,7 +828,7 @@ private function getSheetIndex($sheet_name) * @param string $name The name of the worksheet being added * @param int $index The index of the worksheet being added */ - public function setExtSheet($name, $index) + public function setExtSheet($name, $index): void { $this->externalSheets[$name] = $index; } @@ -885,7 +885,7 @@ private function rangeToPackedRange($range) $col2 = 65535; // FIXME: maximum possible value for Excel 5 (change this!!!) // FIXME: this changes for BIFF8 - if (($row1 >= 65536) or ($row2 >= 65536)) { + if (($row1 >= 65536) || ($row2 >= 65536)) { throw new WriterException("Row in: $range greater than 65536 "); } @@ -924,7 +924,7 @@ private function cellToRowcol($cell) $col = 0; $col_ref_length = strlen($col_ref); for ($i = 0; $i < $col_ref_length; ++$i) { - $col += (ord($col_ref[$i]) - 64) * pow(26, $expn); + $col += (ord($col_ref[$i]) - 64) * 26 ** $expn; --$expn; } @@ -1018,7 +1018,7 @@ private function match($token) break; case '<': // it's a LE or a NE token - if (($this->lookAhead === '=') or ($this->lookAhead === '>')) { + if (($this->lookAhead === '=') || ($this->lookAhead === '>')) { break; } @@ -1027,33 +1027,33 @@ private function match($token) break; default: // if it's a reference A1 or $A$1 or $A1 or A$1 - if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?\d+$/', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead !== ':') and ($this->lookAhead !== '.') and ($this->lookAhead !== '!')) { + if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?\d+$/', $token) && !preg_match('/\d/', $this->lookAhead) && ($this->lookAhead !== ':') && ($this->lookAhead !== '.') && ($this->lookAhead !== '!')) { return $token; - } elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?[A-Ia-i]?[A-Za-z]\$?\\d+$/u', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead !== ':') and ($this->lookAhead !== '.')) { + } elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?[A-Ia-i]?[A-Za-z]\$?\\d+$/u', $token) && !preg_match('/\d/', $this->lookAhead) && ($this->lookAhead !== ':') && ($this->lookAhead !== '.')) { // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1) return $token; - } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?[A-Ia-i]?[A-Za-z]\\$?\\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead !== ':') and ($this->lookAhead !== '.')) { + } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?[A-Ia-i]?[A-Za-z]\\$?\\d+$/u", $token) && !preg_match('/\d/', $this->lookAhead) && ($this->lookAhead !== ':') && ($this->lookAhead !== '.')) { // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1) return $token; } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+:(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $token) && !preg_match('/\d/', $this->lookAhead)) { // if it's a range A1:A2 or $A$1:$A$2 return $token; - } elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?([A-Ia-i]?[A-Za-z])?\$?\\d+:\$?([A-Ia-i]?[A-Za-z])?\$?\\d+$/u', $token) and !preg_match('/\d/', $this->lookAhead)) { + } elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?([A-Ia-i]?[A-Za-z])?\$?\\d+:\$?([A-Ia-i]?[A-Za-z])?\$?\\d+$/u', $token) && !preg_match('/\d/', $this->lookAhead)) { // If it's an external range like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2 return $token; - } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?([A-Ia-i]?[A-Za-z])?\\$?\\d+:\\$?([A-Ia-i]?[A-Za-z])?\\$?\\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead)) { + } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?([A-Ia-i]?[A-Za-z])?\\$?\\d+:\\$?([A-Ia-i]?[A-Za-z])?\\$?\\d+$/u", $token) && !preg_match('/\d/', $this->lookAhead)) { // If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2 return $token; - } elseif (is_numeric($token) and (!is_numeric($token . $this->lookAhead) or ($this->lookAhead == '')) and ($this->lookAhead !== '!') and ($this->lookAhead !== ':')) { + } elseif (is_numeric($token) && (!is_numeric($token . $this->lookAhead) || ($this->lookAhead == '')) && ($this->lookAhead !== '!') && ($this->lookAhead !== ':')) { // If it's a number (check that it's not a sheet name or range) return $token; - } elseif (preg_match('/"([^"]|""){0,255}"/', $token) and $this->lookAhead !== '"' and (substr_count($token, '"') % 2 == 0)) { + } elseif (preg_match('/"([^"]|""){0,255}"/', $token) && $this->lookAhead !== '"' && (substr_count($token, '"') % 2 == 0)) { // If it's a string (of maximum 255 characters) return $token; - } elseif (preg_match('/^#[A-Z0\\/]{3,5}[!?]{1}$/', $token) or $token === '#N/A') { + } elseif (preg_match('/^#[A-Z0\\/]{3,5}[!?]{1}$/', $token) || $token === '#N/A') { // If it's an error code return $token; - } elseif (preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/i", $token) and ($this->lookAhead === '(')) { + } elseif (preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/i", $token) && ($this->lookAhead === '(')) { // if it's a function call return $token; } elseif (substr($token, -1) === ')') { @@ -1151,7 +1151,7 @@ private function expression() return $result; // If it's an error code - } elseif (preg_match('/^#[A-Z0\\/]{3,5}[!?]{1}$/', $this->currentToken) or $this->currentToken == '#N/A') { + } elseif (preg_match('/^#[A-Z0\\/]{3,5}[!?]{1}$/', $this->currentToken) || $this->currentToken == '#N/A') { $result = $this->createTree($this->currentToken, 'ptgErr', ''); $this->advance(); @@ -1172,8 +1172,8 @@ private function expression() return $this->createTree('ptgUplus', $result2, ''); } $result = $this->term(); - while (($this->currentToken == '+') or - ($this->currentToken == '-') or + while (($this->currentToken == '+') || + ($this->currentToken == '-') || ($this->currentToken == '^')) { if ($this->currentToken == '+') { $this->advance(); @@ -1215,7 +1215,7 @@ private function parenthesizedExpression() private function term() { $result = $this->fact(); - while (($this->currentToken == '*') or + while (($this->currentToken == '*') || ($this->currentToken == '/')) { if ($this->currentToken == '*') { $this->advance(); @@ -1270,7 +1270,7 @@ private function fact() $this->advance(); return $result; - } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+:(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $this->currentToken) or + } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+:(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $this->currentToken) || preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $this->currentToken)) { // if it's a range A1:B2 or $A$1:$B$2 // must be an error? @@ -1344,7 +1344,7 @@ private function func() } $args = $this->functions[$function][1]; // If fixed number of args eg. TIME($i, $j, $k). Check that the number of args is valid. - if (($args >= 0) and ($args != $num_args)) { + if (($args >= 0) && ($args != $num_args)) { throw new WriterException("Incorrect number of arguments in function $function() "); } @@ -1417,10 +1417,10 @@ public function toReversePolish($tree = []) $polish .= $converted_tree; } // if it's a function convert it here (so we can set it's arguments) - if (preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/", $tree['value']) and - !preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/', $tree['value']) and - !preg_match('/^[A-Ia-i]?[A-Za-z](\\d+)\\.\\.[A-Ia-i]?[A-Za-z](\\d+)$/', $tree['value']) and - !is_numeric($tree['value']) and + if (preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/", $tree['value']) && + !preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/', $tree['value']) && + !preg_match('/^[A-Ia-i]?[A-Za-z](\\d+)\\.\\.[A-Ia-i]?[A-Za-z](\\d+)$/', $tree['value']) && + !is_numeric($tree['value']) && !isset($this->ptg[$tree['value']])) { // left subtree for a function is always an array. if ($tree['left'] != '') { diff --git a/src/PhpSpreadsheet/Writer/Xls/Workbook.php b/src/PhpSpreadsheet/Writer/Xls/Workbook.php index 41c8e64e29..d5f61bf208 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xls/Workbook.php @@ -222,7 +222,6 @@ public function __construct(Spreadsheet $spreadsheet, &$str_total, &$str_unique, /** * Add a new XF writer. * - * @param Style $style * @param bool $isStyleXf Is it a style XF? * * @return int Index to XF record @@ -273,8 +272,6 @@ public function addXfWriter(Style $style, $isStyleXf = false) /** * Add a font to added fonts. * - * @param \PhpOffice\PhpSpreadsheet\Style\Font $font - * * @return int Index to FONT record */ public function addFont(\PhpOffice\PhpSpreadsheet\Style\Font $font) @@ -343,7 +340,7 @@ private function addColor($rgb) /** * Sets the colour palette to the Excel 97+ default. */ - private function setPaletteXl97() + private function setPaletteXl97(): void { $this->palette = [ 0x08 => [0x00, 0x00, 0x00, 0x00], @@ -465,7 +462,7 @@ public function writeWorkbook(array $pWorksheetSizes) /** * Calculate offsets for Worksheet BOF records. */ - private function calcSheetOffsets() + private function calcSheetOffsets(): void { $boundsheet_length = 10; // fixed length for a BOUNDSHEET record @@ -489,7 +486,7 @@ private function calcSheetOffsets() /** * Store the Excel FONT records. */ - private function writeAllFonts() + private function writeAllFonts(): void { foreach ($this->fontWriters as $fontWriter) { $this->append($fontWriter->writeFont()); @@ -499,7 +496,7 @@ private function writeAllFonts() /** * Store user defined numerical formats i.e. FORMAT records. */ - private function writeAllNumberFormats() + private function writeAllNumberFormats(): void { foreach ($this->numberFormats as $numberFormatIndex => $numberFormat) { $this->writeNumberFormat($numberFormat->getFormatCode(), $numberFormatIndex); @@ -509,7 +506,7 @@ private function writeAllNumberFormats() /** * Write all XF records. */ - private function writeAllXfs() + private function writeAllXfs(): void { foreach ($this->xfWriters as $xfWriter) { $this->append($xfWriter->writeXf()); @@ -519,7 +516,7 @@ private function writeAllXfs() /** * Write all STYLE records. */ - private function writeAllStyles() + private function writeAllStyles(): void { $this->writeStyle(); } @@ -554,7 +551,7 @@ private function writeAllDefinedNamesBiff8() $formulaData = $this->parser->toReversePolish(); // make sure tRef3d is of type tRef3dR (0x3A) - if (isset($formulaData[0]) and ($formulaData[0] == "\x7A" or $formulaData[0] == "\x5A")) { + if (isset($formulaData[0]) && ($formulaData[0] == "\x7A" || $formulaData[0] == "\x5A")) { $formulaData = "\x3A" . substr($formulaData, 1); } @@ -754,7 +751,7 @@ private function writeShortNameBiff8($name, $sheetIndex, $rangeBounds, $isHidden /** * Stores the CODEPAGE biff record. */ - private function writeCodepage() + private function writeCodepage(): void { $record = 0x0042; // Record identifier $length = 0x0002; // Number of bytes to follow @@ -769,7 +766,7 @@ private function writeCodepage() /** * Write Excel BIFF WINDOW1 record. */ - private function writeWindow1() + private function writeWindow1(): void { $record = 0x003D; // Record identifier $length = 0x0012; // Number of bytes to follow @@ -801,7 +798,7 @@ private function writeWindow1() * @param Worksheet $sheet Worksheet name * @param int $offset Location of worksheet BOF */ - private function writeBoundSheet($sheet, $offset) + private function writeBoundSheet($sheet, $offset): void { $sheetname = $sheet->getTitle(); $record = 0x0085; // Record identifier @@ -876,7 +873,7 @@ private function writeExternalsheetBiff8() /** * Write Excel BIFF STYLE records. */ - private function writeStyle() + private function writeStyle(): void { $record = 0x0293; // Record identifier $length = 0x0004; // Bytes to follow @@ -896,7 +893,7 @@ private function writeStyle() * @param string $format Custom format string * @param int $ifmt Format index code */ - private function writeNumberFormat($format, $ifmt) + private function writeNumberFormat($format, $ifmt): void { $record = 0x041E; // Record identifier @@ -911,7 +908,7 @@ private function writeNumberFormat($format, $ifmt) /** * Write DATEMODE record to indicate the date system in use (1904 or 1900). */ - private function writeDateMode() + private function writeDateMode(): void { $record = 0x0022; // Record identifier $length = 0x0002; // Bytes to follow @@ -963,7 +960,7 @@ private function writeRecalcId() /** * Stores the PALETTE biff record. */ - private function writePalette() + private function writePalette(): void { $aref = $this->palette; @@ -1143,7 +1140,7 @@ public function getEscher() * * @param \PhpOffice\PhpSpreadsheet\Shared\Escher $pValue */ - public function setEscher(\PhpOffice\PhpSpreadsheet\Shared\Escher $pValue = null) + public function setEscher(?\PhpOffice\PhpSpreadsheet\Shared\Escher $pValue = null): void { $this->escher = $pValue; } diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 5a6fa61ac9..f6b3e29734 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -277,7 +277,7 @@ public function __construct(&$str_total, &$str_unique, &$str_table, &$colors, Pa * * @see \PhpOffice\PhpSpreadsheet\Writer\Xls\Workbook::storeWorkbook() */ - public function close() + public function close(): void { $phpSheet = $this->phpSheet; @@ -603,7 +603,7 @@ public function getData() // Return data stored in memory if (isset($this->_data)) { $tmp = $this->_data; - unset($this->_data); + $this->_data = null; return $tmp; } @@ -616,7 +616,7 @@ public function getData() * * @param int $print Whether to print the headers or not. Defaults to 1 (print). */ - public function printRowColHeaders($print = 1) + public function printRowColHeaders($print = 1): void { $this->printHeaders = $print; } @@ -630,7 +630,7 @@ public function printRowColHeaders($print = 1) * @param bool $symbols_right * @param bool $auto_style */ - public function setOutline($visible = true, $symbols_below = true, $symbols_right = true, $auto_style = false) + public function setOutline($visible = true, $symbols_below = true, $symbols_right = true, $auto_style = false): void { $this->outlineOn = $visible; $this->outlineBelow = $symbols_below; @@ -683,7 +683,7 @@ private function writeNumber($row, $col, $num, $xfIndex) * @param string $str The string * @param int $xfIndex Index to XF record */ - private function writeString($row, $col, $str, $xfIndex) + private function writeString($row, $col, $str, $xfIndex): void { $this->writeLabelSst($row, $col, $str, $xfIndex); } @@ -698,7 +698,7 @@ private function writeString($row, $col, $str, $xfIndex) * @param int $xfIndex The XF format index for the cell * @param array $arrcRun Index to Font record and characters beginning */ - private function writeRichTextString($row, $col, $str, $xfIndex, $arrcRun) + private function writeRichTextString($row, $col, $str, $xfIndex, $arrcRun): void { $record = 0x00FD; // Record identifier $length = 0x000A; // Bytes to follow @@ -725,7 +725,7 @@ private function writeRichTextString($row, $col, $str, $xfIndex, $arrcRun) * @param string $str The string to write * @param mixed $xfIndex The XF format index for the cell */ - private function writeLabelSst($row, $col, $str, $xfIndex) + private function writeLabelSst($row, $col, $str, $xfIndex): void { $record = 0x00FD; // Record identifier $length = 0x000A; // Bytes to follow @@ -901,7 +901,7 @@ private function writeFormula($row, $col, $formula, $xfIndex, $calculatedValue) * * @param string $stringValue */ - private function writeStringRecord($stringValue) + private function writeStringRecord($stringValue): void { $record = 0x0207; // Record identifier $data = StringHelper::UTF8toBIFF8UnicodeLong($stringValue); @@ -1176,7 +1176,7 @@ public function writeUrlExternal($row1, $col1, $row2, $col2, $url) * @param bool $hidden The optional hidden attribute * @param int $level The optional outline level for row, in range [0,7] */ - private function writeRow($row, $height, $xfIndex, $hidden = false, $level = 0) + private function writeRow($row, $height, $xfIndex, $hidden = false, $level = 0): void { $record = 0x0208; // Record identifier $length = 0x0010; // Number of bytes to follow @@ -1225,7 +1225,7 @@ private function writeRow($row, $height, $xfIndex, $hidden = false, $level = 0) /** * Writes Excel DIMENSIONS to define the area in which there is data. */ - private function writeDimensions() + private function writeDimensions(): void { $record = 0x0200; // Record identifier @@ -1239,7 +1239,7 @@ private function writeDimensions() /** * Write BIFF record Window2. */ - private function writeWindow2() + private function writeWindow2(): void { $record = 0x023E; // Record identifier $length = 0x0012; @@ -1291,7 +1291,7 @@ private function writeWindow2() /** * Write BIFF record DEFAULTROWHEIGHT. */ - private function writeDefaultRowHeight() + private function writeDefaultRowHeight(): void { $defaultRowHeight = $this->phpSheet->getDefaultRowDimension()->getRowHeight(); @@ -1313,7 +1313,7 @@ private function writeDefaultRowHeight() /** * Write BIFF record DEFCOLWIDTH if COLINFO records are in use. */ - private function writeDefcol() + private function writeDefcol(): void { $defaultColWidth = 8; @@ -1339,7 +1339,7 @@ private function writeDefcol() * 4 => Option flags. * 5 => Optional outline level */ - private function writeColinfo($col_array) + private function writeColinfo($col_array): void { if (isset($col_array[0])) { $colFirst = $col_array[0]; @@ -1386,7 +1386,7 @@ private function writeColinfo($col_array) /** * Write BIFF record SELECTION. */ - private function writeSelection() + private function writeSelection(): void { // look up the selected cell range $selectedCells = Coordinate::splitRange($this->phpSheet->getSelectedCells()); @@ -1446,7 +1446,7 @@ private function writeSelection() /** * Store the MERGEDCELLS records for all ranges of merged cells. */ - private function writeMergedCells() + private function writeMergedCells(): void { $mergeCells = $this->phpSheet->getMergeCells(); $countMergeCells = count($mergeCells); @@ -1484,7 +1484,7 @@ private function writeMergedCells() $recordData .= pack('vvvv', $firstRow - 1, $lastRow - 1, Coordinate::columnIndexFromString($firstColumn) - 1, Coordinate::columnIndexFromString($lastColumn) - 1); // flush record if we have reached limit for number of merged cells, or reached final merged cell - if ($j == $maxCountMergeCellsPerRecord or $i == $countMergeCells) { + if ($j == $maxCountMergeCellsPerRecord || $i == $countMergeCells) { $recordData = pack('v', $j) . $recordData; $length = strlen($recordData); $header = pack('vv', $record, $length); @@ -1500,7 +1500,7 @@ private function writeMergedCells() /** * Write SHEETLAYOUT record. */ - private function writeSheetLayout() + private function writeSheetLayout(): void { if (!$this->phpSheet->isTabColorSet()) { return; @@ -1527,7 +1527,7 @@ private function writeSheetLayout() /** * Write SHEETPROTECTION. */ - private function writeSheetProtection() + private function writeSheetProtection(): void { // record identifier $record = 0x0867; @@ -1574,7 +1574,7 @@ private function writeSheetProtection() * Openoffice.org's Documentaion of the Microsoft Excel File Format uses term RANGEPROTECTION for these records * Microsoft Office Excel 97-2007 Binary File Format Specification uses term FEAT for these records */ - private function writeRangeProtection() + private function writeRangeProtection(): void { foreach ($this->phpSheet->getProtectedCells() as $range => $password) { // number of ranges, e.g. 'A1:B3 C20:D25' @@ -1622,7 +1622,7 @@ private function writeRangeProtection() * Frozen panes are specified in terms of an integer number of rows and columns. * Thawed panes are specified in terms of Excel's units for rows and columns. */ - private function writePanes() + private function writePanes(): void { $panes = []; if ($this->phpSheet->getFreezePane()) { @@ -1706,7 +1706,7 @@ private function writePanes() /** * Store the page setup SETUP BIFF record. */ - private function writeSetup() + private function writeSetup(): void { $record = 0x00A1; // Record identifier $length = 0x0022; // Number of bytes to follow @@ -1767,7 +1767,7 @@ private function writeSetup() /** * Store the header caption BIFF record. */ - private function writeHeader() + private function writeHeader(): void { $record = 0x0014; // Record identifier @@ -1791,7 +1791,7 @@ private function writeHeader() /** * Store the footer caption BIFF record. */ - private function writeFooter() + private function writeFooter(): void { $record = 0x0015; // Record identifier @@ -1815,7 +1815,7 @@ private function writeFooter() /** * Store the horizontal centering HCENTER BIFF record. */ - private function writeHcenter() + private function writeHcenter(): void { $record = 0x0083; // Record identifier $length = 0x0002; // Bytes to follow @@ -1831,7 +1831,7 @@ private function writeHcenter() /** * Store the vertical centering VCENTER BIFF record. */ - private function writeVcenter() + private function writeVcenter(): void { $record = 0x0084; // Record identifier $length = 0x0002; // Bytes to follow @@ -1846,7 +1846,7 @@ private function writeVcenter() /** * Store the LEFTMARGIN BIFF record. */ - private function writeMarginLeft() + private function writeMarginLeft(): void { $record = 0x0026; // Record identifier $length = 0x0008; // Bytes to follow @@ -1865,7 +1865,7 @@ private function writeMarginLeft() /** * Store the RIGHTMARGIN BIFF record. */ - private function writeMarginRight() + private function writeMarginRight(): void { $record = 0x0027; // Record identifier $length = 0x0008; // Bytes to follow @@ -1884,7 +1884,7 @@ private function writeMarginRight() /** * Store the TOPMARGIN BIFF record. */ - private function writeMarginTop() + private function writeMarginTop(): void { $record = 0x0028; // Record identifier $length = 0x0008; // Bytes to follow @@ -1903,7 +1903,7 @@ private function writeMarginTop() /** * Store the BOTTOMMARGIN BIFF record. */ - private function writeMarginBottom() + private function writeMarginBottom(): void { $record = 0x0029; // Record identifier $length = 0x0008; // Bytes to follow @@ -1922,7 +1922,7 @@ private function writeMarginBottom() /** * Write the PRINTHEADERS BIFF record. */ - private function writePrintHeaders() + private function writePrintHeaders(): void { $record = 0x002a; // Record identifier $length = 0x0002; // Bytes to follow @@ -1938,7 +1938,7 @@ private function writePrintHeaders() * Write the PRINTGRIDLINES BIFF record. Must be used in conjunction with the * GRIDSET record. */ - private function writePrintGridlines() + private function writePrintGridlines(): void { $record = 0x002b; // Record identifier $length = 0x0002; // Bytes to follow @@ -1954,7 +1954,7 @@ private function writePrintGridlines() * Write the GRIDSET BIFF record. Must be used in conjunction with the * PRINTGRIDLINES record. */ - private function writeGridset() + private function writeGridset(): void { $record = 0x0082; // Record identifier $length = 0x0002; // Bytes to follow @@ -1969,7 +1969,7 @@ private function writeGridset() /** * Write the AUTOFILTERINFO BIFF record. This is used to configure the number of autofilter select used in the sheet. */ - private function writeAutoFilterInfo() + private function writeAutoFilterInfo(): void { $record = 0x009D; // Record identifier $length = 0x0002; // Bytes to follow @@ -1989,7 +1989,7 @@ private function writeAutoFilterInfo() * * @see writeWsbool() */ - private function writeGuts() + private function writeGuts(): void { $record = 0x0080; // Record identifier $length = 0x0008; // Bytes to follow @@ -2033,7 +2033,7 @@ private function writeGuts() * Write the WSBOOL BIFF record, mainly for fit-to-page. Used in conjunction * with the SETUP record. */ - private function writeWsbool() + private function writeWsbool(): void { $record = 0x0081; // Record identifier $length = 0x0002; // Bytes to follow @@ -2068,7 +2068,7 @@ private function writeWsbool() /** * Write the HORIZONTALPAGEBREAKS and VERTICALPAGEBREAKS BIFF records. */ - private function writeBreaks() + private function writeBreaks(): void { // initialize $vbreaks = []; @@ -2151,7 +2151,7 @@ private function writeBreaks() /** * Set the Biff PROTECT record to indicate that the worksheet is protected. */ - private function writeProtect() + private function writeProtect(): void { // Exit unless sheet protection has been specified if (!$this->phpSheet->getProtection()->getSheet()) { @@ -2172,7 +2172,7 @@ private function writeProtect() /** * Write SCENPROTECT. */ - private function writeScenProtect() + private function writeScenProtect(): void { // Exit if sheet protection is not active if (!$this->phpSheet->getProtection()->getSheet()) { @@ -2196,7 +2196,7 @@ private function writeScenProtect() /** * Write OBJECTPROTECT. */ - private function writeObjectProtect() + private function writeObjectProtect(): void { // Exit if sheet protection is not active if (!$this->phpSheet->getProtection()->getSheet()) { @@ -2220,7 +2220,7 @@ private function writeObjectProtect() /** * Write the worksheet PASSWORD record. */ - private function writePassword() + private function writePassword(): void { // Exit unless sheet protection and password have been specified if (!$this->phpSheet->getProtection()->getSheet() || !$this->phpSheet->getProtection()->getPassword()) { @@ -2249,7 +2249,7 @@ private function writePassword() * @param float $scale_x The horizontal scale * @param float $scale_y The vertical scale */ - public function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1) + public function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1): void { $bitmap_array = (is_resource($bitmap) ? $this->processBitmapGd($bitmap) : $this->processBitmap($bitmap)); [$width, $height, $size, $data] = $bitmap_array; @@ -2322,7 +2322,7 @@ public function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, * @param int $width Width of image frame * @param int $height Height of image frame */ - public function positionImage($col_start, $row_start, $x1, $y1, $width, $height) + public function positionImage($col_start, $row_start, $x1, $y1, $width, $height): void { // Initialise end cell to the same as the start cell $col_end = $col_start; // Col containing lower right corner of object @@ -2389,7 +2389,7 @@ public function positionImage($col_start, $row_start, $x1, $y1, $width, $height) * @param int $rwB Row containing bottom right corner of object * @param int $dyB Distance from bottom of cell */ - private function writeObjPicture($colL, $dxL, $rwT, $dyT, $colR, $dxR, $rwB, $dyB) + private function writeObjPicture($colL, $dxL, $rwT, $dyT, $colR, $dxR, $rwB, $dyB): void { $record = 0x005d; // Record identifier $length = 0x003c; // Bytes to follow @@ -2573,7 +2573,7 @@ public function processBitmap($bitmap) * Store the window zoom factor. This should be a reduced fraction but for * simplicity we will store all fractions with a numerator of 100. */ - private function writeZoom() + private function writeZoom(): void { // If scale is 100 we don't need to write a record if ($this->phpSheet->getSheetView()->getZoomScale() == 100) { @@ -2603,7 +2603,7 @@ public function getEscher() * * @param \PhpOffice\PhpSpreadsheet\Shared\Escher $pValue */ - public function setEscher(\PhpOffice\PhpSpreadsheet\Shared\Escher $pValue = null) + public function setEscher(?\PhpOffice\PhpSpreadsheet\Shared\Escher $pValue = null): void { $this->escher = $pValue; } @@ -2611,7 +2611,7 @@ public function setEscher(\PhpOffice\PhpSpreadsheet\Shared\Escher $pValue = null /** * Write MSODRAWING record. */ - private function writeMsoDrawing() + private function writeMsoDrawing(): void { // write the Escher stream if necessary if (isset($this->escher)) { @@ -2696,7 +2696,7 @@ private function writeMsoDrawing() /** * Store the DATAVALIDATIONS and DATAVALIDATION records. */ - private function writeDataValidity() + private function writeDataValidity(): void { // Datavalidation collection $dataValidationCollection = $this->phpSheet->getDataValidationCollection(); @@ -2938,7 +2938,7 @@ private static function mapErrorCode($errorCode) /** * Write PLV Record. */ - private function writePageLayoutView() + private function writePageLayoutView(): void { $record = 0x088B; // Record identifier $length = 0x0010; // Bytes to follow @@ -2968,10 +2968,8 @@ private function writePageLayoutView() /** * Write CFRule Record. - * - * @param Conditional $conditional */ - private function writeCFRule(Conditional $conditional) + private function writeCFRule(Conditional $conditional): void { $record = 0x01B1; // Record identifier @@ -3769,10 +3767,12 @@ private function writeCFRule(Conditional $conditional) break; } - //@todo writeCFRule() => $blockLineStyle => Index Color for left line - //@todo writeCFRule() => $blockLineStyle => Index Color for right line - //@todo writeCFRule() => $blockLineStyle => Top-left to bottom-right on/off - //@todo writeCFRule() => $blockLineStyle => Bottom-left to top-right on/off + /** + *@todo writeCFRule() => $blockLineStyle => Index Color for left line + *@todo writeCFRule() => $blockLineStyle => Index Color for right line + *@todo writeCFRule() => $blockLineStyle => Top-left to bottom-right on/off + *@todo writeCFRule() => $blockLineStyle => Bottom-left to top-right on/off + */ $blockColor = 0; //@todo writeCFRule() => $blockColor => Index Color for top line //@todo writeCFRule() => $blockColor => Index Color for bottom line @@ -4434,7 +4434,7 @@ private function writeCFRule(Conditional $conditional) /** * Write CFHeader record. */ - private function writeCFHeader() + private function writeCFHeader(): void { $record = 0x01B0; // Record identifier $length = 0x0016; // Bytes to follow diff --git a/src/PhpSpreadsheet/Writer/Xls/Xf.php b/src/PhpSpreadsheet/Writer/Xls/Xf.php index 238fb34c68..3e8169b306 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Xf.php +++ b/src/PhpSpreadsheet/Writer/Xls/Xf.php @@ -248,7 +248,7 @@ public function writeXf() * * @param bool $value */ - public function setIsStyleXf($value) + public function setIsStyleXf($value): void { $this->isStyleXf = $value; } @@ -258,7 +258,7 @@ public function setIsStyleXf($value) * * @param int $colorIndex Color index */ - public function setBottomColor($colorIndex) + public function setBottomColor($colorIndex): void { $this->bottomBorderColor = $colorIndex; } @@ -268,7 +268,7 @@ public function setBottomColor($colorIndex) * * @param int $colorIndex Color index */ - public function setTopColor($colorIndex) + public function setTopColor($colorIndex): void { $this->topBorderColor = $colorIndex; } @@ -278,7 +278,7 @@ public function setTopColor($colorIndex) * * @param int $colorIndex Color index */ - public function setLeftColor($colorIndex) + public function setLeftColor($colorIndex): void { $this->leftBorderColor = $colorIndex; } @@ -288,7 +288,7 @@ public function setLeftColor($colorIndex) * * @param int $colorIndex Color index */ - public function setRightColor($colorIndex) + public function setRightColor($colorIndex): void { $this->rightBorderColor = $colorIndex; } @@ -298,7 +298,7 @@ public function setRightColor($colorIndex) * * @param int $colorIndex Color index */ - public function setDiagColor($colorIndex) + public function setDiagColor($colorIndex): void { $this->_diag_color = $colorIndex; } @@ -308,7 +308,7 @@ public function setDiagColor($colorIndex) * * @param int $colorIndex Color index */ - public function setFgColor($colorIndex) + public function setFgColor($colorIndex): void { $this->foregroundColor = $colorIndex; } @@ -318,7 +318,7 @@ public function setFgColor($colorIndex) * * @param int $colorIndex Color index */ - public function setBgColor($colorIndex) + public function setBgColor($colorIndex): void { $this->backgroundColor = $colorIndex; } @@ -329,7 +329,7 @@ public function setBgColor($colorIndex) * * @param int $numberFormatIndex Index to format record */ - public function setNumberFormatIndex($numberFormatIndex) + public function setNumberFormatIndex($numberFormatIndex): void { $this->numberFormatIndex = $numberFormatIndex; } @@ -339,7 +339,7 @@ public function setNumberFormatIndex($numberFormatIndex) * * @param int $value Font index, note that value 4 does not exist */ - public function setFontIndex($value) + public function setFontIndex($value): void { $this->fontIndex = $value; } diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index 4d4d79d6ea..bfcde049c1 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -109,8 +109,6 @@ class Xlsx extends BaseWriter /** * Create a new Xlsx Writer. - * - * @param Spreadsheet $spreadsheet */ public function __construct(Spreadsheet $spreadsheet) { @@ -171,7 +169,7 @@ public function getWriterPart($pPartName) * * @param resource|string $pFilename */ - public function save($pFilename) + public function save($pFilename): void { if ($this->spreadSheet !== null) { // garbage collect diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php index aeb7a76b26..583b262c35 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php @@ -26,7 +26,6 @@ class Chart extends WriterPart /** * Write charts to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Chart\Chart $pChart * @param mixed $calculateCellValues * * @return string XML Output @@ -108,7 +107,7 @@ public function writeChart(\PhpOffice\PhpSpreadsheet\Chart\Chart $pChart, $calcu * @param XMLWriter $objWriter XML Writer * @param Title $title */ - private function writeTitle(XMLWriter $objWriter, Title $title = null) + private function writeTitle(XMLWriter $objWriter, ?Title $title = null): void { if ($title === null) { return; @@ -151,7 +150,7 @@ private function writeTitle(XMLWriter $objWriter, Title $title = null) * @param XMLWriter $objWriter XML Writer * @param Legend $legend */ - private function writeLegend(XMLWriter $objWriter, Legend $legend = null) + private function writeLegend(XMLWriter $objWriter, ?Legend $legend = null): void { if ($legend === null) { return; @@ -198,16 +197,12 @@ private function writeLegend(XMLWriter $objWriter, Legend $legend = null) * Write Chart Plot Area. * * @param XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet - * @param PlotArea $plotArea * @param Title $xAxisLabel * @param Title $yAxisLabel * @param Axis $xAxis * @param Axis $yAxis - * @param null|GridLines $majorGridlines - * @param null|GridLines $minorGridlines */ - private function writePlotArea(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet, PlotArea $plotArea, Title $xAxisLabel = null, Title $yAxisLabel = null, Axis $xAxis = null, Axis $yAxis = null, GridLines $majorGridlines = null, GridLines $minorGridlines = null) + private function writePlotArea(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet, PlotArea $plotArea, ?Title $xAxisLabel = null, ?Title $yAxisLabel = null, ?Axis $xAxis = null, ?Axis $yAxis = null, ?GridLines $majorGridlines = null, ?GridLines $minorGridlines = null): void { if ($plotArea === null) { return; @@ -336,7 +331,7 @@ private function writePlotArea(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\W * @param XMLWriter $objWriter XML Writer * @param \PhpOffice\PhpSpreadsheet\Chart\Layout $chartLayout Chart layout */ - private function writeDataLabels(XMLWriter $objWriter, Layout $chartLayout = null) + private function writeDataLabels(XMLWriter $objWriter, ?Layout $chartLayout = null): void { $objWriter->startElement('c:dLbls'); @@ -386,9 +381,8 @@ private function writeDataLabels(XMLWriter $objWriter, Layout $chartLayout = nul * @param string $id1 * @param string $id2 * @param bool $isMultiLevelSeries - * @param Axis $yAxis */ - private function writeCategoryAxis($objWriter, $xAxisLabel, $id1, $id2, $isMultiLevelSeries, Axis $yAxis) + private function writeCategoryAxis($objWriter, $xAxisLabel, $id1, $id2, $isMultiLevelSeries, Axis $yAxis): void { $objWriter->startElement('c:catAx'); @@ -505,11 +499,8 @@ private function writeCategoryAxis($objWriter, $xAxisLabel, $id1, $id2, $isMulti * @param string $id1 * @param string $id2 * @param bool $isMultiLevelSeries - * @param Axis $xAxis - * @param GridLines $majorGridlines - * @param GridLines $minorGridlines */ - private function writeValueAxis($objWriter, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, Axis $xAxis, GridLines $majorGridlines, GridLines $minorGridlines) + private function writeValueAxis($objWriter, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, Axis $xAxis, GridLines $majorGridlines, GridLines $minorGridlines): void { $objWriter->startElement('c:valAx'); @@ -1051,7 +1042,7 @@ private function writePlotSeriesValuesElement($objWriter, $val = 3, $fillColor = * @param bool &$valIsMultiLevelSeries Is value set a multi-series set * @param string &$plotGroupingType Type of grouping for multi-series values */ - private function writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMultiLevelSeries, &$valIsMultiLevelSeries, &$plotGroupingType) + private function writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMultiLevelSeries, &$valIsMultiLevelSeries, &$plotGroupingType): void { if ($plotGroup === null) { return; @@ -1235,7 +1226,7 @@ private function writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMulti * @param DataSeriesValues $plotSeriesLabel * @param XMLWriter $objWriter XML Writer */ - private function writePlotSeriesLabel($plotSeriesLabel, $objWriter) + private function writePlotSeriesLabel($plotSeriesLabel, $objWriter): void { if ($plotSeriesLabel === null) { return; @@ -1270,7 +1261,7 @@ private function writePlotSeriesLabel($plotSeriesLabel, $objWriter) * @param string $groupType Type of plot for dataseries * @param string $dataType Datatype of series values */ - private function writePlotSeriesValues($plotSeriesValues, XMLWriter $objWriter, $groupType, $dataType = 'str') + private function writePlotSeriesValues($plotSeriesValues, XMLWriter $objWriter, $groupType, $dataType = 'str'): void { if ($plotSeriesValues === null) { return; @@ -1360,7 +1351,7 @@ private function writePlotSeriesValues($plotSeriesValues, XMLWriter $objWriter, * @param DataSeriesValues $plotSeriesValues * @param XMLWriter $objWriter XML Writer */ - private function writeBubbles($plotSeriesValues, $objWriter) + private function writeBubbles($plotSeriesValues, $objWriter): void { if ($plotSeriesValues === null) { return; @@ -1405,7 +1396,7 @@ private function writeBubbles($plotSeriesValues, $objWriter) * @param XMLWriter $objWriter XML Writer * @param Layout $layout */ - private function writeLayout(XMLWriter $objWriter, Layout $layout = null) + private function writeLayout(XMLWriter $objWriter, ?Layout $layout = null): void { $objWriter->startElement('c:layout'); @@ -1472,7 +1463,7 @@ private function writeLayout(XMLWriter $objWriter, Layout $layout = null) * * @param XMLWriter $objWriter XML Writer */ - private function writeAlternateContent($objWriter) + private function writeAlternateContent($objWriter): void { $objWriter->startElement('mc:AlternateContent'); $objWriter->writeAttribute('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); @@ -1500,7 +1491,7 @@ private function writeAlternateContent($objWriter) * * @param XMLWriter $objWriter XML Writer */ - private function writePrintSettings($objWriter) + private function writePrintSettings($objWriter): void { $objWriter->startElement('c:printSettings'); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php index ee34e318b8..73c4308b8b 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php @@ -11,8 +11,6 @@ class Comments extends WriterPart /** * Write comments to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet - * * @return string XML Output */ public function writeComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet) @@ -72,7 +70,7 @@ public function writeComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWo * @param Comment $pComment Comment * @param array $pAuthors Array of authors */ - private function writeComment(XMLWriter $objWriter, $pCellReference, Comment $pComment, array $pAuthors) + private function writeComment(XMLWriter $objWriter, $pCellReference, Comment $pComment, array $pAuthors): void { // comment $objWriter->startElement('comment'); @@ -90,8 +88,6 @@ private function writeComment(XMLWriter $objWriter, $pCellReference, Comment $pC /** * Write VML comments to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet - * * @return string XML Output */ public function writeVMLComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet) @@ -166,7 +162,7 @@ public function writeVMLComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $ * @param string $pCellReference Cell reference, eg: 'A1' * @param Comment $pComment Comment */ - private function writeVMLComment(XMLWriter $objWriter, $pCellReference, Comment $pComment) + private function writeVMLComment(XMLWriter $objWriter, $pCellReference, Comment $pComment): void { // Metadata [$column, $row] = Coordinate::coordinateFromString($pCellReference); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php index 421f1e73ac..2cff1a8f6f 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php @@ -13,7 +13,6 @@ class ContentTypes extends WriterPart /** * Write content types to XML format. * - * @param Spreadsheet $spreadsheet * @param bool $includeCharts Flag indicating if we should include drawing details for charts * * @return string XML Output @@ -206,7 +205,7 @@ private function getImageMimeType($pFile) * @param string $pPartname Part name * @param string $pContentType Content type */ - private function writeDefaultContentType(XMLWriter $objWriter, $pPartname, $pContentType) + private function writeDefaultContentType(XMLWriter $objWriter, $pPartname, $pContentType): void { if ($pPartname != '' && $pContentType != '') { // Write content type @@ -226,7 +225,7 @@ private function writeDefaultContentType(XMLWriter $objWriter, $pPartname, $pCon * @param string $pPartname Part name * @param string $pContentType Content type */ - private function writeOverrideContentType(XMLWriter $objWriter, $pPartname, $pContentType) + private function writeOverrideContentType(XMLWriter $objWriter, $pPartname, $pContentType): void { if ($pPartname != '' && $pContentType != '') { // Write content type diff --git a/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php b/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php index 289d08c731..bcbc2379df 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php @@ -10,8 +10,6 @@ class DocProps extends WriterPart /** * Write docProps/app.xml to XML format. * - * @param Spreadsheet $spreadsheet - * * @return string XML Output */ public function writeDocPropsApp(Spreadsheet $spreadsheet) @@ -107,8 +105,6 @@ public function writeDocPropsApp(Spreadsheet $spreadsheet) /** * Write docProps/core.xml to XML format. * - * @param Spreadsheet $spreadsheet - * * @return string XML Output */ public function writeDocPropsCore(Spreadsheet $spreadsheet) @@ -174,8 +170,6 @@ public function writeDocPropsCore(Spreadsheet $spreadsheet) /** * Write docProps/custom.xml to XML format. * - * @param Spreadsheet $spreadsheet - * * @return string XML Output */ public function writeDocPropsCustom(Spreadsheet $spreadsheet) diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php index 4c5a413e85..1713b98229 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php @@ -14,7 +14,6 @@ class Drawing extends WriterPart /** * Write drawings to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * @param bool $includeCharts Flag indicating if we should include drawing details for charts * * @return string XML Output @@ -80,10 +79,9 @@ public function writeDrawings(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWo * Write drawings to XML format. * * @param XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Chart\Chart $pChart * @param int $pRelationId */ - public function writeChart(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Chart\Chart $pChart, $pRelationId = -1) + public function writeChart(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Chart\Chart $pChart, $pRelationId = -1): void { $tl = $pChart->getTopLeftPosition(); $tl['colRow'] = Coordinate::coordinateFromString($tl['cell']); @@ -151,11 +149,10 @@ public function writeChart(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Chart * Write drawings to XML format. * * @param XMLWriter $objWriter XML Writer - * @param BaseDrawing $pDrawing * @param int $pRelationId * @param null|int $hlinkClickId */ - public function writeDrawing(XMLWriter $objWriter, BaseDrawing $pDrawing, $pRelationId = -1, $hlinkClickId = null) + public function writeDrawing(XMLWriter $objWriter, BaseDrawing $pDrawing, $pRelationId = -1, $hlinkClickId = null): void { if ($pRelationId >= 0) { // xdr:oneCellAnchor @@ -283,8 +280,6 @@ public function writeDrawing(XMLWriter $objWriter, BaseDrawing $pDrawing, $pRela /** * Write VML header/footer images to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet - * * @return string XML Output */ public function writeVMLHeaderFooterImages(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet) @@ -434,7 +429,7 @@ public function writeVMLHeaderFooterImages(\PhpOffice\PhpSpreadsheet\Worksheet\W * @param string $pReference Reference * @param HeaderFooterDrawing $pImage Image */ - private function writeVMLHeaderFooterImage(XMLWriter $objWriter, $pReference, HeaderFooterDrawing $pImage) + private function writeVMLHeaderFooterImage(XMLWriter $objWriter, $pReference, HeaderFooterDrawing $pImage): void { // Calculate object id preg_match('{(\d+)}', md5($pReference), $m); @@ -471,8 +466,6 @@ private function writeVMLHeaderFooterImage(XMLWriter $objWriter, $pReference, He /** * Get an array of all drawings. * - * @param Spreadsheet $spreadsheet - * * @return \PhpOffice\PhpSpreadsheet\Worksheet\Drawing[] All drawings in PhpSpreadsheet */ public function allDrawings(Spreadsheet $spreadsheet) @@ -496,10 +489,9 @@ public function allDrawings(Spreadsheet $spreadsheet) } /** - * @param XMLWriter $objWriter * @param null|int $hlinkClickId */ - private function writeHyperLinkDrawing(XMLWriter $objWriter, $hlinkClickId) + private function writeHyperLinkDrawing(XMLWriter $objWriter, $hlinkClickId): void { if ($hlinkClickId === null) { return; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php index 6dc415029f..c28760657c 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php @@ -12,8 +12,6 @@ class Rels extends WriterPart /** * Write relationships to XML format. * - * @param Spreadsheet $spreadsheet - * * @return string XML Output */ public function writeRelationships(Spreadsheet $spreadsheet) @@ -85,8 +83,6 @@ public function writeRelationships(Spreadsheet $spreadsheet) /** * Write workbook relationships to XML format. * - * @param Spreadsheet $spreadsheet - * * @return string XML Output */ public function writeWorkbookRelationships(Spreadsheet $spreadsheet) @@ -164,7 +160,6 @@ public function writeWorkbookRelationships(Spreadsheet $spreadsheet) * rId1 - Drawings * rId_hyperlink_x - Hyperlinks * - * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * @param int $pWorksheetId * @param bool $includeCharts Flag indicating if we should write charts * @@ -271,7 +266,7 @@ public function writeWorksheetRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\ return $objWriter->getData(); } - private function writeUnparsedRelationship(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet, XMLWriter $objWriter, $relationship, $type) + private function writeUnparsedRelationship(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet, XMLWriter $objWriter, $relationship, $type): void { $unparsedLoadedData = $pWorksheet->getParent()->getUnparsedLoadedData(); if (!isset($unparsedLoadedData['sheets'][$pWorksheet->getCodeName()][$relationship])) { @@ -291,7 +286,6 @@ private function writeUnparsedRelationship(\PhpOffice\PhpSpreadsheet\Worksheet\W /** * Write drawing relationships to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * @param int &$chartRef Chart ID * @param bool $includeCharts Flag indicating if we should write charts * @@ -360,8 +354,6 @@ public function writeDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Wo /** * Write header/footer drawing relationships to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet - * * @return string XML Output */ public function writeHeaderFooterDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet) @@ -406,7 +398,7 @@ public function writeHeaderFooterDrawingRelationships(\PhpOffice\PhpSpreadsheet\ * @param string $pTarget Relationship target * @param string $pTargetMode Relationship target mode */ - private function writeRelationship(XMLWriter $objWriter, $pId, $pType, $pTarget, $pTargetMode = '') + private function writeRelationship(XMLWriter $objWriter, $pId, $pType, $pTarget, $pTargetMode = ''): void { if ($pType != '' && $pTarget != '') { // Write relationship diff --git a/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php b/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php index 531111abd9..8005207cc2 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php @@ -10,8 +10,6 @@ class RelsRibbon extends WriterPart /** * Write relationships for additional objects of custom UI (ribbon). * - * @param Spreadsheet $spreadsheet - * * @return string XML Output */ public function writeRibbonRelationships(Spreadsheet $spreadsheet) diff --git a/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php b/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php index fb508c6b50..55bcd360df 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php @@ -10,8 +10,6 @@ class RelsVBA extends WriterPart /** * Write relationships for a signed VBA Project. * - * @param Spreadsheet $spreadsheet - * * @return string XML Output */ public function writeVBARelationships(Spreadsheet $spreadsheet) diff --git a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php index 8e18e6f869..872d034349 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php @@ -112,7 +112,7 @@ public function writeStringTable(array $pStringTable) * @param RichText $pRichText Rich text * @param string $prefix Optional Namespace prefix */ - public function writeRichText(XMLWriter $objWriter, RichText $pRichText, $prefix = null) + public function writeRichText(XMLWriter $objWriter, RichText $pRichText, $prefix = null): void { if ($prefix !== null) { $prefix .= ':'; @@ -195,7 +195,7 @@ public function writeRichText(XMLWriter $objWriter, RichText $pRichText, $prefix * @param RichText|string $pRichText text string or Rich text * @param string $prefix Optional Namespace prefix */ - public function writeRichTextForCharts(XMLWriter $objWriter, $pRichText = null, $prefix = null) + public function writeRichTextForCharts(XMLWriter $objWriter, $pRichText = null, $prefix = null): void { if (!$pRichText instanceof RichText) { $textRun = $pRichText; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Style.php b/src/PhpSpreadsheet/Writer/Xlsx/Style.php index 54ec664fe1..74300a9c26 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Style.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Style.php @@ -18,8 +18,6 @@ class Style extends WriterPart /** * Write styles to XML format. * - * @param Spreadsheet $spreadsheet - * * @return string XML Output */ public function writeStyles(Spreadsheet $spreadsheet) @@ -151,7 +149,7 @@ public function writeStyles(Spreadsheet $spreadsheet) * @param XMLWriter $objWriter XML Writer * @param Fill $pFill Fill style */ - private function writeFill(XMLWriter $objWriter, Fill $pFill) + private function writeFill(XMLWriter $objWriter, Fill $pFill): void { // Check if this is a pattern type or gradient type if ($pFill->getFillType() === Fill::FILL_GRADIENT_LINEAR || @@ -170,7 +168,7 @@ private function writeFill(XMLWriter $objWriter, Fill $pFill) * @param XMLWriter $objWriter XML Writer * @param Fill $pFill Fill style */ - private function writeGradientFill(XMLWriter $objWriter, Fill $pFill) + private function writeGradientFill(XMLWriter $objWriter, Fill $pFill): void { // fill $objWriter->startElement('fill'); @@ -213,7 +211,7 @@ private function writeGradientFill(XMLWriter $objWriter, Fill $pFill) * @param XMLWriter $objWriter XML Writer * @param Fill $pFill Fill style */ - private function writePatternFill(XMLWriter $objWriter, Fill $pFill) + private function writePatternFill(XMLWriter $objWriter, Fill $pFill): void { // fill $objWriter->startElement('fill'); @@ -250,7 +248,7 @@ private function writePatternFill(XMLWriter $objWriter, Fill $pFill) * @param XMLWriter $objWriter XML Writer * @param Font $pFont Font style */ - private function writeFont(XMLWriter $objWriter, Font $pFont) + private function writeFont(XMLWriter $objWriter, Font $pFont): void { // font $objWriter->startElement('font'); @@ -329,7 +327,7 @@ private function writeFont(XMLWriter $objWriter, Font $pFont) * @param XMLWriter $objWriter XML Writer * @param Borders $pBorders Borders style */ - private function writeBorder(XMLWriter $objWriter, Borders $pBorders) + private function writeBorder(XMLWriter $objWriter, Borders $pBorders): void { // Write border $objWriter->startElement('border'); @@ -368,7 +366,7 @@ private function writeBorder(XMLWriter $objWriter, Borders $pBorders) * @param \PhpOffice\PhpSpreadsheet\Style\Style $pStyle Style * @param Spreadsheet $spreadsheet Workbook */ - private function writeCellStyleXf(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Style $pStyle, Spreadsheet $spreadsheet) + private function writeCellStyleXf(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Style $pStyle, Spreadsheet $spreadsheet): void { // xf $objWriter->startElement('xf'); @@ -442,7 +440,7 @@ private function writeCellStyleXf(XMLWriter $objWriter, \PhpOffice\PhpSpreadshee * @param XMLWriter $objWriter XML Writer * @param \PhpOffice\PhpSpreadsheet\Style\Style $pStyle Style */ - private function writeCellStyleDxf(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Style $pStyle) + private function writeCellStyleDxf(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Style $pStyle): void { // dxf $objWriter->startElement('dxf'); @@ -506,7 +504,7 @@ private function writeCellStyleDxf(XMLWriter $objWriter, \PhpOffice\PhpSpreadshe * @param string $pName Element name * @param Border $pBorder Border style */ - private function writeBorderPr(XMLWriter $objWriter, $pName, Border $pBorder) + private function writeBorderPr(XMLWriter $objWriter, $pName, Border $pBorder): void { // Write BorderPr if ($pBorder->getBorderStyle() != Border::BORDER_NONE) { @@ -529,7 +527,7 @@ private function writeBorderPr(XMLWriter $objWriter, $pName, Border $pBorder) * @param NumberFormat $pNumberFormat Number Format * @param int $pId Number Format identifier */ - private function writeNumFmt(XMLWriter $objWriter, NumberFormat $pNumberFormat, $pId = 0) + private function writeNumFmt(XMLWriter $objWriter, NumberFormat $pNumberFormat, $pId = 0): void { // Translate formatcode $formatCode = $pNumberFormat->getFormatCode(); @@ -546,8 +544,6 @@ private function writeNumFmt(XMLWriter $objWriter, NumberFormat $pNumberFormat, /** * Get an array of all styles. * - * @param Spreadsheet $spreadsheet - * * @return \PhpOffice\PhpSpreadsheet\Style\Style[] All styles in PhpSpreadsheet */ public function allStyles(Spreadsheet $spreadsheet) @@ -558,8 +554,6 @@ public function allStyles(Spreadsheet $spreadsheet) /** * Get an array of all conditional styles. * - * @param Spreadsheet $spreadsheet - * * @return Conditional[] All conditional styles in PhpSpreadsheet */ public function allConditionalStyles(Spreadsheet $spreadsheet) @@ -582,8 +576,6 @@ public function allConditionalStyles(Spreadsheet $spreadsheet) /** * Get an array of all fills. * - * @param Spreadsheet $spreadsheet - * * @return Fill[] All fills in PhpSpreadsheet */ public function allFills(Spreadsheet $spreadsheet) @@ -614,8 +606,6 @@ public function allFills(Spreadsheet $spreadsheet) /** * Get an array of all fonts. * - * @param Spreadsheet $spreadsheet - * * @return Font[] All fonts in PhpSpreadsheet */ public function allFonts(Spreadsheet $spreadsheet) @@ -637,8 +627,6 @@ public function allFonts(Spreadsheet $spreadsheet) /** * Get an array of all borders. * - * @param Spreadsheet $spreadsheet - * * @return Borders[] All borders in PhpSpreadsheet */ public function allBorders(Spreadsheet $spreadsheet) @@ -660,8 +648,6 @@ public function allBorders(Spreadsheet $spreadsheet) /** * Get an array of all number formats. * - * @param Spreadsheet $spreadsheet - * * @return NumberFormat[] All number formats in PhpSpreadsheet */ public function allNumberFormats(Spreadsheet $spreadsheet) diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Theme.php b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php index c609039501..5119117afd 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Theme.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php @@ -109,8 +109,6 @@ class Theme extends WriterPart /** * Write theme to XML format. * - * @param Spreadsheet $spreadsheet - * * @return string XML Output */ public function writeTheme(Spreadsheet $spreadsheet) diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php index a56c5b72fb..88befd0212 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php @@ -15,7 +15,6 @@ class Workbook extends WriterPart /** * Write workbook to XML format. * - * @param Spreadsheet $spreadsheet * @param bool $recalcRequired Indicate whether formulas should be recalculated before writing * * @return string XML Output @@ -72,7 +71,7 @@ public function writeWorkbook(Spreadsheet $spreadsheet, $recalcRequired = false) * * @param XMLWriter $objWriter XML Writer */ - private function writeFileVersion(XMLWriter $objWriter) + private function writeFileVersion(XMLWriter $objWriter): void { $objWriter->startElement('fileVersion'); $objWriter->writeAttribute('appName', 'xl'); @@ -87,7 +86,7 @@ private function writeFileVersion(XMLWriter $objWriter) * * @param XMLWriter $objWriter XML Writer */ - private function writeWorkbookPr(XMLWriter $objWriter) + private function writeWorkbookPr(XMLWriter $objWriter): void { $objWriter->startElement('workbookPr'); @@ -104,9 +103,8 @@ private function writeWorkbookPr(XMLWriter $objWriter) * Write BookViews. * * @param XMLWriter $objWriter XML Writer - * @param Spreadsheet $spreadsheet */ - private function writeBookViews(XMLWriter $objWriter, Spreadsheet $spreadsheet) + private function writeBookViews(XMLWriter $objWriter, Spreadsheet $spreadsheet): void { // bookViews $objWriter->startElement('bookViews'); @@ -133,9 +131,8 @@ private function writeBookViews(XMLWriter $objWriter, Spreadsheet $spreadsheet) * Write WorkbookProtection. * * @param XMLWriter $objWriter XML Writer - * @param Spreadsheet $spreadsheet */ - private function writeWorkbookProtection(XMLWriter $objWriter, Spreadsheet $spreadsheet) + private function writeWorkbookProtection(XMLWriter $objWriter, Spreadsheet $spreadsheet): void { if ($spreadsheet->getSecurity()->isSecurityEnabled()) { $objWriter->startElement('workbookProtection'); @@ -161,7 +158,7 @@ private function writeWorkbookProtection(XMLWriter $objWriter, Spreadsheet $spre * @param XMLWriter $objWriter XML Writer * @param bool $recalcRequired Indicate whether formulas should be recalculated before writing */ - private function writeCalcPr(XMLWriter $objWriter, $recalcRequired = true) + private function writeCalcPr(XMLWriter $objWriter, $recalcRequired = true): void { $objWriter->startElement('calcPr'); @@ -182,9 +179,8 @@ private function writeCalcPr(XMLWriter $objWriter, $recalcRequired = true) * Write sheets. * * @param XMLWriter $objWriter XML Writer - * @param Spreadsheet $spreadsheet */ - private function writeSheets(XMLWriter $objWriter, Spreadsheet $spreadsheet) + private function writeSheets(XMLWriter $objWriter, Spreadsheet $spreadsheet): void { // Write sheets $objWriter->startElement('sheets'); @@ -212,7 +208,7 @@ private function writeSheets(XMLWriter $objWriter, Spreadsheet $spreadsheet) * @param int $pRelId Relationship ID * @param string $sheetState Sheet state (visible, hidden, veryHidden) */ - private function writeSheet(XMLWriter $objWriter, $pSheetname, $pSheetId = 1, $pRelId = 1, $sheetState = 'visible') + private function writeSheet(XMLWriter $objWriter, $pSheetname, $pSheetId = 1, $pRelId = 1, $sheetState = 'visible'): void { if ($pSheetname != '') { // Write sheet @@ -233,9 +229,8 @@ private function writeSheet(XMLWriter $objWriter, $pSheetname, $pSheetId = 1, $p * Write Defined Names. * * @param XMLWriter $objWriter XML Writer - * @param Spreadsheet $spreadsheet */ - private function writeDefinedNames(XMLWriter $objWriter, Spreadsheet $spreadsheet) + private function writeDefinedNames(XMLWriter $objWriter, Spreadsheet $spreadsheet): void { // Write defined names $objWriter->startElement('definedNames'); @@ -266,9 +261,8 @@ private function writeDefinedNames(XMLWriter $objWriter, Spreadsheet $spreadshee * Write named ranges. * * @param XMLWriter $objWriter XML Writer - * @param Spreadsheet $spreadsheet */ - private function writeNamedRanges(XMLWriter $objWriter, Spreadsheet $spreadsheet) + private function writeNamedRanges(XMLWriter $objWriter, Spreadsheet $spreadsheet): void { // Loop named ranges $namedRanges = $spreadsheet->getNamedRanges(); @@ -281,9 +275,8 @@ private function writeNamedRanges(XMLWriter $objWriter, Spreadsheet $spreadsheet * Write Defined Name for named range. * * @param XMLWriter $objWriter XML Writer - * @param NamedRange $pNamedRange */ - private function writeDefinedNameForNamedRange(XMLWriter $objWriter, NamedRange $pNamedRange) + private function writeDefinedNameForNamedRange(XMLWriter $objWriter, NamedRange $pNamedRange): void { // definedName for named range $objWriter->startElement('definedName'); @@ -312,10 +305,9 @@ private function writeDefinedNameForNamedRange(XMLWriter $objWriter, NamedRange * Write Defined Name for autoFilter. * * @param XMLWriter $objWriter XML Writer - * @param Worksheet $pSheet * @param int $pSheetId */ - private function writeDefinedNameForAutofilter(XMLWriter $objWriter, Worksheet $pSheet, $pSheetId = 0) + private function writeDefinedNameForAutofilter(XMLWriter $objWriter, Worksheet $pSheet, $pSheetId = 0): void { // definedName for autoFilter $autoFilterRange = $pSheet->getAutoFilter()->getRange(); @@ -345,10 +337,9 @@ private function writeDefinedNameForAutofilter(XMLWriter $objWriter, Worksheet $ * Write Defined Name for PrintTitles. * * @param XMLWriter $objWriter XML Writer - * @param Worksheet $pSheet * @param int $pSheetId */ - private function writeDefinedNameForPrintTitles(XMLWriter $objWriter, Worksheet $pSheet, $pSheetId = 0) + private function writeDefinedNameForPrintTitles(XMLWriter $objWriter, Worksheet $pSheet, $pSheetId = 0): void { // definedName for PrintTitles if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet() || $pSheet->getPageSetup()->isRowsToRepeatAtTopSet()) { @@ -387,10 +378,9 @@ private function writeDefinedNameForPrintTitles(XMLWriter $objWriter, Worksheet * Write Defined Name for PrintTitles. * * @param XMLWriter $objWriter XML Writer - * @param Worksheet $pSheet * @param int $pSheetId */ - private function writeDefinedNameForPrintArea(XMLWriter $objWriter, Worksheet $pSheet, $pSheetId = 0) + private function writeDefinedNameForPrintArea(XMLWriter $objWriter, Worksheet $pSheet, $pSheetId = 0): void { // definedName for PrintArea if ($pSheet->getPageSetup()->isPrintAreaSet()) { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index febee54dd4..25b09d1978 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -23,7 +23,6 @@ class Worksheet extends WriterPart /** * Write worksheet to XML format. * - * @param PhpspreadsheetWorksheet $pSheet * @param string[] $pStringTable * @param bool $includeCharts Flag indicating if we should write charts * @@ -132,7 +131,7 @@ public function writeWorksheet(PhpspreadsheetWorksheet $pSheet, $pStringTable = * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeSheetPr(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeSheetPr(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // sheetPr $objWriter->startElement('sheetPr'); @@ -178,7 +177,7 @@ private function writeSheetPr(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSh * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeDimension(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeDimension(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // dimension $objWriter->startElement('dimension'); @@ -192,7 +191,7 @@ private function writeDimension(XMLWriter $objWriter, PhpspreadsheetWorksheet $p * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeSheetViews(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeSheetViews(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // sheetViews $objWriter->startElement('sheetViews'); @@ -306,7 +305,7 @@ private function writeSheetViews(XMLWriter $objWriter, PhpspreadsheetWorksheet $ * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeSheetFormatPr(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeSheetFormatPr(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // sheetFormatPr $objWriter->startElement('sheetFormatPr'); @@ -357,7 +356,7 @@ private function writeSheetFormatPr(XMLWriter $objWriter, PhpspreadsheetWorkshee * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeCols(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeCols(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // cols if (count($pSheet->getColumnDimensions()) > 0) { @@ -421,7 +420,7 @@ private function writeCols(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeSheetProtection(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeSheetProtection(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // sheetProtection $objWriter->startElement('sheetProtection'); @@ -504,7 +503,7 @@ private static function writeTextCondElements(XMLWriter $objWriter, Conditional * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeConditionalFormatting(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeConditionalFormatting(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // Conditional id $id = 1; @@ -557,7 +556,7 @@ private function writeConditionalFormatting(XMLWriter $objWriter, Phpspreadsheet * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeDataValidations(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeDataValidations(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // Datavalidation collection $dataValidationCollection = $pSheet->getDataValidationCollection(); @@ -623,7 +622,7 @@ private function writeDataValidations(XMLWriter $objWriter, PhpspreadsheetWorksh * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeHyperlinks(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeHyperlinks(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // Hyperlink collection $hyperlinkCollection = $pSheet->getHyperlinkCollection(); @@ -664,7 +663,7 @@ private function writeHyperlinks(XMLWriter $objWriter, PhpspreadsheetWorksheet $ * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeProtectedRanges(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeProtectedRanges(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { if (count($pSheet->getProtectedCells()) > 0) { // protectedRanges @@ -692,7 +691,7 @@ private function writeProtectedRanges(XMLWriter $objWriter, PhpspreadsheetWorksh * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeMergeCells(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeMergeCells(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { if (count($pSheet->getMergeCells()) > 0) { // mergeCells @@ -716,7 +715,7 @@ private function writeMergeCells(XMLWriter $objWriter, PhpspreadsheetWorksheet $ * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writePrintOptions(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writePrintOptions(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // printOptions $objWriter->startElement('printOptions'); @@ -741,7 +740,7 @@ private function writePrintOptions(XMLWriter $objWriter, PhpspreadsheetWorksheet * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writePageMargins(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writePageMargins(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // pageMargins $objWriter->startElement('pageMargins'); @@ -760,7 +759,7 @@ private function writePageMargins(XMLWriter $objWriter, PhpspreadsheetWorksheet * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeAutoFilter(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeAutoFilter(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { $autoFilterRange = $pSheet->getAutoFilter()->getRange(); if (!empty($autoFilterRange)) { @@ -850,7 +849,7 @@ private function writeAutoFilter(XMLWriter $objWriter, PhpspreadsheetWorksheet $ * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writePageSetup(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writePageSetup(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // pageSetup $objWriter->startElement('pageSetup'); @@ -889,7 +888,7 @@ private function writePageSetup(XMLWriter $objWriter, PhpspreadsheetWorksheet $p * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeHeaderFooter(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeHeaderFooter(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // headerFooter $objWriter->startElement('headerFooter'); @@ -913,7 +912,7 @@ private function writeHeaderFooter(XMLWriter $objWriter, PhpspreadsheetWorksheet * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeBreaks(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeBreaks(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // Get row and column breaks $aRowBreaks = []; @@ -970,7 +969,7 @@ private function writeBreaks(XMLWriter $objWriter, PhpspreadsheetWorksheet $pShe * @param PhpspreadsheetWorksheet $pSheet Worksheet * @param string[] $pStringTable String table */ - private function writeSheetData(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet, array $pStringTable) + private function writeSheetData(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet, array $pStringTable): void { // Flipped stringtable, for faster index searching $aFlippedStringTable = $this->getParentWriter()->getWriterPart('stringtable')->flipStringTable($pStringTable); @@ -1049,8 +1048,6 @@ private function writeSheetData(XMLWriter $objWriter, PhpspreadsheetWorksheet $p } /** - * @param XMLWriter $objWriter - * @param string $mappedType * @param RichText|string $cellValue */ private function writeCellInlineStr(XMLWriter $objWriter, string $mappedType, $cellValue): void @@ -1066,8 +1063,6 @@ private function writeCellInlineStr(XMLWriter $objWriter, string $mappedType, $c } /** - * @param XMLWriter $objWriter - * @param string $mappedType * @param RichText|string $cellValue * @param string[] $pFlippedStringTable */ @@ -1082,7 +1077,6 @@ private function writeCellString(XMLWriter $objWriter, string $mappedType, $cell } /** - * @param XMLWriter $objWriter * @param float|int $cellValue */ private function writeCellNumeric(XMLWriter $objWriter, $cellValue): void @@ -1156,7 +1150,7 @@ private function writeCellFormula(XMLWriter $objWriter, string $cellValue, Cell * @param string $pCellAddress Cell Address * @param string[] $pFlippedStringTable String table (flipped), for faster index searching */ - private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet, string $pCellAddress, array $pFlippedStringTable) + private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet, string $pCellAddress, array $pFlippedStringTable): void { // Cell $pCell = $pSheet->getCell($pCellAddress); @@ -1210,7 +1204,7 @@ private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet * @param PhpspreadsheetWorksheet $pSheet Worksheet * @param bool $includeCharts Flag indicating if we should include drawing details for charts */ - private function writeDrawings(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet, $includeCharts = false) + private function writeDrawings(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet, $includeCharts = false): void { $unparsedLoadedData = $pSheet->getParent()->getUnparsedLoadedData(); $hasUnparsedDrawing = isset($unparsedLoadedData['sheets'][$pSheet->getCodeName()]['drawingOriginalIds']); @@ -1239,7 +1233,7 @@ private function writeDrawings(XMLWriter $objWriter, PhpspreadsheetWorksheet $pS * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeLegacyDrawing(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeLegacyDrawing(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // If sheet contains comments, add the relationships if (count($pSheet->getComments()) > 0) { @@ -1255,7 +1249,7 @@ private function writeLegacyDrawing(XMLWriter $objWriter, PhpspreadsheetWorkshee * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet */ - private function writeLegacyDrawingHF(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeLegacyDrawingHF(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { // If sheet contains images, add the relationships if (count($pSheet->getHeaderFooter()->getImages()) > 0) { @@ -1265,7 +1259,7 @@ private function writeLegacyDrawingHF(XMLWriter $objWriter, PhpspreadsheetWorksh } } - private function writeAlternateContent(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) + private function writeAlternateContent(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet): void { if (empty($pSheet->getParent()->getUnparsedLoadedData()['sheets'][$pSheet->getCodeName()]['AlternateContents'])) { return; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php b/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php index 7119512ce4..a9137dfc85 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php @@ -25,8 +25,6 @@ public function getParentWriter() /** * Set parent Xlsx object. - * - * @param Xlsx $pWriter */ public function __construct(Xlsx $pWriter) { diff --git a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php index a923fa1994..80431c4dfb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php @@ -27,7 +27,7 @@ protected function tearDown(): void * @param mixed $expectedResultExcel * @param mixed $expectedResultOpenOffice */ - public function testBinaryComparisonOperation($formula, $expectedResultExcel, $expectedResultOpenOffice) + public function testBinaryComparisonOperation($formula, $expectedResultExcel, $expectedResultOpenOffice): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $resultExcel = Calculation::getInstance()->_calculateFormulaValue($formula); @@ -50,7 +50,7 @@ public function providerBinaryComparisonOperation() * @param array|string $functionCall * @param string $argumentCount */ - public function testGetFunctions($category, $functionCall, $argumentCount) + public function testGetFunctions($category, $functionCall, $argumentCount): void { self::assertIsCallable($functionCall); } @@ -60,7 +60,7 @@ public function providerGetFunctions() return Calculation::getInstance()->getFunctions(); } - public function testIsImplemented() + public function testIsImplemented(): void { $calculation = Calculation::getInstance(); self::assertFalse($calculation->isImplemented('non-existing-function')); @@ -74,7 +74,7 @@ public function testIsImplemented() * * @param string $locale */ - public function testCanLoadAllSupportedLocales($locale) + public function testCanLoadAllSupportedLocales($locale): void { $calculation = Calculation::getInstance(); self::assertTrue($calculation->setLocale($locale)); @@ -104,7 +104,7 @@ public function providerCanLoadAllSupportedLocales() ]; } - public function testDoesHandleXlfnFunctions() + public function testDoesHandleXlfnFunctions(): void { $calculation = Calculation::getInstance(); @@ -119,7 +119,7 @@ public function testDoesHandleXlfnFunctions() self::assertEquals('Function', $function['type']); } - public function testFormulaWithOptionalArgumentsAndRequiredCellReferenceShouldPassNullForMissingArguments() + public function testFormulaWithOptionalArgumentsAndRequiredCellReferenceShouldPassNullForMissingArguments(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -141,7 +141,7 @@ public function testFormulaWithOptionalArgumentsAndRequiredCellReferenceShouldPa self::assertEquals(5, $cell->getCalculatedValue(), 'missing arguments should be filled with null'); } - public function testCellSetAsQuotedText() + public function testCellSetAsQuotedText(): void { $spreadsheet = new Spreadsheet(); $workSheet = $spreadsheet->getActiveSheet(); @@ -153,7 +153,7 @@ public function testCellSetAsQuotedText() self::assertEquals("=cmd|'/C calc'!A0", $cell->getCalculatedValue()); } - public function testCellWithDdeExpresion() + public function testCellWithDdeExpresion(): void { $spreadsheet = new Spreadsheet(); $workSheet = $spreadsheet->getActiveSheet(); @@ -164,7 +164,7 @@ public function testCellWithDdeExpresion() self::assertEquals("=cmd|'/C calc'!A0", $cell->getCalculatedValue()); } - public function testCellWithFormulaTwoIndirect() + public function testCellWithFormulaTwoIndirect(): void { $spreadsheet = new Spreadsheet(); $workSheet = $spreadsheet->getActiveSheet(); @@ -180,7 +180,7 @@ public function testCellWithFormulaTwoIndirect() self::assertEquals('9', $cell3->getCalculatedValue()); } - public function testBranchPruningFormulaParsingSimpleCase() + public function testBranchPruningFormulaParsingSimpleCase(): void { $calculation = Calculation::getInstance(); $calculation->flushInstance(); // resets the ids @@ -204,11 +204,11 @@ public function testBranchPruningFormulaParsingSimpleCase() $foundConditionalOnB1 = $foundConditionalOnB1 || ($isB1Reference && $correctOnlyIf); } - $this->assertTrue($foundEqualAssociatedToStoreKey); - $this->assertTrue($foundConditionalOnB1); + self::assertTrue($foundEqualAssociatedToStoreKey); + self::assertTrue($foundConditionalOnB1); } - public function testBranchPruningFormulaParsingMultipleIfsCase() + public function testBranchPruningFormulaParsingMultipleIfsCase(): void { $calculation = Calculation::getInstance(); $calculation->flushInstance(); // resets the ids @@ -235,11 +235,11 @@ public function testBranchPruningFormulaParsingMultipleIfsCase() $correctOnlyIf = ($token['onlyIf'] ?? '') == 'storeKey-1'; $productFunctionCorrectlyTagged = $productFunctionCorrectlyTagged || ($isFunction && $isProductFunction && $correctOnlyIf); } - $this->assertFalse($plusGotTagged, 'chaining IF( should not affect the external operators'); - $this->assertTrue($productFunctionCorrectlyTagged, 'function nested inside if should be tagged to be processed only if parent branching requires it'); + self::assertFalse($plusGotTagged, 'chaining IF( should not affect the external operators'); + self::assertTrue($productFunctionCorrectlyTagged, 'function nested inside if should be tagged to be processed only if parent branching requires it'); } - public function testBranchPruningFormulaParingNestedIfCase() + public function testBranchPruningFormulaParingNestedIfCase(): void { $calculation = Calculation::getInstance(); $calculation->flushInstance(); // resets the ids @@ -266,12 +266,12 @@ public function testBranchPruningFormulaParingNestedIfCase() $productFunctionCorrectlyTagged = $productFunctionCorrectlyTagged || ($isProductFunction && $isOnlyIfNotDepth1 && !$isStoreKeyDepth1 && !$isOnlyIfNotDepth0); $findOneOperandCountTagged = $findOneOperandCountTagged || ($isIfOperand && $isOnlyIfNotDepth0); } - $this->assertTrue($plusCorrectlyTagged); - $this->assertTrue($productFunctionCorrectlyTagged); - $this->assertTrue($notFunctionCorrectlyTagged); + self::assertTrue($plusCorrectlyTagged); + self::assertTrue($productFunctionCorrectlyTagged); + self::assertTrue($notFunctionCorrectlyTagged); } - public function testBranchPruningFormulaParsingNoArgumentFunctionCase() + public function testBranchPruningFormulaParsingNoArgumentFunctionCase(): void { $calculation = Calculation::getInstance(); $calculation->flushInstance(); // resets the ids @@ -283,7 +283,7 @@ public function testBranchPruningFormulaParsingNoArgumentFunctionCase() self::assertTrue(true); } - public function testBranchPruningFormulaParsingInequalitiesConditionsCase() + public function testBranchPruningFormulaParsingInequalitiesConditionsCase(): void { $calculation = Calculation::getInstance(); $calculation->flushInstance(); // resets the ids @@ -298,7 +298,7 @@ public function testBranchPruningFormulaParsingInequalitiesConditionsCase() $properlyTaggedPlus = $properlyTaggedPlus || ($isPlus && $hasOnlyIf); } - $this->assertTrue($properlyTaggedPlus); + self::assertTrue($properlyTaggedPlus); } /** @@ -320,7 +320,7 @@ public function testFullExecution( $cellCoordinates, $shouldBeSetInCacheCells = [], $shouldNotBeSetInCacheCells = [] - ) { + ): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -330,24 +330,24 @@ public function testFullExecution( $cell->setValue($formula); $calculated = $cell->getCalculatedValue(); - $this->assertEquals($expectedResult, $calculated); + self::assertEquals($expectedResult, $calculated); // this mostly to ensure that at least some cells are cached foreach ($shouldBeSetInCacheCells as $setCell) { unset($inCache); $calculation->getValueFromCache('Worksheet!' . $setCell, $inCache); - $this->assertNotEmpty($inCache); + self::assertNotEmpty($inCache); } foreach ($shouldNotBeSetInCacheCells as $notSetCell) { unset($inCache); $calculation->getValueFromCache('Worksheet!' . $notSetCell, $inCache); - $this->assertEmpty($inCache); + self::assertEmpty($inCache); } $calculation->disableBranchPruning(); $calculated = $cell->getCalculatedValue(); - $this->assertEquals($expectedResult, $calculated); + self::assertEquals($expectedResult, $calculated); } public function dataProviderBranchPruningFullExecution() diff --git a/tests/PhpSpreadsheetTests/Calculation/DefinedNameConfusedForCellTest.php b/tests/PhpSpreadsheetTests/Calculation/DefinedNameConfusedForCellTest.php index 54333afa54..12d73356ae 100644 --- a/tests/PhpSpreadsheetTests/Calculation/DefinedNameConfusedForCellTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/DefinedNameConfusedForCellTest.php @@ -7,7 +7,7 @@ class DefinedNameConfusedForCellTest extends TestCase { - public function testDefinedName() + public function testDefinedName(): void { $obj = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); $sheet0 = $obj->setActiveSheetIndex(0); diff --git a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php index 5c3928eb4d..e80ef35b66 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php @@ -18,7 +18,7 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testAMORDEGRC($expectedResult, ...$args) + public function testAMORDEGRC($expectedResult, ...$args): void { $result = Financial::AMORDEGRC(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -34,7 +34,7 @@ public function providerAMORDEGRC() * * @param mixed $expectedResult */ - public function testAMORLINC($expectedResult, ...$args) + public function testAMORLINC($expectedResult, ...$args): void { $result = Financial::AMORLINC(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -50,7 +50,7 @@ public function providerAMORLINC() * * @param mixed $expectedResult */ - public function testCOUPDAYBS($expectedResult, ...$args) + public function testCOUPDAYBS($expectedResult, ...$args): void { $result = Financial::COUPDAYBS(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -66,7 +66,7 @@ public function providerCOUPDAYBS() * * @param mixed $expectedResult */ - public function testCOUPDAYS($expectedResult, ...$args) + public function testCOUPDAYS($expectedResult, ...$args): void { $result = Financial::COUPDAYS(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -82,7 +82,7 @@ public function providerCOUPDAYS() * * @param mixed $expectedResult */ - public function testCOUPDAYSNC($expectedResult, ...$args) + public function testCOUPDAYSNC($expectedResult, ...$args): void { $result = Financial::COUPDAYSNC(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -98,7 +98,7 @@ public function providerCOUPDAYSNC() * * @param mixed $expectedResult */ - public function testCOUPNCD($expectedResult, ...$args) + public function testCOUPNCD($expectedResult, ...$args): void { $result = Financial::COUPNCD(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -114,7 +114,7 @@ public function providerCOUPNCD() * * @param mixed $expectedResult */ - public function testCOUPNUM($expectedResult, ...$args) + public function testCOUPNUM($expectedResult, ...$args): void { $result = Financial::COUPNUM(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -130,7 +130,7 @@ public function providerCOUPNUM() * * @param mixed $expectedResult */ - public function testCOUPPCD($expectedResult, ...$args) + public function testCOUPPCD($expectedResult, ...$args): void { $result = Financial::COUPPCD(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -146,7 +146,7 @@ public function providerCOUPPCD() * * @param mixed $expectedResult */ - public function testCUMIPMT($expectedResult, ...$args) + public function testCUMIPMT($expectedResult, ...$args): void { $result = Financial::CUMIPMT(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -162,7 +162,7 @@ public function providerCUMIPMT() * * @param mixed $expectedResult */ - public function testCUMPRINC($expectedResult, ...$args) + public function testCUMPRINC($expectedResult, ...$args): void { $result = Financial::CUMPRINC(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -178,7 +178,7 @@ public function providerCUMPRINC() * * @param mixed $expectedResult */ - public function testDB($expectedResult, ...$args) + public function testDB($expectedResult, ...$args): void { $result = Financial::DB(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -194,7 +194,7 @@ public function providerDB() * * @param mixed $expectedResult */ - public function testDDB($expectedResult, ...$args) + public function testDDB($expectedResult, ...$args): void { $result = Financial::DDB(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -210,7 +210,7 @@ public function providerDDB() * * @param mixed $expectedResult */ - public function testDISC($expectedResult, ...$args) + public function testDISC($expectedResult, ...$args): void { $result = Financial::DISC(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -226,7 +226,7 @@ public function providerDISC() * * @param mixed $expectedResult */ - public function testDOLLARDE($expectedResult, ...$args) + public function testDOLLARDE($expectedResult, ...$args): void { $result = Financial::DOLLARDE(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -242,7 +242,7 @@ public function providerDOLLARDE() * * @param mixed $expectedResult */ - public function testDOLLARFR($expectedResult, ...$args) + public function testDOLLARFR($expectedResult, ...$args): void { $result = Financial::DOLLARFR(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -258,7 +258,7 @@ public function providerDOLLARFR() * * @param mixed $expectedResult */ - public function testEFFECT($expectedResult, ...$args) + public function testEFFECT($expectedResult, ...$args): void { $result = Financial::EFFECT(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -274,7 +274,7 @@ public function providerEFFECT() * * @param mixed $expectedResult */ - public function testFV($expectedResult, ...$args) + public function testFV($expectedResult, ...$args): void { $result = Financial::FV(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -290,7 +290,7 @@ public function providerFV() * * @param mixed $expectedResult */ - public function testFVSCHEDULE($expectedResult, ...$args) + public function testFVSCHEDULE($expectedResult, ...$args): void { $result = Financial::FVSCHEDULE(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -306,7 +306,7 @@ public function providerFVSCHEDULE() * * @param mixed $expectedResult */ - public function testINTRATE($expectedResult, ...$args) + public function testINTRATE($expectedResult, ...$args): void { $result = Financial::INTRATE(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -322,7 +322,7 @@ public function providerINTRATE() * * @param mixed $expectedResult */ - public function testIPMT($expectedResult, ...$args) + public function testIPMT($expectedResult, ...$args): void { $result = Financial::IPMT(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -338,7 +338,7 @@ public function providerIPMT() * * @param mixed $expectedResult */ - public function testIRR($expectedResult, ...$args) + public function testIRR($expectedResult, ...$args): void { $result = Financial::IRR(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -354,7 +354,7 @@ public function providerIRR() * * @param mixed $expectedResult */ - public function testISPMT($expectedResult, ...$args) + public function testISPMT($expectedResult, ...$args): void { $result = Financial::ISPMT(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -370,7 +370,7 @@ public function providerISPMT() * * @param mixed $expectedResult */ - public function testMIRR($expectedResult, ...$args) + public function testMIRR($expectedResult, ...$args): void { $result = Financial::MIRR(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -386,7 +386,7 @@ public function providerMIRR() * * @param mixed $expectedResult */ - public function testNOMINAL($expectedResult, ...$args) + public function testNOMINAL($expectedResult, ...$args): void { $result = Financial::NOMINAL(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -402,7 +402,7 @@ public function providerNOMINAL() * * @param mixed $expectedResult */ - public function testNPER($expectedResult, ...$args) + public function testNPER($expectedResult, ...$args): void { $result = Financial::NPER(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -418,7 +418,7 @@ public function providerNPER() * * @param mixed $expectedResult */ - public function testNPV($expectedResult, ...$args) + public function testNPV($expectedResult, ...$args): void { $result = Financial::NPV(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -434,7 +434,7 @@ public function providerNPV() * * @param mixed $expectedResult */ - public function testPRICE($expectedResult, ...$args) + public function testPRICE($expectedResult, ...$args): void { $result = Financial::PRICE(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-7); @@ -450,7 +450,7 @@ public function providerPRICE() * * @param mixed $expectedResult */ - public function testPRICE3($expectedResult, ...$args) + public function testPRICE3($expectedResult, ...$args): void { // These results (PRICE function with basis codes 2 and 3) // agree with published algorithm, LibreOffice, and Gnumeric. @@ -469,7 +469,7 @@ public function providerPRICE3() * * @param mixed $expectedResult */ - public function testPRICEDISC($expectedResult, array $args) + public function testPRICEDISC($expectedResult, array $args): void { $result = Financial::PRICEDISC(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -485,7 +485,7 @@ public function providerPRICEDISC() * * @param mixed $expectedResult */ - public function testPV($expectedResult, array $args) + public function testPV($expectedResult, array $args): void { $result = Financial::PV(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -501,7 +501,7 @@ public function providerPV() * * @param mixed $expectedResult */ - public function testRATE($expectedResult, ...$args) + public function testRATE($expectedResult, ...$args): void { $result = Financial::RATE(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -518,7 +518,7 @@ public function providerRATE() * @param mixed $expectedResult * @param mixed $message */ - public function testXIRR($expectedResult, $message, ...$args) + public function testXIRR($expectedResult, $message, ...$args): void { $result = Financial::XIRR(...$args); if (is_numeric($result) && is_numeric($expectedResult)) { @@ -543,7 +543,7 @@ public function providerXIRR() * @param mixed $expectedResult * @param mixed $message */ - public function testXNPV($expectedResult, $message, ...$args) + public function testXNPV($expectedResult, $message, ...$args): void { $result = Financial::XNPV(...$args); if (is_numeric($result) && is_numeric($expectedResult)) { @@ -567,7 +567,7 @@ public function providerXNPV() * * @param mixed $expectedResult */ - public function testPDURATION($expectedResult, array $args) + public function testPDURATION($expectedResult, array $args): void { $result = Financial::PDURATION(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -583,7 +583,7 @@ public function providerPDURATION() * * @param mixed $expectedResult */ - public function testRRI($expectedResult, array $args) + public function testRRI($expectedResult, array $args): void { $result = Financial::RRI(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -599,7 +599,7 @@ public function providerRRI() * * @param mixed $expectedResult */ - public function testSLN($expectedResult, array $args) + public function testSLN($expectedResult, array $args): void { $result = Financial::SLN(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -615,7 +615,7 @@ public function providerSLN() * * @param mixed $expectedResult */ - public function testSYD($expectedResult, array $args) + public function testSYD($expectedResult, array $args): void { $result = Financial::SYD(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); diff --git a/tests/PhpSpreadsheetTests/Calculation/FormulaAsStringTest.php b/tests/PhpSpreadsheetTests/Calculation/FormulaAsStringTest.php index abf7589a08..2cbdc960c9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FormulaAsStringTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FormulaAsStringTest.php @@ -13,7 +13,7 @@ class FormulaAsStringTest extends TestCase * @param mixed $expectedResult * @param string $formula */ - public function testFunctionsAsString($expectedResult, $formula) + public function testFunctionsAsString($expectedResult, $formula): void { $spreadsheet = new Spreadsheet(); $workSheet = $spreadsheet->getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php index 35fbe05bc5..db8e29a1f7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php @@ -24,10 +24,10 @@ protected function setUp(): void * @param $endDate * @param $unit */ - public function testDATEDIF($expectedResult, $startDate, $endDate, $unit) + public function testDATEDIF($expectedResult, $startDate, $endDate, $unit): void { $result = DateTime::DATEDIF($startDate, $endDate, $unit); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerDATEDIF() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php index c354f851b2..48f7cfd7ec 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php @@ -24,10 +24,10 @@ protected function setUp(): void * @param $month * @param $day */ - public function testDATE($expectedResult, $year, $month, $day) + public function testDATE($expectedResult, $year, $month, $day): void { $result = DateTime::DATE($year, $month, $day); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerDATE() @@ -35,41 +35,41 @@ public function providerDATE() return require 'tests/data/Calculation/DateTime/DATE.php'; } - public function testDATEtoUnixTimestamp() + public function testDATEtoUnixTimestamp(): void { Functions::setReturnDateType(Functions::RETURNDATE_UNIX_TIMESTAMP); $result = DateTime::DATE(2012, 1, 31); - $this->assertEquals(1327968000, $result); - $this->assertEqualsWithDelta(1327968000, $result, 1E-8); + self::assertEquals(1327968000, $result); + self::assertEqualsWithDelta(1327968000, $result, 1E-8); } - public function testDATEtoDateTimeObject() + public function testDATEtoDateTimeObject(): void { Functions::setReturnDateType(Functions::RETURNDATE_PHP_DATETIME_OBJECT); $result = DateTime::DATE(2012, 1, 31); // Must return an object... - $this->assertIsObject($result); + self::assertIsObject($result); // ... of the correct type - $this->assertTrue(is_a($result, 'DateTimeInterface')); + self::assertTrue(is_a($result, 'DateTimeInterface')); // ... with the correct value - $this->assertEquals($result->format('d-M-Y'), '31-Jan-2012'); + self::assertEquals($result->format('d-M-Y'), '31-Jan-2012'); } - public function testDATEwith1904Calendar() + public function testDATEwith1904Calendar(): void { Date::setExcelCalendar(Date::CALENDAR_MAC_1904); $result = DateTime::DATE(1918, 11, 11); - $this->assertEquals($result, 5428); + self::assertEquals($result, 5428); } - public function testDATEwith1904CalendarError() + public function testDATEwith1904CalendarError(): void { Date::setExcelCalendar(Date::CALENDAR_MAC_1904); $result = DateTime::DATE(1901, 1, 31); - $this->assertEquals($result, '#NUM!'); + self::assertEquals($result, '#NUM!'); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php index 205418015c..51e4f7c0cf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php @@ -23,10 +23,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $dateValue */ - public function testDATEVALUE($expectedResult, $dateValue) + public function testDATEVALUE($expectedResult, $dateValue): void { $result = DateTime::DATEVALUE($dateValue); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerDATEVALUE() @@ -34,25 +34,25 @@ public function providerDATEVALUE() return require 'tests/data/Calculation/DateTime/DATEVALUE.php'; } - public function testDATEVALUEtoUnixTimestamp() + public function testDATEVALUEtoUnixTimestamp(): void { Functions::setReturnDateType(Functions::RETURNDATE_UNIX_TIMESTAMP); $result = DateTime::DATEVALUE('2012-1-31'); - $this->assertEquals(1327968000, $result); - $this->assertEqualsWithDelta(1327968000, $result, 1E-8); + self::assertEquals(1327968000, $result); + self::assertEqualsWithDelta(1327968000, $result, 1E-8); } - public function testDATEVALUEtoDateTimeObject() + public function testDATEVALUEtoDateTimeObject(): void { Functions::setReturnDateType(Functions::RETURNDATE_PHP_DATETIME_OBJECT); $result = DateTime::DATEVALUE('2012-1-31'); // Must return an object... - $this->assertIsObject($result); + self::assertIsObject($result); // ... of the correct type - $this->assertTrue(is_a($result, DateTimeInterface::class)); + self::assertTrue(is_a($result, DateTimeInterface::class)); // ... with the correct value - $this->assertEquals($result->format('d-M-Y'), '31-Jan-2012'); + self::assertEquals($result->format('d-M-Y'), '31-Jan-2012'); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php index 77c2993924..8f4639eb9f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php @@ -23,15 +23,15 @@ protected function setUp(): void * @param mixed $expectedResultOpenOffice * @param $dateTimeValue */ - public function testDAY($expectedResultExcel, $expectedResultOpenOffice, $dateTimeValue) + public function testDAY($expectedResultExcel, $expectedResultOpenOffice, $dateTimeValue): void { $resultExcel = DateTime::DAYOFMONTH($dateTimeValue); - $this->assertEqualsWithDelta($expectedResultExcel, $resultExcel, 1E-8); + self::assertEqualsWithDelta($expectedResultExcel, $resultExcel, 1E-8); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); $resultOpenOffice = DateTime::DAYOFMONTH($dateTimeValue); - $this->assertEqualsWithDelta($expectedResultOpenOffice, $resultOpenOffice, 1E-8); + self::assertEqualsWithDelta($expectedResultOpenOffice, $resultOpenOffice, 1E-8); } public function providerDAY() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php index 40e86f311c..47449e0d17 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php @@ -24,10 +24,10 @@ protected function setUp(): void * @param $endDate * @param $method */ - public function testDAYS360($expectedResult, $startDate, $endDate, $method) + public function testDAYS360($expectedResult, $startDate, $endDate, $method): void { $result = DateTime::DAYS360($startDate, $endDate, $method); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerDAYS360() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php index 3c04395064..fe31dfcc7e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php @@ -23,10 +23,10 @@ protected function setUp(): void * @param $endDate * @param $startDate */ - public function testDAYS($expectedResult, $endDate, $startDate) + public function testDAYS($expectedResult, $endDate, $startDate): void { $result = DateTime::DAYS($endDate, $startDate); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerDAYS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php index f931543e7e..a887ba5b63 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php @@ -23,10 +23,10 @@ protected function setUp(): void * @param $dateValue * @param $adjustmentMonths */ - public function testEDATE($expectedResult, $dateValue, $adjustmentMonths) + public function testEDATE($expectedResult, $dateValue, $adjustmentMonths): void { $result = DateTime::EDATE($dateValue, $adjustmentMonths); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerEDATE() @@ -34,25 +34,25 @@ public function providerEDATE() return require 'tests/data/Calculation/DateTime/EDATE.php'; } - public function testEDATEtoUnixTimestamp() + public function testEDATEtoUnixTimestamp(): void { Functions::setReturnDateType(Functions::RETURNDATE_UNIX_TIMESTAMP); $result = DateTime::EDATE('2012-1-26', -1); - $this->assertEquals(1324857600, $result); - $this->assertEqualsWithDelta(1324857600, $result, 1E-8); + self::assertEquals(1324857600, $result); + self::assertEqualsWithDelta(1324857600, $result, 1E-8); } - public function testEDATEtoDateTimeObject() + public function testEDATEtoDateTimeObject(): void { Functions::setReturnDateType(Functions::RETURNDATE_PHP_DATETIME_OBJECT); $result = DateTime::EDATE('2012-1-26', -1); // Must return an object... - $this->assertIsObject($result); + self::assertIsObject($result); // ... of the correct type - $this->assertTrue(is_a($result, 'DateTimeInterface')); + self::assertTrue(is_a($result, 'DateTimeInterface')); // ... with the correct value - $this->assertEquals($result->format('d-M-Y'), '26-Dec-2011'); + self::assertEquals($result->format('d-M-Y'), '26-Dec-2011'); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php index 7c8352fe84..f9c54039e1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php @@ -23,10 +23,10 @@ protected function setUp(): void * @param $dateValue * @param $adjustmentMonths */ - public function testEOMONTH($expectedResult, $dateValue, $adjustmentMonths) + public function testEOMONTH($expectedResult, $dateValue, $adjustmentMonths): void { $result = DateTime::EOMONTH($dateValue, $adjustmentMonths); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerEOMONTH() @@ -34,25 +34,25 @@ public function providerEOMONTH() return require 'tests/data/Calculation/DateTime/EOMONTH.php'; } - public function testEOMONTHtoUnixTimestamp() + public function testEOMONTHtoUnixTimestamp(): void { Functions::setReturnDateType(Functions::RETURNDATE_UNIX_TIMESTAMP); $result = DateTime::EOMONTH('2012-1-26', -1); - $this->assertEquals(1325289600, $result); - $this->assertEqualsWithDelta(1325289600, $result, 1E-8); + self::assertEquals(1325289600, $result); + self::assertEqualsWithDelta(1325289600, $result, 1E-8); } - public function testEOMONTHtoDateTimeObject() + public function testEOMONTHtoDateTimeObject(): void { Functions::setReturnDateType(Functions::RETURNDATE_PHP_DATETIME_OBJECT); $result = DateTime::EOMONTH('2012-1-26', -1); // Must return an object... - $this->assertIsObject($result); + self::assertIsObject($result); // ... of the correct type - $this->assertTrue(is_a($result, 'DateTimeInterface')); + self::assertTrue(is_a($result, 'DateTimeInterface')); // ... with the correct value - $this->assertEquals($result->format('d-M-Y'), '31-Dec-2011'); + self::assertEquals($result->format('d-M-Y'), '31-Dec-2011'); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php index 5110f93c8c..2d0cd5d1b4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php @@ -22,10 +22,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $dateTimeValue */ - public function testHOUR($expectedResult, $dateTimeValue) + public function testHOUR($expectedResult, $dateTimeValue): void { $result = DateTime::HOUROFDAY($dateTimeValue); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerHOUR() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php index 608a1bf859..1ef0080add 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php @@ -22,10 +22,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed $dateValue */ - public function testISOWEEKNUM($expectedResult, $dateValue) + public function testISOWEEKNUM($expectedResult, $dateValue): void { $result = DateTime::ISOWEEKNUM($dateValue); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerISOWEEKNUM() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php index 36e248be53..8472c6de07 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php @@ -22,10 +22,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $dateTimeValue */ - public function testMINUTE($expectedResult, $dateTimeValue) + public function testMINUTE($expectedResult, $dateTimeValue): void { $result = DateTime::MINUTE($dateTimeValue); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerMINUTE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php index 8f938c8341..6251370261 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php @@ -22,10 +22,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $dateTimeValue */ - public function testMONTH($expectedResult, $dateTimeValue) + public function testMONTH($expectedResult, $dateTimeValue): void { $result = DateTime::MONTHOFYEAR($dateTimeValue); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerMONTH() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php index 4fa86be8fc..e366c44ec8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php @@ -21,10 +21,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testNETWORKDAYS($expectedResult, ...$args) + public function testNETWORKDAYS($expectedResult, ...$args): void { $result = DateTime::NETWORKDAYS(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerNETWORKDAYS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php index e1032b9465..bc2b075253 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php @@ -22,10 +22,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $dateTimeValue */ - public function testSECOND($expectedResult, $dateTimeValue) + public function testSECOND($expectedResult, $dateTimeValue): void { $result = DateTime::SECOND($dateTimeValue); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerSECOND() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php index 1cd0c89b0a..344061d48b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php @@ -21,10 +21,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testTIME($expectedResult, ...$args) + public function testTIME($expectedResult, ...$args): void { $result = DateTime::TIME(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerTIME() @@ -32,24 +32,24 @@ public function providerTIME() return require 'tests/data/Calculation/DateTime/TIME.php'; } - public function testTIMEtoUnixTimestamp() + public function testTIMEtoUnixTimestamp(): void { Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC); $result = DateTime::TIME(7, 30, 20); - $this->assertEqualsWithDelta(27020, $result, 1E-8); + self::assertEqualsWithDelta(27020, $result, 1E-8); } - public function testTIMEtoDateTimeObject() + public function testTIMEtoDateTimeObject(): void { Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT); $result = DateTime::TIME(7, 30, 20); // Must return an object... - $this->assertIsObject($result); + self::assertIsObject($result); // ... of the correct type - $this->assertTrue(is_a($result, 'DateTimeInterface')); + self::assertTrue(is_a($result, 'DateTimeInterface')); // ... with the correct value - $this->assertEquals($result->format('H:i:s'), '07:30:20'); + self::assertEquals($result->format('H:i:s'), '07:30:20'); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php index ed025cff99..04b8c05840 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php @@ -22,10 +22,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $timeValue */ - public function testTIMEVALUE($expectedResult, $timeValue) + public function testTIMEVALUE($expectedResult, $timeValue): void { $result = DateTime::TIMEVALUE($timeValue); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerTIMEVALUE() @@ -33,25 +33,25 @@ public function providerTIMEVALUE() return require 'tests/data/Calculation/DateTime/TIMEVALUE.php'; } - public function testTIMEVALUEtoUnixTimestamp() + public function testTIMEVALUEtoUnixTimestamp(): void { Functions::setReturnDateType(Functions::RETURNDATE_UNIX_TIMESTAMP); $result = DateTime::TIMEVALUE('7:30:20'); - $this->assertEquals(23420, $result); - $this->assertEqualsWithDelta(23420, $result, 1E-8); + self::assertEquals(23420, $result); + self::assertEqualsWithDelta(23420, $result, 1E-8); } - public function testTIMEVALUEtoDateTimeObject() + public function testTIMEVALUEtoDateTimeObject(): void { Functions::setReturnDateType(Functions::RETURNDATE_PHP_DATETIME_OBJECT); $result = DateTime::TIMEVALUE('7:30:20'); // Must return an object... - $this->assertIsObject($result); + self::assertIsObject($result); // ... of the correct type - $this->assertTrue(is_a($result, 'DateTimeInterface')); + self::assertTrue(is_a($result, 'DateTimeInterface')); // ... with the correct value - $this->assertEquals($result->format('H:i:s'), '07:30:20'); + self::assertEquals($result->format('H:i:s'), '07:30:20'); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php index fe81c1a4a7..c5b89e01e1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php @@ -21,10 +21,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testWEEKDAY($expectedResult, ...$args) + public function testWEEKDAY($expectedResult, ...$args): void { $result = DateTime::WEEKDAY(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerWEEKDAY() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php index 96c2077ba3..9d8e1eb281 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php @@ -21,10 +21,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testWEEKNUM($expectedResult, ...$args) + public function testWEEKNUM($expectedResult, ...$args): void { $result = DateTime::WEEKNUM(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerWEEKNUM() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php index bc6fd6cc42..4784e4630d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php @@ -21,10 +21,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testWORKDAY($expectedResult, ...$args) + public function testWORKDAY($expectedResult, ...$args): void { $result = DateTime::WORKDAY(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerWORKDAY() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php index 37364030c7..05f1131099 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php @@ -21,10 +21,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testYEARFRAC($expectedResult, ...$args) + public function testYEARFRAC($expectedResult, ...$args): void { $result = DateTime::YEARFRAC(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerYEARFRAC() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php index 26e416ec2f..bbdaf92a4f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php @@ -22,10 +22,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $dateTimeValue */ - public function testYEAR($expectedResult, $dateTimeValue) + public function testYEAR($expectedResult, $dateTimeValue): void { $result = DateTime::YEAR($dateTimeValue); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerYEAR() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php index d7b23909ea..8fff98afa5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php @@ -20,10 +20,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testBESSELI($expectedResult, ...$args) + public function testBESSELI($expectedResult, ...$args): void { $result = Engineering::BESSELI(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); + self::assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); } public function providerBESSELI() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php index 5e4d2f3bcf..d10f028f8f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php @@ -20,10 +20,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testBESSELJ($expectedResult, ...$args) + public function testBESSELJ($expectedResult, ...$args): void { $result = Engineering::BESSELJ(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); + self::assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); } public function providerBESSEJ() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php index 6a048f3743..27123a26d8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php @@ -20,10 +20,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testBESSELK($expectedResult, ...$args) + public function testBESSELK($expectedResult, ...$args): void { $result = Engineering::BESSELK(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); + self::assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); } public function providerBESSELK() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php index 98c238e2ef..ab55f0ac44 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php @@ -20,10 +20,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testBESSELY($expectedResult, ...$args) + public function testBESSELY($expectedResult, ...$args): void { $result = Engineering::BESSELY(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); + self::assertEqualsWithDelta($expectedResult, $result, self::BESSEL_PRECISION); } public function providerBESSELY() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php index 341493ea10..faba3de803 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testBIN2DEC($expectedResult, ...$args) + public function testBIN2DEC($expectedResult, ...$args): void { $result = Engineering::BINTODEC(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerBIN2DEC() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php index 63945fd151..2a16d5ac47 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testBIN2HEX($expectedResult, ...$args) + public function testBIN2HEX($expectedResult, ...$args): void { $result = Engineering::BINTOHEX(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerBIN2HEX() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php index 2aeeb1bca7..78db6a6ecf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testBIN2OCT($expectedResult, ...$args) + public function testBIN2OCT($expectedResult, ...$args): void { $result = Engineering::BINTOOCT(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerBIN2OCT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php index 483bf09968..e73efccca1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed[] $args */ - public function testBITAND($expectedResult, array $args) + public function testBITAND($expectedResult, array $args): void { $result = Engineering::BITAND(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerBITAND() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php index bf280f1628..61aa89b4ad 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed[] $args */ - public function testBITLSHIFT($expectedResult, array $args) + public function testBITLSHIFT($expectedResult, array $args): void { $result = Engineering::BITLSHIFT(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerBITLSHIFT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php index 6e45543172..857c7466a8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed[] $args */ - public function testBITOR($expectedResult, array $args) + public function testBITOR($expectedResult, array $args): void { $result = Engineering::BITOR(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerBITOR() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php index 26bece5345..26b13d0742 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed[] $args */ - public function testBITRSHIFT($expectedResult, array $args) + public function testBITRSHIFT($expectedResult, array $args): void { $result = Engineering::BITRSHIFT(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerBITRSHIFT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php index 51401f636a..4415f6dabe 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed[] $args */ - public function testBITXOR($expectedResult, array $args) + public function testBITXOR($expectedResult, array $args): void { $result = Engineering::BITXOR(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerBITXOR() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php index 5bb7fbcd3e..4b857e2de4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testCOMPLEX($expectedResult, ...$args) + public function testCOMPLEX($expectedResult, ...$args): void { $result = Engineering::COMPLEX(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerCOMPLEX() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php index 3d6a077785..7a18067fd2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php @@ -13,28 +13,28 @@ protected function setUp(): void Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } - public function testGetConversionGroups() + public function testGetConversionGroups(): void { $result = Engineering::getConversionGroups(); - $this->assertIsArray($result); + self::assertIsArray($result); } - public function testGetConversionGroupUnits() + public function testGetConversionGroupUnits(): void { $result = Engineering::getConversionGroupUnits(); - $this->assertIsArray($result); + self::assertIsArray($result); } - public function testGetConversionGroupUnitDetails() + public function testGetConversionGroupUnitDetails(): void { $result = Engineering::getConversionGroupUnitDetails(); - $this->assertIsArray($result); + self::assertIsArray($result); } - public function testGetConversionMultipliers() + public function testGetConversionMultipliers(): void { $result = Engineering::getConversionMultipliers(); - $this->assertIsArray($result); + self::assertIsArray($result); } /** @@ -42,10 +42,10 @@ public function testGetConversionMultipliers() * * @param mixed $expectedResult */ - public function testCONVERTUOM($expectedResult, ...$args) + public function testCONVERTUOM($expectedResult, ...$args): void { $result = Engineering::CONVERTUOM(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerCONVERTUOM() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php index 740fe3c979..3626ac6b1c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testDEC2BIN($expectedResult, ...$args) + public function testDEC2BIN($expectedResult, ...$args): void { $result = Engineering::DECTOBIN(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerDEC2BIN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php index c7aae44135..d191f6205d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testDEC2HEX($expectedResult, ...$args) + public function testDEC2HEX($expectedResult, ...$args): void { $result = Engineering::DECTOHEX(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerDEC2HEX() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php index 68456d1a26..61eb3dbbce 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testDEC2OCT($expectedResult, ...$args) + public function testDEC2OCT($expectedResult, ...$args): void { $result = Engineering::DECTOOCT(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerDEC2OCT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php index fc2df95b71..a93d2ea6d9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testDELTA($expectedResult, ...$args) + public function testDELTA($expectedResult, ...$args): void { $result = Engineering::DELTA(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerDELTA() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php index 5409db5f53..09bf448e8d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php @@ -20,11 +20,11 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testERFC($expectedResult, ...$args) + public function testERFC($expectedResult, ...$args): void { $result = Engineering::ERFC(...$args); - $this->assertEquals($expectedResult, $result); - $this->assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION); + self::assertEquals($expectedResult, $result); + self::assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION); } public function providerERFC() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php index 857e41c13a..eb26ae9835 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php @@ -20,11 +20,11 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testERFPRECISE($expectedResult, ...$args) + public function testERFPRECISE($expectedResult, ...$args): void { $result = Engineering::ERFPRECISE(...$args); - $this->assertEquals($expectedResult, $result); - $this->assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION); + self::assertEquals($expectedResult, $result); + self::assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION); } public function providerERFPRECISE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php index d148501bc8..8201edbc59 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php @@ -20,11 +20,11 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testERF($expectedResult, ...$args) + public function testERF($expectedResult, ...$args): void { $result = Engineering::ERF(...$args); - $this->assertEquals($expectedResult, $result); - $this->assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION); + self::assertEquals($expectedResult, $result); + self::assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION); } public function providerERF() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php index 24ba1a0f43..370c1a82fe 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testGESTEP($expectedResult, ...$args) + public function testGESTEP($expectedResult, ...$args): void { $result = Engineering::GESTEP(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerGESTEP() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php index 83fcb1e7a9..44d8908d03 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testHEX2BIN($expectedResult, ...$args) + public function testHEX2BIN($expectedResult, ...$args): void { $result = Engineering::HEXTOBIN(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerHEX2BIN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php index 5765494e20..b388b2b772 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testHEX2DEC($expectedResult, ...$args) + public function testHEX2DEC($expectedResult, ...$args): void { $result = Engineering::HEXTODEC(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerHEX2DEC() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php index 25ba63005d..bc0a5cb7a8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testHEX2OCT($expectedResult, ...$args) + public function testHEX2OCT($expectedResult, ...$args): void { $result = Engineering::HEXTOOCT(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerHEX2OCT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php index c812fdfa15..1f1ee9dda7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php @@ -21,10 +21,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMABS($expectedResult, $value) + public function testIMABS($expectedResult, $value): void { $result = Engineering::IMABS($value); - $this->assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); + self::assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } public function providerIMABS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php index 60883e1499..6f1a648523 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php @@ -21,10 +21,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMARGUMENT($expectedResult, $value) + public function testIMARGUMENT($expectedResult, $value): void { $result = Engineering::IMARGUMENT($value); - $this->assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); + self::assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } public function providerIMARGUMENT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php index 81323a53a8..bc3a39187e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMCONJUGATE($expectedResult, $value) + public function testIMCONJUGATE($expectedResult, $value): void { $result = Engineering::IMCONJUGATE($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php index c1c610fba5..693f0babc8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMCOS($expectedResult, $value) + public function testIMCOS($expectedResult, $value): void { $result = Engineering::IMCOS($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php index 7dacb7cd01..ae035fef7d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMCOSH($expectedResult, $value) + public function testIMCOSH($expectedResult, $value): void { $result = Engineering::IMCOSH($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php index 512d96f9a9..8b888b3fd4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMCOT($expectedResult, $value) + public function testIMCOT($expectedResult, $value): void { $result = Engineering::IMCOT($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php index 5fb3f49d99..5a08c0b60e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMCSC($expectedResult, $value) + public function testIMCSC($expectedResult, $value): void { $result = Engineering::IMCSC($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php index 9b1934bbe7..a95a4eafb1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMCSCH($expectedResult, $value) + public function testIMCSCH($expectedResult, $value): void { $result = Engineering::IMCSCH($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php index 7809ab0600..2bc9161908 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php @@ -32,10 +32,10 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testIMDIV($expectedResult, ...$args) + public function testIMDIV($expectedResult, ...$args): void { $result = Engineering::IMDIV(...$args); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php index 3af044d772..7debbc9c23 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMEXP($expectedResult, $value) + public function testIMEXP($expectedResult, $value): void { $result = Engineering::IMEXP($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php index bb09860aea..3e27097518 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMLN($expectedResult, $value) + public function testIMLN($expectedResult, $value): void { $result = Engineering::IMLN($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php index 4831387dbc..2a4db7fbd7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMLOG10($expectedResult, $value) + public function testIMLOG10($expectedResult, $value): void { $result = Engineering::IMLOG10($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php index b6f25123bf..53b302dda0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMLOG2($expectedResult, $value) + public function testIMLOG2($expectedResult, $value): void { $result = Engineering::IMLOG2($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php index c198ffb928..41e528780c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php @@ -32,10 +32,10 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testIMPOWER($expectedResult, ...$args) + public function testIMPOWER($expectedResult, ...$args): void { $result = Engineering::IMPOWER(...$args); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php index 2fd383c437..43495739b8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php @@ -32,10 +32,10 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testIMPRODUCT($expectedResult, ...$args) + public function testIMPRODUCT($expectedResult, ...$args): void { $result = Engineering::IMPRODUCT(...$args); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php index bd4baf9f54..08d2feb152 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php @@ -21,10 +21,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMREAL($expectedResult, $value) + public function testIMREAL($expectedResult, $value): void { $result = Engineering::IMREAL($value); - $this->assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); + self::assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } public function providerIMREAL() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php index 4de6fcffd8..e785d3ac6c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMSEC($expectedResult, $value) + public function testIMSEC($expectedResult, $value): void { $result = Engineering::IMSEC($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php index 11aa8e28d7..22cb6faecf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMSECH($expectedResult, $value) + public function testIMSECH($expectedResult, $value): void { $result = Engineering::IMSECH($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php index f3c6afe99b..dd797a3522 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMSIN($expectedResult, $value) + public function testIMSIN($expectedResult, $value): void { $result = Engineering::IMSIN($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php index 7478c15c94..4174d1c05f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMSINH($expectedResult, $value) + public function testIMSINH($expectedResult, $value): void { $result = Engineering::IMSINH($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php index f9a151953a..091b11c5f5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMSQRT($expectedResult, $value) + public function testIMSQRT($expectedResult, $value): void { $result = Engineering::IMSQRT($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php index 2ddc3f57e6..79286120f2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php @@ -32,10 +32,10 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testIMSUB($expectedResult, ...$args) + public function testIMSUB($expectedResult, ...$args): void { $result = Engineering::IMSUB(...$args); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php index 23f716ca98..8abc363881 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php @@ -32,10 +32,10 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testIMSUM($expectedResult, ...$args) + public function testIMSUM($expectedResult, ...$args): void { $result = Engineering::IMSUM(...$args); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php index d9f39ad522..57b238155d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php @@ -33,10 +33,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMTAN($expectedResult, $value) + public function testIMTAN($expectedResult, $value): void { $result = Engineering::IMTAN($value); - $this->assertTrue( + self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() ); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php index 4d2e678169..6ad7228717 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php @@ -21,10 +21,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed $value */ - public function testIMAGINARY($expectedResult, $value) + public function testIMAGINARY($expectedResult, $value): void { $result = Engineering::IMAGINARY($value); - $this->assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); + self::assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } public function providerIMAGINARY() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php index 217494fae4..e56c8652cd 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testOCT2BIN($expectedResult, ...$args) + public function testOCT2BIN($expectedResult, ...$args): void { $result = Engineering::OCTTOBIN(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerOCT2BIN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php index c959236c94..87e213ef99 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testOCT2DEC($expectedResult, ...$args) + public function testOCT2DEC($expectedResult, ...$args): void { $result = Engineering::OCTTODEC(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerOCT2DEC() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php index 1d14bd7866..e2d75a78d0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testOCT2HEX($expectedResult, ...$args) + public function testOCT2HEX($expectedResult, ...$args): void { $result = Engineering::OCTTOHEX(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerOCT2HEX() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php index bc1437a362..1022052e65 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php @@ -13,16 +13,16 @@ protected function setUp(): void Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } - public function testParseComplex() + public function testParseComplex(): void { [$real, $imaginary, $suffix] = [1.23e-4, 5.67e+8, 'j']; $result = Engineering::parseComplex('1.23e-4+5.67e+8j'); - $this->assertArrayHasKey('real', $result); - $this->assertEquals($real, $result['real']); - $this->assertArrayHasKey('imaginary', $result); - $this->assertEquals($imaginary, $result['imaginary']); - $this->assertArrayHasKey('suffix', $result); - $this->assertEquals($suffix, $result['suffix']); + self::assertArrayHasKey('real', $result); + self::assertEquals($real, $result['real']); + self::assertArrayHasKey('imaginary', $result); + self::assertEquals($imaginary, $result['imaginary']); + self::assertArrayHasKey('suffix', $result); + self::assertEquals($suffix, $result['suffix']); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php index 33921bb3a3..597db5c2cf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php @@ -18,7 +18,7 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testACCRINTM($expectedResult, ...$args) + public function testACCRINTM($expectedResult, ...$args): void { $result = Financial::ACCRINTM(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php index 21aadd0af8..edb792305d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testACCRINT($expectedResult, ...$args) + public function testACCRINT($expectedResult, ...$args): void { $result = Financial::ACCRINT(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerACCRINT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php index c133498856..d315e82a52 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testAND($expectedResult, ...$args) + public function testAND($expectedResult, ...$args): void { $result = Logical::logicalAnd(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerAND() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/FalseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/FalseTest.php index c546554efe..1fa78af03d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/FalseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/FalseTest.php @@ -13,9 +13,9 @@ protected function setUp(): void Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } - public function testFALSE() + public function testFALSE(): void { $result = Logical::FALSE(); - $this->assertFalse($result); + self::assertFalse($result); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php index 1e9ef8bc1e..c1602edacf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php @@ -20,10 +20,10 @@ protected function setUp(): void * @param $value * @param $return */ - public function testIFERROR($expectedResult, $value, $return) + public function testIFERROR($expectedResult, $value, $return): void { $result = Logical::IFERROR($value, $return); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerIFERROR() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php index e151cd75f9..2976761a2f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php @@ -20,10 +20,10 @@ protected function setUp(): void * @param $value * @param $return */ - public function testIFNA($expectedResult, $value, $return) + public function testIFNA($expectedResult, $value, $return): void { $result = Logical::IFNA($value, $return); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerIFNA() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php index f289995a0d..571a80e36f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testIF($expectedResult, ...$args) + public function testIF($expectedResult, ...$args): void { $result = Logical::statementIf(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerIF() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php index abc0e5bc7b..4b7c70be74 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testNOT($expectedResult, ...$args) + public function testNOT($expectedResult, ...$args): void { $result = Logical::NOT(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerNOT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php index 46046b7c96..021cc97bb4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testOR($expectedResult, ...$args) + public function testOR($expectedResult, ...$args): void { $result = Logical::logicalOr(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerOR() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php index 2781334deb..eacad823df 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testSWITCH($expectedResult, ...$args) + public function testSWITCH($expectedResult, ...$args): void { $result = Logical::statementSwitch(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerSwitch() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php index 77166db09b..21e65b76c0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php @@ -13,9 +13,9 @@ protected function setUp(): void Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } - public function testTRUE() + public function testTRUE(): void { $result = Logical::TRUE(); - $this->assertTrue($result); + self::assertTrue($result); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php index 8f7a921b88..8ca05f84a7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testXOR($expectedResult, ...$args) + public function testXOR($expectedResult, ...$args): void { $result = Logical::logicalXor(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerXOR() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php index 00e2c61ccb..01ba6f7554 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testCHOOSE($expectedResult, ...$args) + public function testCHOOSE($expectedResult, ...$args): void { $result = LookupRef::CHOOSE(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerCHOOSE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php index 61c0f8b4ef..a79082415f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testCOLUMNS($expectedResult, ...$args) + public function testCOLUMNS($expectedResult, ...$args): void { $result = LookupRef::COLUMNS(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerCOLUMNS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php index d317089d1b..767b6de81a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testHLOOKUP($expectedResult, ...$args) + public function testHLOOKUP($expectedResult, ...$args): void { $result = LookupRef::HLOOKUP(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerHLOOKUP() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php index 241d86f772..8ff6693169 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testINDEX($expectedResult, ...$args) + public function testINDEX($expectedResult, ...$args): void { $result = LookupRef::INDEX(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerINDEX() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php index 6e1fb73a3b..d1b36e4a51 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testLOOKUP($expectedResult, ...$args) + public function testLOOKUP($expectedResult, ...$args): void { $result = LookupRef::LOOKUP(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerLOOKUP() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php index 2bf322fcfa..e020d3bae7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testMATCH($expectedResult, ...$args) + public function testMATCH($expectedResult, ...$args): void { $result = LookupRef::MATCH(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerMATCH() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php index 41b0bd2b1d..62a0662674 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testROWS($expectedResult, ...$args) + public function testROWS($expectedResult, ...$args): void { $result = LookupRef::ROWS(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerROWS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php index bffecb8ec1..badf8f68aa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testVLOOKUP($expectedResult, ...$args) + public function testVLOOKUP($expectedResult, ...$args): void { $result = LookupRef::VLOOKUP(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerVLOOKUP() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php index 2a3cd654e1..d81c3b9d72 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed $number */ - public function testACOT($expectedResult, $number) + public function testACOT($expectedResult, $number): void { $result = MathTrig::ACOT($number); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerACOT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php index 9661b6761d..0a3864cc94 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed $number */ - public function testACOTH($expectedResult, $number) + public function testACOTH($expectedResult, $number): void { $result = MathTrig::ACOTH($number); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerACOTH() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php index 0371e0a762..7b3a5e15dd 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param string $romanNumeral */ - public function testARABIC($expectedResult, $romanNumeral) + public function testARABIC($expectedResult, $romanNumeral): void { $result = MathTrig::ARABIC($romanNumeral); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerARABIC() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php index c6281fc210..4edec4cb06 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php @@ -20,10 +20,10 @@ protected function setUp(): void * @param mixed $x * @param mixed $y */ - public function testATAN2($expectedResult, $x, $y) + public function testATAN2($expectedResult, $x, $y): void { $result = MathTrig::ATAN2($x, $y); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerATAN2() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php index fdca1f49ed..72b525593d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testBASE($expectedResult, ...$args) + public function testBASE($expectedResult, ...$args): void { $result = MathTrig::BASE(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerBASE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php index c987cc2ed2..b60d7c304e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testCEILING($expectedResult, ...$args) + public function testCEILING($expectedResult, ...$args): void { $result = MathTrig::CEILING(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCEILING() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php index 8c982b6b3e..d91563398f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testCOMBIN($expectedResult, ...$args) + public function testCOMBIN($expectedResult, ...$args): void { $result = MathTrig::COMBIN(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOMBIN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php index f864d226ad..3fee6901cd 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed $angle */ - public function testCOT($expectedResult, $angle) + public function testCOT($expectedResult, $angle): void { $result = MathTrig::COT($angle); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php index 9243c09551..e3db23d577 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed $angle */ - public function testCOTH($expectedResult, $angle) + public function testCOTH($expectedResult, $angle): void { $result = MathTrig::COTH($angle); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOTH() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php index 24abad4ee7..675ebf57ea 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed $angle */ - public function testCSC($expectedResult, $angle) + public function testCSC($expectedResult, $angle): void { $result = MathTrig::CSC($angle); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCSC() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php index 393c088350..c630be2f3c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed $angle */ - public function testCSCH($expectedResult, $angle) + public function testCSCH($expectedResult, $angle): void { $result = MathTrig::CSCH($angle); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCSCH() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php index b81b119f92..96c0b04629 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $value */ - public function testEVEN($expectedResult, $value) + public function testEVEN($expectedResult, $value): void { $result = MathTrig::EVEN($value); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerEVEN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php index c311894239..f0b6b146ac 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $value */ - public function testFACTDOUBLE($expectedResult, $value) + public function testFACTDOUBLE($expectedResult, $value): void { $result = MathTrig::FACTDOUBLE($value); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFACTDOUBLE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php index b765d4125a..f609289633 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $value */ - public function testFACT($expectedResult, $value) + public function testFACT($expectedResult, $value): void { $result = MathTrig::FACT($value); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFACT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php index c5b797f149..d7d51b590b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testFLOORMATH($expectedResult, ...$args) + public function testFLOORMATH($expectedResult, ...$args): void { $result = MathTrig::FLOORMATH(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFLOORMATH() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php index 399f05d2eb..ae5a3199f7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testFLOOR($expectedResult, ...$args) + public function testFLOOR($expectedResult, ...$args): void { $result = MathTrig::FLOORPRECISE(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFLOORPRECISE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php index fac02f16b9..e66d97ae26 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testFLOOR($expectedResult, ...$args) + public function testFLOOR($expectedResult, ...$args): void { $result = MathTrig::FLOOR(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFLOOR() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php index 825a9d059b..ce1aec3fa4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testGCD($expectedResult, ...$args) + public function testGCD($expectedResult, ...$args): void { $result = MathTrig::GCD(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerGCD() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php index 3a9b1e5b72..f400a7feb6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $value */ - public function testINT($expectedResult, $value) + public function testINT($expectedResult, $value): void { $result = MathTrig::INT($value); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerINT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php index 58ea6a6b1e..57b4a67f3d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testLCM($expectedResult, ...$args) + public function testLCM($expectedResult, ...$args): void { $result = MathTrig::LCM(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerLCM() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php index 82c63f9960..184d83e63b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testLOG($expectedResult, ...$args) + public function testLOG($expectedResult, ...$args): void { $result = MathTrig::logBase(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerLOG() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php index 3d784a871c..a500c3f63a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testMINVERSE($expectedResult, ...$args) + public function testMINVERSE($expectedResult, ...$args): void { $result = MathTrig::MINVERSE(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerMINVERSE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php index 16a52e75c8..66fa80db4a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testMMULT($expectedResult, ...$args) + public function testMMULT($expectedResult, ...$args): void { $result = MathTrig::MMULT(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerMMULT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php index 7356874771..32c9c35544 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testMROUND($expectedResult, ...$args) + public function testMROUND($expectedResult, ...$args): void { $result = MathTrig::MROUND(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerMROUND() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php index 672d5dec62..995ea2f35f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testMDETERM($expectedResult, ...$args) + public function testMDETERM($expectedResult, ...$args): void { $result = MathTrig::MDETERM(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerMDETERM() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php index ae8637923c..930708f5f8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testMOD($expectedResult, ...$args) + public function testMOD($expectedResult, ...$args): void { $result = MathTrig::MOD(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerMOD() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php index dd2faf2c95..93735ba9bb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testMULTINOMIAL($expectedResult, ...$args) + public function testMULTINOMIAL($expectedResult, ...$args): void { $result = MathTrig::MULTINOMIAL(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerMULTINOMIAL() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php index 7a9d367c75..6c5758c67a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $value */ - public function testODD($expectedResult, $value) + public function testODD($expectedResult, $value): void { $result = MathTrig::ODD($value); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerODD() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php index 05edecf984..6749b14ad7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testPOWER($expectedResult, ...$args) + public function testPOWER($expectedResult, ...$args): void { $result = MathTrig::POWER(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerPOWER() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php index 3e185bd73d..251b783b75 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testPRODUCT($expectedResult, ...$args) + public function testPRODUCT($expectedResult, ...$args): void { $result = MathTrig::PRODUCT(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerPRODUCT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php index 96e0b84a41..4232729a6b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testQUOTIENT($expectedResult, ...$args) + public function testQUOTIENT($expectedResult, ...$args): void { $result = MathTrig::QUOTIENT(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerQUOTIENT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php index a136371498..c74daa32ef 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testROMAN($expectedResult, ...$args) + public function testROMAN($expectedResult, ...$args): void { $result = MathTrig::ROMAN(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerROMAN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php index 17b6780b94..2fc211f32e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testROUNDDOWN($expectedResult, ...$args) + public function testROUNDDOWN($expectedResult, ...$args): void { $result = MathTrig::ROUNDDOWN(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerROUNDDOWN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php index 6d1c57ba16..825fe4194b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testROUNDUP($expectedResult, ...$args) + public function testROUNDUP($expectedResult, ...$args): void { $result = MathTrig::ROUNDUP(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerROUNDUP() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php index 8dad0b9d94..ad4b196c43 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed $angle */ - public function testSEC($expectedResult, $angle) + public function testSEC($expectedResult, $angle): void { $result = MathTrig::SEC($angle); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSEC() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php index f98b673e50..b9488bdaa6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param mixed $angle */ - public function testSECH($expectedResult, $angle) + public function testSECH($expectedResult, $angle): void { $result = MathTrig::SECH($angle); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSECH() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php index 4f8d4db143..689336a3a6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testSERIESSUM($expectedResult, ...$args) + public function testSERIESSUM($expectedResult, ...$args): void { $result = MathTrig::SERIESSUM(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSERIESSUM() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php index d7b6bacb4c..68f5acb97d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $value */ - public function testSIGN($expectedResult, $value) + public function testSIGN($expectedResult, $value): void { $result = MathTrig::SIGN($value); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSIGN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php index 38528548b0..bb4bba4b2a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $value */ - public function testSQRTPI($expectedResult, $value) + public function testSQRTPI($expectedResult, $value): void { $result = MathTrig::SQRTPI($value); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSQRTPI() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php index 38434278f5..14865673f1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php @@ -22,7 +22,7 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testSUBTOTAL($expectedResult, ...$args) + public function testSUBTOTAL($expectedResult, ...$args): void { $cell = $this->getMockBuilder(Cell::class) ->setMethods(['getValue', 'isFormula']) @@ -49,7 +49,7 @@ public function testSUBTOTAL($expectedResult, ...$args) array_push($args, $cellReference); $result = MathTrig::SUBTOTAL(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUBTOTAL() @@ -70,7 +70,7 @@ protected function rowVisibility() * * @param mixed $expectedResult */ - public function testHiddenSUBTOTAL($expectedResult, ...$args) + public function testHiddenSUBTOTAL($expectedResult, ...$args): void { $visibilityGenerator = $this->rowVisibility(); @@ -79,12 +79,12 @@ public function testHiddenSUBTOTAL($expectedResult, ...$args) ->disableOriginalConstructor() ->getMock(); $rowDimension->method('getVisible') - ->will($this->returnCallback(function () use ($visibilityGenerator) { + ->willReturnCallback(function () use ($visibilityGenerator) { $result = $visibilityGenerator->current(); $visibilityGenerator->next(); return $result; - })); + }); $columnDimension = $this->getMockBuilder(ColumnDimension::class) ->setMethods(['getVisible']) ->disableOriginalConstructor() @@ -120,7 +120,7 @@ public function testHiddenSUBTOTAL($expectedResult, ...$args) array_push($args, $cellReference); $result = MathTrig::SUBTOTAL(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerHiddenSUBTOTAL() @@ -147,7 +147,7 @@ protected function cellIsFormula(array $cellValues) * * @param mixed $expectedResult */ - public function testNestedSUBTOTAL($expectedResult, ...$args) + public function testNestedSUBTOTAL($expectedResult, ...$args): void { $cellValueGenerator = $this->cellValues(Functions::flattenArray(array_slice($args, 1))); $cellIsFormulaGenerator = $this->cellIsFormula(Functions::flattenArray(array_slice($args, 1))); @@ -157,19 +157,19 @@ public function testNestedSUBTOTAL($expectedResult, ...$args) ->disableOriginalConstructor() ->getMock(); $cell->method('getValue') - ->will($this->returnCallback(function () use ($cellValueGenerator) { + ->willReturnCallback(function () use ($cellValueGenerator) { $result = $cellValueGenerator->current(); $cellValueGenerator->next(); return $result; - })); + }); $cell->method('isFormula') - ->will($this->returnCallback(function () use ($cellIsFormulaGenerator) { + ->willReturnCallback(function () use ($cellIsFormulaGenerator) { $result = $cellIsFormulaGenerator->current(); $cellIsFormulaGenerator->next(); return $result; - })); + }); $worksheet = $this->getMockBuilder(Worksheet::class) ->setMethods(['cellExists', 'getCell']) ->disableOriginalConstructor() @@ -188,7 +188,7 @@ public function testNestedSUBTOTAL($expectedResult, ...$args) array_push($args, $cellReference); $result = MathTrig::SUBTOTAL(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerNestedSUBTOTAL() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php index 639e8bdd59..f7ff928f0b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testSUMIF($expectedResult, ...$args) + public function testSUMIF($expectedResult, ...$args): void { $result = MathTrig::SUMIF(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUMIF() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php index dab255c250..b7be17c92d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testSUMIFS($expectedResult, ...$args) + public function testSUMIFS($expectedResult, ...$args): void { $result = MathTrig::SUMIFS(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUMIFS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php index 6b94dafaaa..b34036e58b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testSUMPRODUCT($expectedResult, ...$args) + public function testSUMPRODUCT($expectedResult, ...$args): void { $result = MathTrig::SUMPRODUCT(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUMPRODUCT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php index bcb00acc42..f1165e7be4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testSUMSQ($expectedResult, ...$args) + public function testSUMSQ($expectedResult, ...$args): void { $result = MathTrig::SUMSQ(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUMSQ() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php index 1bfe592309..3bf2785be7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testSUMX2MY2($expectedResult, ...$args) + public function testSUMX2MY2($expectedResult, ...$args): void { $result = MathTrig::SUMX2MY2(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUMX2MY2() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php index c53630de8f..a370d79bf7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testSUMX2PY2($expectedResult, ...$args) + public function testSUMX2PY2($expectedResult, ...$args): void { $result = MathTrig::SUMX2PY2(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUMX2PY2() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php index bb4dc527c7..1f64523bc4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testSUMXMY2($expectedResult, ...$args) + public function testSUMXMY2($expectedResult, ...$args): void { $result = MathTrig::SUMXMY2(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSUMXMY2() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php index 244889dc49..5fc248ccea 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testTRUNC($expectedResult, ...$args) + public function testTRUNC($expectedResult, ...$args): void { $result = MathTrig::TRUNC(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerTRUNC() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php index a61730add7..571c06c331 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testAVEDEV($expectedResult, ...$args) + public function testAVEDEV($expectedResult, ...$args): void { $result = Statistical::AVEDEV(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerAVEDEV() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php index 6c5f4093df..1af96dfc4a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testAVERAGEA($expectedResult, ...$args) + public function testAVERAGEA($expectedResult, ...$args): void { $result = Statistical::AVERAGEA(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerAVERAGEA() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php index f1b4081ac7..69dcfb873c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testAVERAGEIF($expectedResult, ...$args) + public function testAVERAGEIF($expectedResult, ...$args): void { $result = Statistical::AVERAGEIF(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerAVERAGEIF() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php index 3d03524ea4..c67452ab2f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testAVERAGE($expectedResult, ...$args) + public function testAVERAGE($expectedResult, ...$args): void { $result = Statistical::AVERAGE(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerAVERAGE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php index 1cd9280ddc..a85781e588 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testBETADIST($expectedResult, ...$args) + public function testBETADIST($expectedResult, ...$args): void { $result = Statistical::BETADIST(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerBETADIST() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php index 10c47c7697..24ddd3fcb2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testBETAINV($expectedResult, ...$args) + public function testBETAINV($expectedResult, ...$args): void { $result = Statistical::BETAINV(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerBETAINV() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php index e489154675..8b3e685678 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testBINOMDIST($expectedResult, ...$args) + public function testBINOMDIST($expectedResult, ...$args): void { $result = Statistical::BINOMDIST(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerBINOMDIST() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php index d00d5fb0af..9dc7326c6f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testCHIDIST($expectedResult, ...$args) + public function testCHIDIST($expectedResult, ...$args): void { $result = Statistical::CHIDIST(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCHIDIST() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php index e2b93e95c3..7268091493 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testCHIINV($expectedResult, ...$args) + public function testCHIINV($expectedResult, ...$args): void { $result = Statistical::CHIINV(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCHIINV() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php index 9a131ed0fc..d4bc586f7d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testCONFIDENCE($expectedResult, ...$args) + public function testCONFIDENCE($expectedResult, ...$args): void { $result = Statistical::CONFIDENCE(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCONFIDENCE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php index f2bba8d758..52f773bc17 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testCORREL($expectedResult, array $xargs, array $yargs) + public function testCORREL($expectedResult, array $xargs, array $yargs): void { $result = Statistical::CORREL($xargs, $yargs); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCORREL() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php index 15f9c4bf0f..2df0ebd177 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testCOUNTA($expectedResult, ...$args) + public function testCOUNTA($expectedResult, ...$args): void { $result = Statistical::COUNTA(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOUNTA() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php index 8e61bb4768..b0c6698b0a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testCOUNTBLANK($expectedResult, ...$args) + public function testCOUNTBLANK($expectedResult, ...$args): void { $result = Statistical::COUNTBLANK(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOUNTBLANK() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php index 7f1dd221ab..fed32e5c4f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testCOUNTIF($expectedResult, ...$args) + public function testCOUNTIF($expectedResult, ...$args): void { $result = Statistical::COUNTIF(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOUNTIF() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php index 301c3f4c82..1eeb4f6717 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testCOUNTIFS($expectedResult, ...$args) + public function testCOUNTIFS($expectedResult, ...$args): void { $result = Statistical::COUNTIFS(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOUNTIFS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php index 1bfac28e76..26e621ec89 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testBasicCOUNT($expectedResult, ...$args) + public function testBasicCOUNT($expectedResult, ...$args): void { $result = Statistical::COUNT(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerBasicCOUNT() @@ -34,10 +34,10 @@ public function providerBasicCOUNT() * * @param mixed $expectedResult */ - public function testExcelCOUNT($expectedResult, ...$args) + public function testExcelCOUNT($expectedResult, ...$args): void { $result = Statistical::COUNT(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerExcelCOUNT() @@ -50,12 +50,12 @@ public function providerExcelCOUNT() * * @param mixed $expectedResult */ - public function testOpenOfficeCOUNT($expectedResult, ...$args) + public function testOpenOfficeCOUNT($expectedResult, ...$args): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); $result = Statistical::COUNT(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerOpenOfficeCOUNT() @@ -68,12 +68,12 @@ public function providerOpenOfficeCOUNT() * * @param mixed $expectedResult */ - public function testGnumericCOUNT($expectedResult, ...$args) + public function testGnumericCOUNT($expectedResult, ...$args): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); $result = Statistical::COUNT(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerGnumericCOUNT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php index c34e36d2c5..5b73d1d9a9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testCOVAR($expectedResult, ...$args) + public function testCOVAR($expectedResult, ...$args): void { $result = Statistical::COVAR(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerCOVAR() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php index cf3e884973..0296ab7b38 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testEXPONDIST($expectedResult, ...$args) + public function testEXPONDIST($expectedResult, ...$args): void { $result = Statistical::EXPONDIST(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerEXPONDIST() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php index f8eb7554b9..efd212c8cb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $value */ - public function testFISHERINV($expectedResult, $value) + public function testFISHERINV($expectedResult, $value): void { $result = Statistical::FISHERINV($value); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFISHERINV() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php index 5f9733ab51..788ffc6a59 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $value */ - public function testFISHER($expectedResult, $value) + public function testFISHER($expectedResult, $value): void { $result = Statistical::FISHER($value); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFISHER() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php index 4de6450058..6ecbb9c8c1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testFORECAST($expectedResult, ...$args) + public function testFORECAST($expectedResult, ...$args): void { $result = Statistical::FORECAST(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerFORECAST() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php index 41806e5637..6765d340a9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testGAMMADIST($expectedResult, ...$args) + public function testGAMMADIST($expectedResult, ...$args): void { $result = Statistical::GAMMADIST(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerGAMMADIST() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php index ad72277a46..3e9e41cba4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testGAMMAINV($expectedResult, ...$args) + public function testGAMMAINV($expectedResult, ...$args): void { $result = Statistical::GAMMAINV(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerGAMMAINV() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php index 2fde78aa35..d0ae623fbe 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php @@ -19,10 +19,10 @@ protected function setUp(): void * @param mixed $expectedResult * @param $value */ - public function testGAMMALN($expectedResult, $value) + public function testGAMMALN($expectedResult, $value): void { $result = Statistical::GAMMALN($value); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerGAMMALN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php index 6f8f60533b..99f125d105 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testGEOMEAN($expectedResult, ...$args) + public function testGEOMEAN($expectedResult, ...$args): void { $result = Statistical::GEOMEAN(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerGEOMEAN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php index 38ad95db79..5ddf58a83d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testHARMEAN($expectedResult, ...$args) + public function testHARMEAN($expectedResult, ...$args): void { $result = Statistical::HARMEAN(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerHARMEAN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php index e3f9383cec..51245861c0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testINTERCEPT($expectedResult, array $xargs, array $yargs) + public function testINTERCEPT($expectedResult, array $xargs, array $yargs): void { $result = Statistical::INTERCEPT($xargs, $yargs); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerINTERCEPT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php index c8d3d02c18..a031203a24 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testMAXIFS($expectedResult, ...$args) + public function testMAXIFS($expectedResult, ...$args): void { $result = Statistical::MAXIFS(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerMAXIFS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php index 571fca237f..c29d65e5eb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testMEDIAN($expectedResult, ...$args) + public function testMEDIAN($expectedResult, ...$args): void { $result = Statistical::MEDIAN(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerMEDIAN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php index b8c1e29100..f17401109b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testMINIFS($expectedResult, ...$args) + public function testMINIFS($expectedResult, ...$args): void { $result = Statistical::MINIFS(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerMINIFS() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ModeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ModeTest.php index d3eb6f3228..9f8112875e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ModeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ModeTest.php @@ -11,7 +11,6 @@ class ModeTest extends TestCase * @dataProvider providerMODE * * @param mixed $expectedResult - * @param string $str */ public function testMODE($expectedResult, string $str): void { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php index 7e7ae7a7c2..98e399787a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testPERMUT($expectedResult, ...$args) + public function testPERMUT($expectedResult, ...$args): void { $result = Statistical::PERMUT(...$args); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerPERMUT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php index a0959eacf3..423cc3ae60 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testRSQ($expectedResult, array $xargs, array $yargs) + public function testRSQ($expectedResult, array $xargs, array $yargs): void { $result = Statistical::RSQ($xargs, $yargs); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerRSQ() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php index fe28f5ebc5..467bff1e8e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testSLOPE($expectedResult, array $xargs, array $yargs) + public function testSLOPE($expectedResult, array $xargs, array $yargs): void { $result = Statistical::SLOPE($xargs, $yargs); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSLOPE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php index 5ab6b66227..ab109345c8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php @@ -18,10 +18,10 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testSTEYX($expectedResult, array $xargs, array $yargs) + public function testSTEYX($expectedResult, array $xargs, array $yargs): void { $result = Statistical::STEYX($xargs, $yargs); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-12); + self::assertEqualsWithDelta($expectedResult, $result, 1E-12); } public function providerSTEYX() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php index 86483180df..70ea7526b2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php @@ -31,10 +31,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param $character */ - public function testCHAR($expectedResult, $character) + public function testCHAR($expectedResult, $character): void { $result = TextData::CHARACTER($character); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerCHAR() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php index 63042fa5bd..6aedb5996a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php @@ -31,10 +31,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param $value */ - public function testCLEAN($expectedResult, $value) + public function testCLEAN($expectedResult, $value): void { $result = TextData::TRIMNONPRINTABLE($value); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerCLEAN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php index b39b66bfec..ec9f26d633 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php @@ -31,10 +31,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param $character */ - public function testCODE($expectedResult, $character) + public function testCODE($expectedResult, $character): void { $result = TextData::ASCIICODE($character); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerCODE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php index 6d32298e08..18a2d6847a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php @@ -30,10 +30,10 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testCONCATENATE($expectedResult, ...$args) + public function testCONCATENATE($expectedResult, ...$args): void { $result = TextData::CONCATENATE(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerCONCATENATE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php index 3f0ae34fce..4a0f60132a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php @@ -30,10 +30,10 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testDOLLAR($expectedResult, ...$args) + public function testDOLLAR($expectedResult, ...$args): void { $result = TextData::DOLLAR(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerDOLLAR() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php index ad44c03ff8..09d45a325f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php @@ -31,14 +31,14 @@ protected function tearDown(): void * @param mixed $expectedResult * @param array $args */ - public function testEXACT($expectedResult, ...$args) + public function testEXACT($expectedResult, ...$args): void { StringHelper::setDecimalSeparator('.'); StringHelper::setThousandsSeparator(' '); StringHelper::setCurrencyCode('$'); $result = TextData::EXACT(...$args); - $this->assertSame($expectedResult, $result); + self::assertSame($expectedResult, $result); } /** diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php index c20d7df3b6..38203a332d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php @@ -30,10 +30,10 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testFIND($expectedResult, ...$args) + public function testFIND($expectedResult, ...$args): void { $result = TextData::SEARCHSENSITIVE(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerFIND() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php index 010278fc4c..53e6a5132c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php @@ -30,10 +30,10 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testFIXED($expectedResult, ...$args) + public function testFIXED($expectedResult, ...$args): void { $result = TextData::FIXEDFORMAT(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerFIXED() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php index d1eba19ef8..9a033ae73c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php @@ -30,10 +30,10 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testLEFT($expectedResult, ...$args) + public function testLEFT($expectedResult, ...$args): void { $result = TextData::LEFT(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerLEFT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php index 8e711fa9a7..af7841631f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php @@ -31,10 +31,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param $value */ - public function testLEN($expectedResult, $value) + public function testLEN($expectedResult, $value): void { $result = TextData::STRINGLENGTH($value); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerLEN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php index e329dda39a..6ad522d827 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php @@ -31,10 +31,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param $value */ - public function testLOWER($expectedResult, $value) + public function testLOWER($expectedResult, $value): void { $result = TextData::LOWERCASE($value); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerLOWER() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php index 5bcc43fc93..df02575fbc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php @@ -30,10 +30,10 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testMID($expectedResult, ...$args) + public function testMID($expectedResult, ...$args): void { $result = TextData::MID(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerMID() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php index 45e3c6be95..006e4ce10c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php @@ -29,12 +29,11 @@ protected function tearDown(): void * @dataProvider providerNUMBERVALUE * * @param mixed $expectedResult - * @param array $args */ - public function testNUMBERVALUE($expectedResult, array $args) + public function testNUMBERVALUE($expectedResult, array $args): void { $result = TextData::NUMBERVALUE(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerNUMBERVALUE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php index 13efbd9a14..d799b3954a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php @@ -31,10 +31,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param $value */ - public function testPROPER($expectedResult, $value) + public function testPROPER($expectedResult, $value): void { $result = TextData::PROPERCASE($value); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerPROPER() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php index f319b16ed0..ff3d58bbc4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php @@ -30,10 +30,10 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testREPLACE($expectedResult, ...$args) + public function testREPLACE($expectedResult, ...$args): void { $result = TextData::REPLACE(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerREPLACE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php index 216050c3f1..a89ea6ed1d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php @@ -30,10 +30,10 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testRIGHT($expectedResult, ...$args) + public function testRIGHT($expectedResult, ...$args): void { $result = TextData::RIGHT(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerRIGHT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php index ab3fcb115b..919ec0fbf6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php @@ -30,10 +30,10 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testSEARCH($expectedResult, ...$args) + public function testSEARCH($expectedResult, ...$args): void { $result = TextData::SEARCHINSENSITIVE(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerSEARCH() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php index 89a89ba3a8..d1884fd896 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php @@ -30,10 +30,10 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testSUBSTITUTE($expectedResult, ...$args) + public function testSUBSTITUTE($expectedResult, ...$args): void { $result = TextData::SUBSTITUTE(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerSUBSTITUTE() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php index 56b00838cb..1ce989b46a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php @@ -31,10 +31,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param $value */ - public function testT($expectedResult, $value) + public function testT($expectedResult, $value): void { $result = TextData::RETURNSTRING($value); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php index ec04ce1319..7eec585c97 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php @@ -29,12 +29,11 @@ protected function tearDown(): void * @dataProvider providerTEXTJOIN * * @param mixed $expectedResult - * @param array $args */ - public function testTEXTJOIN($expectedResult, array $args) + public function testTEXTJOIN($expectedResult, array $args): void { $result = TextData::TEXTJOIN(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerTEXTJOIN() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php index f7638e4c6b..eab517cc28 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php @@ -30,7 +30,7 @@ protected function tearDown(): void * * @param mixed $expectedResult */ - public function testTEXT($expectedResult, ...$args) + public function testTEXT($expectedResult, ...$args): void { // Enforce decimal and thousands separator values to UK/US, and currency code to USD StringHelper::setDecimalSeparator('.'); @@ -38,7 +38,7 @@ public function testTEXT($expectedResult, ...$args) StringHelper::setCurrencyCode('$'); $result = TextData::TEXTFORMAT(...$args); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerTEXT() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php index d5907803bf..24ede75fc5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php @@ -31,10 +31,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param $character */ - public function testTRIM($expectedResult, $character) + public function testTRIM($expectedResult, $character): void { $result = TextData::TRIMSPACES($character); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerTRIM() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php index a69d8279e6..1600f37ce2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php @@ -31,10 +31,10 @@ protected function tearDown(): void * @param mixed $expectedResult * @param $value */ - public function testUPPER($expectedResult, $value) + public function testUPPER($expectedResult, $value): void { $result = TextData::UPPERCASE($value); - $this->assertEquals($expectedResult, $result); + self::assertEquals($expectedResult, $result); } public function providerUPPER() diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php index b2e31ba38a..a5083b22f5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php @@ -31,14 +31,14 @@ protected function tearDown(): void * @param mixed $expectedResult * @param $value */ - public function testVALUE($expectedResult, $value) + public function testVALUE($expectedResult, $value): void { StringHelper::setDecimalSeparator('.'); StringHelper::setThousandsSeparator(' '); StringHelper::setCurrencyCode('$'); $result = TextData::VALUE($value); - $this->assertEqualsWithDelta($expectedResult, $result, 1E-8); + self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } public function providerVALUE() diff --git a/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php index 94788c2dc5..4412215afc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php @@ -22,85 +22,85 @@ protected function tearDown(): void Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); } - public function testCompatibilityMode() + public function testCompatibilityMode(): void { $result = Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); // Test for a true response for success - $this->assertTrue($result); + self::assertTrue($result); // Test that mode has been changed - $this->assertEquals(Functions::COMPATIBILITY_GNUMERIC, Functions::getCompatibilityMode()); + self::assertEquals(Functions::COMPATIBILITY_GNUMERIC, Functions::getCompatibilityMode()); } - public function testInvalidCompatibilityMode() + public function testInvalidCompatibilityMode(): void { $result = Functions::setCompatibilityMode('INVALIDMODE'); // Test for a false response for failure - $this->assertFalse($result); + self::assertFalse($result); // Test that mode has not been changed - $this->assertEquals(Functions::COMPATIBILITY_EXCEL, Functions::getCompatibilityMode()); + self::assertEquals(Functions::COMPATIBILITY_EXCEL, Functions::getCompatibilityMode()); } - public function testReturnDateType() + public function testReturnDateType(): void { $result = Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT); // Test for a true response for success - $this->assertTrue($result); + self::assertTrue($result); // Test that mode has been changed - $this->assertEquals(Functions::RETURNDATE_PHP_OBJECT, Functions::getReturnDateType()); + self::assertEquals(Functions::RETURNDATE_PHP_OBJECT, Functions::getReturnDateType()); } - public function testInvalidReturnDateType() + public function testInvalidReturnDateType(): void { $result = Functions::setReturnDateType('INVALIDTYPE'); // Test for a false response for failure - $this->assertFalse($result); + self::assertFalse($result); // Test that mode has not been changed - $this->assertEquals(Functions::RETURNDATE_EXCEL, Functions::getReturnDateType()); + self::assertEquals(Functions::RETURNDATE_EXCEL, Functions::getReturnDateType()); } - public function testDUMMY() + public function testDUMMY(): void { $result = Functions::DUMMY(); self::assertEquals('#Not Yet Implemented', $result); } - public function testDIV0() + public function testDIV0(): void { $result = Functions::DIV0(); self::assertEquals('#DIV/0!', $result); } - public function testNA() + public function testNA(): void { $result = Functions::NA(); self::assertEquals('#N/A', $result); } - public function testNAN() + public function testNAN(): void { $result = Functions::NAN(); self::assertEquals('#NUM!', $result); } - public function testNAME() + public function testNAME(): void { $result = Functions::NAME(); self::assertEquals('#NAME?', $result); } - public function testREF() + public function testREF(): void { $result = Functions::REF(); self::assertEquals('#REF!', $result); } - public function testNULL() + public function testNULL(): void { $result = Functions::null(); self::assertEquals('#NULL!', $result); } - public function testVALUE() + public function testVALUE(): void { $result = Functions::VALUE(); self::assertEquals('#VALUE!', $result); @@ -111,7 +111,7 @@ public function testVALUE() * * @param mixed $expectedResult */ - public function testIsBlank($expectedResult, ...$args) + public function testIsBlank($expectedResult, ...$args): void { $result = Functions::isBlank(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -127,7 +127,7 @@ public function providerIsBlank() * * @param mixed $expectedResult */ - public function testIsErr($expectedResult, ...$args) + public function testIsErr($expectedResult, ...$args): void { $result = Functions::isErr(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -143,7 +143,7 @@ public function providerIsErr() * * @param mixed $expectedResult */ - public function testIsError($expectedResult, ...$args) + public function testIsError($expectedResult, ...$args): void { $result = Functions::isError(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -159,7 +159,7 @@ public function providerIsError() * * @param mixed $expectedResult */ - public function testErrorType($expectedResult, ...$args) + public function testErrorType($expectedResult, ...$args): void { $result = Functions::errorType(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -175,7 +175,7 @@ public function providerErrorType() * * @param mixed $expectedResult */ - public function testIsLogical($expectedResult, ...$args) + public function testIsLogical($expectedResult, ...$args): void { $result = Functions::isLogical(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -191,7 +191,7 @@ public function providerIsLogical() * * @param mixed $expectedResult */ - public function testIsNa($expectedResult, ...$args) + public function testIsNa($expectedResult, ...$args): void { $result = Functions::isNa(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -207,7 +207,7 @@ public function providerIsNa() * * @param mixed $expectedResult */ - public function testIsNumber($expectedResult, ...$args) + public function testIsNumber($expectedResult, ...$args): void { $result = Functions::isNumber(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -223,7 +223,7 @@ public function providerIsNumber() * * @param mixed $expectedResult */ - public function testIsText($expectedResult, ...$args) + public function testIsText($expectedResult, ...$args): void { $result = Functions::isText(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -239,7 +239,7 @@ public function providerIsText() * * @param mixed $expectedResult */ - public function testIsNonText($expectedResult, ...$args) + public function testIsNonText($expectedResult, ...$args): void { $result = Functions::isNonText(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -255,7 +255,7 @@ public function providerIsNonText() * * @param mixed $expectedResult */ - public function testIsEven($expectedResult, ...$args) + public function testIsEven($expectedResult, ...$args): void { $result = Functions::isEven(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -271,7 +271,7 @@ public function providerIsEven() * * @param mixed $expectedResult */ - public function testIsOdd($expectedResult, ...$args) + public function testIsOdd($expectedResult, ...$args): void { $result = Functions::isOdd(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -287,7 +287,7 @@ public function providerIsOdd() * * @param mixed $expectedResult */ - public function testTYPE($expectedResult, ...$args) + public function testTYPE($expectedResult, ...$args): void { $result = Functions::TYPE(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -303,7 +303,7 @@ public function providerTYPE() * * @param mixed $expectedResult */ - public function testN($expectedResult, ...$args) + public function testN($expectedResult, ...$args): void { $result = Functions::n(...$args); self::assertEqualsWithDelta($expectedResult, $result, 1E-8); @@ -321,7 +321,7 @@ public function providerN() * @param mixed $reference Reference to the cell we wish to test * @param mixed $value Value of the cell we wish to test */ - public function testIsFormula($expectedResult, $reference, $value = 'undefined') + public function testIsFormula($expectedResult, $reference, $value = 'undefined'): void { $ourCell = null; if ($value !== 'undefined') { @@ -329,33 +329,33 @@ public function testIsFormula($expectedResult, $reference, $value = 'undefined') ->disableOriginalConstructor() ->getMock(); $remoteCell->method('isFormula') - ->will($this->returnValue(substr($value, 0, 1) == '=')); + ->willReturn(substr($value, 0, 1) == '='); $remoteSheet = $this->getMockBuilder(Worksheet::class) ->disableOriginalConstructor() ->getMock(); $remoteSheet->method('getCell') - ->will($this->returnValue($remoteCell)); + ->willReturn($remoteCell); $workbook = $this->getMockBuilder(Spreadsheet::class) ->disableOriginalConstructor() ->getMock(); $workbook->method('getSheetByName') - ->will($this->returnValue($remoteSheet)); + ->willReturn($remoteSheet); $sheet = $this->getMockBuilder(Worksheet::class) ->disableOriginalConstructor() ->getMock(); $sheet->method('getCell') - ->will($this->returnValue($remoteCell)); + ->willReturn($remoteCell); $sheet->method('getParent') - ->will($this->returnValue($workbook)); + ->willReturn($workbook); $ourCell = $this->getMockBuilder(Cell::class) ->disableOriginalConstructor() ->getMock(); $ourCell->method('getWorksheet') - ->will($this->returnValue($sheet)); + ->willReturn($sheet); } $result = Functions::isFormula($reference, $ourCell); @@ -372,7 +372,7 @@ public function providerIsFormula() * * @param mixed $expectedResult */ - public function testIfCondition($expectedResult, ...$args) + public function testIfCondition($expectedResult, ...$args): void { $result = Functions::ifCondition(...$args); self::assertEquals($expectedResult, $result); diff --git a/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php b/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php index dff80fadd7..04dc0a32e5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php @@ -26,7 +26,7 @@ protected function setUp(): void * @param mixed $reference Reference to the cell we wish to test * @param mixed $value Value of the cell we wish to test */ - public function testFormulaText($expectedResult, $reference, $value = 'undefined') + public function testFormulaText($expectedResult, $reference, $value = 'undefined'): void { $ourCell = null; if ($value !== 'undefined') { @@ -34,35 +34,35 @@ public function testFormulaText($expectedResult, $reference, $value = 'undefined ->disableOriginalConstructor() ->getMock(); $remoteCell->method('isFormula') - ->will($this->returnValue(substr($value, 0, 1) == '=')); + ->willReturn(substr($value, 0, 1) == '='); $remoteCell->method('getValue') - ->will($this->returnValue($value)); + ->willReturn($value); $remoteSheet = $this->getMockBuilder(Worksheet::class) ->disableOriginalConstructor() ->getMock(); $remoteSheet->method('getCell') - ->will($this->returnValue($remoteCell)); + ->willReturn($remoteCell); $workbook = $this->getMockBuilder(Spreadsheet::class) ->disableOriginalConstructor() ->getMock(); $workbook->method('getSheetByName') - ->will($this->returnValue($remoteSheet)); + ->willReturn($remoteSheet); $sheet = $this->getMockBuilder(Worksheet::class) ->disableOriginalConstructor() ->getMock(); $sheet->method('getCell') - ->will($this->returnValue($remoteCell)); + ->willReturn($remoteCell); $sheet->method('getParent') - ->will($this->returnValue($workbook)); + ->willReturn($workbook); $ourCell = $this->getMockBuilder(Cell::class) ->disableOriginalConstructor() ->getMock(); $ourCell->method('getWorksheet') - ->will($this->returnValue($sheet)); + ->willReturn($sheet); } $result = LookupRef::FORMULATEXT($reference, $ourCell); diff --git a/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php b/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php index fe77073122..936092d4ae 100644 --- a/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php +++ b/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php @@ -40,7 +40,7 @@ public function provider() * @param mixed $decimalSeparator * @param mixed $currencyCode */ - public function testCurrency($value, $valueBinded, $format, $thousandsSeparator, $decimalSeparator, $currencyCode) + public function testCurrency($value, $valueBinded, $format, $thousandsSeparator, $decimalSeparator, $currencyCode): void { $sheet = $this->getMockBuilder(Worksheet::class) ->setMethods(['getStyle', 'getNumberFormat', 'setFormatCode', 'getCellCollection']) @@ -48,23 +48,23 @@ public function testCurrency($value, $valueBinded, $format, $thousandsSeparator, $cellCollection = $this->getMockBuilder(Cells::class) ->disableOriginalConstructor() ->getMock(); - $cellCollection->expects($this->any()) + $cellCollection->expects(self::any()) ->method('getParent') - ->will($this->returnValue($sheet)); + ->willReturn($sheet); - $sheet->expects($this->once()) + $sheet->expects(self::once()) ->method('getStyle') - ->will($this->returnSelf()); - $sheet->expects($this->once()) + ->willReturnSelf(); + $sheet->expects(self::once()) ->method('getNumberFormat') - ->will($this->returnSelf()); - $sheet->expects($this->once()) + ->willReturnSelf(); + $sheet->expects(self::once()) ->method('setFormatCode') ->with($format) - ->will($this->returnSelf()); - $sheet->expects($this->any()) + ->willReturnSelf(); + $sheet->expects(self::any()) ->method('getCellCollection') - ->will($this->returnValue($cellCollection)); + ->willReturn($cellCollection); StringHelper::setCurrencyCode($currencyCode); StringHelper::setDecimalSeparator($decimalSeparator); diff --git a/tests/PhpSpreadsheetTests/Cell/CellTest.php b/tests/PhpSpreadsheetTests/Cell/CellTest.php index 15e1d38407..8c95e86458 100644 --- a/tests/PhpSpreadsheetTests/Cell/CellTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CellTest.php @@ -13,9 +13,8 @@ class CellTest extends TestCase * * @param mixed $expected * @param mixed $value - * @param string $dataType */ - public function testSetValueExplicit($expected, $value, string $dataType) + public function testSetValueExplicit($expected, $value, string $dataType): void { $spreadsheet = new Spreadsheet(); $cell = $spreadsheet->getActiveSheet()->getCell('A1'); @@ -32,11 +31,9 @@ public function providerSetValueExplicit() /** * @dataProvider providerSetValueExplicitException * - * @param mixed $expected * @param mixed $value - * @param string $dataType */ - public function testSetValueExplicitException($value, string $dataType) + public function testSetValueExplicitException($value, string $dataType): void { $this->expectException(Exception::class); diff --git a/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php b/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php index 7a12ceb7c0..37579e80c6 100644 --- a/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php @@ -5,6 +5,7 @@ use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Exception; use PHPUnit\Framework\TestCase; +use TypeError; class CoordinateTest extends TestCase { @@ -14,7 +15,7 @@ class CoordinateTest extends TestCase * @param mixed $expectedResult * @param mixed $string */ - public function testColumnIndexFromString($expectedResult, $string) + public function testColumnIndexFromString($expectedResult, $string): void { $columnIndex = Coordinate::columnIndexFromString($string); self::assertEquals($expectedResult, $columnIndex); @@ -28,7 +29,7 @@ public function providerColumnString() return require 'tests/data/ColumnString.php'; } - public function testColumnIndexFromStringTooLong() + public function testColumnIndexFromStringTooLong(): void { $cellAddress = 'ABCD'; @@ -40,10 +41,10 @@ public function testColumnIndexFromStringTooLong() return; } - $this->fail('An expected exception has not been raised.'); + self::fail('An expected exception has not been raised.'); } - public function testColumnIndexFromStringTooShort() + public function testColumnIndexFromStringTooShort(): void { $cellAddress = ''; @@ -55,7 +56,7 @@ public function testColumnIndexFromStringTooShort() return; } - $this->fail('An expected exception has not been raised.'); + self::fail('An expected exception has not been raised.'); } /** @@ -64,7 +65,7 @@ public function testColumnIndexFromStringTooShort() * @param mixed $expectedResult * @param int $columnIndex */ - public function testStringFromColumnIndex($expectedResult, $columnIndex) + public function testStringFromColumnIndex($expectedResult, $columnIndex): void { $string = Coordinate::stringFromColumnIndex($columnIndex); self::assertEquals($expectedResult, $string); @@ -83,7 +84,7 @@ public function providerColumnIndex() * * @param mixed $expectedResult */ - public function testCoordinateFromString($expectedResult, ...$args) + public function testCoordinateFromString($expectedResult, ...$args): void { $result = Coordinate::coordinateFromString(...$args); self::assertEquals($expectedResult, $result); @@ -94,7 +95,7 @@ public function providerCoordinates() return require 'tests/data/CellCoordinates.php'; } - public function testCoordinateFromStringWithRangeAddress() + public function testCoordinateFromStringWithRangeAddress(): void { $cellAddress = 'A1:AI2012'; @@ -106,10 +107,10 @@ public function testCoordinateFromStringWithRangeAddress() return; } - $this->fail('An expected exception has not been raised.'); + self::fail('An expected exception has not been raised.'); } - public function testCoordinateFromStringWithEmptyAddress() + public function testCoordinateFromStringWithEmptyAddress(): void { $cellAddress = ''; @@ -121,10 +122,10 @@ public function testCoordinateFromStringWithEmptyAddress() return; } - $this->fail('An expected exception has not been raised.'); + self::fail('An expected exception has not been raised.'); } - public function testCoordinateFromStringWithInvalidAddress() + public function testCoordinateFromStringWithInvalidAddress(): void { $cellAddress = 'AI'; @@ -136,7 +137,7 @@ public function testCoordinateFromStringWithInvalidAddress() return; } - $this->fail('An expected exception has not been raised.'); + self::fail('An expected exception has not been raised.'); } /** @@ -144,7 +145,7 @@ public function testCoordinateFromStringWithInvalidAddress() * * @param mixed $expectedResult */ - public function testAbsoluteCoordinateFromString($expectedResult, ...$args) + public function testAbsoluteCoordinateFromString($expectedResult, ...$args): void { $result = Coordinate::absoluteCoordinate(...$args); self::assertEquals($expectedResult, $result); @@ -155,7 +156,7 @@ public function providerAbsoluteCoordinates() return require 'tests/data/CellAbsoluteCoordinate.php'; } - public function testAbsoluteCoordinateFromStringWithRangeAddress() + public function testAbsoluteCoordinateFromStringWithRangeAddress(): void { $cellAddress = 'A1:AI2012'; @@ -167,7 +168,7 @@ public function testAbsoluteCoordinateFromStringWithRangeAddress() return; } - $this->fail('An expected exception has not been raised.'); + self::fail('An expected exception has not been raised.'); } /** @@ -175,7 +176,7 @@ public function testAbsoluteCoordinateFromStringWithRangeAddress() * * @param mixed $expectedResult */ - public function testAbsoluteReferenceFromString($expectedResult, ...$args) + public function testAbsoluteReferenceFromString($expectedResult, ...$args): void { $result = Coordinate::absoluteReference(...$args); self::assertEquals($expectedResult, $result); @@ -186,7 +187,7 @@ public function providerAbsoluteReferences() return require 'tests/data/CellAbsoluteReference.php'; } - public function testAbsoluteReferenceFromStringWithRangeAddress() + public function testAbsoluteReferenceFromStringWithRangeAddress(): void { $cellAddress = 'A1:AI2012'; @@ -198,7 +199,7 @@ public function testAbsoluteReferenceFromStringWithRangeAddress() return; } - $this->fail('An expected exception has not been raised.'); + self::fail('An expected exception has not been raised.'); } /** @@ -206,7 +207,7 @@ public function testAbsoluteReferenceFromStringWithRangeAddress() * * @param mixed $expectedResult */ - public function testSplitRange($expectedResult, ...$args) + public function testSplitRange($expectedResult, ...$args): void { $result = Coordinate::splitRange(...$args); foreach ($result as $key => $split) { @@ -228,7 +229,7 @@ public function providerSplitRange() * * @param mixed $expectedResult */ - public function testBuildRange($expectedResult, ...$args) + public function testBuildRange($expectedResult, ...$args): void { $result = Coordinate::buildRange(...$args); self::assertEquals($expectedResult, $result); @@ -239,9 +240,9 @@ public function providerBuildRange() return require 'tests/data/CellBuildRange.php'; } - public function testBuildRangeInvalid() + public function testBuildRangeInvalid(): void { - $this->expectException(\TypeError::class); + $this->expectException(TypeError::class); $cellRange = ''; Coordinate::buildRange($cellRange); @@ -252,7 +253,7 @@ public function testBuildRangeInvalid() * * @param mixed $expectedResult */ - public function testRangeBoundaries($expectedResult, ...$args) + public function testRangeBoundaries($expectedResult, ...$args): void { $result = Coordinate::rangeBoundaries(...$args); self::assertEquals($expectedResult, $result); @@ -268,7 +269,7 @@ public function providerRangeBoundaries() * * @param mixed $expectedResult */ - public function testRangeDimension($expectedResult, ...$args) + public function testRangeDimension($expectedResult, ...$args): void { $result = Coordinate::rangeDimension(...$args); self::assertEquals($expectedResult, $result); @@ -284,7 +285,7 @@ public function providerRangeDimension() * * @param mixed $expectedResult */ - public function testGetRangeBoundaries($expectedResult, ...$args) + public function testGetRangeBoundaries($expectedResult, ...$args): void { $result = Coordinate::getRangeBoundaries(...$args); self::assertEquals($expectedResult, $result); @@ -300,7 +301,7 @@ public function providerGetRangeBoundaries() * * @param mixed $expectedResult */ - public function testExtractAllCellReferencesInRange($expectedResult, ...$args) + public function testExtractAllCellReferencesInRange($expectedResult, ...$args): void { $result = Coordinate::extractAllCellReferencesInRange(...$args); self::assertEquals($expectedResult, $result); @@ -316,7 +317,7 @@ public function providerExtractAllCellReferencesInRange() * * @param string $range */ - public function testExtractAllCellReferencesInRangeInvalidRange($range) + public function testExtractAllCellReferencesInRangeInvalidRange($range): void { $this->expectException(Exception::class); $this->expectExceptionMessage('Invalid range: "' . $range . '"'); @@ -334,7 +335,7 @@ public function providerInvalidRange() * * @param mixed $expectedResult */ - public function testMergeRangesInCollection($expectedResult, ...$args) + public function testMergeRangesInCollection($expectedResult, ...$args): void { $result = Coordinate::mergeRangesInCollection(...$args); self::assertEquals($expectedResult, $result); @@ -350,7 +351,7 @@ public function providerMergeRangesInCollection() * * @param mixed $expectedResult */ - public function testCoordinateIsRange($expectedResult, ...$args) + public function testCoordinateIsRange($expectedResult, ...$args): void { $result = Coordinate::coordinateIsRange(...$args); self::assertEquals($expectedResult, $result); diff --git a/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php b/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php index 8acba29789..95454c16f0 100644 --- a/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php @@ -8,7 +8,7 @@ class DataTypeTest extends TestCase { - public function testGetErrorCodes() + public function testGetErrorCodes(): void { $result = DataType::getErrorCodes(); self::assertIsArray($result); @@ -16,7 +16,7 @@ public function testGetErrorCodes() self::assertArrayHasKey('#NULL!', $result); } - public function testCheckString() + public function testCheckString(): void { $richText = new RichText(); $result1 = DataType::checkString($richText); diff --git a/tests/PhpSpreadsheetTests/Cell/DataValidationTest.php b/tests/PhpSpreadsheetTests/Cell/DataValidationTest.php index c41c0335fb..62be68dd26 100644 --- a/tests/PhpSpreadsheetTests/Cell/DataValidationTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DataValidationTest.php @@ -7,7 +7,7 @@ class DataValidationTest extends TestCase { - public function testNoValidation() + public function testNoValidation(): void { $dataValidation = new DataValidation(); self::assertSame('090624f04837265d79323c4a1b7e89d1', $dataValidation->getHashCode()); diff --git a/tests/PhpSpreadsheetTests/Cell/DataValidatorTest.php b/tests/PhpSpreadsheetTests/Cell/DataValidatorTest.php index 9d4db699b7..bae315affc 100644 --- a/tests/PhpSpreadsheetTests/Cell/DataValidatorTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DataValidatorTest.php @@ -8,7 +8,7 @@ class DataValidatorTest extends TestCase { - public function testNoValidation() + public function testNoValidation(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -17,7 +17,7 @@ public function testNoValidation() self::assertTrue($testCell->hasValidValue(), 'a cell without any validation data is always valid'); } - public function testUnsupportedType() + public function testUnsupportedType(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -30,7 +30,7 @@ public function testUnsupportedType() self::assertFalse($testCell->hasValidValue(), 'cannot assert that value is valid when the validation type is not supported'); } - public function testList() + public function testList(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php index d22e03cb95..90dabce3f1 100644 --- a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php @@ -21,9 +21,9 @@ private function createCellStub() ->getMock(); // Configure the stub. - $cellStub->expects($this->any()) + $cellStub->expects(self::any()) ->method('setValueExplicit') - ->will($this->returnValue(true)); + ->willReturn(true); return $cellStub; } @@ -33,7 +33,7 @@ private function createCellStub() * * @param mixed $value */ - public function testBindValue($value) + public function testBindValue($value): void { $cellStub = $this->createCellStub(); $binder = new DefaultValueBinder(); @@ -65,7 +65,7 @@ public function binderProvider() * * @param mixed $expectedResult */ - public function testDataTypeForValue($expectedResult, ...$args) + public function testDataTypeForValue($expectedResult, ...$args): void { $result = DefaultValueBinder::dataTypeForValue(...$args); self::assertEquals($expectedResult, $result); @@ -76,7 +76,7 @@ public function providerDataTypeForValue() return require 'tests/data/Cell/DefaultValueBinder.php'; } - public function testDataTypeForRichTextObject() + public function testDataTypeForRichTextObject(): void { $objRichText = new RichText(); $objRichText->createText('Hello World'); @@ -86,7 +86,7 @@ public function testDataTypeForRichTextObject() self::assertEquals($expectedResult, $result); } - public function testCanOverrideStaticMethodWithoutOverridingBindValue() + public function testCanOverrideStaticMethodWithoutOverridingBindValue(): void { $cellStub = $this->createCellStub(); $binder = new ValueBinderWithOverriddenDataTypeForValue(); diff --git a/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php b/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php index b1337a0bda..9c09aa75e3 100644 --- a/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php +++ b/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php @@ -7,7 +7,7 @@ class HyperlinkTest extends TestCase { - public function testGetUrl() + public function testGetUrl(): void { $urlValue = 'https://www.example.com'; @@ -17,7 +17,7 @@ public function testGetUrl() self::assertEquals($urlValue, $result); } - public function testSetUrl() + public function testSetUrl(): void { $initialUrlValue = 'https://www.example.com'; $newUrlValue = 'http://github.com/PHPOffice/PhpSpreadsheet'; @@ -30,7 +30,7 @@ public function testSetUrl() self::assertEquals($newUrlValue, $result); } - public function testGetTooltip() + public function testGetTooltip(): void { $tooltipValue = 'PhpSpreadsheet Web Site'; @@ -40,7 +40,7 @@ public function testGetTooltip() self::assertEquals($tooltipValue, $result); } - public function testSetTooltip() + public function testSetTooltip(): void { $initialTooltipValue = 'PhpSpreadsheet Web Site'; $newTooltipValue = 'PhpSpreadsheet Repository on Github'; @@ -53,7 +53,7 @@ public function testSetTooltip() self::assertEquals($newTooltipValue, $result); } - public function testIsInternal() + public function testIsInternal(): void { $initialUrlValue = 'https://www.example.com'; $newUrlValue = 'sheet://Worksheet1!A1'; @@ -67,7 +67,7 @@ public function testIsInternal() self::assertTrue($result); } - public function testGetHashCode() + public function testGetHashCode(): void { $urlValue = 'https://www.example.com'; $tooltipValue = 'PhpSpreadsheet Web Site'; diff --git a/tests/PhpSpreadsheetTests/Chart/DataSeriesValuesTest.php b/tests/PhpSpreadsheetTests/Chart/DataSeriesValuesTest.php index 6641cc6b0c..c34ca697ff 100644 --- a/tests/PhpSpreadsheetTests/Chart/DataSeriesValuesTest.php +++ b/tests/PhpSpreadsheetTests/Chart/DataSeriesValuesTest.php @@ -8,7 +8,7 @@ class DataSeriesValuesTest extends TestCase { - public function testSetDataType() + public function testSetDataType(): void { $dataTypeValues = [ 'Number', @@ -23,7 +23,7 @@ public function testSetDataType() } } - public function testSetInvalidDataTypeThrowsException() + public function testSetInvalidDataTypeThrowsException(): void { $testInstance = new DataSeriesValues(); @@ -34,10 +34,10 @@ public function testSetInvalidDataTypeThrowsException() return; } - $this->fail('An expected exception has not been raised.'); + self::fail('An expected exception has not been raised.'); } - public function testGetDataType() + public function testGetDataType(): void { $dataTypeValue = 'String'; @@ -48,7 +48,7 @@ public function testGetDataType() self::assertEquals($dataTypeValue, $result); } - public function testGetLineWidth() + public function testGetLineWidth(): void { $testInstance = new DataSeriesValues(); self::assertEquals(12700, $testInstance->getLineWidth(), 'should have default'); @@ -60,7 +60,7 @@ public function testGetLineWidth() self::assertEquals(12700, $testInstance->getLineWidth(), 'should enforce minimum width'); } - public function testFillColorCorrectInput() + public function testFillColorCorrectInput(): void { $testInstance = new DataSeriesValues(); @@ -68,7 +68,7 @@ public function testFillColorCorrectInput() self::assertEquals($testInstance, $testInstance->setFillColor(['00abb8', 'b8292f'])); } - public function testFillColorInvalidInput() + public function testFillColorInvalidInput(): void { $testInstance = new DataSeriesValues(); $this->expectException(\Exception::class); @@ -77,7 +77,7 @@ public function testFillColorInvalidInput() $testInstance->setFillColor('WRONG COLOR'); } - public function testFillColorInvalidInputInArray() + public function testFillColorInvalidInputInArray(): void { $testInstance = new DataSeriesValues(); $this->expectException(\Exception::class); diff --git a/tests/PhpSpreadsheetTests/Chart/LayoutTest.php b/tests/PhpSpreadsheetTests/Chart/LayoutTest.php index 9ae804601d..8e92798565 100644 --- a/tests/PhpSpreadsheetTests/Chart/LayoutTest.php +++ b/tests/PhpSpreadsheetTests/Chart/LayoutTest.php @@ -7,7 +7,7 @@ class LayoutTest extends TestCase { - public function testSetLayoutTarget() + public function testSetLayoutTarget(): void { $LayoutTargetValue = 'String'; @@ -17,7 +17,7 @@ public function testSetLayoutTarget() self::assertInstanceOf(Layout::class, $result); } - public function testGetLayoutTarget() + public function testGetLayoutTarget(): void { $LayoutTargetValue = 'String'; diff --git a/tests/PhpSpreadsheetTests/Chart/LegendTest.php b/tests/PhpSpreadsheetTests/Chart/LegendTest.php index e21baaf5f0..3071536549 100644 --- a/tests/PhpSpreadsheetTests/Chart/LegendTest.php +++ b/tests/PhpSpreadsheetTests/Chart/LegendTest.php @@ -7,7 +7,7 @@ class LegendTest extends TestCase { - public function testSetPosition() + public function testSetPosition(): void { $positionValues = [ Legend::POSITION_RIGHT, @@ -25,7 +25,7 @@ public function testSetPosition() } } - public function testSetInvalidPositionReturnsFalse() + public function testSetInvalidPositionReturnsFalse(): void { $testInstance = new Legend(); @@ -36,7 +36,7 @@ public function testSetInvalidPositionReturnsFalse() self::assertEquals(Legend::POSITION_RIGHT, $result); } - public function testGetPosition() + public function testGetPosition(): void { $PositionValue = Legend::POSITION_BOTTOM; @@ -47,7 +47,7 @@ public function testGetPosition() self::assertEquals($PositionValue, $result); } - public function testSetPositionXL() + public function testSetPositionXL(): void { $positionValues = [ Legend::XL_LEGEND_POSITION_BOTTOM, @@ -66,7 +66,7 @@ public function testSetPositionXL() } } - public function testSetInvalidXLPositionReturnsFalse() + public function testSetInvalidXLPositionReturnsFalse(): void { $testInstance = new Legend(); @@ -77,7 +77,7 @@ public function testSetInvalidXLPositionReturnsFalse() self::assertEquals(Legend::XL_LEGEND_POSITION_RIGHT, $result); } - public function testGetPositionXL() + public function testGetPositionXL(): void { $PositionValue = Legend::XL_LEGEND_POSITION_CORNER; @@ -88,7 +88,7 @@ public function testGetPositionXL() self::assertEquals($PositionValue, $result); } - public function testSetOverlay() + public function testSetOverlay(): void { $overlayValues = [ true, @@ -103,7 +103,7 @@ public function testSetOverlay() } } - public function testSetInvalidOverlayReturnsFalse() + public function testSetInvalidOverlayReturnsFalse(): void { $testInstance = new Legend(); @@ -114,7 +114,7 @@ public function testSetInvalidOverlayReturnsFalse() self::assertFalse($result); } - public function testGetOverlay() + public function testGetOverlay(): void { $OverlayValue = true; diff --git a/tests/PhpSpreadsheetTests/Collection/CellsTest.php b/tests/PhpSpreadsheetTests/Collection/CellsTest.php index e1dcfc8f80..539d0232de 100644 --- a/tests/PhpSpreadsheetTests/Collection/CellsTest.php +++ b/tests/PhpSpreadsheetTests/Collection/CellsTest.php @@ -11,7 +11,7 @@ class CellsTest extends TestCase { - public function testCollectionCell() + public function testCollectionCell(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -63,7 +63,7 @@ public function testCollectionCell() self::assertEquals(['A1', 'C3'], $collection->getCoordinates(), 'cell list should contains the cell'); } - public function testCacheLastCell() + public function testCacheLastCell(): void { $workbook = new Spreadsheet(); $cells = ['A1', 'A2']; @@ -73,7 +73,7 @@ public function testCacheLastCell() self::assertEquals($cells, $sheet->getCoordinates(), 'list should include last added cell'); } - public function testCanGetCellAfterAnotherIsDeleted() + public function testCanGetCellAfterAnotherIsDeleted(): void { $workbook = new Spreadsheet(); $sheet = $workbook->getActiveSheet(); @@ -85,7 +85,7 @@ public function testCanGetCellAfterAnotherIsDeleted() self::assertNotNull($collection->get('A2'), 'should be able to get back the cell even when another cell was deleted while this one was the current one'); } - public function testThrowsWhenCellCannotBeRetrievedFromCache() + public function testThrowsWhenCellCannotBeRetrievedFromCache(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -100,7 +100,7 @@ public function testThrowsWhenCellCannotBeRetrievedFromCache() $collection->get('A2'); } - public function testThrowsWhenCellCannotBeStoredInCache() + public function testThrowsWhenCellCannotBeStoredInCache(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -115,20 +115,20 @@ public function testThrowsWhenCellCannotBeStoredInCache() $collection->add('A2', $cell); } - public function testGetHighestColumn() + public function testGetHighestColumn(): void { $workbook = new Spreadsheet(); $sheet = $workbook->getActiveSheet(); $collection = $sheet->getCellCollection(); // check for empty sheet - $this->assertEquals('A', $collection->getHighestColumn()); - $this->assertEquals('A', $collection->getHighestColumn(1)); + self::assertEquals('A', $collection->getHighestColumn()); + self::assertEquals('A', $collection->getHighestColumn(1)); // set a value and check again $sheet->getCell('C4')->setValue(1); - $this->assertEquals('C', $collection->getHighestColumn()); - $this->assertEquals('A', $collection->getHighestColumn(1)); - $this->assertEquals('C', $collection->getHighestColumn(4)); + self::assertEquals('C', $collection->getHighestColumn()); + self::assertEquals('A', $collection->getHighestColumn(1)); + self::assertEquals('C', $collection->getHighestColumn(4)); } } diff --git a/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php b/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php index d039dab042..4d1025d216 100644 --- a/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php +++ b/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php @@ -27,7 +27,7 @@ private function adjustDelta($expected, $actual, $delta) if (abs($actual) > 10 && abs($expected) > 10) { $variance = floor(log10(abs($expected))); - $adjustedDelta *= pow(10, $variance); + $adjustedDelta *= 10 ** $variance; } return $adjustedDelta > 1.0 ? 1.0 : $adjustedDelta; diff --git a/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php index 214fe593d3..ac9af83841 100644 --- a/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php +++ b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php @@ -12,9 +12,6 @@ class DocumentGeneratorTest extends TestCase { /** * @dataProvider providerGenerateFunctionListByName - * - * @param array $phpSpreadsheetFunctions - * @param string $expected */ public function testGenerateFunctionListByName(array $phpSpreadsheetFunctions, string $expected): void { @@ -23,9 +20,6 @@ public function testGenerateFunctionListByName(array $phpSpreadsheetFunctions, s /** * @dataProvider providerGenerateFunctionListByCategory - * - * @param array $phpSpreadsheetFunctions - * @param string $expected */ public function testGenerateFunctionListByCategory(array $phpSpreadsheetFunctions, string $expected): void { diff --git a/tests/PhpSpreadsheetTests/Functional/AbstractFunctional.php b/tests/PhpSpreadsheetTests/Functional/AbstractFunctional.php index da9f76e056..f242c698df 100644 --- a/tests/PhpSpreadsheetTests/Functional/AbstractFunctional.php +++ b/tests/PhpSpreadsheetTests/Functional/AbstractFunctional.php @@ -15,13 +15,11 @@ abstract class AbstractFunctional extends TestCase /** * Write spreadsheet to disk, reload and return it. * - * @param Spreadsheet $spreadsheet * @param string $format - * @param null|callable $readerCustomizer * * @return Spreadsheet */ - protected function writeAndReload(Spreadsheet $spreadsheet, $format, callable $readerCustomizer = null) + protected function writeAndReload(Spreadsheet $spreadsheet, $format, ?callable $readerCustomizer = null) { $filename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); $writer = IOFactory::createWriter($spreadsheet, $format); diff --git a/tests/PhpSpreadsheetTests/Functional/ActiveSheetTest.php b/tests/PhpSpreadsheetTests/Functional/ActiveSheetTest.php index 9274e9c4b1..56682b34a1 100644 --- a/tests/PhpSpreadsheetTests/Functional/ActiveSheetTest.php +++ b/tests/PhpSpreadsheetTests/Functional/ActiveSheetTest.php @@ -20,7 +20,7 @@ public function providerFormats() * * @param string $format */ - public function testActiveSheet($format) + public function testActiveSheet($format): void { $spreadsheet = new Spreadsheet(); diff --git a/tests/PhpSpreadsheetTests/Functional/ColumnWidthTest.php b/tests/PhpSpreadsheetTests/Functional/ColumnWidthTest.php index 6d4fc2ca21..5cd0aec754 100644 --- a/tests/PhpSpreadsheetTests/Functional/ColumnWidthTest.php +++ b/tests/PhpSpreadsheetTests/Functional/ColumnWidthTest.php @@ -18,7 +18,7 @@ public function providerFormats() * * @param $format */ - public function testReadColumnWidth($format) + public function testReadColumnWidth($format): void { // create new sheet with column width $spreadsheet = new Spreadsheet(); @@ -31,7 +31,7 @@ public function testReadColumnWidth($format) $this->assertColumn($reloadedSpreadsheet); } - private function assertColumn(Spreadsheet $spreadsheet) + private function assertColumn(Spreadsheet $spreadsheet): void { $sheet = $spreadsheet->getActiveSheet(); $columnDimensions = $sheet->getColumnDimensions(); diff --git a/tests/PhpSpreadsheetTests/Functional/CommentsTest.php b/tests/PhpSpreadsheetTests/Functional/CommentsTest.php index a394c96725..6f1c534026 100644 --- a/tests/PhpSpreadsheetTests/Functional/CommentsTest.php +++ b/tests/PhpSpreadsheetTests/Functional/CommentsTest.php @@ -23,7 +23,7 @@ public function providerFormats() * * @param $format */ - public function testComments($format) + public function testComments($format): void { $spreadsheet = new Spreadsheet(); diff --git a/tests/PhpSpreadsheetTests/Functional/ConditionalStopIfTrueTest.php b/tests/PhpSpreadsheetTests/Functional/ConditionalStopIfTrueTest.php index 3aa3f949f9..3183450fbc 100644 --- a/tests/PhpSpreadsheetTests/Functional/ConditionalStopIfTrueTest.php +++ b/tests/PhpSpreadsheetTests/Functional/ConditionalStopIfTrueTest.php @@ -21,7 +21,7 @@ public function providerFormats() * * @param string $format */ - public function testConditionalStopIfTrue($format) + public function testConditionalStopIfTrue($format): void { $pCoordinate = 'A1:A3'; diff --git a/tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php b/tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php index 99333150be..7a8e2cda90 100644 --- a/tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php +++ b/tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php @@ -8,7 +8,7 @@ class DrawingImageHyperlinkTest extends AbstractFunctional { - public function testDrawingImageHyperlinkTest() + public function testDrawingImageHyperlinkTest(): void { $baseUrl = 'https://github.com/PHPOffice/PhpSpreadsheet'; $spreadsheet = new Spreadsheet(); diff --git a/tests/PhpSpreadsheetTests/Functional/EnclosureTest.php b/tests/PhpSpreadsheetTests/Functional/EnclosureTest.php index 3a5f961632..1f1cb7eb0c 100644 --- a/tests/PhpSpreadsheetTests/Functional/EnclosureTest.php +++ b/tests/PhpSpreadsheetTests/Functional/EnclosureTest.php @@ -22,7 +22,7 @@ public function providerFormats() * * @param string $format */ - public function testEnclosure($format) + public function testEnclosure($format): void { $value = ''; diff --git a/tests/PhpSpreadsheetTests/Functional/FreezePaneTest.php b/tests/PhpSpreadsheetTests/Functional/FreezePaneTest.php index 3870971644..4e725d03c1 100644 --- a/tests/PhpSpreadsheetTests/Functional/FreezePaneTest.php +++ b/tests/PhpSpreadsheetTests/Functional/FreezePaneTest.php @@ -19,7 +19,7 @@ public function providerFormats() * * @param string $format */ - public function testFreezePane($format) + public function testFreezePane($format): void { $cellSplit = 'B4'; $topLeftCell = 'E7'; @@ -43,7 +43,7 @@ public function testFreezePane($format) * * @param string $format */ - public function testFreezePaneWithInvalidSelectedCells($format) + public function testFreezePaneWithInvalidSelectedCells($format): void { $cellSplit = 'A7'; $topLeftCell = 'A24'; @@ -71,7 +71,7 @@ public function testFreezePaneWithInvalidSelectedCells($format) * * @param string $format */ - public function testFreezePaneUserSelectedCell($format) + public function testFreezePaneUserSelectedCell($format): void { $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); @@ -100,7 +100,7 @@ public function testFreezePaneUserSelectedCell($format) * * @param string $format */ - public function testNoFreezePaneUserSelectedCell($format) + public function testNoFreezePaneUserSelectedCell($format): void { $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Functional/MergedCellsTest.php b/tests/PhpSpreadsheetTests/Functional/MergedCellsTest.php index 7a60194972..39865817ad 100644 --- a/tests/PhpSpreadsheetTests/Functional/MergedCellsTest.php +++ b/tests/PhpSpreadsheetTests/Functional/MergedCellsTest.php @@ -21,7 +21,7 @@ public function providerFormats() * * @param string $format */ - public function testMergedCells($format) + public function testMergedCells($format): void { $spreadsheet = new Spreadsheet(); $spreadsheet->setActiveSheetIndex(0); diff --git a/tests/PhpSpreadsheetTests/Functional/PrintAreaTest.php b/tests/PhpSpreadsheetTests/Functional/PrintAreaTest.php index 7c3a9112eb..a335fd2f16 100644 --- a/tests/PhpSpreadsheetTests/Functional/PrintAreaTest.php +++ b/tests/PhpSpreadsheetTests/Functional/PrintAreaTest.php @@ -20,7 +20,7 @@ public function providerFormats() * * @param string $format */ - public function testPageSetup($format) + public function testPageSetup($format): void { // Create new workbook with 3 sheets and different print areas $spreadsheet = new Spreadsheet(); @@ -35,7 +35,7 @@ public function testPageSetup($format) $worksheet4 = $spreadsheet->createSheet()->setTitle('Sheet 4'); $worksheet4->getPageSetup()->setPrintArea('A4:B4,D1:E4'); - $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format, function (BaseReader $reader) { + $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format, function (BaseReader $reader): void { $reader->setLoadSheetsOnly(['Sheet 1', 'Sheet 3', 'Sheet 4']); }); diff --git a/tests/PhpSpreadsheetTests/Functional/ReadBlankCellsTest.php b/tests/PhpSpreadsheetTests/Functional/ReadBlankCellsTest.php index 02c752aca9..9dac34377d 100644 --- a/tests/PhpSpreadsheetTests/Functional/ReadBlankCellsTest.php +++ b/tests/PhpSpreadsheetTests/Functional/ReadBlankCellsTest.php @@ -22,10 +22,9 @@ public function providerSheetFormat() * * @dataProvider providerSheetFormat * - * @param array $arrayData * @param mixed $format */ - public function testXlsxLoadWithNoBlankCells($format) + public function testXlsxLoadWithNoBlankCells($format): void { $spreadsheet = new Spreadsheet(); $spreadsheet->getActiveSheet()->getCell('B2')->setValue(''); @@ -33,15 +32,15 @@ public function testXlsxLoadWithNoBlankCells($format) $spreadsheet->getActiveSheet()->getCell('C3')->setValue('C3'); $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format); - $this->assertTrue($reloadedSpreadsheet->getActiveSheet()->getCellCollection()->has('B2')); - $this->assertFalse($reloadedSpreadsheet->getActiveSheet()->getCellCollection()->has('C2')); - $this->assertTrue($reloadedSpreadsheet->getActiveSheet()->getCellCollection()->has('C3')); + self::assertTrue($reloadedSpreadsheet->getActiveSheet()->getCellCollection()->has('B2')); + self::assertFalse($reloadedSpreadsheet->getActiveSheet()->getCellCollection()->has('C2')); + self::assertTrue($reloadedSpreadsheet->getActiveSheet()->getCellCollection()->has('C3')); - $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format, function ($reader) { + $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format, function ($reader): void { $reader->setReadEmptyCells(false); }); - $this->assertFalse($reloadedSpreadsheet->getActiveSheet()->getCellCollection()->has('B2')); - $this->assertFalse($reloadedSpreadsheet->getActiveSheet()->getCellCollection()->has('C2')); - $this->assertTrue($reloadedSpreadsheet->getActiveSheet()->getCellCollection()->has('C3')); + self::assertFalse($reloadedSpreadsheet->getActiveSheet()->getCellCollection()->has('B2')); + self::assertFalse($reloadedSpreadsheet->getActiveSheet()->getCellCollection()->has('C2')); + self::assertTrue($reloadedSpreadsheet->getActiveSheet()->getCellCollection()->has('C3')); } } diff --git a/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php b/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php index 288fc57ede..efca228cd8 100644 --- a/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php +++ b/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php @@ -34,10 +34,9 @@ public function providerCellsValues() * * @dataProvider providerCellsValues * - * @param array $arrayData * @param mixed $format */ - public function testXlsxLoadWithoutReadFilter($format, array $arrayData) + public function testXlsxLoadWithoutReadFilter($format, array $arrayData): void { $spreadsheet = new Spreadsheet(); @@ -62,19 +61,18 @@ public function testXlsxLoadWithoutReadFilter($format, array $arrayData) * * @dataProvider providerCellsValues * - * @param array $arrayData * @param mixed $format */ - public function testXlsxLoadWithReadFilter($format, array $arrayData) + public function testXlsxLoadWithReadFilter($format, array $arrayData): void { $spreadsheet = new Spreadsheet(); $spreadsheet->getActiveSheet()->fromArray($arrayData, null, 'A1'); - $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format, function ($reader) { + $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format, function ($reader): void { // Create a stub for the readFilter class. $readFilterStub = $this->createMock(IReadFilter::class); $readFilterStub->method('readCell') - ->will($this->returnCallback([$this, 'readFilterReadCell'])); + ->willReturnCallback([$this, 'readFilterReadCell']); // apply filter $reader->setReadFilter($readFilterStub); }); diff --git a/tests/PhpSpreadsheetTests/Functional/SelectedCellsTest.php b/tests/PhpSpreadsheetTests/Functional/SelectedCellsTest.php index 03d4be9f87..625f242816 100644 --- a/tests/PhpSpreadsheetTests/Functional/SelectedCellsTest.php +++ b/tests/PhpSpreadsheetTests/Functional/SelectedCellsTest.php @@ -20,7 +20,7 @@ public function providerFormats() * * @param string $format */ - public function testSelectedCells($format) + public function testSelectedCells($format): void { $spreadsheet = new Spreadsheet(); diff --git a/tests/PhpSpreadsheetTests/Functional/StreamTest.php b/tests/PhpSpreadsheetTests/Functional/StreamTest.php index 20e588bb4c..dcca6b8a07 100644 --- a/tests/PhpSpreadsheetTests/Functional/StreamTest.php +++ b/tests/PhpSpreadsheetTests/Functional/StreamTest.php @@ -24,8 +24,6 @@ public function providerFormats(): array /** * @dataProvider providerFormats - * - * @param string $format */ public function testAllWritersCanWriteToStream(string $format): void { diff --git a/tests/PhpSpreadsheetTests/Functional/TypeAttributePreservationTest.php b/tests/PhpSpreadsheetTests/Functional/TypeAttributePreservationTest.php index cca3777adf..e6d6377b02 100644 --- a/tests/PhpSpreadsheetTests/Functional/TypeAttributePreservationTest.php +++ b/tests/PhpSpreadsheetTests/Functional/TypeAttributePreservationTest.php @@ -27,9 +27,8 @@ public function providerFormulae() * @dataProvider providerFormulae * * @param string $format - * @param array $values */ - public function testFormulae($format, array $values) + public function testFormulae($format, array $values): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Functional/WorkbookViewAttributesTest.php b/tests/PhpSpreadsheetTests/Functional/WorkbookViewAttributesTest.php index cce2a95bf7..f97ad9cfb1 100644 --- a/tests/PhpSpreadsheetTests/Functional/WorkbookViewAttributesTest.php +++ b/tests/PhpSpreadsheetTests/Functional/WorkbookViewAttributesTest.php @@ -24,7 +24,7 @@ public function providerFormats() * * @param string $format */ - public function testPreserveWorkbookViewAttributes($format) + public function testPreserveWorkbookViewAttributes($format): void { // Create a dummy workbook with two worksheets $workbook = new Spreadsheet(); @@ -36,14 +36,14 @@ public function testPreserveWorkbookViewAttributes($format) $worksheet2->setCellValue('A1', 2); // Check that the bookview attributes return default values - $this->assertTrue($workbook->getShowHorizontalScroll()); - $this->assertTrue($workbook->getShowVerticalScroll()); - $this->assertTrue($workbook->getShowSheetTabs()); - $this->assertTrue($workbook->getAutoFilterDateGrouping()); - $this->assertFalse($workbook->getMinimized()); - $this->assertSame(0, $workbook->getFirstSheetIndex()); - $this->assertSame(600, $workbook->getTabRatio()); - $this->assertSame(Spreadsheet::VISIBILITY_VISIBLE, $workbook->getVisibility()); + self::assertTrue($workbook->getShowHorizontalScroll()); + self::assertTrue($workbook->getShowVerticalScroll()); + self::assertTrue($workbook->getShowSheetTabs()); + self::assertTrue($workbook->getAutoFilterDateGrouping()); + self::assertFalse($workbook->getMinimized()); + self::assertSame(0, $workbook->getFirstSheetIndex()); + self::assertSame(600, $workbook->getTabRatio()); + self::assertSame(Spreadsheet::VISIBILITY_VISIBLE, $workbook->getVisibility()); // Set the bookview attributes to non-default values $workbook->setShowHorizontalScroll(false); @@ -56,25 +56,25 @@ public function testPreserveWorkbookViewAttributes($format) $workbook->setVisibility(Spreadsheet::VISIBILITY_HIDDEN); // Check that bookview attributes were set properly - $this->assertFalse($workbook->getShowHorizontalScroll()); - $this->assertFalse($workbook->getShowVerticalScroll()); - $this->assertFalse($workbook->getShowSheetTabs()); - $this->assertFalse($workbook->getAutoFilterDateGrouping()); - $this->assertTrue($workbook->getMinimized()); - $this->assertSame(1, $workbook->getFirstSheetIndex()); - $this->assertSame(700, $workbook->getTabRatio()); - $this->assertSame(Spreadsheet::VISIBILITY_HIDDEN, $workbook->getVisibility()); + self::assertFalse($workbook->getShowHorizontalScroll()); + self::assertFalse($workbook->getShowVerticalScroll()); + self::assertFalse($workbook->getShowSheetTabs()); + self::assertFalse($workbook->getAutoFilterDateGrouping()); + self::assertTrue($workbook->getMinimized()); + self::assertSame(1, $workbook->getFirstSheetIndex()); + self::assertSame(700, $workbook->getTabRatio()); + self::assertSame(Spreadsheet::VISIBILITY_HIDDEN, $workbook->getVisibility()); $workbook2 = $this->writeAndReload($workbook, $format); // Check that the read spreadsheet has the right bookview attributes - $this->assertFalse($workbook2->getShowHorizontalScroll()); - $this->assertFalse($workbook2->getShowVerticalScroll()); - $this->assertFalse($workbook2->getShowSheetTabs()); - $this->assertFalse($workbook2->getAutoFilterDateGrouping()); - $this->assertTrue($workbook2->getMinimized()); - $this->assertSame(1, $workbook2->getFirstSheetIndex()); - $this->assertSame(700, $workbook2->getTabRatio()); - $this->assertSame(Spreadsheet::VISIBILITY_HIDDEN, $workbook2->getVisibility()); + self::assertFalse($workbook2->getShowHorizontalScroll()); + self::assertFalse($workbook2->getShowVerticalScroll()); + self::assertFalse($workbook2->getShowSheetTabs()); + self::assertFalse($workbook2->getAutoFilterDateGrouping()); + self::assertTrue($workbook2->getMinimized()); + self::assertSame(1, $workbook2->getFirstSheetIndex()); + self::assertSame(700, $workbook2->getTabRatio()); + self::assertSame(Spreadsheet::VISIBILITY_HIDDEN, $workbook2->getVisibility()); } } diff --git a/tests/PhpSpreadsheetTests/Helper/HtmlTest.php b/tests/PhpSpreadsheetTests/Helper/HtmlTest.php index b15a728521..d47c2f6467 100644 --- a/tests/PhpSpreadsheetTests/Helper/HtmlTest.php +++ b/tests/PhpSpreadsheetTests/Helper/HtmlTest.php @@ -13,7 +13,7 @@ class HtmlTest extends TestCase * @param mixed $expected * @param mixed $input */ - public function testUtf8EncodingSupport($expected, $input) + public function testUtf8EncodingSupport($expected, $input): void { $html = new Html(); $actual = $html->toRichTextObject($input); diff --git a/tests/PhpSpreadsheetTests/Helper/SampleTest.php b/tests/PhpSpreadsheetTests/Helper/SampleTest.php index 6bd9c42299..eb729dc9a9 100644 --- a/tests/PhpSpreadsheetTests/Helper/SampleTest.php +++ b/tests/PhpSpreadsheetTests/Helper/SampleTest.php @@ -14,10 +14,10 @@ class SampleTest extends TestCase * * @param mixed $sample */ - public function testSample($sample) + public function testSample($sample): void { // Suppress output to console - $this->setOutputCallback(function () { + $this->setOutputCallback(function (): void { }); require $sample; diff --git a/tests/PhpSpreadsheetTests/IOFactoryTest.php b/tests/PhpSpreadsheetTests/IOFactoryTest.php index 5084354fb9..983ba35ef4 100644 --- a/tests/PhpSpreadsheetTests/IOFactoryTest.php +++ b/tests/PhpSpreadsheetTests/IOFactoryTest.php @@ -2,6 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests; +use InvalidArgumentException; use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Reader; use PhpOffice\PhpSpreadsheet\Spreadsheet; @@ -16,7 +17,7 @@ class IOFactoryTest extends TestCase * @param string $name * @param string $expected */ - public function testCreateWriter($name, $expected) + public function testCreateWriter($name, $expected): void { $spreadsheet = new Spreadsheet(); $actual = IOFactory::createWriter($spreadsheet, $name); @@ -37,7 +38,7 @@ public function providerCreateWriter() ]; } - public function testRegisterWriter() + public function testRegisterWriter(): void { IOFactory::registerWriter('Pdf', Writer\Pdf\Mpdf::class); $spreadsheet = new Spreadsheet(); @@ -51,7 +52,7 @@ public function testRegisterWriter() * @param string $name * @param string $expected */ - public function testCreateReader($name, $expected) + public function testCreateReader($name, $expected): void { $actual = IOFactory::createReader($name); self::assertInstanceOf($expected, $actual); @@ -71,7 +72,7 @@ public function providerCreateReader() ]; } - public function testRegisterReader() + public function testRegisterReader(): void { IOFactory::registerReader('Custom', Reader\Html::class); $actual = IOFactory::createReader('Custom'); @@ -85,7 +86,7 @@ public function testRegisterReader() * @param string $expectedName * @param string $expectedClass */ - public function testIdentify($file, $expectedName, $expectedClass) + public function testIdentify($file, $expectedName, $expectedClass): void { $actual = IOFactory::identify($file); self::assertSame($expectedName, $actual); @@ -98,7 +99,7 @@ public function testIdentify($file, $expectedName, $expectedClass) * @param string $expectedName * @param string $expectedClass */ - public function testCreateReaderForFile($file, $expectedName, $expectedClass) + public function testCreateReaderForFile($file, $expectedName, $expectedClass): void { $actual = IOFactory::createReaderForFile($file); self::assertInstanceOf($expectedClass, $actual); @@ -111,7 +112,7 @@ public function testCreateReaderForFile($file, $expectedName, $expectedClass) * @param string $expectedName * @param string $expectedClass */ - public function testLoad($file, $expectedName, $expectedClass) + public function testLoad($file, $expectedName, $expectedClass): void { $actual = IOFactory::load($file); self::assertInstanceOf(Spreadsheet::class, $actual); @@ -130,28 +131,28 @@ public function providerIdentify() ]; } - public function testIdentifyNonExistingFileThrowException() + public function testIdentifyNonExistingFileThrowException(): void { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); IOFactory::identify('/non/existing/file'); } - public function testIdentifyExistingDirectoryThrowExceptions() + public function testIdentifyExistingDirectoryThrowExceptions(): void { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); IOFactory::identify('.'); } - public function testRegisterInvalidWriter() + public function testRegisterInvalidWriter(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Writer\Exception::class); IOFactory::registerWriter('foo', 'bar'); } - public function testRegisterInvalidReader() + public function testRegisterInvalidReader(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Reader\Exception::class); diff --git a/tests/PhpSpreadsheetTests/Reader/CondNumFmtTest.php b/tests/PhpSpreadsheetTests/Reader/CondNumFmtTest.php index 1743c43353..c7474c6ac3 100644 --- a/tests/PhpSpreadsheetTests/Reader/CondNumFmtTest.php +++ b/tests/PhpSpreadsheetTests/Reader/CondNumFmtTest.php @@ -8,7 +8,7 @@ class CondNumFmtTest extends TestCase { - public function testLoadCondNumFmt() + public function testLoadCondNumFmt(): void { $filename = 'tests/data/Reader/XLSX/condfmtnum.xlsx'; $reader = new Xlsx(); diff --git a/tests/PhpSpreadsheetTests/Reader/CsvContiguousFilter.php b/tests/PhpSpreadsheetTests/Reader/CsvContiguousFilter.php index 95f7e78721..9bc16ae0e6 100644 --- a/tests/PhpSpreadsheetTests/Reader/CsvContiguousFilter.php +++ b/tests/PhpSpreadsheetTests/Reader/CsvContiguousFilter.php @@ -19,13 +19,13 @@ class CsvContiguousFilter implements IReadFilter * @param mixed $startRow * @param mixed $chunkSize */ - public function setRows($startRow, $chunkSize) + public function setRows($startRow, $chunkSize): void { $this->startRow = $startRow; $this->endRow = $startRow + $chunkSize; } - public function setFilterType($type) + public function setFilterType($type): void { $this->filterType = $type; } diff --git a/tests/PhpSpreadsheetTests/Reader/CsvContiguousTest.php b/tests/PhpSpreadsheetTests/Reader/CsvContiguousTest.php index 4920c00147..3a41779147 100644 --- a/tests/PhpSpreadsheetTests/Reader/CsvContiguousTest.php +++ b/tests/PhpSpreadsheetTests/Reader/CsvContiguousTest.php @@ -10,7 +10,7 @@ class CsvContiguousTest extends TestCase { private $inputFileName = 'samples/Reader/sampleData/example2.csv'; - public function testContiguous() + public function testContiguous(): void { // Create a new Reader of the type defined in $inputFileType $reader = new Csv(); @@ -54,7 +54,7 @@ public function testContiguous() self::assertEquals(-20.1, $sheet->getCell('C6')->getValue()); } - public function testContiguous2() + public function testContiguous2(): void { // Create a new Reader of the type defined in $inputFileType $reader = new Csv(); diff --git a/tests/PhpSpreadsheetTests/Reader/CsvTest.php b/tests/PhpSpreadsheetTests/Reader/CsvTest.php index 3b6c61b86d..cb2b619672 100644 --- a/tests/PhpSpreadsheetTests/Reader/CsvTest.php +++ b/tests/PhpSpreadsheetTests/Reader/CsvTest.php @@ -16,7 +16,7 @@ class CsvTest extends TestCase * @param string $cell * @param float|int|string $expectedValue */ - public function testDelimiterDetection($filename, $expectedDelimiter, $cell, $expectedValue) + public function testDelimiterDetection($filename, $expectedDelimiter, $cell, $expectedValue): void { $reader = new Csv(); self::assertNull($reader->getDelimiter()); @@ -95,7 +95,7 @@ public function providerDelimiterDetection() * @param bool $expected * @param string $filename */ - public function testCanLoad($expected, $filename) + public function testCanLoad($expected, $filename): void { $reader = new Csv(); self::assertSame($expected, $reader->canRead($filename)); @@ -117,7 +117,7 @@ public function providerCanLoad() ]; } - public function testEscapeCharacters() + public function testEscapeCharacters(): void { $reader = (new Csv())->setEscapeCharacter('"'); $worksheet = $reader->load('tests/data/Reader/CSV/backslash.csv') @@ -128,8 +128,8 @@ public function testEscapeCharacters() ['field 3\\', 'field 4'], ]; - $this->assertSame('"', $reader->getEscapeCharacter()); - $this->assertSame($expected, $worksheet->toArray()); + self::assertSame('"', $reader->getEscapeCharacter()); + self::assertSame($expected, $worksheet->toArray()); } /** @@ -138,7 +138,7 @@ public function testEscapeCharacters() * @param string $filename * @param string $encoding */ - public function testEncodings($filename, $encoding) + public function testEncodings($filename, $encoding): void { $reader = new Csv(); $reader->setInputEncoding($encoding); @@ -147,7 +147,7 @@ public function testEncodings($filename, $encoding) self::assertEquals('Å', $sheet->getCell('A1')->getValue()); } - public function testInvalidWorkSheetInfo() + public function testInvalidWorkSheetInfo(): void { $this->expectException(ReaderException::class); $reader = new Csv(); @@ -160,7 +160,7 @@ public function testInvalidWorkSheetInfo() * @param string $filename * @param string $encoding */ - public function testWorkSheetInfo($filename, $encoding) + public function testWorkSheetInfo($filename, $encoding): void { $reader = new Csv(); $reader->setInputEncoding($encoding); @@ -185,7 +185,7 @@ public function providerEncodings() ]; } - public function testUtf16LineBreak() + public function testUtf16LineBreak(): void { $reader = new Csv(); $reader->setInputEncoding('UTF-16BE'); @@ -200,7 +200,7 @@ public function testUtf16LineBreak() self::assertEquals($expected, $sheet->getCell('B3')->getValue()); } - public function testSeparatorLine() + public function testSeparatorLine(): void { $reader = new Csv(); $reader->setSheetIndex(3); @@ -215,7 +215,7 @@ public function testSeparatorLine() self::assertEquals(3, $sheet->getCell('B2')->getValue()); } - public function testDefaultSettings() + public function testDefaultSettings(): void { $reader = new Csv(); self::assertEquals('UTF-8', $reader->getInputEncoding()); @@ -226,7 +226,7 @@ public function testDefaultSettings() self::assertEquals('"', $reader->getEnclosure()); } - public function testReadEmptyFileName() + public function testReadEmptyFileName(): void { $this->expectException(ReaderException::class); $reader = new Csv(); @@ -234,7 +234,7 @@ public function testReadEmptyFileName() $reader->load($filename); } - public function testReadNonexistentFileName() + public function testReadNonexistentFileName(): void { $this->expectException(ReaderException::class); $reader = new Csv(); diff --git a/tests/PhpSpreadsheetTests/Reader/HtmlTest.php b/tests/PhpSpreadsheetTests/Reader/HtmlTest.php index 14cccb6b84..b0994a3344 100644 --- a/tests/PhpSpreadsheetTests/Reader/HtmlTest.php +++ b/tests/PhpSpreadsheetTests/Reader/HtmlTest.php @@ -11,7 +11,7 @@ class HtmlTest extends TestCase { - public function testCsvWithAngleBracket() + public function testCsvWithAngleBracket(): void { $filename = 'tests/data/Reader/HTML/csv_with_angle_bracket.csv'; $reader = new Html(); @@ -36,7 +36,7 @@ public function providerCanReadVerySmallFile() * @param bool $expected * @param string $content */ - public function testCanReadVerySmallFile($expected, $content) + public function testCanReadVerySmallFile($expected, $content): void { $filename = $this->createHtml($content); $reader = new Html(); @@ -47,7 +47,7 @@ public function testCanReadVerySmallFile($expected, $content) unlink($filename); } - public function testBackgroundColorInRanding() + public function testBackgroundColorInRanding(): void { $html = '
'; - $html .= $this->writeImageInCell($pSheet, $col . $row); - if ($this->includeCharts) { - $html .= $this->writeChartInCell($pSheet, $col . $row); + $htmlx = $this->writeImageInCell($pSheet, $col . $row); + $htmlx .= $this->includeCharts ? $this->writeChartInCell($pSheet, $col . $row) : ''; + if ($htmlx) { + $html .= "$htmlx
@@ -64,7 +64,7 @@ public function testBackgroundColorInRanding() unlink($filename); } - public function testCanApplyInlineBordersStyles() + public function testCanApplyInlineBordersStyles(): void { $html = '
@@ -110,7 +110,7 @@ public function testCanApplyInlineBordersStyles() unlink($filename); } - public function testCanApplyInlineFontStyles() + public function testCanApplyInlineFontStyles(): void { $html = '
@@ -147,7 +147,7 @@ public function testCanApplyInlineFontStyles() unlink($filename); } - public function testCanApplyInlineWidth() + public function testCanApplyInlineWidth(): void { $html = '
@@ -168,7 +168,7 @@ public function testCanApplyInlineWidth() unlink($filename); } - public function testCanApplyInlineHeight() + public function testCanApplyInlineHeight(): void { $html = '
@@ -191,7 +191,7 @@ public function testCanApplyInlineHeight() unlink($filename); } - public function testCanApplyAlignment() + public function testCanApplyAlignment(): void { $html = '
@@ -228,7 +228,7 @@ public function testCanApplyAlignment() unlink($filename); } - public function testCanApplyInlineDataFormat() + public function testCanApplyInlineDataFormat(): void { $html = '
@@ -245,7 +245,7 @@ public function testCanApplyInlineDataFormat() unlink($filename); } - public function testCanInsertImage() + public function testCanInsertImage(): void { $imagePath = realpath(__DIR__ . '/../../data/Reader/HTML/image.jpg'); @@ -266,7 +266,7 @@ public function testCanInsertImage() unlink($filename); } - public function testCanApplyCellWrapping() + public function testCanApplyCellWrapping(): void { $html = '
@@ -289,17 +289,17 @@ public function testCanApplyCellWrapping() $cellStyle = $firstSheet->getStyle('A2'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A2')->getValue(); - $this->assertStringContainsString("\n", $cellValue); + self::assertStringContainsString("\n", $cellValue); $cellStyle = $firstSheet->getStyle('A3'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A3')->getValue(); - $this->assertStringContainsString("\n", $cellValue); + self::assertStringContainsString("\n", $cellValue); unlink($filename); } - public function testCanLoadFromString() + public function testCanLoadFromString(): void { $html = '
@@ -321,15 +321,15 @@ public function testCanLoadFromString() $cellStyle = $firstSheet->getStyle('A2'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A2')->getValue(); - $this->assertStringContainsString("\n", $cellValue); + self::assertStringContainsString("\n", $cellValue); $cellStyle = $firstSheet->getStyle('A3'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A3')->getValue(); - $this->assertStringContainsString("\n", $cellValue); + self::assertStringContainsString("\n", $cellValue); } - public function testCanLoadFromStringIntoExistingSpreadsheet() + public function testCanLoadFromStringIntoExistingSpreadsheet(): void { $html = '
@@ -352,12 +352,12 @@ public function testCanLoadFromStringIntoExistingSpreadsheet() $cellStyle = $firstSheet->getStyle('A2'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A2')->getValue(); - $this->assertStringContainsString("\n", $cellValue); + self::assertStringContainsString("\n", $cellValue); $cellStyle = $firstSheet->getStyle('A3'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A3')->getValue(); - $this->assertStringContainsString("\n", $cellValue); + self::assertStringContainsString("\n", $cellValue); $reader->setSheetIndex(1); $html = '
@@ -394,7 +394,7 @@ private function loadHtmlIntoSpreadsheet($filename) return (new Html())->load($filename); } - public function testRowspanInRendering() + public function testRowspanInRendering(): void { $filename = 'tests/data/Reader/HTML/rowspan.html'; $reader = new Html(); @@ -404,7 +404,7 @@ public function testRowspanInRendering() self::assertSame(['A2:C2' => 'A2:C2'], $actual); } - public function testTextIndentUseRowspan() + public function testTextIndentUseRowspan(): void { $html = '
diff --git a/tests/PhpSpreadsheetTests/Reader/OdsTest.php b/tests/PhpSpreadsheetTests/Reader/OdsTest.php index 82813b7483..6b11149788 100644 --- a/tests/PhpSpreadsheetTests/Reader/OdsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/OdsTest.php @@ -56,7 +56,7 @@ protected function loadDataFile() return $this->spreadsheetData; } - public function testReadFileProperties() + public function testReadFileProperties(): void { $filename = 'tests/data/Reader/Ods/data.ods'; @@ -71,7 +71,7 @@ public function testReadFileProperties() ], $reader->listWorksheetNames($filename)); } - public function testLoadWorksheets() + public function testLoadWorksheets(): void { $spreadsheet = $this->loadDataFile(); @@ -86,7 +86,7 @@ public function testLoadWorksheets() self::assertInstanceOf('PhpOffice\PhpSpreadsheet\Worksheet\Worksheet', $secondSheet); } - public function testReadValueAndComments() + public function testReadValueAndComments(): void { $spreadsheet = $this->loadOdsTestFile(); @@ -151,7 +151,7 @@ public function testReadValueAndComments() self::assertEquals(20, $firstSheet->getCell('A5')->getValue()); } - public function testReadColors() + public function testReadColors(): void { $spreadsheet = $this->loadOdsTestFile(); $firstSheet = $spreadsheet->getSheet(0); @@ -165,7 +165,7 @@ public function testReadColors() self::assertEquals('FF000000', $style->getFill()->getEndColor()->getARGB()); } - public function testReadRichText() + public function testReadRichText(): void { $spreadsheet = $this->loadOdsTestFile(); $firstSheet = $spreadsheet->getSheet(0); @@ -177,7 +177,7 @@ public function testReadRichText() ); } - public function testReadCellsWithRepeatedSpaces() + public function testReadCellsWithRepeatedSpaces(): void { $spreadsheet = $this->loadDataFile(); $firstSheet = $spreadsheet->getSheet(0); @@ -188,7 +188,7 @@ public function testReadCellsWithRepeatedSpaces() self::assertEquals("test with new \nLines", $firstSheet->getCell('A11')->getValue()); } - public function testReadHyperlinks() + public function testReadHyperlinks(): void { $spreadsheet = $this->loadOdsTestFile(); $firstSheet = $spreadsheet->getSheet(0); @@ -202,9 +202,9 @@ public function testReadHyperlinks() // Below some test for features not implemented yet - public function testReadBoldItalicUnderline() + public function testReadBoldItalicUnderline(): void { - $this->markTestIncomplete('Features not implemented yet'); + self::markTestIncomplete('Features not implemented yet'); $spreadsheet = $this->loadOdsTestFile(); $firstSheet = $spreadsheet->getSheet(0); @@ -224,7 +224,7 @@ public function testReadBoldItalicUnderline() self::assertTrue($style->getFont()->getItalic()); } - public function testLoadOdsWorkbookProperties() + public function testLoadOdsWorkbookProperties(): void { $customPropertySet = [ 'Owner' => ['type' => Properties::PROPERTY_TYPE_STRING, 'value' => 'PHPOffice'], diff --git a/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php b/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php index 4bf4642950..8f42af10cb 100644 --- a/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Reader\Xls; use PhpOffice\PhpSpreadsheet\Reader\Xlsx; use PHPUnit\Framework\TestCase; +use XMLReader; class XmlScannerTest extends TestCase { @@ -21,7 +22,7 @@ protected function setUp(): void * @param mixed $expectedResult * @param $libxmlDisableEntityLoader */ - public function testValidXML($filename, $expectedResult, $libxmlDisableEntityLoader) + public function testValidXML($filename, $expectedResult, $libxmlDisableEntityLoader): void { $oldDisableEntityLoaderState = libxml_disable_entity_loader($libxmlDisableEntityLoader); @@ -51,7 +52,7 @@ public function providerValidXML() * @param mixed $filename * @param $libxmlDisableEntityLoader */ - public function testInvalidXML($filename, $libxmlDisableEntityLoader) + public function testInvalidXML($filename, $libxmlDisableEntityLoader): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Reader\Exception::class); @@ -76,7 +77,7 @@ public function providerInvalidXML() return $tests; } - public function testGetSecurityScannerForXmlBasedReader() + public function testGetSecurityScannerForXmlBasedReader(): void { $fileReader = new Xlsx(); $scanner = $fileReader->getSecurityScanner(); @@ -84,15 +85,15 @@ public function testGetSecurityScannerForXmlBasedReader() // Must return an object... self::assertIsObject($scanner); // ... of the correct type - $this->assertInstanceOf(XmlScanner::class, $scanner); + self::assertInstanceOf(XmlScanner::class, $scanner); } - public function testGetSecurityScannerForNonXmlBasedReader() + public function testGetSecurityScannerForNonXmlBasedReader(): void { $fileReader = new Xls(); $scanner = $fileReader->getSecurityScanner(); // Must return a null... - $this->assertNull($scanner); + self::assertNull($scanner); } /** @@ -101,14 +102,14 @@ public function testGetSecurityScannerForNonXmlBasedReader() * @param mixed $filename * @param mixed $expectedResult */ - public function testSecurityScanWithCallback($filename, $expectedResult) + public function testSecurityScanWithCallback($filename, $expectedResult): void { $fileReader = new Xlsx(); $scanner = $fileReader->getSecurityScanner(); $scanner->setAdditionalCallback('strrev'); $xml = $scanner->scanFile($filename); - $this->assertEquals(strrev($expectedResult), $xml); + self::assertEquals(strrev($expectedResult), $xml); } public function providerValidXMLForCallback() @@ -121,20 +122,20 @@ public function providerValidXMLForCallback() return $tests; } - public function testLibxmlDisableEntityLoaderIsRestoredWithoutShutdown() + public function testLibxmlDisableEntityLoaderIsRestoredWithoutShutdown(): void { $reader = new Xlsx(); unset($reader); - $reader = new \XMLReader(); + $reader = new XMLReader(); $opened = $reader->open('tests/data/Reader/Xml/SecurityScannerWithCallbackExample.xml'); - $this->assertTrue($opened); + self::assertTrue($opened); } - public function testEncodingAllowsMixedCase() + public function testEncodingAllowsMixedCase(): void { $scanner = new XmlScanner(); $output = $scanner->scan($input = 'bar'); - $this->assertSame($input, $output); + self::assertSame($input, $output); } } diff --git a/tests/PhpSpreadsheetTests/Reader/XlsTest.php b/tests/PhpSpreadsheetTests/Reader/XlsTest.php index dd6344b4c9..77ad91fab2 100644 --- a/tests/PhpSpreadsheetTests/Reader/XlsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XlsTest.php @@ -10,7 +10,7 @@ class XlsTest extends TestCase /** * Test load Xls file. */ - public function testLoadXlsSample() + public function testLoadXlsSample(): void { $filename = 'tests/data/Reader/XLS/sample.xls'; $reader = new Xls(); diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/AutoFilterTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/AutoFilterTest.php index 90ea17aa0d..63da2d05bc 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/AutoFilterTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/AutoFilterTest.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter as WorksheetAutoFilter; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PHPUnit\Framework\TestCase; +use SimpleXMLElement; class AutoFilterTest extends TestCase { @@ -18,7 +19,7 @@ private function getWorksheetInstance() private function getXMLInstance($ref) { - return new \SimpleXMLElement( + return new SimpleXMLElement( '' . '' . '' . @@ -50,15 +51,15 @@ public function loadDataProvider() * @param int $expectedReadAutoFilterCalled * @param string $expectedRef */ - public function testLoad($ref, $expectedReadAutoFilterCalled, $expectedRef) + public function testLoad($ref, $expectedReadAutoFilterCalled, $expectedRef): void { $worksheetAutoFilter = $this->getAutoFilterInstance(); - $worksheetAutoFilter->expects($this->exactly($expectedReadAutoFilterCalled ? 1 : 0)) + $worksheetAutoFilter->expects(self::exactly($expectedReadAutoFilterCalled ? 1 : 0)) ->method('setRange') ->with($expectedRef); $worksheet = $this->getWorksheetInstance(); - $worksheet->expects($this->exactly($expectedReadAutoFilterCalled ? 1 : 0)) + $worksheet->expects(self::exactly($expectedReadAutoFilterCalled ? 1 : 0)) ->method('getAutoFilter') ->willReturn($worksheetAutoFilter); diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php index b77796c61b..4d0b6a8a1f 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php @@ -19,7 +19,7 @@ protected function tearDown(): void } } - public function testLoadXlsxConditionalFormatting2() + public function testLoadXlsxConditionalFormatting2(): void { // Make sure Conditionals are read correctly from existing file $filename = 'tests/data/Reader/XLSX/conditionalFormatting2Test.xlsx'; @@ -53,7 +53,7 @@ public function testLoadXlsxConditionalFormatting2() self::assertEquals('5', $conditions[0]); } - public function testReloadXlsxConditionalFormatting2() + public function testReloadXlsxConditionalFormatting2(): void { // Make sure conditionals from existing file are maintained across save $filename = 'tests/data/Reader/XLSX/conditionalFormatting2Test.xlsx'; @@ -91,7 +91,7 @@ public function testReloadXlsxConditionalFormatting2() self::assertEquals('5', $conditions[0]); } - public function testNewXlsxConditionalFormatting2() + public function testNewXlsxConditionalFormatting2(): void { // Make sure blanks/non-blanks added by PhpSpreadsheet are handled correctly $outfile = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); diff --git a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php index efa7af72b5..9e0b5f662a 100644 --- a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php @@ -14,7 +14,7 @@ class XlsxTest extends TestCase { - public function testLoadXlsxWorkbookProperties() + public function testLoadXlsxWorkbookProperties(): void { $customPropertySet = [ 'Publisher' => ['type' => Properties::PROPERTY_TYPE_STRING, 'value' => 'PHPOffice Suite'], @@ -30,32 +30,32 @@ public function testLoadXlsxWorkbookProperties() $properties = $spreadsheet->getProperties(); // Core Properties - $this->assertSame('Mark Baker', $properties->getCreator()); - $this->assertSame('Unit Testing', $properties->getTitle()); - $this->assertSame('Property Test', $properties->getSubject()); + self::assertSame('Mark Baker', $properties->getCreator()); + self::assertSame('Unit Testing', $properties->getTitle()); + self::assertSame('Property Test', $properties->getSubject()); // Extended Properties - $this->assertSame('PHPOffice', $properties->getCompany()); - $this->assertSame('The Big Boss', $properties->getManager()); + self::assertSame('PHPOffice', $properties->getCompany()); + self::assertSame('The Big Boss', $properties->getManager()); // Custom Properties $customProperties = $properties->getCustomProperties(); self::assertIsArray($customProperties); $customProperties = array_flip($customProperties); - $this->assertArrayHasKey('Publisher', $customProperties); + self::assertArrayHasKey('Publisher', $customProperties); foreach ($customPropertySet as $propertyName => $testData) { - $this->assertTrue($properties->isCustomPropertySet($propertyName)); - $this->assertSame($testData['type'], $properties->getCustomPropertyType($propertyName)); + self::assertTrue($properties->isCustomPropertySet($propertyName)); + self::assertSame($testData['type'], $properties->getCustomPropertyType($propertyName)); if ($properties->getCustomPropertyType($propertyName) == Properties::PROPERTY_TYPE_DATE) { - $this->assertSame($testData['value'], date('Y-m-d', $properties->getCustomPropertyValue($propertyName))); + self::assertSame($testData['value'], date('Y-m-d', $properties->getCustomPropertyValue($propertyName))); } else { - $this->assertSame($testData['value'], $properties->getCustomPropertyValue($propertyName)); + self::assertSame($testData['value'], $properties->getCustomPropertyValue($propertyName)); } } } - public function testLoadXlsxRowColumnAttributes() + public function testLoadXlsxRowColumnAttributes(): void { $filename = 'tests/data/Reader/XLSX/rowColumnAttributeTest.xlsx'; $reader = new Xlsx(); @@ -63,23 +63,23 @@ public function testLoadXlsxRowColumnAttributes() $worksheet = $spreadsheet->getActiveSheet(); for ($row = 1; $row <= 4; ++$row) { - $this->assertEquals($row * 5 + 10, floor($worksheet->getRowDimension($row)->getRowHeight())); + self::assertEquals($row * 5 + 10, floor($worksheet->getRowDimension($row)->getRowHeight())); } - $this->assertFalse($worksheet->getRowDimension(5)->getVisible()); + self::assertFalse($worksheet->getRowDimension(5)->getVisible()); for ($column = 1; $column <= 4; ++$column) { $columnAddress = Coordinate::stringFromColumnIndex($column); - $this->assertEquals( + self::assertEquals( $column * 2 + 2, floor($worksheet->getColumnDimension($columnAddress)->getWidth()) ); } - $this->assertFalse($worksheet->getColumnDimension('E')->getVisible()); + self::assertFalse($worksheet->getColumnDimension('E')->getVisible()); } - public function testLoadXlsxWithStyles() + public function testLoadXlsxWithStyles(): void { $expectedColours = [ 1 => ['A' => 'C00000', 'C' => 'FF0000', 'E' => 'FFC000'], @@ -95,7 +95,7 @@ public function testLoadXlsxWithStyles() $worksheet = $spreadsheet->getActiveSheet(); for ($row = 1; $row <= 8; $row += 2) { for ($column = 'A'; $column !== 'G'; ++$column, ++$column) { - $this->assertEquals( + self::assertEquals( $expectedColours[$row][$column], $worksheet->getStyle($column . $row)->getFill()->getStartColor()->getRGB() ); @@ -103,7 +103,7 @@ public function testLoadXlsxWithStyles() } } - public function testLoadXlsxAutofilter() + public function testLoadXlsxAutofilter(): void { $filename = 'tests/data/Reader/XLSX/autofilterTest.xlsx'; $reader = new Xlsx(); @@ -112,15 +112,15 @@ public function testLoadXlsxAutofilter() $worksheet = $spreadsheet->getActiveSheet(); $autofilter = $worksheet->getAutoFilter(); - $this->assertInstanceOf(AutoFilter::class, $autofilter); - $this->assertEquals('A1:D57', $autofilter->getRange()); - $this->assertEquals( + self::assertInstanceOf(AutoFilter::class, $autofilter); + self::assertEquals('A1:D57', $autofilter->getRange()); + self::assertEquals( AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER, $autofilter->getColumn('A')->getFilterType() ); } - public function testLoadXlsxPageSetup() + public function testLoadXlsxPageSetup(): void { $filename = 'tests/data/Reader/XLSX/pageSetupTest.xlsx'; $reader = new Xlsx(); @@ -130,16 +130,16 @@ public function testLoadXlsxPageSetup() $pageMargins = $worksheet->getPageMargins(); // Convert from inches to cm for testing - $this->assertEquals(2.5, $pageMargins->getTop() * 2.54); - $this->assertEquals(3.3, $pageMargins->getLeft() * 2.54); - $this->assertEquals(3.3, $pageMargins->getRight() * 2.54); - $this->assertEquals(1.3, $pageMargins->getHeader() * 2.54); + self::assertEquals(2.5, $pageMargins->getTop() * 2.54); + self::assertEquals(3.3, $pageMargins->getLeft() * 2.54); + self::assertEquals(3.3, $pageMargins->getRight() * 2.54); + self::assertEquals(1.3, $pageMargins->getHeader() * 2.54); - $this->assertEquals(PageSetup::PAPERSIZE_A4, $worksheet->getPageSetup()->getPaperSize()); - $this->assertEquals(['A10', 'A20', 'A30', 'A40', 'A50'], array_keys($worksheet->getBreaks())); + self::assertEquals(PageSetup::PAPERSIZE_A4, $worksheet->getPageSetup()->getPaperSize()); + self::assertEquals(['A10', 'A20', 'A30', 'A40', 'A50'], array_keys($worksheet->getBreaks())); } - public function testLoadXlsxConditionalFormatting() + public function testLoadXlsxConditionalFormatting(): void { $filename = 'tests/data/Reader/XLSX/conditionalFormattingTest.xlsx'; $reader = new Xlsx(); @@ -149,16 +149,16 @@ public function testLoadXlsxConditionalFormatting() $conditionalStyle = $worksheet->getCell('B2')->getStyle()->getConditionalStyles(); - $this->assertNotEmpty($conditionalStyle); + self::assertNotEmpty($conditionalStyle); $conditionalRule = $conditionalStyle[0]; - $this->assertNotEmpty($conditionalRule->getConditions()); - $this->assertEquals(Conditional::CONDITION_CELLIS, $conditionalRule->getConditionType()); - $this->assertEquals(Conditional::OPERATOR_BETWEEN, $conditionalRule->getOperatorType()); - $this->assertEquals(['200', '400'], $conditionalRule->getConditions()); - $this->assertInstanceOf(Style::class, $conditionalRule->getStyle()); + self::assertNotEmpty($conditionalRule->getConditions()); + self::assertEquals(Conditional::CONDITION_CELLIS, $conditionalRule->getConditionType()); + self::assertEquals(Conditional::OPERATOR_BETWEEN, $conditionalRule->getOperatorType()); + self::assertEquals(['200', '400'], $conditionalRule->getConditions()); + self::assertInstanceOf(Style::class, $conditionalRule->getStyle()); } - public function testLoadXlsxDataValidation() + public function testLoadXlsxDataValidation(): void { $filename = 'tests/data/Reader/XLSX/dataValidationTest.xlsx'; $reader = new Xlsx(); @@ -166,7 +166,7 @@ public function testLoadXlsxDataValidation() $worksheet = $spreadsheet->getActiveSheet(); - $this->assertTrue($worksheet->getCell('B3')->hasDataValidation()); + self::assertTrue($worksheet->getCell('B3')->hasDataValidation()); } /** @@ -174,7 +174,7 @@ public function testLoadXlsxDataValidation() * * @doesNotPerformAssertions */ - public function testLoadXlsxWithoutCellReference() + public function testLoadXlsxWithoutCellReference(): void { $filename = 'tests/data/Reader/XLSX/without_cell_reference.xlsx'; $reader = new Xlsx(); @@ -184,7 +184,7 @@ public function testLoadXlsxWithoutCellReference() /** * Test load Xlsx file and use a read filter. */ - public function testLoadWithReadFilter() + public function testLoadWithReadFilter(): void { $filename = 'tests/data/Reader/XLSX/without_cell_reference.xlsx'; $reader = new Xlsx(); @@ -193,7 +193,7 @@ public function testLoadWithReadFilter() $ref = [1.0, null, 3.0, null, 5.0, null, 7.0, null, 9.0, null]; for ($i = 0; $i < 10; ++$i) { - $this->assertEquals($ref, \array_slice($data[$i], 0, 10, true)); + self::assertEquals($ref, \array_slice($data[$i], 0, 10, true)); } } @@ -202,7 +202,7 @@ public function testLoadWithReadFilter() * * @doesNotPerformAssertions */ - public function testLoadXlsxWithDoubleAttrDrawing() + public function testLoadXlsxWithDoubleAttrDrawing(): void { $filename = 'tests/data/Reader/XLSX/double_attr_drawing.xlsx'; $reader = new Xlsx(); @@ -213,7 +213,7 @@ public function testLoadXlsxWithDoubleAttrDrawing() * Test correct save and load xlsx files with empty drawings. * Such files can be generated by Google Sheets. */ - public function testLoadSaveWithEmptyDrawings() + public function testLoadSaveWithEmptyDrawings(): void { $filename = 'tests/data/Reader/XLSX/empty_drawing.xlsx'; $reader = new Xlsx(); @@ -223,7 +223,7 @@ public function testLoadSaveWithEmptyDrawings() $writer->save($resultFilename); $excel = $reader->load($resultFilename); // Fake assert. The only thing we need is to ensure the file is loaded without exception - $this->assertNotNull($excel); + self::assertNotNull($excel); } /** @@ -233,10 +233,10 @@ public function testLoadSaveWithEmptyDrawings() * @param $string * @dataProvider providerStripsWhiteSpaceFromStyleString */ - public function testStripsWhiteSpaceFromStyleString($string) + public function testStripsWhiteSpaceFromStyleString($string): void { $string = Xlsx::stripWhiteSpaceFromStyleString($string); - $this->assertEquals(preg_match('/\s/', $string), 0); + self::assertEquals(preg_match('/\s/', $string), 0); } public function providerStripsWhiteSpaceFromStyleString() diff --git a/tests/PhpSpreadsheetTests/Reader/XmlTest.php b/tests/PhpSpreadsheetTests/Reader/XmlTest.php index 116ec03e8d..a8de877491 100644 --- a/tests/PhpSpreadsheetTests/Reader/XmlTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XmlTest.php @@ -13,7 +13,7 @@ class XmlTest extends TestCase * * @param $filename */ - public function testInvalidSimpleXML($filename) + public function testInvalidSimpleXML($filename): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Reader\Exception::class); @@ -34,7 +34,7 @@ public function providerInvalidSimpleXML() /** * Check if it can read XML Hyperlink correctly. */ - public function testReadHyperlinks() + public function testReadHyperlinks(): void { $reader = new Xml(); $spreadsheet = $reader->load('samples/templates/Excel2003XMLTest.xml'); @@ -47,7 +47,7 @@ public function testReadHyperlinks() self::assertEquals('https://phpspreadsheet.readthedocs.io', $hyperlink->getHyperlink()->getUrl()); } - public function testReadWithoutStyle() + public function testReadWithoutStyle(): void { $reader = new Xml(); $spreadsheet = $reader->load('tests/data/Reader/Xml/WithoutStyle.xml'); diff --git a/tests/PhpSpreadsheetTests/ReferenceHelperTest.php b/tests/PhpSpreadsheetTests/ReferenceHelperTest.php index 6de3d79209..374b63c960 100644 --- a/tests/PhpSpreadsheetTests/ReferenceHelperTest.php +++ b/tests/PhpSpreadsheetTests/ReferenceHelperTest.php @@ -11,7 +11,7 @@ protected function setUp(): void { } - public function testColumnSort() + public function testColumnSort(): void { $columnBase = $columnExpectedResult = [ 'A', 'B', 'Z', @@ -32,7 +32,7 @@ public function testColumnSort() } } - public function testColumnReverseSort() + public function testColumnReverseSort(): void { $columnBase = $columnExpectedResult = [ 'A', 'B', 'Z', @@ -54,7 +54,7 @@ public function testColumnReverseSort() } } - public function testCellSort() + public function testCellSort(): void { $cellBase = $columnExpectedResult = [ 'A1', 'B1', 'AZB1', @@ -75,7 +75,7 @@ public function testCellSort() } } - public function testCellReverseSort() + public function testCellReverseSort(): void { $cellBase = $columnExpectedResult = [ 'BBA544', 'ABB289', 'ABA121', diff --git a/tests/PhpSpreadsheetTests/SettingsTest.php b/tests/PhpSpreadsheetTests/SettingsTest.php index 1a1d24e76b..4dff2d2594 100644 --- a/tests/PhpSpreadsheetTests/SettingsTest.php +++ b/tests/PhpSpreadsheetTests/SettingsTest.php @@ -23,14 +23,14 @@ protected function tearDown(): void libxml_disable_entity_loader($this->prevValue); } - public function testGetXMLSettings() + public function testGetXMLSettings(): void { $result = Settings::getLibXmlLoaderOptions(); self::assertTrue((bool) ((LIBXML_DTDLOAD | LIBXML_DTDATTR) & $result)); self::assertFalse(libxml_disable_entity_loader()); } - public function testSetXMLSettings() + public function testSetXMLSettings(): void { Settings::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID); $result = Settings::getLibXmlLoaderOptions(); diff --git a/tests/PhpSpreadsheetTests/Shared/CodePageTest.php b/tests/PhpSpreadsheetTests/Shared/CodePageTest.php index e3638687c4..b86f9015d6 100644 --- a/tests/PhpSpreadsheetTests/Shared/CodePageTest.php +++ b/tests/PhpSpreadsheetTests/Shared/CodePageTest.php @@ -13,7 +13,7 @@ class CodePageTest extends TestCase * * @param mixed $expectedResult */ - public function testCodePageNumberToName($expectedResult, ...$args) + public function testCodePageNumberToName($expectedResult, ...$args): void { $result = CodePage::numberToName(...$args); self::assertEquals($expectedResult, $result); @@ -24,7 +24,7 @@ public function providerCodePage() return require 'tests/data/Shared/CodePage.php'; } - public function testNumberToNameWithInvalidCodePage() + public function testNumberToNameWithInvalidCodePage(): void { $invalidCodePage = 12345; @@ -35,10 +35,10 @@ public function testNumberToNameWithInvalidCodePage() return; } - $this->fail('An expected exception has not been raised.'); + self::fail('An expected exception has not been raised.'); } - public function testNumberToNameWithUnsupportedCodePage() + public function testNumberToNameWithUnsupportedCodePage(): void { $unsupportedCodePage = 720; @@ -49,6 +49,6 @@ public function testNumberToNameWithUnsupportedCodePage() return; } - $this->fail('An expected exception has not been raised.'); + self::fail('An expected exception has not been raised.'); } } diff --git a/tests/PhpSpreadsheetTests/Shared/DateTest.php b/tests/PhpSpreadsheetTests/Shared/DateTest.php index 14930677cb..23b310760d 100644 --- a/tests/PhpSpreadsheetTests/Shared/DateTest.php +++ b/tests/PhpSpreadsheetTests/Shared/DateTest.php @@ -7,7 +7,7 @@ class DateTest extends TestCase { - public function testSetExcelCalendar() + public function testSetExcelCalendar(): void { $calendarValues = [ Date::CALENDAR_MAC_1904, @@ -20,7 +20,7 @@ public function testSetExcelCalendar() } } - public function testSetExcelCalendarWithInvalidValue() + public function testSetExcelCalendarWithInvalidValue(): void { $unsupportedCalendar = '2012'; $result = Date::setExcelCalendar($unsupportedCalendar); @@ -32,7 +32,7 @@ public function testSetExcelCalendarWithInvalidValue() * * @param mixed $expectedResult */ - public function testDateTimeExcelToTimestamp1900($expectedResult, ...$args) + public function testDateTimeExcelToTimestamp1900($expectedResult, ...$args): void { Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); @@ -50,7 +50,7 @@ public function providerDateTimeExcelToTimestamp1900() * * @param mixed $expectedResult */ - public function testDateTimeTimestampToExcel1900($expectedResult, ...$args) + public function testDateTimeTimestampToExcel1900($expectedResult, ...$args): void { Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); @@ -68,7 +68,7 @@ public function providerDateTimeTimestampToExcel1900() * * @param mixed $expectedResult */ - public function testDateTimeDateTimeToExcel($expectedResult, ...$args) + public function testDateTimeDateTimeToExcel($expectedResult, ...$args): void { Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); @@ -86,7 +86,7 @@ public function providerDateTimeDateTimeToExcel() * * @param mixed $expectedResult */ - public function testDateTimeFormattedPHPToExcel1900($expectedResult, ...$args) + public function testDateTimeFormattedPHPToExcel1900($expectedResult, ...$args): void { Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); @@ -104,7 +104,7 @@ public function providerDateTimeFormattedPHPToExcel1900() * * @param mixed $expectedResult */ - public function testDateTimeExcelToTimestamp1904($expectedResult, ...$args) + public function testDateTimeExcelToTimestamp1904($expectedResult, ...$args): void { Date::setExcelCalendar(Date::CALENDAR_MAC_1904); @@ -122,7 +122,7 @@ public function providerDateTimeExcelToTimestamp1904() * * @param mixed $expectedResult */ - public function testDateTimeTimestampToExcel1904($expectedResult, ...$args) + public function testDateTimeTimestampToExcel1904($expectedResult, ...$args): void { Date::setExcelCalendar(Date::CALENDAR_MAC_1904); @@ -140,7 +140,7 @@ public function providerDateTimeTimestampToExcel1904() * * @param mixed $expectedResult */ - public function testIsDateTimeFormatCode($expectedResult, ...$args) + public function testIsDateTimeFormatCode($expectedResult, ...$args): void { $result = Date::isDateTimeFormatCode(...$args); self::assertEquals($expectedResult, $result); @@ -156,7 +156,7 @@ public function providerIsDateTimeFormatCode() * * @param mixed $expectedResult */ - public function testDateTimeExcelToTimestamp1900Timezone($expectedResult, ...$args) + public function testDateTimeExcelToTimestamp1900Timezone($expectedResult, ...$args): void { Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); diff --git a/tests/PhpSpreadsheetTests/Shared/FileTest.php b/tests/PhpSpreadsheetTests/Shared/FileTest.php index 91c68bfc7b..6b9500f6fe 100644 --- a/tests/PhpSpreadsheetTests/Shared/FileTest.php +++ b/tests/PhpSpreadsheetTests/Shared/FileTest.php @@ -7,7 +7,7 @@ class FileTest extends TestCase { - public function testGetUseUploadTempDirectory() + public function testGetUseUploadTempDirectory(): void { $expectedResult = false; @@ -15,7 +15,7 @@ public function testGetUseUploadTempDirectory() self::assertEquals($expectedResult, $result); } - public function testSetUseUploadTempDirectory() + public function testSetUseUploadTempDirectory(): void { $useUploadTempDirectoryValues = [ true, diff --git a/tests/PhpSpreadsheetTests/Shared/FontTest.php b/tests/PhpSpreadsheetTests/Shared/FontTest.php index 03ff2c4ec3..5eb7085270 100644 --- a/tests/PhpSpreadsheetTests/Shared/FontTest.php +++ b/tests/PhpSpreadsheetTests/Shared/FontTest.php @@ -7,7 +7,7 @@ class FontTest extends TestCase { - public function testGetAutoSizeMethod() + public function testGetAutoSizeMethod(): void { $expectedResult = Font::AUTOSIZE_METHOD_APPROX; @@ -15,7 +15,7 @@ public function testGetAutoSizeMethod() self::assertEquals($expectedResult, $result); } - public function testSetAutoSizeMethod() + public function testSetAutoSizeMethod(): void { $autosizeMethodValues = [ Font::AUTOSIZE_METHOD_EXACT, @@ -28,7 +28,7 @@ public function testSetAutoSizeMethod() } } - public function testSetAutoSizeMethodWithInvalidValue() + public function testSetAutoSizeMethodWithInvalidValue(): void { $unsupportedAutosizeMethod = 'guess'; @@ -41,7 +41,7 @@ public function testSetAutoSizeMethodWithInvalidValue() * * @param mixed $expectedResult */ - public function testFontSizeToPixels($expectedResult, ...$args) + public function testFontSizeToPixels($expectedResult, ...$args): void { $result = Font::fontSizeToPixels(...$args); self::assertEquals($expectedResult, $result); @@ -57,7 +57,7 @@ public function providerFontSizeToPixels() * * @param mixed $expectedResult */ - public function testInchSizeToPixels($expectedResult, ...$args) + public function testInchSizeToPixels($expectedResult, ...$args): void { $result = Font::inchSizeToPixels(...$args); self::assertEquals($expectedResult, $result); @@ -73,7 +73,7 @@ public function providerInchSizeToPixels() * * @param mixed $expectedResult */ - public function testCentimeterSizeToPixels($expectedResult, ...$args) + public function testCentimeterSizeToPixels($expectedResult, ...$args): void { $result = Font::centimeterSizeToPixels(...$args); self::assertEquals($expectedResult, $result); diff --git a/tests/PhpSpreadsheetTests/Shared/OLEReadTest.php b/tests/PhpSpreadsheetTests/Shared/OLEReadTest.php index 6135232c1a..7fe485c9cc 100644 --- a/tests/PhpSpreadsheetTests/Shared/OLEReadTest.php +++ b/tests/PhpSpreadsheetTests/Shared/OLEReadTest.php @@ -7,7 +7,7 @@ class OLEReadTest extends TestCase { - public function testReadOleStreams() + public function testReadOleStreams(): void { $dataDir = 'tests/data/Shared/OLERead/'; $ole = new OLERead(); diff --git a/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php b/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php index e92e0886c2..0d2867254a 100644 --- a/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php +++ b/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php @@ -12,7 +12,7 @@ class PasswordHasherTest extends TestCase * * @param mixed $expectedResult */ - public function testHashPassword($expectedResult, ...$args) + public function testHashPassword($expectedResult, ...$args): void { $result = PasswordHasher::hashPassword(...$args); self::assertEquals($expectedResult, $result); diff --git a/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php b/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php index fd1ec153d9..b11bf76487 100644 --- a/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php +++ b/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php @@ -15,13 +15,13 @@ protected function setUp(): void StringHelper::setCurrencyCode(null); } - public function testGetIsIconvEnabled() + public function testGetIsIconvEnabled(): void { $result = StringHelper::getIsIconvEnabled(); self::assertTrue($result); } - public function testGetDecimalSeparator() + public function testGetDecimalSeparator(): void { $localeconv = localeconv(); @@ -30,7 +30,7 @@ public function testGetDecimalSeparator() self::assertEquals($expectedResult, $result); } - public function testSetDecimalSeparator() + public function testSetDecimalSeparator(): void { $expectedResult = ','; StringHelper::setDecimalSeparator($expectedResult); @@ -39,7 +39,7 @@ public function testSetDecimalSeparator() self::assertEquals($expectedResult, $result); } - public function testGetThousandsSeparator() + public function testGetThousandsSeparator(): void { $localeconv = localeconv(); @@ -48,7 +48,7 @@ public function testGetThousandsSeparator() self::assertEquals($expectedResult, $result); } - public function testSetThousandsSeparator() + public function testSetThousandsSeparator(): void { $expectedResult = ' '; StringHelper::setThousandsSeparator($expectedResult); @@ -57,7 +57,7 @@ public function testSetThousandsSeparator() self::assertEquals($expectedResult, $result); } - public function testGetCurrencyCode() + public function testGetCurrencyCode(): void { $localeconv = localeconv(); $expectedResult = (!empty($localeconv['currency_symbol']) ? $localeconv['currency_symbol'] : (!empty($localeconv['int_curr_symbol']) ? $localeconv['int_curr_symbol'] : '$')); @@ -65,7 +65,7 @@ public function testGetCurrencyCode() self::assertEquals($expectedResult, $result); } - public function testSetCurrencyCode() + public function testSetCurrencyCode(): void { $expectedResult = '£'; StringHelper::setCurrencyCode($expectedResult); @@ -74,7 +74,7 @@ public function testSetCurrencyCode() self::assertEquals($expectedResult, $result); } - public function testControlCharacterPHP2OOXML() + public function testControlCharacterPHP2OOXML(): void { $expectedResult = 'foo_x000B_bar'; $result = StringHelper::controlCharacterPHP2OOXML('foo' . chr(11) . 'bar'); @@ -82,7 +82,7 @@ public function testControlCharacterPHP2OOXML() self::assertEquals($expectedResult, $result); } - public function testControlCharacterOOXML2PHP() + public function testControlCharacterOOXML2PHP(): void { $expectedResult = 'foo' . chr(11) . 'bar'; $result = StringHelper::controlCharacterOOXML2PHP('foo_x000B_bar'); @@ -90,7 +90,7 @@ public function testControlCharacterOOXML2PHP() self::assertEquals($expectedResult, $result); } - public function testSYLKtoUTF8() + public function testSYLKtoUTF8(): void { $expectedResult = 'foo' . chr(11) . 'bar'; $result = StringHelper::SYLKtoUTF8("foo\x1B ;bar"); diff --git a/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php b/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php index def37fa855..f6e2f5d511 100644 --- a/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php +++ b/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php @@ -7,7 +7,7 @@ class TimeZoneTest extends TestCase { - public function testSetTimezone() + public function testSetTimezone(): void { $timezoneValues = [ 'Europe/Prague', @@ -23,7 +23,7 @@ public function testSetTimezone() } } - public function testSetTimezoneWithInvalidValue() + public function testSetTimezoneWithInvalidValue(): void { $unsupportedTimezone = 'Etc/GMT+10'; $result = TimeZone::setTimezone($unsupportedTimezone); diff --git a/tests/PhpSpreadsheetTests/SpreadsheetTest.php b/tests/PhpSpreadsheetTests/SpreadsheetTest.php index 498ce27b94..05fbe1b549 100644 --- a/tests/PhpSpreadsheetTests/SpreadsheetTest.php +++ b/tests/PhpSpreadsheetTests/SpreadsheetTest.php @@ -49,8 +49,8 @@ public function dataProviderForSheetNames() * * @dataProvider dataProviderForSheetNames */ - public function testGetSheetByName($index, $sheetName) + public function testGetSheetByName($index, $sheetName): void { - $this->assertEquals($this->object->getSheet($index), $this->object->getSheetByName($sheetName)); + self::assertEquals($this->object->getSheet($index), $this->object->getSheetByName($sheetName)); } } diff --git a/tests/PhpSpreadsheetTests/Style/BorderRangeTest.php b/tests/PhpSpreadsheetTests/Style/BorderRangeTest.php index 115e830d12..aec5520d93 100644 --- a/tests/PhpSpreadsheetTests/Style/BorderRangeTest.php +++ b/tests/PhpSpreadsheetTests/Style/BorderRangeTest.php @@ -9,7 +9,7 @@ class BorderRangeTest extends TestCase { - public function testBorderRangeInAction() + public function testBorderRangeInAction(): void { // testcase for the initial bug problem: setting border+color fails // set red borders aroundlA1:B3 square. Verify that the borders set are actually correct @@ -62,7 +62,7 @@ public function testBorderRangeInAction() } } - public function testBorderRangeDirectly() + public function testBorderRangeDirectly(): void { // testcase for the underlying problem directly $spreadsheet = new Spreadsheet(); diff --git a/tests/PhpSpreadsheetTests/Style/BorderTest.php b/tests/PhpSpreadsheetTests/Style/BorderTest.php index 7efe935a6b..f1f1bf562a 100644 --- a/tests/PhpSpreadsheetTests/Style/BorderTest.php +++ b/tests/PhpSpreadsheetTests/Style/BorderTest.php @@ -8,7 +8,7 @@ class BorderTest extends TestCase { - public function testCase() + public function testCase(): void { $spreadsheet = new Spreadsheet(); $borders = $spreadsheet->getActiveSheet()->getStyle('A1')->getBorders(); diff --git a/tests/PhpSpreadsheetTests/Style/ColorTest.php b/tests/PhpSpreadsheetTests/Style/ColorTest.php index 5bd2f20865..9b524e9335 100644 --- a/tests/PhpSpreadsheetTests/Style/ColorTest.php +++ b/tests/PhpSpreadsheetTests/Style/ColorTest.php @@ -12,7 +12,7 @@ class ColorTest extends TestCase * * @param mixed $expectedResult */ - public function testGetRed($expectedResult, ...$args) + public function testGetRed($expectedResult, ...$args): void { $result = Color::getRed(...$args); self::assertEquals($expectedResult, $result); @@ -28,7 +28,7 @@ public function providerColorGetRed() * * @param mixed $expectedResult */ - public function testGetGreen($expectedResult, ...$args) + public function testGetGreen($expectedResult, ...$args): void { $result = Color::getGreen(...$args); self::assertEquals($expectedResult, $result); @@ -44,7 +44,7 @@ public function providerColorGetGreen() * * @param mixed $expectedResult */ - public function testGetBlue($expectedResult, ...$args) + public function testGetBlue($expectedResult, ...$args): void { $result = Color::getBlue(...$args); self::assertEquals($expectedResult, $result); @@ -60,7 +60,7 @@ public function providerColorGetBlue() * * @param mixed $expectedResult */ - public function testChangeBrightness($expectedResult, ...$args) + public function testChangeBrightness($expectedResult, ...$args): void { $result = Color::changeBrightness(...$args); self::assertEquals($expectedResult, $result); diff --git a/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php b/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php index ba44b6afe8..e995ededf2 100644 --- a/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php +++ b/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php @@ -19,7 +19,7 @@ protected function setUp(): void * * @param mixed $expectedResult */ - public function testFormatValueWithMask($expectedResult, ...$args) + public function testFormatValueWithMask($expectedResult, ...$args): void { $result = NumberFormat::toFormattedString(...$args); self::assertEquals($expectedResult, $result); @@ -35,7 +35,7 @@ public function providerNumberFormat() * * @param mixed $expectedResult */ - public function testFormatValueWithMaskDate($expectedResult, ...$args) + public function testFormatValueWithMaskDate($expectedResult, ...$args): void { $result = NumberFormat::toFormattedString(...$args); self::assertEquals($expectedResult, $result); @@ -46,7 +46,7 @@ public function providerNumberFormatDates() return require 'tests/data/Style/NumberFormatDates.php'; } - public function testCurrencyCode() + public function testCurrencyCode(): void { // "Currency symbol" replaces $ in some cases, not in others $cur = StringHelper::getCurrencyCode(); diff --git a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/Column/RuleTest.php b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/Column/RuleTest.php index 4a0e5c2c88..156a95de23 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/Column/RuleTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/Column/RuleTest.php @@ -22,13 +22,13 @@ protected function setUp(): void ); } - public function testGetRuleType() + public function testGetRuleType(): void { $result = $this->testAutoFilterRuleObject->getRuleType(); self::assertEquals(Column\Rule::AUTOFILTER_RULETYPE_FILTER, $result); } - public function testSetRuleType() + public function testSetRuleType(): void { $expectedResult = Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP; @@ -40,7 +40,7 @@ public function testSetRuleType() self::assertEquals($expectedResult, $result); } - public function testSetValue() + public function testSetValue(): void { $expectedResult = 100; @@ -52,13 +52,13 @@ public function testSetValue() self::assertEquals($expectedResult, $result); } - public function testGetOperator() + public function testGetOperator(): void { $result = $this->testAutoFilterRuleObject->getOperator(); self::assertEquals(Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, $result); } - public function testSetOperator() + public function testSetOperator(): void { $expectedResult = Column\Rule::AUTOFILTER_COLUMN_RULE_LESSTHAN; @@ -70,7 +70,7 @@ public function testSetOperator() self::assertEquals($expectedResult, $result); } - public function testSetGrouping() + public function testSetGrouping(): void { $expectedResult = Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH; @@ -82,20 +82,20 @@ public function testSetGrouping() self::assertEquals($expectedResult, $result); } - public function testGetParent() + public function testGetParent(): void { $result = $this->testAutoFilterRuleObject->getParent(); self::assertInstanceOf(Column::class, $result); } - public function testSetParent() + public function testSetParent(): void { // Setters return the instance to implement the fluent interface $result = $this->testAutoFilterRuleObject->setParent($this->mockAutoFilterColumnObject); self::assertInstanceOf(Column\Rule::class, $result); } - public function testClone() + public function testClone(): void { $result = clone $this->testAutoFilterRuleObject; self::assertInstanceOf(Column\Rule::class, $result); diff --git a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php index fd462b43a9..ef67b05da2 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php @@ -19,20 +19,20 @@ protected function setUp(): void ->disableOriginalConstructor() ->getMock(); - $this->mockAutoFilterObject->expects($this->any()) + $this->mockAutoFilterObject->expects(self::any()) ->method('testColumnInRange') - ->will($this->returnValue(3)); + ->willReturn(3); $this->testAutoFilterColumnObject = new AutoFilter\Column($this->testInitialColumn, $this->mockAutoFilterObject); } - public function testGetColumnIndex() + public function testGetColumnIndex(): void { $result = $this->testAutoFilterColumnObject->getColumnIndex(); self::assertEquals($this->testInitialColumn, $result); } - public function testSetColumnIndex() + public function testSetColumnIndex(): void { $expectedResult = 'L'; @@ -44,26 +44,26 @@ public function testSetColumnIndex() self::assertEquals($expectedResult, $result); } - public function testGetParent() + public function testGetParent(): void { $result = $this->testAutoFilterColumnObject->getParent(); self::assertInstanceOf(AutoFilter::class, $result); } - public function testSetParent() + public function testSetParent(): void { // Setters return the instance to implement the fluent interface $result = $this->testAutoFilterColumnObject->setParent($this->mockAutoFilterObject); self::assertInstanceOf(AutoFilter\Column::class, $result); } - public function testGetFilterType() + public function testGetFilterType(): void { $result = $this->testAutoFilterColumnObject->getFilterType(); self::assertEquals(AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER, $result); } - public function testSetFilterType() + public function testSetFilterType(): void { $result = $this->testAutoFilterColumnObject->setFilterType(AutoFilter\Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER); self::assertInstanceOf(AutoFilter\Column::class, $result); @@ -72,7 +72,7 @@ public function testSetFilterType() self::assertEquals(AutoFilter\Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER, $result); } - public function testSetInvalidFilterTypeThrowsException() + public function testSetInvalidFilterTypeThrowsException(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -81,13 +81,13 @@ public function testSetInvalidFilterTypeThrowsException() $this->testAutoFilterColumnObject->setFilterType($expectedResult); } - public function testGetJoin() + public function testGetJoin(): void { $result = $this->testAutoFilterColumnObject->getJoin(); self::assertEquals(AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_OR, $result); } - public function testSetJoin() + public function testSetJoin(): void { $result = $this->testAutoFilterColumnObject->setJoin(AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_AND); self::assertInstanceOf(AutoFilter\Column::class, $result); @@ -96,7 +96,7 @@ public function testSetJoin() self::assertEquals(AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_AND, $result); } - public function testSetInvalidJoinThrowsException() + public function testSetInvalidJoinThrowsException(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -105,7 +105,7 @@ public function testSetInvalidJoinThrowsException() $this->testAutoFilterColumnObject->setJoin($expectedResult); } - public function testSetAttributes() + public function testSetAttributes(): void { $attributeSet = [ 'val' => 100, @@ -117,7 +117,7 @@ public function testSetAttributes() self::assertInstanceOf(AutoFilter\Column::class, $result); } - public function testGetAttributes() + public function testGetAttributes(): void { $attributeSet = [ 'val' => 100, @@ -131,7 +131,7 @@ public function testGetAttributes() self::assertCount(count($attributeSet), $result); } - public function testSetAttribute() + public function testSetAttribute(): void { $attributeSet = [ 'val' => 100, @@ -145,7 +145,7 @@ public function testSetAttribute() } } - public function testGetAttribute() + public function testGetAttribute(): void { $attributeSet = [ 'val' => 100, @@ -162,7 +162,7 @@ public function testGetAttribute() self::assertNull($result); } - public function testClone() + public function testClone(): void { $originalRule = $this->testAutoFilterColumnObject->createRule(); $result = clone $this->testAutoFilterColumnObject; diff --git a/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php b/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php index c2c7f6fc98..17b4c02287 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php @@ -29,14 +29,14 @@ protected function setUp(): void $this->cellCollection = $this->getMockBuilder(Cells::class) ->disableOriginalConstructor() ->getMock(); - $this->mockWorksheetObject->expects($this->any()) + $this->mockWorksheetObject->expects(self::any()) ->method('getCellCollection') - ->will($this->returnValue($this->cellCollection)); + ->willReturn($this->cellCollection); $this->testAutoFilterObject = new AutoFilter($this->testInitialRange, $this->mockWorksheetObject); } - public function testToString() + public function testToString(): void { $expectedResult = $this->testInitialRange; @@ -45,20 +45,20 @@ public function testToString() self::assertEquals($expectedResult, $result); } - public function testGetParent() + public function testGetParent(): void { $result = $this->testAutoFilterObject->getParent(); self::assertInstanceOf(Worksheet::class, $result); } - public function testSetParent() + public function testSetParent(): void { // Setters return the instance to implement the fluent interface $result = $this->testAutoFilterObject->setParent($this->mockWorksheetObject); self::assertInstanceOf(AutoFilter::class, $result); } - public function testGetRange() + public function testGetRange(): void { $expectedResult = $this->testInitialRange; @@ -67,7 +67,7 @@ public function testGetRange() self::assertEquals($expectedResult, $result); } - public function testSetRange() + public function testSetRange(): void { $ranges = [ 'G1:J512' => 'Worksheet1!G1:J512', @@ -85,7 +85,7 @@ public function testSetRange() } } - public function testClearRange() + public function testClearRange(): void { $expectedResult = ''; @@ -98,7 +98,7 @@ public function testClearRange() self::assertEquals($expectedResult, $result); } - public function testSetRangeInvalidRange() + public function testSetRangeInvalidRange(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -107,7 +107,7 @@ public function testSetRangeInvalidRange() $this->testAutoFilterObject->setRange($expectedResult); } - public function testGetColumnsEmpty() + public function testGetColumnsEmpty(): void { // There should be no columns yet defined $result = $this->testAutoFilterObject->getColumns(); @@ -115,7 +115,7 @@ public function testGetColumnsEmpty() self::assertCount(0, $result); } - public function testGetColumnOffset() + public function testGetColumnOffset(): void { $columnIndexes = [ 'H' => 0, @@ -131,7 +131,7 @@ public function testGetColumnOffset() } } - public function testGetInvalidColumnOffset() + public function testGetInvalidColumnOffset(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -140,7 +140,7 @@ public function testGetInvalidColumnOffset() $this->testAutoFilterObject->getColumnOffset($invalidColumn); } - public function testSetColumnWithString() + public function testSetColumnWithString(): void { $expectedResult = 'L'; @@ -157,7 +157,7 @@ public function testSetColumnWithString() self::assertInstanceOf(Column::class, $result[$expectedResult]); } - public function testSetInvalidColumnWithString() + public function testSetInvalidColumnWithString(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -166,7 +166,7 @@ public function testSetInvalidColumnWithString() $this->testAutoFilterObject->setColumn($invalidColumn); } - public function testSetColumnWithColumnObject() + public function testSetColumnWithColumnObject(): void { $expectedResult = 'M'; $columnObject = new AutoFilter\Column($expectedResult); @@ -184,7 +184,7 @@ public function testSetColumnWithColumnObject() self::assertInstanceOf(Column::class, $result[$expectedResult]); } - public function testSetInvalidColumnWithObject() + public function testSetInvalidColumnWithObject(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -192,7 +192,7 @@ public function testSetInvalidColumnWithObject() $this->testAutoFilterObject->setColumn($invalidColumn); } - public function testSetColumnWithInvalidDataType() + public function testSetColumnWithInvalidDataType(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -200,7 +200,7 @@ public function testSetColumnWithInvalidDataType() $this->testAutoFilterObject->setColumn($invalidColumn); } - public function testGetColumns() + public function testGetColumns(): void { $columnIndexes = ['L', 'M']; @@ -219,7 +219,7 @@ public function testGetColumns() } } - public function testGetColumn() + public function testGetColumn(): void { $columnIndexes = ['L', 'M']; @@ -235,7 +235,7 @@ public function testGetColumn() } } - public function testGetColumnByOffset() + public function testGetColumnByOffset(): void { $columnIndexes = [ 0 => 'H', @@ -252,7 +252,7 @@ public function testGetColumnByOffset() } } - public function testGetColumnIfNotSet() + public function testGetColumnIfNotSet(): void { // If we request a specific column by its column ID, we should // get a \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\AutoFilter\Column object returned @@ -260,7 +260,7 @@ public function testGetColumnIfNotSet() self::assertInstanceOf(Column::class, $result); } - public function testGetColumnWithoutRangeSet() + public function testGetColumnWithoutRangeSet(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -269,7 +269,7 @@ public function testGetColumnWithoutRangeSet() $this->testAutoFilterObject->getColumn('A'); } - public function testClearRangeWithExistingColumns() + public function testClearRangeWithExistingColumns(): void { $expectedResult = ''; @@ -292,7 +292,7 @@ public function testClearRangeWithExistingColumns() self::assertCount(0, $result); } - public function testSetRangeWithExistingColumns() + public function testSetRangeWithExistingColumns(): void { $expectedResult = 'G1:J512'; @@ -322,7 +322,7 @@ public function testSetRangeWithExistingColumns() self::assertCount(count($columnIndexes1), $result); } - public function testClone() + public function testClone(): void { $columnIndexes = ['L', 'M']; diff --git a/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php index 5d4706dc99..2083f347c4 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php @@ -23,15 +23,15 @@ protected function setUp(): void ->disableOriginalConstructor() ->getMock(); - $this->mockWorksheet->expects($this->any()) + $this->mockWorksheet->expects(self::any()) ->method('getHighestRow') - ->will($this->returnValue(5)); - $this->mockWorksheet->expects($this->any()) + ->willReturn(5); + $this->mockWorksheet->expects(self::any()) ->method('getCellByColumnAndRow') - ->will($this->returnValue($this->mockCell)); + ->willReturn($this->mockCell); } - public function testIteratorFullRange() + public function testIteratorFullRange(): void { $iterator = new ColumnCellIterator($this->mockWorksheet, 'A'); $ColumnCellIndexResult = 1; @@ -43,7 +43,7 @@ public function testIteratorFullRange() } } - public function testIteratorStartEndRange() + public function testIteratorStartEndRange(): void { $iterator = new ColumnCellIterator($this->mockWorksheet, 'A', 2, 4); $ColumnCellIndexResult = 2; @@ -55,7 +55,7 @@ public function testIteratorStartEndRange() } } - public function testIteratorSeekAndPrev() + public function testIteratorSeekAndPrev(): void { $iterator = new ColumnCellIterator($this->mockWorksheet, 'A', 2, 4); $columnIndexResult = 4; @@ -68,7 +68,7 @@ public function testIteratorSeekAndPrev() } } - public function testSeekOutOfRange() + public function testSeekOutOfRange(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -76,7 +76,7 @@ public function testSeekOutOfRange() $iterator->seek(1); } - public function testPrevOutOfRange() + public function testPrevOutOfRange(): void { $iterator = new ColumnCellIterator($this->mockWorksheet, 'A', 2, 4); $iterator->prev(); diff --git a/tests/PhpSpreadsheetTests/Worksheet/ColumnDimensionTest.php b/tests/PhpSpreadsheetTests/Worksheet/ColumnDimensionTest.php index 1f31fdb92d..b10875c28a 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ColumnDimensionTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ColumnDimensionTest.php @@ -7,7 +7,7 @@ class ColumnDimensionTest extends TestCase { - public function testInstantiateColumnDimensionDefault() + public function testInstantiateColumnDimensionDefault(): void { $expected = 'A'; $columnDimension = new ColumnDimension(); @@ -16,7 +16,7 @@ public function testInstantiateColumnDimensionDefault() self::assertEquals($expected, $result); } - public function testGetAndSetColumnIndex() + public function testGetAndSetColumnIndex(): void { $expected = 'B'; $columnDimension = new ColumnDimension(); @@ -25,7 +25,7 @@ public function testGetAndSetColumnIndex() self::assertSame($expected, $result); } - public function testGetAndSetWidth() + public function testGetAndSetWidth(): void { $expected = 1.2; $columnDimension = new ColumnDimension(); @@ -34,7 +34,7 @@ public function testGetAndSetWidth() self::assertSame($expected, $result); } - public function testGetAndSetAutoSize() + public function testGetAndSetAutoSize(): void { $expected = true; $columnDimension = new ColumnDimension(); diff --git a/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php index eb0b1e0f04..de985ceecd 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php @@ -23,12 +23,12 @@ protected function setUp(): void ->disableOriginalConstructor() ->getMock(); - $this->mockWorksheet->expects($this->any()) + $this->mockWorksheet->expects(self::any()) ->method('getHighestColumn') - ->will($this->returnValue('E')); + ->willReturn('E'); } - public function testIteratorFullRange() + public function testIteratorFullRange(): void { $iterator = new ColumnIterator($this->mockWorksheet); $columnIndexResult = 'A'; @@ -40,7 +40,7 @@ public function testIteratorFullRange() } } - public function testIteratorStartEndRange() + public function testIteratorStartEndRange(): void { $iterator = new ColumnIterator($this->mockWorksheet, 'B', 'D'); $columnIndexResult = 'B'; @@ -52,7 +52,7 @@ public function testIteratorStartEndRange() } } - public function testIteratorSeekAndPrev() + public function testIteratorSeekAndPrev(): void { $ranges = range('A', 'E'); $iterator = new ColumnIterator($this->mockWorksheet, 'B', 'D'); @@ -67,7 +67,7 @@ public function testIteratorSeekAndPrev() } } - public function testSeekOutOfRange() + public function testSeekOutOfRange(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -75,7 +75,7 @@ public function testSeekOutOfRange() $iterator->seek('A'); } - public function testPrevOutOfRange() + public function testPrevOutOfRange(): void { $iterator = new ColumnIterator($this->mockWorksheet, 'B', 'D'); $iterator->prev(); diff --git a/tests/PhpSpreadsheetTests/Worksheet/ColumnTest.php b/tests/PhpSpreadsheetTests/Worksheet/ColumnTest.php index d8c5c9972c..0abff0ec45 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ColumnTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ColumnTest.php @@ -18,12 +18,12 @@ protected function setUp(): void $this->mockWorksheet = $this->getMockBuilder(Worksheet::class) ->disableOriginalConstructor() ->getMock(); - $this->mockWorksheet->expects($this->any()) + $this->mockWorksheet->expects(self::any()) ->method('getHighestRow') - ->will($this->returnValue(5)); + ->willReturn(5); } - public function testInstantiateColumnDefault() + public function testInstantiateColumnDefault(): void { $column = new Column($this->mockWorksheet); self::assertInstanceOf(Column::class, $column); @@ -31,7 +31,7 @@ public function testInstantiateColumnDefault() self::assertEquals('A', $columnIndex); } - public function testInstantiateColumnSpecified() + public function testInstantiateColumnSpecified(): void { $column = new Column($this->mockWorksheet, 'E'); self::assertInstanceOf(Column::class, $column); @@ -39,7 +39,7 @@ public function testInstantiateColumnSpecified() self::assertEquals('E', $columnIndex); } - public function testGetCellIterator() + public function testGetCellIterator(): void { $column = new Column($this->mockWorksheet); $cellIterator = $column->getCellIterator(); diff --git a/tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php b/tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php index 32bd97f392..f126a529f7 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php @@ -8,7 +8,7 @@ class DrawingTest extends TestCase { - public function testCloningWorksheetWithImages() + public function testCloningWorksheetWithImages(): void { $spreadsheet = new Spreadsheet(); $aSheet = $spreadsheet->getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Worksheet/IteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/IteratorTest.php index 80a2d7837e..b2a063439d 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/IteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/IteratorTest.php @@ -9,7 +9,7 @@ class IteratorTest extends TestCase { - public function testIteratorFullRange() + public function testIteratorFullRange(): void { $spreadsheet = new Spreadsheet(); $spreadsheet->createSheet(); diff --git a/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php index 786a0d1a1d..bc2c16dc1d 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php @@ -23,15 +23,15 @@ protected function setUp(): void ->disableOriginalConstructor() ->getMock(); - $this->mockWorksheet->expects($this->any()) + $this->mockWorksheet->expects(self::any()) ->method('getHighestColumn') - ->will($this->returnValue('E')); - $this->mockWorksheet->expects($this->any()) + ->willReturn('E'); + $this->mockWorksheet->expects(self::any()) ->method('getCellByColumnAndRow') - ->will($this->returnValue($this->mockCell)); + ->willReturn($this->mockCell); } - public function testIteratorFullRange() + public function testIteratorFullRange(): void { $iterator = new RowCellIterator($this->mockWorksheet); $RowCellIndexResult = 'A'; @@ -43,7 +43,7 @@ public function testIteratorFullRange() } } - public function testIteratorStartEndRange() + public function testIteratorStartEndRange(): void { $iterator = new RowCellIterator($this->mockWorksheet, 2, 'B', 'D'); $RowCellIndexResult = 'B'; @@ -55,7 +55,7 @@ public function testIteratorStartEndRange() } } - public function testIteratorSeekAndPrev() + public function testIteratorSeekAndPrev(): void { $ranges = range('A', 'E'); $iterator = new RowCellIterator($this->mockWorksheet, 2, 'B', 'D'); @@ -70,7 +70,7 @@ public function testIteratorSeekAndPrev() } } - public function testSeekOutOfRange() + public function testSeekOutOfRange(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -78,7 +78,7 @@ public function testSeekOutOfRange() $iterator->seek(1); } - public function testPrevOutOfRange() + public function testPrevOutOfRange(): void { $iterator = new RowCellIterator($this->mockWorksheet, 2, 'B', 'D'); $iterator->prev(); diff --git a/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php index ea2fe351d4..919da9efad 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php @@ -23,12 +23,12 @@ protected function setUp(): void ->disableOriginalConstructor() ->getMock(); - $this->mockWorksheet->expects($this->any()) + $this->mockWorksheet->expects(self::any()) ->method('getHighestRow') - ->will($this->returnValue(5)); + ->willReturn(5); } - public function testIteratorFullRange() + public function testIteratorFullRange(): void { $iterator = new RowIterator($this->mockWorksheet); $rowIndexResult = 1; @@ -40,7 +40,7 @@ public function testIteratorFullRange() } } - public function testIteratorStartEndRange() + public function testIteratorStartEndRange(): void { $iterator = new RowIterator($this->mockWorksheet, 2, 4); $rowIndexResult = 2; @@ -52,7 +52,7 @@ public function testIteratorStartEndRange() } } - public function testIteratorSeekAndPrev() + public function testIteratorSeekAndPrev(): void { $iterator = new RowIterator($this->mockWorksheet, 2, 4); $columnIndexResult = 4; @@ -65,7 +65,7 @@ public function testIteratorSeekAndPrev() } } - public function testSeekOutOfRange() + public function testSeekOutOfRange(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -73,7 +73,7 @@ public function testSeekOutOfRange() $iterator->seek(1); } - public function testPrevOutOfRange() + public function testPrevOutOfRange(): void { $iterator = new RowIterator($this->mockWorksheet, 2, 4); $iterator->prev(); diff --git a/tests/PhpSpreadsheetTests/Worksheet/RowTest.php b/tests/PhpSpreadsheetTests/Worksheet/RowTest.php index ee2dcffb1b..93ff589c7e 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/RowTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/RowTest.php @@ -18,12 +18,12 @@ protected function setUp(): void $this->mockWorksheet = $this->getMockBuilder(Worksheet::class) ->disableOriginalConstructor() ->getMock(); - $this->mockWorksheet->expects($this->any()) + $this->mockWorksheet->expects(self::any()) ->method('getHighestColumn') - ->will($this->returnValue('E')); + ->willReturn('E'); } - public function testInstantiateRowDefault() + public function testInstantiateRowDefault(): void { $row = new Row($this->mockWorksheet); self::assertInstanceOf(Row::class, $row); @@ -31,7 +31,7 @@ public function testInstantiateRowDefault() self::assertEquals(1, $rowIndex); } - public function testInstantiateRowSpecified() + public function testInstantiateRowSpecified(): void { $row = new Row($this->mockWorksheet, 5); self::assertInstanceOf(Row::class, $row); @@ -39,7 +39,7 @@ public function testInstantiateRowSpecified() self::assertEquals(5, $rowIndex); } - public function testGetCellIterator() + public function testGetCellIterator(): void { $row = new Row($this->mockWorksheet); $cellIterator = $row->getCellIterator(); diff --git a/tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php b/tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php index d1e19df429..46c848ba21 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php @@ -2,13 +2,14 @@ namespace PhpOffice\PhpSpreadsheetTests\Worksheet; +use Exception; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PHPUnit\Framework\TestCase; class WorksheetTest extends TestCase { - public function testSetTitle() + public function testSetTitle(): void { $testTitle = str_repeat('a', 31); @@ -30,7 +31,7 @@ public function setTitleInvalidProvider() * @param string $expectMessage * @dataProvider setTitleInvalidProvider */ - public function testSetTitleInvalid($title, $expectMessage) + public function testSetTitleInvalid($title, $expectMessage): void { // First, test setting title with validation disabled -- should be successful $worksheet = new Worksheet(); @@ -38,12 +39,12 @@ public function testSetTitleInvalid($title, $expectMessage) // Next, test again with validation enabled -- this time we should fail $worksheet = new Worksheet(); - $this->expectException(\Exception::class); + $this->expectException(Exception::class); $this->expectExceptionMessage($expectMessage); $worksheet->setTitle($title); } - public function testSetTitleDuplicate() + public function testSetTitleDuplicate(): void { // Create a Spreadsheet with three Worksheets (the first is created automatically) $spreadsheet = new Spreadsheet(); @@ -66,7 +67,7 @@ public function testSetTitleDuplicate() self::assertSame('Test Title', $sheet->getTitle()); } - public function testSetCodeName() + public function testSetCodeName(): void { $testCodeName = str_repeat('a', 31); @@ -88,7 +89,7 @@ public function setCodeNameInvalidProvider() * @param string $expectMessage * @dataProvider setCodeNameInvalidProvider */ - public function testSetCodeNameInvalid($codeName, $expectMessage) + public function testSetCodeNameInvalid($codeName, $expectMessage): void { // First, test setting code name with validation disabled -- should be successful $worksheet = new Worksheet(); @@ -96,12 +97,12 @@ public function testSetCodeNameInvalid($codeName, $expectMessage) // Next, test again with validation enabled -- this time we should fail $worksheet = new Worksheet(); - $this->expectException(\Exception::class); + $this->expectException(Exception::class); $this->expectExceptionMessage($expectMessage); $worksheet->setCodeName($codeName); } - public function testSetCodeNameDuplicate() + public function testSetCodeNameDuplicate(): void { // Create a Spreadsheet with three Worksheets (the first is created automatically) $spreadsheet = new Spreadsheet(); @@ -124,7 +125,7 @@ public function testSetCodeNameDuplicate() self::assertSame('Test Code Name', $sheet->getCodeName()); } - public function testFreezePaneSelectedCell() + public function testFreezePaneSelectedCell(): void { $worksheet = new Worksheet(); $worksheet->freezePane('B2'); @@ -152,7 +153,7 @@ public function extractSheetTitleProvider() * @param string $expectCell2 * @dataProvider extractSheetTitleProvider */ - public function testExtractSheetTitle($range, $expectTitle, $expectCell, $expectCell2) + public function testExtractSheetTitle($range, $expectTitle, $expectCell, $expectCell2): void { // only cell reference self::assertSame($expectCell, Worksheet::extractSheetTitle($range)); @@ -166,18 +167,18 @@ public function testExtractSheetTitle($range, $expectTitle, $expectCell, $expect * Fix https://github.com/PHPOffice/PhpSpreadsheet/issues/868 when cells are not removed correctly * on row deletion. */ - public function testRemoveCellsCorrectlyWhenRemovingRow() + public function testRemoveCellsCorrectlyWhenRemovingRow(): void { $workbook = new Spreadsheet(); $worksheet = $workbook->getActiveSheet(); $worksheet->getCell('A2')->setValue('A2'); $worksheet->getCell('C1')->setValue('C1'); $worksheet->removeRow(1); - $this->assertEquals( + self::assertEquals( 'A2', $worksheet->getCell('A1')->getValue() ); - $this->assertNull( + self::assertNull( $worksheet->getCell('C1')->getValue() ); } @@ -262,7 +263,7 @@ public function testRemoveColumn( int $columnsToBeRemoved, array $expectedData, string $expectedHighestColumn - ) { + ): void { $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); $worksheet->fromArray($initialData); @@ -394,7 +395,7 @@ public function testRemoveRows( int $rowsQtyToRemove, array $expectedData, int $expectedHighestRow - ) { + ): void { $workbook = new Spreadsheet(); $worksheet = $workbook->getActiveSheet(); $worksheet->fromArray($initialData); diff --git a/tests/PhpSpreadsheetTests/Writer/Csv/CsvWriteTest.php b/tests/PhpSpreadsheetTests/Writer/Csv/CsvWriteTest.php index f55781dad5..7252ecf970 100644 --- a/tests/PhpSpreadsheetTests/Writer/Csv/CsvWriteTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Csv/CsvWriteTest.php @@ -11,7 +11,7 @@ class CsvWriteTest extends Functional\AbstractFunctional { - public function testNotFirstSheet() + public function testNotFirstSheet(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -33,7 +33,7 @@ public function testNotFirstSheet() self::assertEquals(0, $newspreadsheet->getActiveSheetIndex()); } - public function testWriteEmptyFileName() + public function testWriteEmptyFileName(): void { $this->expectException(WriterException::class); $spreadsheet = new Spreadsheet(); @@ -42,7 +42,7 @@ public function testWriteEmptyFileName() $writer->save($filename); } - public function testDefaultSettings() + public function testDefaultSettings(): void { $spreadsheet = new Spreadsheet(); $writer = new CsvWriter($spreadsheet); diff --git a/tests/PhpSpreadsheetTests/Writer/Html/AllOrOneSheetTest.php b/tests/PhpSpreadsheetTests/Writer/Html/AllOrOneSheetTest.php index 03fe741f30..31ed438e26 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/AllOrOneSheetTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/AllOrOneSheetTest.php @@ -2,6 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Writer\Html; +use DOMDocument; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Html; use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf; @@ -10,7 +11,7 @@ class AllOrOneSheetTest extends Functional\AbstractFunctional { - public function testWriteAllSheets() + public function testWriteAllSheets(): void { $spreadsheet = new Spreadsheet(); $sheet1 = $spreadsheet->getActiveSheet(); @@ -23,7 +24,7 @@ public function testWriteAllSheets() $writer->writeAllSheets(); self::assertTrue($writer->getGenerateSheetNavigationBlock()); $html = $writer->generateHTMLAll(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('ul'); // sheet navigation @@ -41,7 +42,7 @@ public function testWriteAllSheets() $this->writeAndReload($spreadsheet, 'Html'); } - public function testWriteAllSheetsNoNav() + public function testWriteAllSheetsNoNav(): void { $spreadsheet = new Spreadsheet(); $sheet1 = $spreadsheet->getActiveSheet(); @@ -53,7 +54,7 @@ public function testWriteAllSheetsNoNav() $writer->writeAllSheets(); $writer->setGenerateSheetNavigationBlock(false); $html = $writer->generateHTMLAll(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('ul'); // sheet navigation @@ -71,7 +72,7 @@ public function testWriteAllSheetsNoNav() $this->writeAndReload($spreadsheet, 'Html'); } - public function testWriteAllSheetsPdf() + public function testWriteAllSheetsPdf(): void { $spreadsheet = new Spreadsheet(); $sheet1 = $spreadsheet->getActiveSheet(); @@ -82,7 +83,7 @@ public function testWriteAllSheetsPdf() $writer = new Mpdf($spreadsheet); $writer->writeAllSheets(); $html = $writer->generateHTMLAll(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('ul'); // sheet navigation @@ -99,7 +100,7 @@ public function testWriteAllSheetsPdf() self::assertEquals('sheet1 gridlines', $tbl->item(0)->getAttribute('class')); } - public function testWriteOneSheet() + public function testWriteOneSheet(): void { $spreadsheet = new Spreadsheet(); $sheet1 = $spreadsheet->getActiveSheet(); @@ -110,7 +111,7 @@ public function testWriteOneSheet() $writer = new Html($spreadsheet); $writer->setSheetIndex(1); $html = $writer->generateHTMLAll(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('ul'); // sheet navigation @@ -124,7 +125,7 @@ public function testWriteOneSheet() $this->writeAndReload($spreadsheet, 'Html'); } - public function testPageBreak() + public function testPageBreak(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -141,7 +142,7 @@ public function testPageBreak() $writer->writeAllSheets(); $html = $writer->generateHTMLAll(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('div'); @@ -163,7 +164,7 @@ public function testPageBreak() $this->writeAndReload($spreadsheet, 'Html'); } - public function testTcpdfPageBreak() + public function testTcpdfPageBreak(): void { $spreadsheet = new Spreadsheet(); $sheet1 = $spreadsheet->getActiveSheet(); @@ -177,7 +178,7 @@ public function testTcpdfPageBreak() $writer = new Tcpdf($spreadsheet); $writer->writeAllSheets(); $html = $writer->generateHtmlAll(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('div'); diff --git a/tests/PhpSpreadsheetTests/Writer/Html/GridlinesTest.php b/tests/PhpSpreadsheetTests/Writer/Html/GridlinesTest.php index 2bbe3541fb..2fa41953f9 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/GridlinesTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/GridlinesTest.php @@ -2,6 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Writer\Html; +use DOMDocument; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Color; use PhpOffice\PhpSpreadsheet\Writer\Html; @@ -9,7 +10,7 @@ class GridlinesTest extends Functional\AbstractFunctional { - public function testGridlines() + public function testGridlines(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -29,7 +30,7 @@ public function testGridlines() $writer->writeAllSheets(); $html = $writer->generateHTMLAll(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('div'); @@ -51,7 +52,7 @@ public function testGridlines() $this->writeAndReload($spreadsheet, 'Html'); } - public function testGridlinesInline() + public function testGridlinesInline(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -72,7 +73,7 @@ public function testGridlinesInline() $writer->setUseInlineCss(true); $html = $writer->generateHTMLAll(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('div'); @@ -94,7 +95,7 @@ public function testGridlinesInline() $this->writeAndReload($spreadsheet, 'Html'); } - public function testRichText() + public function testRichText(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -130,7 +131,7 @@ public function testRichText() $writer = new Html($spreadsheet); $html = $writer->generateHTMLAll(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('div'); diff --git a/tests/PhpSpreadsheetTests/Writer/Html/HtmlCommentsTest.php b/tests/PhpSpreadsheetTests/Writer/Html/HtmlCommentsTest.php index 637c6514cb..0d43d7eb5a 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/HtmlCommentsTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/HtmlCommentsTest.php @@ -46,7 +46,7 @@ public function providerCommentRichText() * * @param mixed $richText */ - public function testComments($richText) + public function testComments($richText): void { $this->spreadsheet = new Spreadsheet(); diff --git a/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php b/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php index 96652d6dc2..9d306fa07d 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php @@ -2,6 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Writer\Html; +use DOMDocument; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Html; @@ -27,7 +28,7 @@ protected function tearDown(): void StringHelper::setThousandsSeparator($this->thosep); } - public function testColorNumberFormat() + public function testColorNumberFormat(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -40,7 +41,7 @@ public function testColorNumberFormat() $writer = new Html($spreadsheet); $html = $writer->generateHTMLAll(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('div'); @@ -81,7 +82,7 @@ public function testColorNumberFormat() $this->writeAndReload($spreadsheet, 'Html'); } - public function testColorNumberFormatComplex() + public function testColorNumberFormatComplex(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -94,7 +95,7 @@ public function testColorNumberFormatComplex() $writer = new Html($spreadsheet); $html = $writer->generateHTMLAll(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('div'); @@ -142,7 +143,7 @@ public function testColorNumberFormatComplex() * @param mixed $val * @param mixed $fmt */ - public function testFormatValueWithMask($expectedResult, $val, $fmt) + public function testFormatValueWithMask($expectedResult, $val, $fmt): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -150,7 +151,7 @@ public function testFormatValueWithMask($expectedResult, $val, $fmt) $writer = new Html($spreadsheet); $html = $writer->generateHTMLAll(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('div'); @@ -178,7 +179,7 @@ public function providerNumberFormat() * @param mixed $val * @param mixed $fmt */ - public function testFormatValueWithMaskDate($expectedResult, $val, $fmt) + public function testFormatValueWithMaskDate($expectedResult, $val, $fmt): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -186,7 +187,7 @@ public function testFormatValueWithMaskDate($expectedResult, $val, $fmt) $writer = new Html($spreadsheet); $html = $writer->generateHTMLAll(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('div'); diff --git a/tests/PhpSpreadsheetTests/Writer/Html/ImagesRootTest.php b/tests/PhpSpreadsheetTests/Writer/Html/ImagesRootTest.php index f7716e33c2..5c887d531c 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/ImagesRootTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/ImagesRootTest.php @@ -2,13 +2,14 @@ namespace PhpOffice\PhpSpreadsheetTests\Writer\Html; +use DOMDocument; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Html; use PhpOffice\PhpSpreadsheetTests\Functional; class ImagesRootTest extends Functional\AbstractFunctional { - public function testImagesRoot() + public function testImagesRoot(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -34,7 +35,7 @@ public function testImagesRoot() $writer->setImagesRoot($root); $html = $writer->generateHTMLAll(); chdir($curdir); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('div'); diff --git a/tests/PhpSpreadsheetTests/Writer/Html/InvalidFileNameTest.php b/tests/PhpSpreadsheetTests/Writer/Html/InvalidFileNameTest.php index f536d2bdbd..7baa233842 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/InvalidFileNameTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/InvalidFileNameTest.php @@ -12,7 +12,7 @@ class InvalidFileNameTest extends Functional\AbstractFunctional { - public function testEmptyFileName() + public function testEmptyFileName(): void { $this->expectException(WriterException::class); $spreadsheet = new Spreadsheet(); @@ -21,7 +21,7 @@ public function testEmptyFileName() $writer->save(''); } - public function testEmptyFileNamePdf() + public function testEmptyFileNamePdf(): void { $this->expectException(WriterException::class); $spreadsheet = new Spreadsheet(); @@ -30,7 +30,7 @@ public function testEmptyFileNamePdf() $writer->save(''); } - public function testEmptyTempdirNamePdf() + public function testEmptyTempdirNamePdf(): void { $this->expectException(WriterException::class); $spreadsheet = new Spreadsheet(); @@ -44,7 +44,7 @@ public function testEmptyTempdirNamePdf() $writer->setTempDir(''); } - public function testWinFileNames() + public function testWinFileNames(): void { self::assertEquals('file:///C:/temp/filename.xlsx', Html::winFileToUrl('C:\\temp\filename.xlsx')); self::assertEquals('/tmp/filename.xlsx', Html::winFileToUrl('/tmp/filename.xlsx')); diff --git a/tests/PhpSpreadsheetTests/Writer/Html/RepeatedRowsTest.php b/tests/PhpSpreadsheetTests/Writer/Html/RepeatedRowsTest.php index e38e4b8e9a..2a0f60c1a3 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/RepeatedRowsTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/RepeatedRowsTest.php @@ -2,13 +2,14 @@ namespace PhpOffice\PhpSpreadsheetTests\Writer\Html; +use DOMDocument; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Html; use PhpOffice\PhpSpreadsheetTests\Functional; class RepeatedRowsTest extends Functional\AbstractFunctional { - public function testWriteRepeats() + public function testWriteRepeats(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -21,7 +22,7 @@ public function testWriteRepeats() $writer = new Html($spreadsheet); $html = $writer->generateHTMLall(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('div'); @@ -39,7 +40,7 @@ public function testWriteRepeats() $this->writeAndReload($spreadsheet, 'Html'); } - public function testWriteNoRepeats() + public function testWriteNoRepeats(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -52,7 +53,7 @@ public function testWriteNoRepeats() $writer = new Html($spreadsheet); $html = $writer->generateHTMLall(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('div'); @@ -69,7 +70,7 @@ public function testWriteNoRepeats() $this->writeAndReload($spreadsheet, 'Html'); } - public function testWriteRepeatsInline() + public function testWriteRepeatsInline(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -84,7 +85,7 @@ public function testWriteRepeatsInline() self::assertFalse($writer->getUseInlineCss()); $writer->setUseInlineCss(true); $html = $writer->generateHTMLall(); - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; $divs = $body->getElementsByTagName('div'); diff --git a/tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php b/tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php index 63cdefb7d9..c5d4da68c8 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php @@ -9,7 +9,7 @@ class VisibilityTest extends Functional\AbstractFunctional { - public function testVisibility1() + public function testVisibility1(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -39,7 +39,7 @@ public function testVisibility1() $this->writeAndReload($spreadsheet, 'Html'); } - public function testVisibility2() + public function testVisibility2(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -72,7 +72,7 @@ public function testVisibility2() $this->writeAndReload($spreadsheet, 'Html'); } - public function testDefaultRowHeight() + public function testDefaultRowHeight(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php b/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php index 5641d330c6..4086914d29 100644 --- a/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php @@ -37,7 +37,7 @@ protected function tearDown(): void Functions::setCompatibilityMode($this->compatibilityMode); } - public function testWriteEmptySpreadsheet() + public function testWriteEmptySpreadsheet(): void { $content = new Content(new Ods(new Spreadsheet())); $xml = $content->write(); @@ -45,7 +45,7 @@ public function testWriteEmptySpreadsheet() self::assertXmlStringEqualsXmlFile($this->samplesPath . '/content-empty.xml', $xml); } - public function testWriteSpreadsheet() + public function testWriteSpreadsheet(): void { $workbook = new Spreadsheet(); diff --git a/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php b/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php index affb917f0d..61c70cb69b 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php @@ -17,7 +17,7 @@ protected function tearDown(): void } } - public function testFormulaError() + public function testFormulaError(): void { $obj = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); $sheet0 = $obj->setActiveSheetIndex(0); diff --git a/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php b/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php index d2080265b8..7a83b697ae 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Writer\Xls\Parser; use PhpOffice\PhpSpreadsheet\Writer\Xls\Workbook; use PHPUnit\Framework\TestCase; +use ReflectionClass; class WorkbookTest extends TestCase { @@ -28,13 +29,10 @@ protected function setUp(): void /** * @dataProvider providerAddColor - * - * @param array $testColors - * @param array $expectedResult */ - public function testAddColor(array $testColors, array $expectedResult) + public function testAddColor(array $testColors, array $expectedResult): void { - $workbookReflection = new \ReflectionClass(Workbook::class); + $workbookReflection = new ReflectionClass(Workbook::class); $methodAddColor = $workbookReflection->getMethod('addColor'); $propertyPalette = $workbookReflection->getProperty('palette'); $methodAddColor->setAccessible(true); @@ -53,7 +51,7 @@ public function providerAddColor() { $this->setUp(); - $workbookReflection = new \ReflectionClass(Workbook::class); + $workbookReflection = new ReflectionClass(Workbook::class); $propertyPalette = $workbookReflection->getProperty('palette'); $propertyPalette->setAccessible(true); diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/FloatsRetainedTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/FloatsRetainedTest.php index 521cc47f0a..aad074de32 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/FloatsRetainedTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/FloatsRetainedTest.php @@ -16,7 +16,7 @@ class FloatsRetainedTest extends TestCase * * @param float|int $value */ - public function testIntyFloatsRetainedByWriter($value) + public function testIntyFloatsRetainedByWriter($value): void { $outputFilename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); Settings::setLibXmlLoaderOptions(null); @@ -29,7 +29,7 @@ public function testIntyFloatsRetainedByWriter($value) $reader = new Reader(); $sheet = $reader->load($outputFilename); - $this->assertSame($value, $sheet->getActiveSheet()->getCell('A1')->getValue()); + self::assertSame($value, $sheet->getActiveSheet()->getCell('A1')->getValue()); } public function providerIntyFloatsRetainedByWriter() diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php index f3f0eda2df..81d4a77736 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php @@ -30,10 +30,10 @@ protected function tearDown(): void } } - public function testLocaleFloatsCorrectlyConvertedByWriter() + public function testLocaleFloatsCorrectlyConvertedByWriter(): void { if (!$this->localeAdjusted) { - $this->markTestSkipped('Unable to set locale for testing.'); + self::markTestSkipped('Unable to set locale for testing.'); } $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); @@ -52,8 +52,8 @@ public function testLocaleFloatsCorrectlyConvertedByWriter() ob_start(); var_dump($result); preg_match('/(?:double|float)\(([^\)]+)\)/mui', ob_get_clean(), $matches); - $this->assertArrayHasKey(1, $matches); + self::assertArrayHasKey(1, $matches); $actual = $matches[1]; - $this->assertEquals('1,1', $actual); + self::assertEquals('1,1', $actual); } } diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php index a826dfaac5..4ea6f95561 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php @@ -13,7 +13,7 @@ class UnparsedDataTest extends TestCase /** * Test load and save Xlsx file with unparsed data (form elements, protected sheets, alternate contents, printer settings,..). */ - public function testLoadSaveXlsxWithUnparsedData() + public function testLoadSaveXlsxWithUnparsedData(): void { $sampleFilename = 'tests/data/Writer/XLSX/form_pass_print.xlsm'; $resultFilename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); @@ -45,59 +45,59 @@ public function testLoadSaveXlsxWithUnparsedData() unlink($resultFilename); // [Content_Types].xml - $this->assertStringContainsString('application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings', $resultContentTypesRaw, 'Content type for printerSettings not found!'); - $this->assertStringContainsString('application/vnd.ms-office.vbaProject', $resultContentTypesRaw, 'Content type for VbaProject not found!'); - $this->assertStringContainsString('application/vnd.ms-excel.controlproperties+xml', $resultContentTypesRaw, 'Content type for ctrlProp not found!'); + self::assertStringContainsString('application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings', $resultContentTypesRaw, 'Content type for printerSettings not found!'); + self::assertStringContainsString('application/vnd.ms-office.vbaProject', $resultContentTypesRaw, 'Content type for VbaProject not found!'); + self::assertStringContainsString('application/vnd.ms-excel.controlproperties+xml', $resultContentTypesRaw, 'Content type for ctrlProp not found!'); // xl/ctrlProps/ctrlProp1.xml - $this->assertNotEmpty($resultControlPropRaw, 'ctrlProp not found!'); + self::assertNotEmpty($resultControlPropRaw, 'ctrlProp not found!'); // xl/drawings/drawing1.xml - $this->assertStringContainsString('assertNotEmpty($resultVmlDrawingRaw, 'vmlDrawing not found!'); + self::assertNotEmpty($resultVmlDrawingRaw, 'vmlDrawing not found!'); // xl/printerSettings/printerSettings1.bin - $this->assertNotEmpty($resultPrinterSettingsRaw, 'printerSettings.bin not found!'); + self::assertNotEmpty($resultPrinterSettingsRaw, 'printerSettings.bin not found!'); // xl/vbaProject.bin - $this->assertNotEmpty($resultVbaProjectRaw, 'vbaProject.bin not found!'); + self::assertNotEmpty($resultVbaProjectRaw, 'vbaProject.bin not found!'); // xl/workbook.xml $xmlWorkbook = simplexml_load_string($resultWorkbookRaw, 'SimpleXMLElement', Settings::getLibXmlLoaderOptions()); if (!$xmlWorkbook->workbookProtection) { - $this->fail('workbook.xml/workbookProtection not found!'); + self::fail('workbook.xml/workbookProtection not found!'); } else { - $this->assertEquals($xmlWorkbook->workbookProtection['workbookPassword'], 'CBEB', 'workbook.xml/workbookProtection[workbookPassword] is wrong!'); - $this->assertEquals($xmlWorkbook->workbookProtection['lockStructure'], 'true', 'workbook.xml/workbookProtection[lockStructure] is wrong!'); + self::assertEquals($xmlWorkbook->workbookProtection['workbookPassword'], 'CBEB', 'workbook.xml/workbookProtection[workbookPassword] is wrong!'); + self::assertEquals($xmlWorkbook->workbookProtection['lockStructure'], 'true', 'workbook.xml/workbookProtection[lockStructure] is wrong!'); - $this->assertEquals($xmlWorkbook->sheets->sheet[0]['state'], '', 'workbook.xml/sheets/sheet[0][state] is wrong!'); - $this->assertEquals($xmlWorkbook->sheets->sheet[1]['state'], 'hidden', 'workbook.xml/sheets/sheet[1][state] is wrong!'); + self::assertEquals($xmlWorkbook->sheets->sheet[0]['state'], '', 'workbook.xml/sheets/sheet[0][state] is wrong!'); + self::assertEquals($xmlWorkbook->sheets->sheet[1]['state'], 'hidden', 'workbook.xml/sheets/sheet[1][state] is wrong!'); } unset($xmlWorkbook); // xl/worksheets/_rels/sheet1.xml.rels - $this->assertStringContainsString('http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings', $resultSheet1RelsRaw, 'Sheet relation with printerSettings not found!'); - $this->assertStringContainsString('http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing', $resultSheet1RelsRaw, 'Sheet relation with vmlDrawing not found!'); - $this->assertStringContainsString('http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp', $resultSheet1RelsRaw, 'Sheet relation with ctrlProp not found!'); + self::assertStringContainsString('http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings', $resultSheet1RelsRaw, 'Sheet relation with printerSettings not found!'); + self::assertStringContainsString('http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing', $resultSheet1RelsRaw, 'Sheet relation with vmlDrawing not found!'); + self::assertStringContainsString('http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp', $resultSheet1RelsRaw, 'Sheet relation with ctrlProp not found!'); // xl/worksheets/sheet1.xml - $this->assertStringContainsString('pageSetup->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $this->assertTrue(isset($pageSetupAttributes->id), 'sheet1.xml/pageSetup[r:id] not found!'); + self::assertTrue(isset($pageSetupAttributes->id), 'sheet1.xml/pageSetup[r:id] not found!'); if (!$xmlWorksheet->sheetProtection) { - $this->fail('sheet1.xml/sheetProtection not found!'); + self::fail('sheet1.xml/sheetProtection not found!'); } else { - $this->assertEquals($xmlWorksheet->sheetProtection['password'], 'CBEB', 'sheet1.xml/sheetProtection[password] is wrong!'); - $this->assertEquals($xmlWorksheet->sheetProtection['sheet'], 'true', 'sheet1.xml/sheetProtection[sheet] is wrong!'); - $this->assertEquals($xmlWorksheet->sheetProtection['objects'], 'true', 'sheet1.xml/sheetProtection[objects] is wrong!'); - $this->assertEquals($xmlWorksheet->sheetProtection['scenarios'], 'true', 'sheet1.xml/sheetProtection[scenarios] is wrong!'); + self::assertEquals($xmlWorksheet->sheetProtection['password'], 'CBEB', 'sheet1.xml/sheetProtection[password] is wrong!'); + self::assertEquals($xmlWorksheet->sheetProtection['sheet'], 'true', 'sheet1.xml/sheetProtection[sheet] is wrong!'); + self::assertEquals($xmlWorksheet->sheetProtection['objects'], 'true', 'sheet1.xml/sheetProtection[objects] is wrong!'); + self::assertEquals($xmlWorksheet->sheetProtection['scenarios'], 'true', 'sheet1.xml/sheetProtection[scenarios] is wrong!'); } unset($xmlWorksheet); // xl/worksheets/sheet2.xml - $this->assertNotEmpty($resultSheet2Raw, 'sheet2.xml not found!'); + self::assertNotEmpty($resultSheet2Raw, 'sheet2.xml not found!'); } } diff --git a/tests/data/Calculation/Calculation.php b/tests/data/Calculation/Calculation.php index 73dc6dad79..2f9e0a0c9c 100644 --- a/tests/data/Calculation/Calculation.php +++ b/tests/data/Calculation/Calculation.php @@ -56,12 +56,12 @@ function calculationTestDataGenerator() $set8 = [4, $dataArray5, $formula3, 'E5', ['A3'], ['B3']]; $dataArray6 = [ - ['=IF(22,"a","b")'] + ['=IF(22,"a","b")'], ]; $set9 = ['a', $dataArray6, '=A1', 'A2']; return [ - $set0, $set1, $set2, $set3, $set4, $set5, $set6, $set7, $set8, $set9 + $set0, $set1, $set2, $set3, $set4, $set5, $set6, $set7, $set8, $set9, ]; } diff --git a/tests/data/Calculation/DateTime/DATE.php b/tests/data/Calculation/DateTime/DATE.php index a7b3e7ccca..9acc6716b9 100644 --- a/tests/data/Calculation/DateTime/DATE.php +++ b/tests/data/Calculation/DateTime/DATE.php @@ -315,5 +315,5 @@ [ '#VALUE!', 2010, 3, 'GHI', - ] + ], ]; diff --git a/tests/data/Calculation/Financial/XIRR.php b/tests/data/Calculation/Financial/XIRR.php index 62b9b66825..3414d13252 100644 --- a/tests/data/Calculation/Financial/XIRR.php +++ b/tests/data/Calculation/Financial/XIRR.php @@ -8,84 +8,84 @@ 'If values and dates contain a different number of values, returns the #NUM! error value', [4000, -46000], ['2015-01-04'], - 0.1 + 0.1, ], [ '#NUM!', 'Expects at least one positive cash flow and one negative cash flow; otherwise returns the #NUM! error value', [-4000, -46000], ['2015-01-04', '2019-06-27'], - 0.1 + 0.1, ], [ '#NUM!', 'Expects at least one positive cash flow and one negative cash flow; otherwise returns the #NUM! error value', [4000, 46000], ['2015-01-04', '2019-06-27'], - 0.1 + 0.1, ], [ '#VALUE!', 'If any number in dates is not a valid date, returns the #VALUE! error value', [4000, -46000], ['2015-01-04', '2019X06-27'], - 0.1 + 0.1, ], [ '#VALUE!', 'If any entry in values is not numeric, returns the #VALUE! error value', ['y', -46000], ['2015-01-04', '2019-06-27'], - 0.1 + 0.1, ], [ '#NUM!', 'If values is not an array, returns the #NUM! error value', -46000, ['2015-01-04', '2019-06-27'], - 0.1 + 0.1, ], [ '#NUM!', 'If dates is not an array but values is, returns the #NUM! error value', [4000, -46000], '2015-01-04', - 0.1 + 0.1, ], [ '#N/A', 'If neither dates nor values is an array, returns the #N/A error value', 4000, '2015-01-04', - 0.1 + 0.1, ], [ 0.137963527441025, 'Dates can be in any order after all', [1893.67, 139947.43, 52573.25, 48849.74, 26369.16, -273029.18], ['2019-06-27', '2019-06-20', '2019-06-21', '2019-06-24', '2019-06-27', '2019-07-27'], - 0.1 + 0.1, ], [ 0.77868869226873, 'XIRR calculation #0 is incorrect', [4000, -46000], ['2015-04-01', '2019-06-27'], - 0.1 + 0.1, ], [ 0.137963527441025, 'XIRR calculation #1 is incorrect', [139947.43, 1893.67, 52573.25, 48849.74, 26369.16, -273029.18], ['2019-06-20', '2019-06-27', '2019-06-21', '2019-06-24', '2019-06-27', '2019-07-27'], - 0.1 + 0.1, ], [ 0.09999999, 'XIRR calculation #2 is incorrect', [100.0, -110.0], ['2019-06-12', '2020-06-11'], - 0.1 + 0.1, ], [ 3235.159644, @@ -116,7 +116,7 @@ 'Substitute for guess=0', [139947.43, 1893.67, 52573.25, 48849.74, 26369.16, -273029.18], ['2019-06-20', '2019-06-27', '2019-06-21', '2019-06-24', '2019-06-27', '2019-07-27'], - 0.00000 + 0.00000, ], [ '#NUM!', diff --git a/tests/data/Calculation/Financial/XNPV.php b/tests/data/Calculation/Financial/XNPV.php index a49c6218cc..4eca0a0133 100644 --- a/tests/data/Calculation/Financial/XNPV.php +++ b/tests/data/Calculation/Financial/XNPV.php @@ -42,7 +42,7 @@ '#VALUE!', 'If any value is non-numeric, return VALUE', 0.10, - [-1000.0, 1000.1, "x"], + [-1000.0, 1000.1, 'x'], ['2018-06-30', '2018-07-30', '2018-08-30'], ], [ diff --git a/tests/data/Calculation/Logical/SWITCH.php b/tests/data/Calculation/Logical/SWITCH.php index d062b7fe0e..df3d6051ea 100644 --- a/tests/data/Calculation/Logical/SWITCH.php +++ b/tests/data/Calculation/Logical/SWITCH.php @@ -3,44 +3,44 @@ return [ // Must be C [ - "C", - "A", - "A", - "C", - "B", - "D", - "??" + 'C', + 'A', + 'A', + 'C', + 'B', + 'D', + '??', ], // Must be Female [ - "Female", + 'Female', 2, - "1", - "Male", - "2", - "Female" + '1', + 'Male', + '2', + 'Female', ], // Must be X using default [ - "X", - "U", - "ABC", - "Y", - "DEF", - "Z", - "X" + 'X', + 'U', + 'ABC', + 'Y', + 'DEF', + 'Z', + 'X', ], // Must be N/A default value not defined [ - "#N/A", - "U", - "ABC", - "Y", - "DEF", - "Z" + '#N/A', + 'U', + 'ABC', + 'Y', + 'DEF', + 'Z', ], // Must be value - no parameter [ - "#VALUE!" + '#VALUE!', ], ]; diff --git a/tests/data/Calculation/LookupRef/CHOOSE.php b/tests/data/Calculation/LookupRef/CHOOSE.php index 020ef49872..06371c79eb 100644 --- a/tests/data/Calculation/LookupRef/CHOOSE.php +++ b/tests/data/Calculation/LookupRef/CHOOSE.php @@ -2,27 +2,27 @@ return [ [ - "brown", - 4, "red", "blue", "green", "brown", + 'brown', + 4, 'red', 'blue', 'green', 'brown', ], [ - "blue", - 2, "red", "blue", "green", "brown", + 'blue', + 2, 'red', 'blue', 'green', 'brown', ], [ - "green", - 3, "red", "blue", "green", "brown", + 'green', + 3, 'red', 'blue', 'green', 'brown', ], [ - "red", - 1, "red", "blue", "green", "brown", + 'red', + 1, 'red', 'blue', 'green', 'brown', ], [ - "#VALUE!", - 5, "red", "blue", "green", "brown", + '#VALUE!', + 5, 'red', 'blue', 'green', 'brown', ], [ - "#VALUE!", - 0, "red", "blue", "green", "brown", + '#VALUE!', + 0, 'red', 'blue', 'green', 'brown', ], ]; diff --git a/tests/data/Calculation/LookupRef/HLOOKUP.php b/tests/data/Calculation/LookupRef/HLOOKUP.php index 6a87a5a108..644ddeba7c 100644 --- a/tests/data/Calculation/LookupRef/HLOOKUP.php +++ b/tests/data/Calculation/LookupRef/HLOOKUP.php @@ -280,19 +280,19 @@ 'x', [ ['Selection column', '0', '0', '0', '0', 'x', 'x', 'x', 'x', 'x'], - ['Value to retrieve', 1, 2, 3, 4, 5, 6, 7, 8, 9] + ['Value to retrieve', 1, 2, 3, 4, 5, 6, 7, 8, 9], ], 2, - false + false, ], [ 2, 'B', [ ['Selection column', 'C', 'B', 'A'], - ['Value to retrieve', 3, 2, 1] + ['Value to retrieve', 3, 2, 1], ], 2, - false + false, ], ]; diff --git a/tests/data/Calculation/LookupRef/LOOKUP.php b/tests/data/Calculation/LookupRef/LOOKUP.php index a39f5e9a93..ab322d57bc 100644 --- a/tests/data/Calculation/LookupRef/LOOKUP.php +++ b/tests/data/Calculation/LookupRef/LOOKUP.php @@ -1,4 +1,5 @@ null, '0.7.A' => 6.7, '0.8.A' => 'STRING', - '0.9.A' => '' + '0.9.A' => '', ], ], [ diff --git a/tests/data/Calculation/Statistical/AVERAGE.php b/tests/data/Calculation/Statistical/AVERAGE.php index c566617280..d435e89bdd 100644 --- a/tests/data/Calculation/Statistical/AVERAGE.php +++ b/tests/data/Calculation/Statistical/AVERAGE.php @@ -38,7 +38,7 @@ '0.6.A' => null, '0.7.A' => 6.7, '0.8.A' => 'STRING', - '0.9.A' => '' + '0.9.A' => '', ], ], [ diff --git a/tests/data/Calculation/Statistical/AVERAGEIF.php b/tests/data/Calculation/Statistical/AVERAGEIF.php index bd9764715a..422a277130 100644 --- a/tests/data/Calculation/Statistical/AVERAGEIF.php +++ b/tests/data/Calculation/Statistical/AVERAGEIF.php @@ -4,22 +4,22 @@ [ 14000, [7000, 14000, 21000, 28000], - "<23000", + '<23000', ], [ 150000, [100000, 200000, 300000, 400000], - "<250000", + '<250000', ], [ '#DIV/0!', [100000, 200000, 300000, 400000], - "<95000", + '<95000', ], [ 24500, [100000, 200000, 300000, 400000], - ">250000", + '>250000', [7000, 14000, 21000, 28000], ], [ @@ -37,17 +37,17 @@ [ 7.8, [2012, 2012, 2013, 2011, 2011, 2010], - ">=2012", + '>=2012', [6, 10.4, 7, 12, 8, 15], ], [ 2011.2, [2012, 2012, 2013, 2011, 2011, 2010], - "<2013", + '<2013', ], [ 14000, [7000, 14000, 'Hello World', 21000, 28000], - "<23000", + '<23000', ], ]; diff --git a/tests/data/Calculation/Statistical/BasicCOUNT.php b/tests/data/Calculation/Statistical/BasicCOUNT.php index 8c0dc1c337..4e1d31b065 100644 --- a/tests/data/Calculation/Statistical/BasicCOUNT.php +++ b/tests/data/Calculation/Statistical/BasicCOUNT.php @@ -21,7 +21,7 @@ '', 4.8, 'Not a numeric', - 6 + 6, ], ], ]; diff --git a/tests/data/Calculation/Statistical/COUNTA.php b/tests/data/Calculation/Statistical/COUNTA.php index 579af954de..0e0ffb1589 100644 --- a/tests/data/Calculation/Statistical/COUNTA.php +++ b/tests/data/Calculation/Statistical/COUNTA.php @@ -24,7 +24,7 @@ '0.11.A' => '', '0.12.A' => 4.8, '0.13.A' => 'Not a numeric', - '0.14.A' => 6 + '0.14.A' => 6, ], ], [ @@ -45,7 +45,7 @@ '', 4.8, 'Not a numeric', - 6 + 6, ], ], ]; diff --git a/tests/data/Calculation/Statistical/FISHER.php b/tests/data/Calculation/Statistical/FISHER.php index 9588245886..fc35acba3e 100644 --- a/tests/data/Calculation/Statistical/FISHER.php +++ b/tests/data/Calculation/Statistical/FISHER.php @@ -12,5 +12,5 @@ [ 1.098612288668, 0.8, - ] + ], ]; diff --git a/tests/data/Calculation/Statistical/SLOPE.php b/tests/data/Calculation/Statistical/SLOPE.php index d0b7dbeb96..a635c0d076 100644 --- a/tests/data/Calculation/Statistical/SLOPE.php +++ b/tests/data/Calculation/Statistical/SLOPE.php @@ -42,7 +42,7 @@ 5, 4, 4, - ] + ], ], [ 0.305555555556, @@ -63,6 +63,6 @@ 5, 4, 4, - ] + ], ], ]; From 137268d61a84983f4e7590f965e76170251099b0 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 18 May 2020 15:49:29 +0900 Subject: [PATCH 049/659] Remove undesired annotations --- .php_cs.dist | 2 +- src/PhpSpreadsheet/Calculation/Database.php | 24 ----- src/PhpSpreadsheet/Calculation/DateTime.php | 22 ---- .../Calculation/Engineering.php | 48 --------- src/PhpSpreadsheet/Calculation/Financial.php | 40 ------- src/PhpSpreadsheet/Calculation/Functions.php | 24 ----- src/PhpSpreadsheet/Calculation/Logical.php | 20 ---- src/PhpSpreadsheet/Calculation/LookupRef.php | 4 +- src/PhpSpreadsheet/Calculation/MathTrig.php | 48 --------- .../Calculation/Statistical.php | 70 +----------- src/PhpSpreadsheet/Shared/OLE.php | 2 - src/PhpSpreadsheet/Shared/OLE/PPS.php | 2 - src/PhpSpreadsheet/Shared/OLE/PPS/File.php | 2 - src/PhpSpreadsheet/Shared/OLE/PPS/Root.php | 2 - src/PhpSpreadsheet/Worksheet/PageSetup.php | 4 - src/PhpSpreadsheet/Writer/Html.php | 2 - .../Writer/Ods/Cell/Comment.php | 3 - src/PhpSpreadsheet/Writer/Ods/Content.php | 6 -- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 100 +++++++++--------- src/PhpSpreadsheet/Writer/Xlsx/Theme.php | 5 - src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 5 - tests/PhpSpreadsheetTests/Reader/OdsTest.php | 2 +- 22 files changed, 55 insertions(+), 382 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 28c859009d..f8797e88de 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -56,7 +56,7 @@ return PhpCsFixer\Config::create() 'function_declaration' => true, 'function_to_constant' => true, 'function_typehint_space' => true, - 'general_phpdoc_annotation_remove' => false, // No use for that + 'general_phpdoc_annotation_remove' => ['access', 'category', 'copyright', 'method', 'throws'], 'global_namespace_import' => true, 'hash_to_slash_comment' => false, // Deprecated 'header_comment' => false, // We don't use common header in all our files diff --git a/src/PhpSpreadsheet/Calculation/Database.php b/src/PhpSpreadsheet/Calculation/Database.php index d31b00dd7d..965990884d 100644 --- a/src/PhpSpreadsheet/Calculation/Database.php +++ b/src/PhpSpreadsheet/Calculation/Database.php @@ -130,8 +130,6 @@ private static function getFilteredColumn($database, $field, $criteria) * Excel Function: * DAVERAGE(database,field,criteria) * - * @category Database Functions - * * @param mixed[] $database The range of cells that makes up the list or database. * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The @@ -174,8 +172,6 @@ public static function DAVERAGE($database, $field, $criteria) * Excel Function: * DAVERAGE(database,field,criteria) * - * @category Database Functions - * * @param mixed[] $database The range of cells that makes up the list or database. * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The @@ -217,8 +213,6 @@ public static function DCOUNT($database, $field, $criteria) * Excel Function: * DCOUNTA(database,[field],criteria) * - * @category Database Functions - * * @param mixed[] $database The range of cells that makes up the list or database. * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The @@ -269,8 +263,6 @@ public static function DCOUNTA($database, $field, $criteria) * Excel Function: * DGET(database,field,criteria) * - * @category Database Functions - * * @param mixed[] $database The range of cells that makes up the list or database. * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The @@ -313,8 +305,6 @@ public static function DGET($database, $field, $criteria) * Excel Function: * DMAX(database,field,criteria) * - * @category Database Functions - * * @param mixed[] $database The range of cells that makes up the list or database. * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The @@ -354,8 +344,6 @@ public static function DMAX($database, $field, $criteria) * Excel Function: * DMIN(database,field,criteria) * - * @category Database Functions - * * @param mixed[] $database The range of cells that makes up the list or database. * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The @@ -394,8 +382,6 @@ public static function DMIN($database, $field, $criteria) * Excel Function: * DPRODUCT(database,field,criteria) * - * @category Database Functions - * * @param mixed[] $database The range of cells that makes up the list or database. * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The @@ -435,8 +421,6 @@ public static function DPRODUCT($database, $field, $criteria) * Excel Function: * DSTDEV(database,field,criteria) * - * @category Database Functions - * * @param mixed[] $database The range of cells that makes up the list or database. * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The @@ -476,8 +460,6 @@ public static function DSTDEV($database, $field, $criteria) * Excel Function: * DSTDEVP(database,field,criteria) * - * @category Database Functions - * * @param mixed[] $database The range of cells that makes up the list or database. * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The @@ -516,8 +498,6 @@ public static function DSTDEVP($database, $field, $criteria) * Excel Function: * DSUM(database,field,criteria) * - * @category Database Functions - * * @param mixed[] $database The range of cells that makes up the list or database. * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The @@ -557,8 +537,6 @@ public static function DSUM($database, $field, $criteria) * Excel Function: * DVAR(database,field,criteria) * - * @category Database Functions - * * @param mixed[] $database The range of cells that makes up the list or database. * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The @@ -598,8 +576,6 @@ public static function DVAR($database, $field, $criteria) * Excel Function: * DVARP(database,field,criteria) * - * @category Database Functions - * * @param mixed[] $database The range of cells that makes up the list or database. * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index a57be297a1..d08ab54313 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -139,8 +139,6 @@ private static function adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0 * Excel Function: * NOW() * - * @category Date/Time Functions - * * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, * depending on the value of the ReturnDateType flag */ @@ -182,8 +180,6 @@ public static function DATETIMENOW() * Excel Function: * TODAY() * - * @category Date/Time Functions - * * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, * depending on the value of the ReturnDateType flag */ @@ -227,8 +223,6 @@ public static function DATENOW() * A Month name or abbreviation (English only at this point) such as 'January' or 'Jan' will still be accepted, * as will a day value with a suffix (e.g. '21st' rather than simply 21); again only English language. * - * @category Date/Time Functions - * * @param int $year The value of the year argument can include one to four digits. * Excel interprets the year argument according to the configured * date system: 1900 or 1904. @@ -341,8 +335,6 @@ public static function DATE($year = 0, $month = 1, $day = 1) * Excel Function: * TIME(hour,minute,second) * - * @category Date/Time Functions - * * @param int $hour A number from 0 (zero) to 32767 representing the hour. * Any value greater than 23 will be divided by 24 and the remainder * will be treated as the hour value. For example, TIME(27,0,0) = @@ -454,8 +446,6 @@ public static function TIME($hour = 0, $minute = 0, $second = 0) * Excel Function: * DATEVALUE(dateValue) * - * @category Date/Time Functions - * * @param string $dateValue Text that represents a date in a Microsoft Excel date format. * For example, "1/30/2008" or "30-Jan-2008" are text strings within * quotation marks that represent dates. Using the default date @@ -589,8 +579,6 @@ public static function DATEVALUE($dateValue = 1) * Excel Function: * TIMEVALUE(timeValue) * - * @category Date/Time Functions - * * @param string $timeValue A text string that represents a time in any one of the Microsoft * Excel time formats; for example, "6:45 PM" and "18:45" text strings * within quotation marks that represent time. @@ -768,8 +756,6 @@ public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') * Excel Function: * DAYS(endDate, startDate) * - * @category Date/Time Functions - * * @param DateTimeImmutable|float|int|string $endDate Excel date serial value (float), * PHP date timestamp (integer), PHP DateTime object, or a standard date string * @param DateTimeImmutable|float|int|string $startDate Excel date serial value (float), @@ -816,8 +802,6 @@ public static function DAYS($endDate = 0, $startDate = 0) * Excel Function: * DAYS360(startDate,endDate[,method]) * - * @category Date/Time Functions - * * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), * PHP DateTime object, or a standard date string * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), @@ -879,8 +863,6 @@ public static function DAYS360($startDate = 0, $endDate = 0, $method = false) * See https://lists.oasis-open.org/archives/office-formula/200806/msg00039.html * for description of algorithm used in Excel * - * @category Date/Time Functions - * * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), * PHP DateTime object, or a standard date string * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), @@ -981,8 +963,6 @@ public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) * Excel Function: * NETWORKDAYS(startDate,endDate[,holidays[,holiday[,...]]]) * - * @category Date/Time Functions - * * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), * PHP DateTime object, or a standard date string * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), @@ -1061,8 +1041,6 @@ public static function NETWORKDAYS($startDate, $endDate, ...$dateArgs) * Excel Function: * WORKDAY(startDate,endDays[,holidays[,holiday[,...]]]) * - * @category Date/Time Functions - * * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), * PHP DateTime object, or a standard date string * @param int $endDays The number of nonweekend and nonholiday days before or after diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php index aad35eecd2..dcbd53941a 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -776,8 +776,6 @@ private static function nbrConversionFormat($xVal, $places) * Excel Function: * BESSELI(x,ord) * - * @category Engineering Functions - * * @param float $x The value at which to evaluate the function. * If x is nonnumeric, BESSELI returns the #VALUE! error value. * @param int $ord The order of the Bessel function. @@ -831,8 +829,6 @@ public static function BESSELI($x, $ord) * Excel Function: * BESSELJ(x,ord) * - * @category Engineering Functions - * * @param float $x The value at which to evaluate the function. * If x is nonnumeric, BESSELJ returns the #VALUE! error value. * @param int $ord The order of the Bessel function. If n is not an integer, it is truncated. @@ -924,8 +920,6 @@ private static function besselK1($fNum) * Excel Function: * BESSELK(x,ord) * - * @category Engineering Functions - * * @param float $x The value at which to evaluate the function. * If x is nonnumeric, BESSELK returns the #VALUE! error value. * @param int $ord The order of the Bessel function. If n is not an integer, it is truncated. @@ -1013,8 +1007,6 @@ private static function besselY1($fNum) * Excel Function: * BESSELY(x,ord) * - * @category Engineering Functions - * * @param float $x The value at which to evaluate the function. * If x is nonnumeric, BESSELK returns the #VALUE! error value. * @param int $ord The order of the Bessel function. If n is not an integer, it is truncated. @@ -1067,8 +1059,6 @@ public static function BESSELY($x, $ord) * Excel Function: * BIN2DEC(x) * - * @category Engineering Functions - * * @param string $x The binary number (as a string) that you want to convert. The number * cannot contain more than 10 characters (10 bits). The most significant * bit of number is the sign bit. The remaining 9 bits are magnitude bits. @@ -1116,8 +1106,6 @@ public static function BINTODEC($x) * Excel Function: * BIN2HEX(x[,places]) * - * @category Engineering Functions - * * @param string $x The binary number (as a string) that you want to convert. The number * cannot contain more than 10 characters (10 bits). The most significant * bit of number is the sign bit. The remaining 9 bits are magnitude bits. @@ -1172,8 +1160,6 @@ public static function BINTOHEX($x, $places = null) * Excel Function: * BIN2OCT(x[,places]) * - * @category Engineering Functions - * * @param string $x The binary number (as a string) that you want to convert. The number * cannot contain more than 10 characters (10 bits). The most significant * bit of number is the sign bit. The remaining 9 bits are magnitude bits. @@ -1227,8 +1213,6 @@ public static function BINTOOCT($x, $places = null) * Excel Function: * DEC2BIN(x[,places]) * - * @category Engineering Functions - * * @param string $x The decimal integer you want to convert. If number is negative, * valid place values are ignored and DEC2BIN returns a 10-character * (10-bit) binary number in which the most significant bit is the sign @@ -1288,8 +1272,6 @@ public static function DECTOBIN($x, $places = null) * Excel Function: * DEC2HEX(x[,places]) * - * @category Engineering Functions - * * @param string $x The decimal integer you want to convert. If number is negative, * places is ignored and DEC2HEX returns a 10-character (40-bit) * hexadecimal number in which the most significant bit is the sign @@ -1343,8 +1325,6 @@ public static function DECTOHEX($x, $places = null) * Excel Function: * DEC2OCT(x[,places]) * - * @category Engineering Functions - * * @param string $x The decimal integer you want to convert. If number is negative, * places is ignored and DEC2OCT returns a 10-character (30-bit) * octal number in which the most significant bit is the sign bit. @@ -1399,8 +1379,6 @@ public static function DECTOOCT($x, $places = null) * Excel Function: * HEX2BIN(x[,places]) * - * @category Engineering Functions - * * @param string $x the hexadecimal number you want to convert. * Number cannot contain more than 10 characters. * The most significant bit of number is the sign bit (40th bit from the right). @@ -1444,8 +1422,6 @@ public static function HEXTOBIN($x, $places = null) * Excel Function: * HEX2DEC(x) * - * @category Engineering Functions - * * @param string $x The hexadecimal number you want to convert. This number cannot * contain more than 10 characters (40 bits). The most significant * bit of number is the sign bit. The remaining 39 bits are magnitude @@ -1495,8 +1471,6 @@ public static function HEXTODEC($x) * Excel Function: * HEX2OCT(x[,places]) * - * @category Engineering Functions - * * @param string $x The hexadecimal number you want to convert. Number cannot * contain more than 10 characters. The most significant bit of * number is the sign bit. The remaining 39 bits are magnitude @@ -1549,8 +1523,6 @@ public static function HEXTOOCT($x, $places = null) * Excel Function: * OCT2BIN(x[,places]) * - * @category Engineering Functions - * * @param string $x The octal number you want to convert. Number may not * contain more than 10 characters. The most significant * bit of number is the sign bit. The remaining 29 bits @@ -1600,8 +1572,6 @@ public static function OCTTOBIN($x, $places = null) * Excel Function: * OCT2DEC(x) * - * @category Engineering Functions - * * @param string $x The octal number you want to convert. Number may not contain * more than 10 octal characters (30 bits). The most significant * bit of number is the sign bit. The remaining 29 bits are @@ -1646,8 +1616,6 @@ public static function OCTTODEC($x) * Excel Function: * OCT2HEX(x[,places]) * - * @category Engineering Functions - * * @param string $x The octal number you want to convert. Number may not contain * more than 10 octal characters (30 bits). The most significant * bit of number is the sign bit. The remaining 29 bits are @@ -1693,8 +1661,6 @@ public static function OCTTOHEX($x, $places = null) * Excel Function: * COMPLEX(realNumber,imaginary[,suffix]) * - * @category Engineering Functions - * * @param float $realNumber the real coefficient of the complex number * @param float $imaginary the imaginary coefficient of the complex number * @param string $suffix The suffix for the imaginary component of the complex number. @@ -1727,8 +1693,6 @@ public static function COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i * Excel Function: * IMAGINARY(complexNumber) * - * @category Engineering Functions - * * @param string $complexNumber the complex number for which you want the imaginary * coefficient * @@ -1749,8 +1713,6 @@ public static function IMAGINARY($complexNumber) * Excel Function: * IMREAL(complexNumber) * - * @category Engineering Functions - * * @param string $complexNumber the complex number for which you want the real coefficient * * @return float @@ -2378,8 +2340,6 @@ private static function validateBitwiseArgument($value) * Excel Function: * BITAND(number1, number2) * - * @category Engineering Functions - * * @param int $number1 * @param int $number2 * @@ -2405,8 +2365,6 @@ public static function BITAND($number1, $number2) * Excel Function: * BITOR(number1, number2) * - * @category Engineering Functions - * * @param int $number1 * @param int $number2 * @@ -2432,8 +2390,6 @@ public static function BITOR($number1, $number2) * Excel Function: * BITXOR(number1, number2) * - * @category Engineering Functions - * * @param int $number1 * @param int $number2 * @@ -2459,8 +2415,6 @@ public static function BITXOR($number1, $number2) * Excel Function: * BITLSHIFT(number, shift_amount) * - * @category Engineering Functions - * * @param int $number * @param int $shiftAmount * @@ -2492,8 +2446,6 @@ public static function BITLSHIFT($number, $shiftAmount) * Excel Function: * BITRSHIFT(number, shift_amount) * - * @category Engineering Functions - * * @param int $number * @param int $shiftAmount * diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php index 624f035ac3..073e7c4883 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -114,8 +114,6 @@ private static function interestAndPrincipal($rate = 0, $per = 0, $nper = 0, $pv * Excel Function: * ACCRINT(issue,firstinterest,settlement,rate,par,frequency[,basis]) * - * @category Financial Functions - * * @param mixed $issue the security's issue date * @param mixed $firstinterest the security's first interest date * @param mixed $settlement The security's settlement date. @@ -175,8 +173,6 @@ public static function ACCRINT($issue, $firstinterest, $settlement, $rate, $par * Excel Function: * ACCRINTM(issue,settlement,rate[,par[,basis]]) * - * @category Financial Functions - * * @param mixed $issue The security's issue date * @param mixed $settlement The security's settlement (or maturity) date * @param float $rate The security's annual coupon rate @@ -233,8 +229,6 @@ public static function ACCRINTM($issue, $settlement, $rate, $par = 1000, $basis * Excel Function: * AMORDEGRC(cost,purchased,firstPeriod,salvage,period,rate[,basis]) * - * @category Financial Functions - * * @param float $cost The cost of the asset * @param mixed $purchased Date of the purchase of the asset * @param mixed $firstPeriod Date of the end of the first period @@ -311,8 +305,6 @@ public static function AMORDEGRC($cost, $purchased, $firstPeriod, $salvage, $per * Excel Function: * AMORLINC(cost,purchased,firstPeriod,salvage,period,rate[,basis]) * - * @category Financial Functions - * * @param float $cost The cost of the asset * @param mixed $purchased Date of the purchase of the asset * @param mixed $firstPeriod Date of the end of the first period @@ -370,8 +362,6 @@ public static function AMORLINC($cost, $purchased, $firstPeriod, $salvage, $peri * Excel Function: * COUPDAYBS(settlement,maturity,frequency[,basis]) * - * @category Financial Functions - * * @param mixed $settlement The security's settlement date. * The security settlement date is the date after the issue * date when the security is traded to the buyer. @@ -429,8 +419,6 @@ public static function COUPDAYBS($settlement, $maturity, $frequency, $basis = 0) * Excel Function: * COUPDAYS(settlement,maturity,frequency[,basis]) * - * @category Financial Functions - * * @param mixed $settlement The security's settlement date. * The security settlement date is the date after the issue * date when the security is traded to the buyer. @@ -499,8 +487,6 @@ public static function COUPDAYS($settlement, $maturity, $frequency, $basis = 0) * Excel Function: * COUPDAYSNC(settlement,maturity,frequency[,basis]) * - * @category Financial Functions - * * @param mixed $settlement The security's settlement date. * The security settlement date is the date after the issue * date when the security is traded to the buyer. @@ -554,8 +540,6 @@ public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis = 0 * Excel Function: * COUPNCD(settlement,maturity,frequency[,basis]) * - * @category Financial Functions - * * @param mixed $settlement The security's settlement date. * The security settlement date is the date after the issue * date when the security is traded to the buyer. @@ -608,8 +592,6 @@ public static function COUPNCD($settlement, $maturity, $frequency, $basis = 0) * Excel Function: * COUPNUM(settlement,maturity,frequency[,basis]) * - * @category Financial Functions - * * @param mixed $settlement The security's settlement date. * The security settlement date is the date after the issue * date when the security is traded to the buyer. @@ -662,8 +644,6 @@ public static function COUPNUM($settlement, $maturity, $frequency, $basis = 0) * Excel Function: * COUPPCD(settlement,maturity,frequency[,basis]) * - * @category Financial Functions - * * @param mixed $settlement The security's settlement date. * The security settlement date is the date after the issue * date when the security is traded to the buyer. @@ -715,8 +695,6 @@ public static function COUPPCD($settlement, $maturity, $frequency, $basis = 0) * Excel Function: * CUMIPMT(rate,nper,pv,start,end[,type]) * - * @category Financial Functions - * * @param float $rate The Interest rate * @param int $nper The total number of payment periods * @param float $pv Present Value @@ -763,8 +741,6 @@ public static function CUMIPMT($rate, $nper, $pv, $start, $end, $type = 0) * Excel Function: * CUMPRINC(rate,nper,pv,start,end[,type]) * - * @category Financial Functions - * * @param float $rate The Interest rate * @param int $nper The total number of payment periods * @param float $pv Present Value @@ -816,8 +792,6 @@ public static function CUMPRINC($rate, $nper, $pv, $start, $end, $type = 0) * Excel Function: * DB(cost,salvage,life,period[,month]) * - * @category Financial Functions - * * @param float $cost Initial cost of the asset * @param float $salvage Value at the end of the depreciation. * (Sometimes called the salvage value of the asset) @@ -883,8 +857,6 @@ public static function DB($cost, $salvage, $life, $period, $month = 12) * Excel Function: * DDB(cost,salvage,life,period[,factor]) * - * @category Financial Functions - * * @param float $cost Initial cost of the asset * @param float $salvage Value at the end of the depreciation. * (Sometimes called the salvage value of the asset) @@ -942,8 +914,6 @@ public static function DDB($cost, $salvage, $life, $period, $factor = 2.0) * Excel Function: * DISC(settlement,maturity,price,redemption[,basis]) * - * @category Financial Functions - * * @param mixed $settlement The security's settlement date. * The security settlement date is the date after the issue * date when the security is traded to the buyer. @@ -998,8 +968,6 @@ public static function DISC($settlement, $maturity, $price, $redemption, $basis * Excel Function: * DOLLARDE(fractional_dollar,fraction) * - * @category Financial Functions - * * @param float $fractional_dollar Fractional Dollar * @param int $fraction Fraction * @@ -1036,8 +1004,6 @@ public static function DOLLARDE($fractional_dollar = null, $fraction = 0) * Excel Function: * DOLLARFR(decimal_dollar,fraction) * - * @category Financial Functions - * * @param float $decimal_dollar Decimal Dollar * @param int $fraction Fraction * @@ -1073,8 +1039,6 @@ public static function DOLLARFR($decimal_dollar = null, $fraction = 0) * Excel Function: * EFFECT(nominal_rate,npery) * - * @category Financial Functions - * * @param float $nominal_rate Nominal interest rate * @param int $npery Number of compounding payments per year * @@ -1101,8 +1065,6 @@ public static function EFFECT($nominal_rate = 0, $npery = 0) * Excel Function: * FV(rate,nper,pmt[,pv[,type]]) * - * @category Financial Functions - * * @param float $rate The interest rate per period * @param int $nper Total number of payment periods in an annuity * @param float $pmt The payment made each period: it cannot change over the @@ -1837,8 +1799,6 @@ public static function PV($rate = 0, $nper = 0, $pmt = 0, $fv = 0, $type = 0) * Excel Function: * RATE(nper,pmt,pv[,fv[,type[,guess]]]) * - * @category Financial Functions - * * @param float $nper The total number of payment periods in an annuity * @param float $pmt The payment made each period and cannot change over the life * of the annuity. diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index af872dd707..148d75b321 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -57,8 +57,6 @@ class Functions /** * Set the Compatibility Mode. * - * @category Function Configuration - * * @param string $compatibilityMode Compatibility Mode * Permitted values are: * Functions::COMPATIBILITY_EXCEL 'Excel' @@ -84,8 +82,6 @@ public static function setCompatibilityMode($compatibilityMode) /** * Return the current Compatibility Mode. * - * @category Function Configuration - * * @return string Compatibility Mode * Possible Return values are: * Functions::COMPATIBILITY_EXCEL 'Excel' @@ -100,8 +96,6 @@ public static function getCompatibilityMode() /** * Set the Return Date Format used by functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object). * - * @category Function Configuration - * * @param string $returnDateType Return Date Format * Permitted values are: * Functions::RETURNDATE_UNIX_TIMESTAMP 'P' @@ -127,8 +121,6 @@ public static function setReturnDateType($returnDateType) /** * Return the current Return Date Format for functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object). * - * @category Function Configuration - * * @return string Return Date Format * Possible Return values are: * Functions::RETURNDATE_UNIX_TIMESTAMP 'P' @@ -143,8 +135,6 @@ public static function getReturnDateType() /** * DUMMY. * - * @category Error Returns - * * @return string #Not Yet Implemented */ public static function DUMMY() @@ -155,8 +145,6 @@ public static function DUMMY() /** * DIV0. * - * @category Error Returns - * * @return string #Not Yet Implemented */ public static function DIV0() @@ -173,8 +161,6 @@ public static function DIV0() * Returns the error value #N/A * #N/A is the error value that means "no value is available." * - * @category Logical Functions - * * @return string #N/A! */ public static function NA() @@ -187,8 +173,6 @@ public static function NA() * * Returns the error value #NUM! * - * @category Error Returns - * * @return string #NUM! */ public static function NAN() @@ -201,8 +185,6 @@ public static function NAN() * * Returns the error value #NAME? * - * @category Error Returns - * * @return string #NAME? */ public static function NAME() @@ -215,8 +197,6 @@ public static function NAME() * * Returns the error value #REF! * - * @category Error Returns - * * @return string #REF! */ public static function REF() @@ -229,8 +209,6 @@ public static function REF() * * Returns the error value #NULL! * - * @category Error Returns - * * @return string #NULL! */ public static function null() @@ -243,8 +221,6 @@ public static function null() * * Returns the error value #VALUE! * - * @category Error Returns - * * @return string #VALUE! */ public static function VALUE() diff --git a/src/PhpSpreadsheet/Calculation/Logical.php b/src/PhpSpreadsheet/Calculation/Logical.php index 416d119ac8..a362a27533 100644 --- a/src/PhpSpreadsheet/Calculation/Logical.php +++ b/src/PhpSpreadsheet/Calculation/Logical.php @@ -12,8 +12,6 @@ class Logical * Excel Function: * =TRUE() * - * @category Logical Functions - * * @return bool True */ public static function true() @@ -29,8 +27,6 @@ public static function true() * Excel Function: * =FALSE() * - * @category Logical Functions - * * @return bool False */ public static function false() @@ -80,8 +76,6 @@ private static function countTrueValues(array $args) * If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds * the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value * - * @category Logical Functions - * * @param mixed ...$args Data values * * @return bool|string the logical AND of the arguments @@ -123,8 +117,6 @@ public static function logicalAnd(...$args) * If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds * the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value * - * @category Logical Functions - * * @param mixed $args Data values * * @return bool|string the logical OR of the arguments @@ -166,8 +158,6 @@ public static function logicalOr(...$args) * If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds * the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value * - * @category Logical Functions - * * @param mixed $args Data values * * @return bool|string the logical XOR of the arguments @@ -207,8 +197,6 @@ public static function logicalXor(...$args) * If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds * the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value * - * @category Logical Functions - * * @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE * * @return bool|string the boolean inverse of the argument @@ -256,8 +244,6 @@ public static function NOT($logical = false) * If condition is FALSE and ReturnIfFalse is blank, then the value 0 (zero) is returned. * ReturnIfFalse can be another formula. * - * @category Logical Functions - * * @param mixed $condition Condition to evaluate * @param mixed $returnIfTrue Value to return when condition is true * @param mixed $returnIfFalse Optional value to return when condition is false @@ -294,8 +280,6 @@ public static function statementIf($condition = true, $returnIfTrue = 0, $return * default * Optional. It is the default to return if expression does not match any of the values (value1, value2, ... value_n). * - * @category Logical Functions - * * @param mixed $arguments Statement arguments * * @return mixed The value of matched expression @@ -337,8 +321,6 @@ public static function statementSwitch(...$arguments) * Excel Function: * =IFERROR(testValue,errorpart) * - * @category Logical Functions - * * @param mixed $testValue Value to check, is also the value returned when no error * @param mixed $errorpart Value to return when testValue is an error condition * @@ -358,8 +340,6 @@ public static function IFERROR($testValue = '', $errorpart = '') * Excel Function: * =IFNA(testValue,napart) * - * @category Logical Functions - * * @param mixed $testValue Value to check, is also the value returned when not an NA * @param mixed $napart Value to return when testValue is an NA condition * diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index 2d196aef51..f82724044b 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -230,8 +230,6 @@ public static function ROWS($cellAddress = null) * Excel Function: * =HYPERLINK(linkURL,displayName) * - * @category Logical Functions - * * @param string $linkURL Value to check, is also the value returned when no error * @param string $displayName Value to return when testValue is an error condition * @param Cell $pCell The cell to set the hyperlink in @@ -273,7 +271,7 @@ public static function HYPERLINK($linkURL = '', $displayName = null, ?Cell $pCel * * @return mixed The cells referenced by cellAddress * - * @todo Support for the optional a1 parameter introduced in Excel 2010 + * @TODO Support for the optional a1 parameter introduced in Excel 2010 */ public static function INDIRECT($cellAddress = null, ?Cell $pCell = null) { diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index 3db3fb8d05..d92ba4048a 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -47,8 +47,6 @@ private static function romanCut($num, $n) * Excel Function: * ARABIC(text) * - * @category Mathematical and Trigonometric Functions - * * @param string $roman * * @return int|string the arabic numberal contrived from the roman numeral @@ -136,8 +134,6 @@ protected static function calculateArabic(array $roman, &$sum = 0, $subtract = 0 * Excel Function: * ATAN2(xCoordinate,yCoordinate) * - * @category Mathematical and Trigonometric Functions - * * @param float $xCoordinate the x-coordinate of the point * @param float $yCoordinate the y-coordinate of the point * @@ -174,8 +170,6 @@ public static function ATAN2($xCoordinate = null, $yCoordinate = null) * Excel Function: * BASE(Number, Radix [Min_length]) * - * @category Mathematical and Trigonometric Functions - * * @param float $number * @param float $radix * @param int $minLength @@ -220,8 +214,6 @@ public static function BASE($number, $radix, $minLength = null) * Excel Function: * CEILING(number[,significance]) * - * @category Mathematical and Trigonometric Functions - * * @param float $number the number you want to round * @param float $significance the multiple to which you want to round * @@ -259,8 +251,6 @@ public static function CEILING($number, $significance = null) * Excel Function: * COMBIN(numObjs,numInSet) * - * @category Mathematical and Trigonometric Functions - * * @param int $numObjs Number of different objects * @param int $numInSet Number of objects in each combination * @@ -296,8 +286,6 @@ public static function COMBIN($numObjs, $numInSet) * Excel Function: * EVEN(number) * - * @category Mathematical and Trigonometric Functions - * * @param float $number Number to round * * @return int|string Rounded Number, or a string containing an error @@ -330,8 +318,6 @@ public static function EVEN($number) * Excel Function: * FACT(factVal) * - * @category Mathematical and Trigonometric Functions - * * @param float $factVal Factorial Value * * @return int|string Factorial, or a string containing an error @@ -369,8 +355,6 @@ public static function FACT($factVal) * Excel Function: * FACTDOUBLE(factVal) * - * @category Mathematical and Trigonometric Functions - * * @param float $factVal Factorial Value * * @return int|string Double Factorial, or a string containing an error @@ -404,8 +388,6 @@ public static function FACTDOUBLE($factVal) * Excel Function: * FLOOR(number[,significance]) * - * @category Mathematical and Trigonometric Functions - * * @param float $number Number to round * @param float $significance Significance * @@ -446,8 +428,6 @@ public static function FLOOR($number, $significance = null) * Excel Function: * FLOOR.MATH(number[,significance[,mode]]) * - * @category Mathematical and Trigonometric Functions - * * @param float $number Number to round * @param float $significance Significance * @param int $mode direction to round negative numbers @@ -487,8 +467,6 @@ public static function FLOORMATH($number, $significance = null, $mode = 0) * Excel Function: * FLOOR.PRECISE(number[,significance]) * - * @category Mathematical and Trigonometric Functions - * * @param float $number Number to round * @param float $significance Significance * @@ -527,8 +505,6 @@ private static function evaluateGCD($a, $b) * Excel Function: * GCD(number1[,number2[, ...]]) * - * @category Mathematical and Trigonometric Functions - * * @param mixed ...$args Data values * * @return int|mixed|string Greatest Common Divisor, or a string containing an error @@ -561,8 +537,6 @@ public static function GCD(...$args) * Excel Function: * INT(number) * - * @category Mathematical and Trigonometric Functions - * * @param float $number Number to cast to an integer * * @return int|string Integer value, or a string containing an error @@ -594,8 +568,6 @@ public static function INT($number) * Excel Function: * LCM(number1[,number2[, ...]]) * - * @category Mathematical and Trigonometric Functions - * * @param mixed ...$args Data values * * @return int|string Lowest Common Multiplier, or a string containing an error @@ -645,8 +617,6 @@ public static function LCM(...$args) * Excel Function: * LOG(number[,base]) * - * @category Mathematical and Trigonometric Functions - * * @param float $number The positive real number for which you want the logarithm * @param float $base The base of the logarithm. If base is omitted, it is assumed to be 10. * @@ -675,8 +645,6 @@ public static function logBase($number = null, $base = 10) * Excel Function: * MDETERM(array) * - * @category Mathematical and Trigonometric Functions - * * @param array $matrixValues A matrix of values * * @return float|string The result, or a string containing an error @@ -727,8 +695,6 @@ public static function MDETERM($matrixValues) * Excel Function: * MINVERSE(array) * - * @category Mathematical and Trigonometric Functions - * * @param array $matrixValues A matrix of values * * @return array|string The result, or a string containing an error @@ -999,8 +965,6 @@ public static function POWER($x = 0, $y = 2) * Excel Function: * PRODUCT(value1[,value2[, ...]]) * - * @category Mathematical and Trigonometric Functions - * * @param mixed ...$args Data values * * @return float @@ -1039,8 +1003,6 @@ public static function PRODUCT(...$args) * Excel Function: * QUOTIENT(value1[,value2[, ...]]) * - * @category Mathematical and Trigonometric Functions - * * @param mixed ...$args Data values * * @return float @@ -1364,8 +1326,6 @@ public static function SUBTOTAL(...$args) * Excel Function: * SUM(value1[,value2[, ...]]) * - * @category Mathematical and Trigonometric Functions - * * @param mixed ...$args Data values * * @return float @@ -1393,8 +1353,6 @@ public static function SUM(...$args) * Excel Function: * SUMIF(value1[,value2[, ...]],condition) * - * @category Mathematical and Trigonometric Functions - * * @param mixed $aArgs Data values * @param string $condition the criteria that defines which cells will be summed * @param mixed $sumArgs @@ -1439,8 +1397,6 @@ public static function SUMIF($aArgs, $condition, $sumArgs = []) * Excel Function: * SUMIFS(value1[,value2[, ...]],condition) * - * @category Mathematical and Trigonometric Functions - * * @param mixed $args Data values * * @return float @@ -1496,8 +1452,6 @@ public static function SUMIFS(...$args) * Excel Function: * SUMPRODUCT(value1[,value2[, ...]]) * - * @category Mathematical and Trigonometric Functions - * * @param mixed ...$args Data values * * @return float|string The result, or a string containing an error @@ -1541,8 +1495,6 @@ public static function SUMPRODUCT(...$args) * Excel Function: * SUMSQ(value1[,value2[, ...]]) * - * @category Mathematical and Trigonometric Functions - * * @param mixed ...$args Data values * * @return float diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php index 675f88efc5..100eb2fa0b 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -565,8 +565,6 @@ private static function isAcceptedCountable($arg, $k) * Excel Function: * AVEDEV(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -616,8 +614,6 @@ public static function AVEDEV(...$args) * Excel Function: * AVERAGE(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -657,8 +653,6 @@ public static function AVERAGE(...$args) * Excel Function: * AVERAGEA(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -700,8 +694,6 @@ public static function AVERAGEA(...$args) * Excel Function: * AVERAGEIF(value1[,value2[, ...]],condition) * - * @category Mathematical and Trigonometric Functions - * * @param mixed $aArgs Data values * @param string $condition the criteria that defines which cells will be checked * @param mixed[] $averageArgs Data values @@ -1053,8 +1045,6 @@ public static function CORREL($yValues, $xValues = null) * Excel Function: * COUNT(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return int @@ -1086,8 +1076,6 @@ public static function COUNT(...$args) * Excel Function: * COUNTA(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return int @@ -1116,8 +1104,6 @@ public static function COUNTA(...$args) * Excel Function: * COUNTBLANK(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return int @@ -1146,8 +1132,6 @@ public static function COUNTBLANK(...$args) * Excel Function: * COUNTIF(value1[,value2[, ...]],condition) * - * @category Statistical Functions - * * @param mixed $aArgs Data values * @param string $condition the criteria that defines which cells will be counted * @@ -1188,8 +1172,6 @@ public static function COUNTIF($aArgs, $condition) * Excel Function: * COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2]…) * - * @category Statistical Functions - * * @param mixed $args Criterias * * @return int @@ -1295,7 +1277,7 @@ public static function COVAR($yValues, $xValues) * * @return int|string * - * @todo Warning. This implementation differs from the algorithm detailed on the MS + * @TODO Warning. This implementation differs from the algorithm detailed on the MS * web site in that $CumPGuessMinus1 = $CumPGuess - 1 rather than $CumPGuess - $PGuess * This eliminates a potential endless loop error, but may have an adverse affect on the * accuracy of the function (although all my tests have so far returned correct results). @@ -1416,8 +1398,6 @@ public static function CRITBINOM($trials, $probability, $alpha) * Excel Function: * DEVSQ(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -1707,8 +1687,6 @@ public static function GAMMALN($value) * Excel Function: * GEOMEAN(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -1769,8 +1747,6 @@ public static function GROWTH($yValues, $xValues = [], $newValues = [], $const = * Excel Function: * HARMEAN(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -1924,8 +1900,6 @@ public static function KURT(...$args) * Excel Function: * LARGE(value1[,value2[, ...]],entry) * - * @category Statistical Functions - * * @param mixed $args Data values * * @return float|string The result, or a string containing an error @@ -2093,7 +2067,7 @@ public static function LOGEST($yValues, $xValues = null, $const = true, $stats = * * @return float|string The result, or a string containing an error * - * @todo Try implementing P J Acklam's refinement algorithm for greater + * @TODO Try implementing P J Acklam's refinement algorithm for greater * accuracy if I can get my head round the mathematics * (as described at) http://home.online.no/~pjacklam/notes/invnorm/ */ @@ -2152,8 +2126,6 @@ public static function LOGNORMDIST($value, $mean, $stdDev) * Excel Function: * MAX(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float @@ -2188,8 +2160,6 @@ public static function MAX(...$args) * Excel Function: * MAXA(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float @@ -2229,8 +2199,6 @@ public static function MAXA(...$args) * Excel Function: * MAXIFS(max_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...) * - * @category Statistical Functions - * * @param mixed $args Data range and criterias * * @return float @@ -2288,8 +2256,6 @@ public static function MAXIFS(...$args) * Excel Function: * MEDIAN(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string The result, or a string containing an error @@ -2332,8 +2298,6 @@ public static function MEDIAN(...$args) * Excel Function: * MIN(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float @@ -2368,8 +2332,6 @@ public static function MIN(...$args) * Excel Function: * MINA(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float @@ -2409,8 +2371,6 @@ public static function MINA(...$args) * Excel Function: * MINIFS(min_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...) * - * @category Statistical Functions - * * @param mixed $args Data range and criterias * * @return float @@ -2517,8 +2477,6 @@ private static function modeCalc($data) * Excel Function: * MODE(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string The result, or a string containing an error @@ -2691,8 +2649,6 @@ public static function NORMSINV($value) * Excel Function: * PERCENTILE(value1[,value2[, ...]],entry) * - * @category Statistical Functions - * * @param mixed $args Data values * * @return float|string The result, or a string containing an error @@ -2860,8 +2816,6 @@ public static function POISSON($value, $mean, $cumulative) * Excel Function: * QUARTILE(value1[,value2[, ...]],entry) * - * @category Statistical Functions - * * @param mixed $args Data values * * @return float|string The result, or a string containing an error @@ -3027,8 +2981,6 @@ public static function SLOPE($yValues, $xValues) * Excel Function: * SMALL(value1[,value2[, ...]],entry) * - * @category Statistical Functions - * * @param mixed $args Data values * * @return float|string The result, or a string containing an error @@ -3098,8 +3050,6 @@ public static function STANDARDIZE($value, $mean, $stdDev) * Excel Function: * STDEV(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string The result, or a string containing an error @@ -3147,8 +3097,6 @@ public static function STDEV(...$args) * Excel Function: * STDEVA(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -3199,8 +3147,6 @@ public static function STDEVA(...$args) * Excel Function: * STDEVP(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -3246,8 +3192,6 @@ public static function STDEVP(...$args) * Excel Function: * STDEVPA(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -3484,8 +3428,6 @@ public static function TREND($yValues, $xValues = [], $newValues = [], $const = * Excel Function: * TRIMEAN(value1[,value2[, ...]], $discard) * - * @category Statistical Functions - * * @param mixed $args Data values * * @return float|string @@ -3529,8 +3471,6 @@ public static function TRIMMEAN(...$args) * Excel Function: * VAR(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float @@ -3573,8 +3513,6 @@ public static function VARFunc(...$args) * Excel Function: * VARA(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float @@ -3626,8 +3564,6 @@ public static function VARA(...$args) * Excel Function: * VARP(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float @@ -3671,8 +3607,6 @@ public static function VARP(...$args) * Excel Function: * VARPA(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float diff --git a/src/PhpSpreadsheet/Shared/OLE.php b/src/PhpSpreadsheet/Shared/OLE.php index 27c72acd0e..32b56e1871 100644 --- a/src/PhpSpreadsheet/Shared/OLE.php +++ b/src/PhpSpreadsheet/Shared/OLE.php @@ -38,8 +38,6 @@ * * @author Xavier Noguer * @author Christian Schmidt - * - * @category PhpSpreadsheet */ class OLE { diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS.php b/src/PhpSpreadsheet/Shared/OLE/PPS.php index e53f2575fc..0407e0d1d5 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS.php @@ -26,8 +26,6 @@ * Class for creating PPS's for OLE containers. * * @author Xavier Noguer - * - * @category PhpSpreadsheet */ class PPS { diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/File.php b/src/PhpSpreadsheet/Shared/OLE/PPS/File.php index b7425af43f..dd1cda2de0 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/File.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/File.php @@ -27,8 +27,6 @@ * Class for creating File PPS's for OLE containers. * * @author Xavier Noguer - * - * @category PhpSpreadsheet */ class File extends PPS { diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php index 0d70df6d29..11655c6505 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php @@ -27,8 +27,6 @@ * Class for creating Root PPS's for OLE containers. * * @author Xavier Noguer - * - * @category PhpSpreadsheet */ class Root extends PPS { diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index 19eabcf493..f29dbad599 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -76,10 +76,6 @@ * 67 = A3 transverse paper (297 mm by 420 mm) * 68 = A3 extra transverse paper (322 mm by 445 mm) * - * - * @category PhpSpreadsheet - * - * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) */ class PageSetup { diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 65b04c7d69..c9f2d7cbfd 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -1448,8 +1448,6 @@ private function generateRowWriteCell(&$html, $pSheet, $coordinate, $cellType, $ * @param int $pRow Row number (0-based) * @param string $cellType eg: 'td' * - * @throws WriterException - * * @return string */ private function generateRow(Worksheet $pSheet, array $pValues, $pRow, $cellType) diff --git a/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php b/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php index 880a8554f1..b0829bf1de 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php +++ b/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php @@ -6,9 +6,6 @@ use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; /** - * @category PhpSpreadsheet - * - * @copyright Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @author Alexander Pervakov */ class Comment diff --git a/src/PhpSpreadsheet/Writer/Ods/Content.php b/src/PhpSpreadsheet/Writer/Ods/Content.php index cb6c66282d..6588473a93 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Content.php +++ b/src/PhpSpreadsheet/Writer/Ods/Content.php @@ -12,15 +12,9 @@ use PhpOffice\PhpSpreadsheet\Worksheet\Row; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Writer\Exception; -use PhpOffice\PhpSpreadsheet\Writer\Ods; use PhpOffice\PhpSpreadsheet\Writer\Ods\Cell\Comment; /** - * @category PhpSpreadsheet - * - * @method Ods getParentWriter - * - * @copyright Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @author Alexander Pervakov */ class Content extends WriterPart diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index f6b3e29734..0dce7ba54e 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -538,7 +538,7 @@ public function close(): void $arrConditionalStyles = $phpSheet->getConditionalStylesCollection(); if (!empty($arrConditionalStyles)) { $arrConditional = []; - // @todo CFRule & CFHeader + // @TODO CFRule & CFHeader // Write CFHEADER record $this->writeCFHeader(); // Write ConditionalFormattingTable records @@ -607,6 +607,7 @@ public function getData() return $tmp; } + // No data to return return false; } @@ -881,8 +882,8 @@ private function writeFormula($row, $col, $formula, $xfIndex, $calculatedValue) $header = pack('vv', $record, $length); $data = pack('vvv', $row, $col, $xfIndex) - . $num - . pack('vVv', $grbit, $unknown, $formlen); + . $num + . pack('vVv', $grbit, $unknown, $formlen); $this->append($header . $data . $formula); // Append also a STRING record if necessary @@ -945,8 +946,6 @@ private function writeUrl($row, $col, $url) * to be written. These are either, Web (http, ftp, mailto), Internal * (Sheet1!A1) or external ('c:\temp\foo.xls#Sheet1!A1'). * - * @see writeUrl() - * * @param int $row1 Start row * @param int $col1 Start column * @param int $row2 End row @@ -954,6 +953,8 @@ private function writeUrl($row, $col, $url) * @param string $url URL string * * @return int + * + * @see writeUrl() */ public function writeUrlRange($row1, $col1, $row2, $col2, $url) { @@ -973,8 +974,6 @@ public function writeUrlRange($row1, $col1, $row2, $col2, $url) * The link type ($options) is 0x03 is the same as absolute dir ref without * sheet. However it is differentiated by the $unknown2 data stream. * - * @see writeUrl() - * * @param int $row1 Start row * @param int $col1 Start column * @param int $row2 End row @@ -982,6 +981,8 @@ public function writeUrlRange($row1, $col1, $row2, $col2, $url) * @param string $url URL string * * @return int + * + * @see writeUrl() */ public function writeUrlWeb($row1, $col1, $row2, $col2, $url) { @@ -1018,8 +1019,6 @@ public function writeUrlWeb($row1, $col1, $row2, $col2, $url) /** * Used to write internal reference hyperlinks such as "Sheet1!A1". * - * @see writeUrl() - * * @param int $row1 Start row * @param int $col1 Start column * @param int $row2 End row @@ -1027,6 +1026,8 @@ public function writeUrlWeb($row1, $col1, $row2, $col2, $url) * @param string $url URL string * * @return int + * + * @see writeUrl() */ public function writeUrlInternal($row1, $col1, $row2, $col2, $url) { @@ -1071,8 +1072,6 @@ public function writeUrlInternal($row1, $col1, $row2, $col2, $url) * Note: Excel writes some relative links with the $dir_long string. We ignore * these cases for the sake of simpler code. * - * @see writeUrl() - * * @param int $row1 Start row * @param int $col1 Start column * @param int $row2 End row @@ -1080,6 +1079,8 @@ public function writeUrlInternal($row1, $col1, $row2, $col2, $url) * @param string $url URL string * * @return int + * + * @see writeUrl() */ public function writeUrlExternal($row1, $col1, $row2, $col2, $url) { @@ -1142,14 +1143,14 @@ public function writeUrlExternal($row1, $col1, $row2, $col2, $url) // Pack the main data stream $data = pack('vvvv', $row1, $row2, $col1, $col2) . - $unknown1 . - $link_type . - $unknown2 . - $up_count . - $dir_short_len . - $dir_short . - $unknown3 . - $stream_len; /*. + $unknown1 . + $link_type . + $unknown2 . + $up_count . + $dir_short_len . + $dir_short . + $unknown3 . + $stream_len; /*. $dir_long_len . $unknown4 . $dir_long . @@ -1534,20 +1535,20 @@ private function writeSheetProtection(): void // prepare options $options = (int) !$this->phpSheet->getProtection()->getObjects() - | (int) !$this->phpSheet->getProtection()->getScenarios() << 1 - | (int) !$this->phpSheet->getProtection()->getFormatCells() << 2 - | (int) !$this->phpSheet->getProtection()->getFormatColumns() << 3 - | (int) !$this->phpSheet->getProtection()->getFormatRows() << 4 - | (int) !$this->phpSheet->getProtection()->getInsertColumns() << 5 - | (int) !$this->phpSheet->getProtection()->getInsertRows() << 6 - | (int) !$this->phpSheet->getProtection()->getInsertHyperlinks() << 7 - | (int) !$this->phpSheet->getProtection()->getDeleteColumns() << 8 - | (int) !$this->phpSheet->getProtection()->getDeleteRows() << 9 - | (int) !$this->phpSheet->getProtection()->getSelectLockedCells() << 10 - | (int) !$this->phpSheet->getProtection()->getSort() << 11 - | (int) !$this->phpSheet->getProtection()->getAutoFilter() << 12 - | (int) !$this->phpSheet->getProtection()->getPivotTables() << 13 - | (int) !$this->phpSheet->getProtection()->getSelectUnlockedCells() << 14; + | (int) !$this->phpSheet->getProtection()->getScenarios() << 1 + | (int) !$this->phpSheet->getProtection()->getFormatCells() << 2 + | (int) !$this->phpSheet->getProtection()->getFormatColumns() << 3 + | (int) !$this->phpSheet->getProtection()->getFormatRows() << 4 + | (int) !$this->phpSheet->getProtection()->getInsertColumns() << 5 + | (int) !$this->phpSheet->getProtection()->getInsertRows() << 6 + | (int) !$this->phpSheet->getProtection()->getInsertHyperlinks() << 7 + | (int) !$this->phpSheet->getProtection()->getDeleteColumns() << 8 + | (int) !$this->phpSheet->getProtection()->getDeleteRows() << 9 + | (int) !$this->phpSheet->getProtection()->getSelectLockedCells() << 10 + | (int) !$this->phpSheet->getProtection()->getSort() << 11 + | (int) !$this->phpSheet->getProtection()->getAutoFilter() << 12 + | (int) !$this->phpSheet->getProtection()->getPivotTables() << 13 + | (int) !$this->phpSheet->getProtection()->getSelectUnlockedCells() << 14; // record data $recordData = pack( @@ -3014,7 +3015,7 @@ private function writeCFRule(Conditional $conditional): void $operatorType = 0x01; break; - // not OPERATOR_NOTBETWEEN 0x02 + // not OPERATOR_NOTBETWEEN 0x02 } } @@ -3062,13 +3063,13 @@ private function writeCFRule(Conditional $conditional): void } // Border $bBorderLeft = ($conditional->getStyle()->getBorders()->getLeft()->getColor()->getARGB() == Color::COLOR_BLACK - && $conditional->getStyle()->getBorders()->getLeft()->getBorderStyle() == Border::BORDER_NONE ? 1 : 0); + && $conditional->getStyle()->getBorders()->getLeft()->getBorderStyle() == Border::BORDER_NONE ? 1 : 0); $bBorderRight = ($conditional->getStyle()->getBorders()->getRight()->getColor()->getARGB() == Color::COLOR_BLACK - && $conditional->getStyle()->getBorders()->getRight()->getBorderStyle() == Border::BORDER_NONE ? 1 : 0); + && $conditional->getStyle()->getBorders()->getRight()->getBorderStyle() == Border::BORDER_NONE ? 1 : 0); $bBorderTop = ($conditional->getStyle()->getBorders()->getTop()->getColor()->getARGB() == Color::COLOR_BLACK - && $conditional->getStyle()->getBorders()->getTop()->getBorderStyle() == Border::BORDER_NONE ? 1 : 0); + && $conditional->getStyle()->getBorders()->getTop()->getBorderStyle() == Border::BORDER_NONE ? 1 : 0); $bBorderBottom = ($conditional->getStyle()->getBorders()->getBottom()->getColor()->getARGB() == Color::COLOR_BLACK - && $conditional->getStyle()->getBorders()->getBottom()->getBorderStyle() == Border::BORDER_NONE ? 1 : 0); + && $conditional->getStyle()->getBorders()->getBottom()->getBorderStyle() == Border::BORDER_NONE ? 1 : 0); if ($bBorderLeft == 0 || $bBorderRight == 0 || $bBorderTop == 0 || $bBorderBottom == 0) { $bFormatBorder = 1; } else { @@ -3767,16 +3768,15 @@ private function writeCFRule(Conditional $conditional): void break; } - /** - *@todo writeCFRule() => $blockLineStyle => Index Color for left line - *@todo writeCFRule() => $blockLineStyle => Index Color for right line - *@todo writeCFRule() => $blockLineStyle => Top-left to bottom-right on/off - *@todo writeCFRule() => $blockLineStyle => Bottom-left to top-right on/off - */ + + // TODO writeCFRule() => $blockLineStyle => Index Color for left line + // TODO writeCFRule() => $blockLineStyle => Index Color for right line + // TODO writeCFRule() => $blockLineStyle => Top-left to bottom-right on/off + // TODO writeCFRule() => $blockLineStyle => Bottom-left to top-right on/off $blockColor = 0; - //@todo writeCFRule() => $blockColor => Index Color for top line - //@todo writeCFRule() => $blockColor => Index Color for bottom line - //@todo writeCFRule() => $blockColor => Index Color for diagonal line + // TODO writeCFRule() => $blockColor => Index Color for top line + // TODO writeCFRule() => $blockColor => Index Color for bottom line + // TODO writeCFRule() => $blockColor => Index Color for diagonal line switch ($conditional->getStyle()->getBorders()->getDiagonal()->getBorderStyle()) { case Border::BORDER_NONE: $blockColor |= 0x00 << 21; @@ -4157,7 +4157,7 @@ private function writeCFRule(Conditional $conditional): void break; default: - $colorIdxBg = 0x41; + $colorIdxBg = 0x41; break; } @@ -4388,7 +4388,7 @@ private function writeCFRule(Conditional $conditional): void break; default: - $colorIdxFg = 0x40; + $colorIdxFg = 0x40; break; } @@ -4447,7 +4447,7 @@ private function writeCFHeader(): void foreach ($this->phpSheet->getConditionalStylesCollection() as $cellCoordinate => $conditionalStyles) { foreach ($conditionalStyles as $conditional) { if ($conditional->getConditionType() == Conditional::CONDITION_EXPRESSION - || $conditional->getConditionType() == Conditional::CONDITION_CELLIS) { + || $conditional->getConditionType() == Conditional::CONDITION_CELLIS) { if (!in_array($conditional->getHashCode(), $arrConditional)) { $arrConditional[] = $conditional->getHashCode(); } diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Theme.php b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php index 5119117afd..3a47be7fb6 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Theme.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php @@ -5,11 +5,6 @@ use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; use PhpOffice\PhpSpreadsheet\Spreadsheet; -/** - * @category PhpSpreadsheet - * - * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) - */ class Theme extends WriterPart { /** diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 25b09d1978..15359a4cc4 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -13,11 +13,6 @@ use PhpOffice\PhpSpreadsheet\Worksheet\SheetView; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet as PhpspreadsheetWorksheet; -/** - * @category PhpSpreadsheet - * - * @copyright Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) - */ class Worksheet extends WriterPart { /** diff --git a/tests/PhpSpreadsheetTests/Reader/OdsTest.php b/tests/PhpSpreadsheetTests/Reader/OdsTest.php index 6b11149788..0aeb55703c 100644 --- a/tests/PhpSpreadsheetTests/Reader/OdsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/OdsTest.php @@ -10,7 +10,7 @@ use PHPUnit\Framework\TestCase; /** - * @todo The class doesn't read the bold/italic/underline properties (rich text) + * @TODO The class doesn't read the bold/italic/underline properties (rich text) */ class OdsTest extends TestCase { From be415fab563683cdfec38c32adc95df0f9efd606 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 18 May 2020 15:50:46 +0900 Subject: [PATCH 050/659] Update functions list --- docs/references/function-list-by-category.md | 4 ++++ docs/references/function-list-by-name.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/docs/references/function-list-by-category.md b/docs/references/function-list-by-category.md index 9f76845918..49bb66c0ed 100644 --- a/docs/references/function-list-by-category.md +++ b/docs/references/function-list-by-category.md @@ -200,6 +200,8 @@ ISREF | **Not yet Implemented** ISTEXT | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isText N | \PhpOffice\PhpSpreadsheet\Calculation\Functions::n NA | \PhpOffice\PhpSpreadsheet\Calculation\Functions::NA +SHEET | **Not yet Implemented** +SHEETS | **Not yet Implemented** TYPE | \PhpOffice\PhpSpreadsheet\Calculation\Functions::TYPE ## CATEGORY_LOGICAL @@ -272,6 +274,8 @@ EXP | exp FACT | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::FACT FACTDOUBLE | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::FACTDOUBLE FLOOR | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::FLOOR +FLOOR.MATH | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::FLOORMATH +FLOOR.PRECISE | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::FLOORPRECISE GCD | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::GCD INT | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::INT LCM | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::LCM diff --git a/docs/references/function-list-by-name.md b/docs/references/function-list-by-name.md index 709b4b1da3..f5493d039c 100644 --- a/docs/references/function-list-by-name.md +++ b/docs/references/function-list-by-name.md @@ -170,6 +170,8 @@ FISHER | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet FISHERINV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::FISHERINV FIXED | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::FIXEDFORMAT FLOOR | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::FLOOR +FLOOR.MATH | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::FLOORMATH +FLOOR.PRECISE | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::FLOORPRECISE FORECAST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::FORECAST FORMULATEXT | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::FORMULATEXT FREQUENCY | CATEGORY_STATISTICAL | **Not yet Implemented** @@ -419,6 +421,8 @@ SEC | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet SECH | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SECH SECOND | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::SECOND SERIESSUM | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SERIESSUM +SHEET | CATEGORY_INFORMATION | **Not yet Implemented** +SHEETS | CATEGORY_INFORMATION | **Not yet Implemented** SIGN | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SIGN SIN | CATEGORY_MATH_AND_TRIG | sin SINH | CATEGORY_MATH_AND_TRIG | sinh From 7b1957f996be566766aec370197dfacdd898592b Mon Sep 17 00:00:00 2001 From: Gianni Genovesi Date: Sat, 23 May 2020 12:49:54 +0200 Subject: [PATCH 051/659] fix: issue #1476 crash with numeric string value terminating with new line (#1481) * fix: issue #1476 crash with numeric string value terminating with new line * test: provided tests for issue #1476 --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Cell/DefaultValueBinder.php | 2 ++ tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php | 1 + tests/data/Cell/DefaultValueBinder.php | 4 ++++ 4 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27d72197f3..eb9b381036 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Fix RATE, PRICE, XIRR, and XNPV Functions [#1456](https://github.com/PHPOffice/PhpSpreadsheet/pull/1456) - Save Excel 2010+ functions properly in XLSX [#1461](https://github.com/PHPOffice/PhpSpreadsheet/pull/1461) - Several improvements in HTML writer [#1464](https://github.com/PHPOffice/PhpSpreadsheet/pull/1464) +- Fix Crash while trying setting a cell the value "123456\n" [#1476](https://github.com/PHPOffice/PhpSpreadsheet/pull/1481) ### Changed diff --git a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php index 3a676c4f89..693446e698 100644 --- a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php +++ b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php @@ -65,6 +65,8 @@ public static function dataTypeForValue($pValue) return DataType::TYPE_STRING; } elseif ((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) { return DataType::TYPE_STRING; + } elseif (!is_numeric($pValue)) { + return DataType::TYPE_STRING; } return DataType::TYPE_NUMERIC; diff --git a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php index 90dabce3f1..e13cd9424b 100644 --- a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php @@ -57,6 +57,7 @@ public function binderProvider() ['#REF!'], [new DateTime()], [new DateTimeImmutable()], + ['123456\n'], ]; } diff --git a/tests/data/Cell/DefaultValueBinder.php b/tests/data/Cell/DefaultValueBinder.php index 53ba628190..1f0c40e06d 100644 --- a/tests/data/Cell/DefaultValueBinder.php +++ b/tests/data/Cell/DefaultValueBinder.php @@ -73,4 +73,8 @@ 'e', '#DIV/0!', ], + [ + 's', + '123456\n', + ], ]; From 0945e87b6da1db95cf94b0cdd92db5456657de61 Mon Sep 17 00:00:00 2001 From: F0Rt04ka Date: Sat, 23 May 2020 17:51:48 +0700 Subject: [PATCH 052/659] Fix "Undefined offset" if border style is "none" (#1423) --- src/PhpSpreadsheet/Reader/Html.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 5e12a2fb8c..2fe85b6f32 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -933,7 +933,12 @@ public function getBorderStyle($style) */ private function setBorderStyle(Style $cellStyle, $styleValue, $type): void { - [, $borderStyle, $color] = explode(' ', $styleValue); + if (trim($styleValue) === Border::BORDER_NONE) { + $borderStyle = Border::BORDER_NONE; + $color = null; + } else { + [, $borderStyle, $color] = explode(' ', $styleValue); + } $cellStyle->applyFromArray([ 'borders' => [ From 6c23de78d8a147557aa2b3cc0c154c51bb35df83 Mon Sep 17 00:00:00 2001 From: Collie-IT <40590185+Collie-IT@users.noreply.github.com> Date: Sat, 23 May 2020 12:56:26 +0200 Subject: [PATCH 053/659] Fix Warning if $relsVML->Relationship is NULL (#1420) Fix Warning if $relsVML->Relationship is NULL (#1420) --- src/PhpSpreadsheet/Reader/Xlsx.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 77035a39b4..797e59eafb 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -1000,12 +1000,13 @@ public function load($pFilename) Settings::getLibXmlLoaderOptions() ); $drawings = []; - foreach ($relsVML->Relationship as $ele) { - if ($ele['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image') { - $drawings[(string) $ele['Id']] = self::dirAdd($vmlRelationship, $ele['Target']); + if (isset($relsVML->Relationship)) { + foreach ($relsVML->Relationship as $ele) { + if ($ele['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image') { + $drawings[(string) $ele['Id']] = self::dirAdd($vmlRelationship, $ele['Target']); + } } } - // Fetch VML document $vmlDrawing = simplexml_load_string( $this->securityScanner->scan($this->getFromZipArchive($zip, $vmlRelationship)), From 3446bb0ef781465f12e073b918dace0cffd03a18 Mon Sep 17 00:00:00 2001 From: Vagir Date: Sat, 23 May 2020 14:09:10 +0300 Subject: [PATCH 054/659] Fix saving XLSX with drawings (#1462) * Fix incorrect behaviour when saving XLSX file with drawings --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Writer/Xlsx/Rels.php | 11 +++-- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 1 + .../Writer/Xlsx/DrawingsTest.php | 45 ++++++++++++++++++ .../data/Writer/XLSX/drawing_on_2nd_page.xlsx | Bin 0 -> 16265 bytes 5 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/Writer/Xlsx/DrawingsTest.php create mode 100644 tests/data/Writer/XLSX/drawing_on_2nd_page.xlsx diff --git a/CHANGELOG.md b/CHANGELOG.md index eb9b381036..22fd8c3d74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Fix RATE, PRICE, XIRR, and XNPV Functions [#1456](https://github.com/PHPOffice/PhpSpreadsheet/pull/1456) - Save Excel 2010+ functions properly in XLSX [#1461](https://github.com/PHPOffice/PhpSpreadsheet/pull/1461) - Several improvements in HTML writer [#1464](https://github.com/PHPOffice/PhpSpreadsheet/pull/1464) +- Fix incorrect behaviour when saving XLSX file with drawings [#1462](https://github.com/PHPOffice/PhpSpreadsheet/pull/1462), - Fix Crash while trying setting a cell the value "123456\n" [#1476](https://github.com/PHPOffice/PhpSpreadsheet/pull/1481) ### Changed diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php index c28760657c..a4e5769e74 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php @@ -183,7 +183,6 @@ public function writeWorksheetRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\ $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); // Write drawing relationships? - $d = 0; $drawingOriginalIds = []; $unparsedLoadedData = $pWorksheet->getParent()->getUnparsedLoadedData(); if (isset($unparsedLoadedData['sheets'][$pWorksheet->getCodeName()]['drawingOriginalIds'])) { @@ -197,13 +196,19 @@ public function writeWorksheetRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\ } if (($pWorksheet->getDrawingCollection()->count() > 0) || (count($charts) > 0) || $drawingOriginalIds) { - $relPath = '../drawings/drawing' . $pWorksheetId . '.xml'; - $rId = ++$d; + $rId = 1; + // Use original $relPath to get original $rId. + // Take first. In future can be overwritten. + // (! synchronize with \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet::writeDrawings) + reset($drawingOriginalIds); + $relPath = key($drawingOriginalIds); if (isset($drawingOriginalIds[$relPath])) { $rId = (int) (substr($drawingOriginalIds[$relPath], 3)); } + // Generate new $relPath to write drawing relationship + $relPath = '../drawings/drawing' . $pWorksheetId . '.xml'; $this->writeRelationship( $objWriter, $rId, diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 15359a4cc4..3d47eeaa5a 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -1215,6 +1215,7 @@ private function writeDrawings(XMLWriter $objWriter, PhpspreadsheetWorksheet $pS if (isset($unparsedLoadedData['sheets'][$pSheet->getCodeName()]['drawingOriginalIds'])) { $drawingOriginalIds = $unparsedLoadedData['sheets'][$pSheet->getCodeName()]['drawingOriginalIds']; // take first. In future can be overriten + // (! synchronize with \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Rels::writeWorksheetRelationships) $rId = reset($drawingOriginalIds); } diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/DrawingsTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/DrawingsTest.php new file mode 100644 index 0000000000..d6ad77c63f --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/DrawingsTest.php @@ -0,0 +1,45 @@ +prevValue = Settings::getLibXmlLoaderOptions(); + + // Disable validating XML with the DTD + Settings::setLibXmlLoaderOptions($this->prevValue & ~LIBXML_DTDVALID & ~LIBXML_DTDATTR & ~LIBXML_DTDLOAD); + } + + protected function tearDown(): void + { + Settings::setLibXmlLoaderOptions($this->prevValue); + } + + /** + * Test save and load XLSX file with drawing on 2nd worksheet. + */ + public function testSaveLoadWithDrawingOn2ndWorksheet(): void + { + // Read spreadsheet from file + $inputFilename = 'tests/data/Writer/XLSX/drawing_on_2nd_page.xlsx'; + $reader = new Xlsx(); + $spreadsheet = $reader->load($inputFilename); + + // Save spreadsheet to file and read it back + $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, 'Xlsx'); + + // Fake assert. The only thing we need is to ensure the file is loaded without exception + self::assertNotNull($reloadedSpreadsheet); + } +} diff --git a/tests/data/Writer/XLSX/drawing_on_2nd_page.xlsx b/tests/data/Writer/XLSX/drawing_on_2nd_page.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..fa51215ac8fe09ce4b7e2e8f0473cc85ffb364b0 GIT binary patch literal 16265 zcmeHuWmFx@w(bIg1$T#_!QFzpyGwwuaCdiy;1)c%y9S5g?h+h=yNBR!?d*L{_RiVo z-TTIPJZ;f8bHk83~2_6ba(1LmDkk3&89r@RJafJKi?Z>R_dWsLkE|-Pu3VH;CRva4y z$y9J!-xbsHDQcNurzTzs);X;?`pZd%Qgq!iC@R18R6eh_3r}GR-(r@SXB94yq)S*m zZ0{suCq?@7lo7=G1a2!%5a2VlQOxTba(JxxBAKRd(uStfgUAQa)(lKA=-S5?{cjae1&qdgaio1UR%=cPzm2il`2om~2W5(z8ncjj^Ne)6nqAFVpp z^WhA)9uC;<(t)!<|8SzBRZti9uSODA;QpiuG7v#f=Y|Ao8COdN7aMyEppA{iZyj5n z%9{KVBeHj9-Sg**>2EOS%2F5D9HBq8dez>>Bg=eaXDvrR=3PZOE?8VBh)Ek>$ z~qU?8wmwMw5P<+<0;9uUO|r9A@T*!AVq3O>U9&) z2=foVKdIUyj1YN_6w9h#)RlbYmMMaF)Y$9l*d7zqxYj@qRJ{&QY*&I5gRHfVlYCu+ zp4p{V+3VLiGpkAmH_^uwdC!S|yy#|)+{vZCBUXXE)|t{ti3X>Jb%LnX;s9eWHU8D_ zlaeZID*{qUFp ziNBj6dPLVXhGGI4QgId@5~XG2av%8w(y@Ql!n@R#(LKGjm|N($`Ql%;Ph=&jC>aSD-ZqHC5vc zRiBz8^OQ!ATHx{>WqCgIV`anytuCcNnwB9%zbiFnN~nMPiNfl%KGsw)m&nsOXOaXF z_cmS1*Gwa8>z(b7%stbucAcI+DnG3TwKp~%fIjcP>WSSKOXVDgACUHywXk392OR??RuZ{>5MH3lR;hn;{uyzJ_b z_otng(|4O8_TeXEE&xB2>>G?zp(@c-_XR%`K0!F%>$<%Nm>I{k8ExnsoYy!R^fgDE zY(m$b@|4Tk*k2l?x?XO-%R=%9g`fl9zsaca&cV6GOh-Afu7XC5B=6BO!*C`|U?B}J zm5r7wW7~d=VF)rrit>hQMk+Mw`(BzD5r@dzKum1kJpaJ;7=J~EVNcOE_AHz1nZnhm zZU>R65Pl;$6m2~B71sH?+?R9s@NN6vtkn0FG1D^Goq5hTwY&us|2fO`3|GycRGQAzv?^MCDzf3Zyl$}=vr(^mgF&KUwA+&=ss1t+dwQY zga@l5Cd`l};)pM`aLjzSc|U3?8CG3JqY05QuqTM^p6K(Ga3aW`ss$q*Gm#Q8H&@bg zgHS0t904um$f@jSozk1VdMjr3d1#}s;XL=1#&^1S0$x;9FGPqEDf?=$)lWIK;-Q!b zwMA<)N-42(7Y?>`)6s3IcBU944K=af7zL=z-0WKp1!}DV-1tM7Hn%i4(Kfh=KH+?Q z&0Qa7!Kk2#H29==X?92Bv(3U6D|g8cht}7QDL+N9PD6c{oOcEUidI(LLhFaa?hNI} z>wds_RPIT;rVib$by68Iv9qg9rVCeP(yq*L^VFdY7p;1dzH~er%otPNvm)iTD-7G$ z=Bet|Vyzmd)Ve0OWpJr?0^^r|-0x7z5q+x}im56V&UlO3jM43%sdO}&X7lx-71Gra z?NiYu!qM?!+UN12d~}RMJP(9X2F*p>Q@NvFJ8bCiJ^!fMo2qB(sIOgcr>L)8ZD{M1 zkq^H{BqoGJGU5|N;(5Se8(AkCxs~Y4PY@7OlqI)V==)P9T|6sZCUDDb2q1>E!24a_ zcY^+Qya3W~m^^1VFrO$jsx!X#UCB8Iv*zH|H0OzQq{oM>VI~aE&KkmDS};eMAEAJ& zLJ>9>fLCn-X1PuRs@h22Q)Lrv*|et8NC`-ntxUXNE)mck&C9Q-)Ev~TRkW`PmrIAZ zwtADNYu?b$E?!{D`rX9b@|OQ^JtOL&AD1UI0C4;2w@Hd0p3%|N$jXS}$L|lPc%(UM zjn9GF4n4rlddK&%5buoAWv;TX#x9uQj4X)Rv$AD_glHGMIIpBO^aU z1`im27!3wgTJ|sM3LiiFMn+yDQ`LABNFwxqAb4{|PX?yMabF6oF1a&sI=>J{0v-?m z>0zX`yl<5TZ)}-?25~alPZ=9o6KA}{ip*jOB_vqd+S6O~#2EdJcw_QxvFy@|*XQ%;@pv&cWbI@kK(1mwbYQg?V z_}XHFjdGT#Yy&!g-gUCeLg78q{F#2?!v4Y?8)fhO+}X8K3)T$XBQCmP9DZ50w0`-b zPK7gM3S;weAV>E*g-XLA2Xw=3>ZKWUv=0NdJGv1kEPMbka*0^7u-8~DJc6VWSM)iC znP@g4GNckcI8w>J8%p`Cl&Tw*cL-OBQH+aS12JmO{zgD6iG|%Tl-Dc^7nOc$YrZ_s z=lv$pnS34(-L>O<9^by-TUwV7#Vv^q&Lnu;-c))&9u}@LJb%C2j_1!;&g_Fjd;Z!o zuJ>@rU#WydGp2L?Fy7Dbk&yp+80-1*TbQs%TCNuw9~l$oDuUPwxU~YDf?PBDhL>|fj7YhFebVwmd&8R- zWf{z#O?C)Pgg3=OoVF5Z+z}1OCHSS6*@{s6XmO_}g&^a0M(UU#f{IJXAfk<%h?{n= zDrNg}dCvl+YKYyLe2&dzU%~^s~m5Gbpdsj@#FqE~tTPTqg zDV;Cd=_>B=QHV0@2;dkbTjA4G9FTjAaV;H^hvhJu9!bquC!RXCG~Om|{p)S5&jqLC z1M3_gz<~U7A`0&s_b^4u&UQ)6^=5$%h08tOW|xct*@m;+Op?0V59!n% zUHk<{c36zN3TKTN&mWac(DE%ascqReo}h^+H$-uIw@0Ypxq~?osL=cx3;h&k1rqfvh=s5-%UXS(aHm9+ zGkl%dLO`>TN?faNQ^s4!unsF5r|$hw^XE4hDF?-8#xerXl1PUqG<^BmH`zPq^mv6C z6ZV=;yvj*0$u7^88gWA^5@jaq-B(w%i{~Gwicf~<5fo}{fPqXYRwA?dB3^G`6x|Y0 z+>LgDqSN}K!o_;Q<~Y5HG@W&-D(h&=0Z2C=h@i|ua8exr;IO|o2fZ>arb4% z@{FMb2HQq_d8TBI4*Rx?XY-4lgC(@Zu=kDe^z-yz5cO#~r_$YCMmVt`6&roD@4c`Z z7%k#h6)nRkPX7v(nk*xTc3QMOUqX!E6ERV?EuR$tpL7myFJ4s1C{k#v#1hBjwXqhg zY5aD85LNNOR+ftjuSW!UqKNv*v;IMqeL}<`w4wYhn2@VYqy>0+t4*Ka#PO@m!57ha zIL-zlZd`4U!SYRAw<_Tsyc&`2;{m zjN{~`oTgxw7U@jO7MxngbCeBnC=Qn-G+%Qx3^Y|VZE;Dc?9!j7>fFHN`Ri-(r5L5w zxMl=nn3&`?nC)sHV}C5NI$JW2wsrq%<>DQ~ol$QdpfQ)ib$(6N;`Vav+bM+G)jE%z zT>eCMAd6L0)}FLHrShV$`j+2_xk%&1PI}!#NPZQ8BaQwi1@pj1Aq51fAh9nMn2Y)v zbT{4h#q-5H{*j_$c5h_lzeC&R31Th0=^)hOK8#K(WKR;KrDygE)SC%DtbMZYQusmyOezKkb7dIW1-*J?g-?Qc8l#iLia%ODQ9 z4Fv!o{N7nRIJ#LHIsBM%QI)m^O}VUK?GeD7V0ZzW8i=VvH(_96z#-$nSEf+&kvGJ% zOx3L?ov@mOPbZA9+5#MM5y@%PQuC~o7>+h#JTHw`ZSe`%{Bzl6*_4_4p8P^k5>tj! zXbm2on4KuFXM+dQZOP3dIO_Vu2M^U1t=Q9b-zu6T3k-1esrRX{%$L{FP)m4aQB&&| zDrg}?Nb58^q>cu3lEoV8Zdz{EESCx;#B3A~t`FC7|8C<@h=?n_yy)4&e1bXJqf zAB=;T?IVhXXM56sE}Ha;nY(`#^)5xNo_Yjqy}5)^LyTxDqggr0(1T3C8z+vaS=W}~ zMyvzbY|FgaSdA}TBq**xEJaHaZ4(f>h&ob{e@Cg@0{QY(j$H8(wj35ZI%I`x2wfd_ z-yUa^^?EVdNt(perxwJp~O*| z|*N`8|N*J0ryRLM7MVjO~0<#1p zWFm#90wV_IFZ zF&k3@UmZW0;cieX2ns!4<@-di8Ey4xvM+u9jB*{ToHhJ>cltJM|0^p(dKgD0XRa_V z*R*ZBZP($o1*%|eui+3sud%%GxV@3G{XwT+F(LP#aJP!gE7o(d+5U+gc%O(2KS!xN(AbS;D+7{XU}7d?MC6o^utNH>0z` z4s8dtMdRYnq}sB>P@`5R?yr?}Rl|d=0v%m-4}zqSW!}}b$rFpNxUndXo{zAQ;!GL? zHmnqR6w{LGC93ge#PA*ETLrD!tojUa=%ThC_>;mth0dxI<5TnCZtDy9KXdL0%e_R} zUW{{cN;@_hq&HgYNjuJW9O4lKv&Yqf_!PnrQi+sF$Vb#p;r7`aLv0nx+XoN0`{=Fs4h(uv1yRGwgfV@tk|+AvUU7nIE-cbP4pLjnm!kJpPUBs z6mlj^WM)26zK=WCSAVDM`Bl@}s>Ou{HSQgAYU8B2pH5u9G=~&cHh1ucE@Xyo#ne?& z8@@}+o9=nJNjpn1{+tPYA%o8S`gcT$)1i*SX%_7YbSAhJT@VYpy;j zMi!lx@KBi*DqVS4itNlg-$?!79*+0jt#w-U+oWt;nZ=)Z*|fFDVfdjvpu_yc%m&$( zu&V)et6*IOs?ktz$0)J^E#?UNtgBe4av%D9lWIA()0f(d@)z~9u1IWYVVRYYp_x8|nU%hY5fi<+t;zG3=M4b1sH>SV03azz z{bSMjcX5!-905>7oD3}7Kog!XKqn1Br%nKff`&FgBYvm zXgDx%D2P8E`j2-7?ZLqyUO*xP08kJB&m@M> zHZz$ElOib##k@vxBTf@87s`((0baa-1UZu*1q>X8mi^bH|W z7S`uQ06eHl;3yC%0Diz&IA5usZ|6HkYKhpemg~?daJyte6DvLWZFEpmg@ce z!R2b`r0e6O#rgQcGr+~;8KB>1s3&>nvSyWuH0r_k4Cv^v*!(u~9r&17SlU~S#!a*I z3^3z=sdp|+{R~Ko3Va4Qr+{u#?`^fLrN_OX8}t?@W|2mUE#siUB-a~K?k1;~Q!r~q zHzkuwRpvtv%wzcgb9bG!WZpHhkoSSvsoIkttGE16U3%_3wFYS5xIU!s+qw9GuZE+s zuC~(ETy%I2jcJv;?*m>3P`1^ z!W3`nZNl~3M({w1z>|`0E#Xp|KxDyyZP~PjgqeJ2Z6jV0ZKSOJ;0t z55HIGjn9Pl?j1+_tB1mQzIp50X!+|*3iZlw4s=>evp6hFwUtqYo4OjVkJSXO*HfVt z>h|aCIukRh*x7-8^S;)=uT9JQ8Q2;P3??ERGI#@aG`bx_MOo1g&ExoL9Rr)u3|EdL zXXD|tV~dCM5RYy}hLn5W29d97xwy2-*u+_tOy7smH0;ubE~Ly2WX=@`d^cbrr9vFt zN7PV)92$QkB(1RkdUGFcfPShEs6w zQZC`y+f3OZM;@UCCmg!|;&izG@nB>`WGrr*)}%GujjXuXhxi_8@9*{w5QojLmRo1j{b3S5B zUJ$zeu*6)us}N?}%lY26jAe#C0~wUJeX0j(-v&C0qmqKVJo@_*?i2Q!_V?eSlq9^a z{c@7L3^{5xp!j8fGk%X&79+JU^lO{Shs9W^5dgxifgER5jHM3=@JpK=!bU;d5=BQt zhv3W&oegpGgMmiEDeltnm}8kSCi3e^3*hGxDW#R{g(|iw$`&>Yb~bLBDJ+O3+)=f_ zY8om=oj$ae8V0v$XytaAoZjv=zQ<3^EvBpbp{wau!wf6a%+-bp>;p!2@QDQI3+I~m zECEwA#LC5XW&%Mt7E&3E38tdtwB)6*!IZD6;N4FxWYpOrhJb9d(UD2_*lsU2q{T`l zw@G`0Z|~wheZ(L&N}d1a?`Ci>tZX}Bbq&-Z;Zwy(YVTKSig7#Ip?jxgM*8LR{(jbJ z#Eow4lhjx8w?OB_OE=_;__0-P&hyuL8PA$NEwBN)1Y(up35arIWxTl>iiswHR8f> zFiJ?2&9T?WUes<>c7~1ceI31hjUcWi*z8DyE2;t>Fll$wu_rZNhPVY3^L zx5^dqWI{q-so9EwF>1l@t`Da&(u>Cyg^U~1g$hOP0r|Z) zpPG+a$+F9=>N6(3jF;FZ%QuzCLI}%UvQc^+u!Osf5D6jYW?V`bk87Q~+S*S&KTyHc z;AE(?88RUHdTTlfxbjBA%EQ9`hI|rd3+HU6Uy_D~Jd)IW5T4*+#%D#9FcGhdtr!C< z3(UcMX2=ozaU}t9rd78!n*}@lb+Gauy`$5CQpaN{&odxg{q%|d$n!${k)J=e@EZrn z1WsCOHof{cFSD0TYMU3MxnS0G*%r>6)j8C)bcX}9$CSeizwxjq4J>Al^&)?$<76d) zh}X(55EH)`60C`24Otes2zNzaLZqtUv2h4_t8UwKV{<&xI}tNGF3SvK<=|A|R=uXZ zZ7qS`P+uV}tKqeL%osiF9JG9;^?hNwf@ViXjv>St25&Im3iq2aKT%3bG~|Mt_PJmu z0fO+^_^YdE524%B>ZYZ1;B_L7vlfG00lB)P8W{HbZX@&j37ouzq9!V(*I!oC{gtpD zTiD8!T)WI`oZU>Ejt=vB)TYBlC@37#P0NU&`2<^rqAsRP!j`xTCtRKZe8)y9nDXXK zGIQEx6Mml$`&%$d++gc<&?@5baOi|Jnda3*PhPXLGboXuM6bvIN_S^H`b|EuBwOV$ zWyCf}I?pag-UrH7=td^7&$0#TE@dD}GRJ%L)K-(#efK+Hf^l%LDmISkwNw0CVVSKW2lpt(&I|#PnT`U||eLU+Z&HjT^fi_$cWARj#dmn{x$6gxj|0icBbGazcq9GK0M(~A9le#f&wy)+c%F>R zEA{K>m8td=x63CpZb!r%0p`zGi{vlCB~rF#1k;Omp|Om4o)PAm5`pp7kJd53tj zN03Z+c&~l!HFth##G|BrgD8>E4z?ZuNa2K+b_63)^o{Fc9hA*a4>SitX6=a-GD^Pu z;!7lOY6LN_H(V)oA1&gY&td!N!x|ZZUe78f52ec64(d1+pP3E>W!x(3Mz^6w3d^$D zaZUxuSAjzL#ccVCSdvV&@rfn2BIfEqDJxnkIe?5}>)7yOo9g@h>A$`AICx_zRWW z=LHo5q>$q&aXedSG(vl8%~XvY8p7!=kChftZ6FDutg$z&OU+AiQz(m8(!<&sw?miK z$_X`duC<3UF;KD}$?IEfU7TyiS&8M?qD9cE_ogMml9tepl{`uKA}ULil?OP|knlL< zeL1v%<@Go!ZyQvhrKcizzNBP~G>!VuhZhHUIidSCe#<*9w=+f6NX>hI={-_*?EB3=XKe{?6lIVc%UB~)`1nz>Xp=-8J0FYtG13$aFo1s_4C#Q%OGPjQ$#Q#p|G4=+(7Wx~smAJ%Gm=kT? zV+gn0@6SVT!=;G#9a2^h88`2xJknG96DR@wla> z^zoq9T<_k=7t*LVdt@E#>3r502uz+geS02>cgS=wk#_p2={1$Y3k!#CVDwd(S^*CA zRLa9PHkc27acCXTDVUo6&E2f4N`!O(vuLlZ^jusSO>C{i3B6x}h!W9pvSv2An4o!M z6&D%5@sYMnYmiwuR$+q%EArvn$B$*Z2-}8j#~o0KBneKJoQJmuxH>zX&cQF}A?{+N`ee4UwXQsjeQX3C@#`#1{Kq`+_$f!~~J zKA#=C@5{@ev2eE&HSln|9$a8C8dbaJW~3H;qd@~Yvrg|l)HuBzR%gt;jU_RP;hwM2 zn5;40f>7fvfD2BDWT@ zHgZ_{aE)~1B0p1cU3%8eUC($kL-g-@R!oPgd6O$PkdPYg*F9|e6D zu)V^F{9C*b)wbL#Pe((w6q=eT-^7f>0b!gsdfM9YJ`N|&F7lh_R0sLXj(m&s-A8bcK%%y<(dUppUR zAe@+9zt%v9vKi2q+OW1SxRn29t}t{)1TID4=X{)&QR*11 zq{m@*BuHZdT`5R3^fU!(6_~KZ77fn!0pU?|OS|{_eB9ZE@w>}8oqo5wPoegN(6+Kc z@%P-G1GX3JQp03P)icK!TVp#(oH$f?xXzyoq_jzxm8o$$03(z+LEH8FO#Kz@W^YA$ zc1*;~ykC5e^Xc+tq`c!hFoYneCsAgrE60xAl&iJ-lt%uj9quVRY=oUn990%mlZN^R z6AV6!f%c+{IFJjwjaM~QiNpoua2BjO=H@cDHt46b0D@~*B&cA;r#chlYk2XDPhiHg`+T=`gB zLTdgNv$lHyqm@A{#iIHdz`EDiJANW}a;W}>W_6Tja|YL}FWdmRf!M~Qd5#9VVkBkk z#BKEN=Q8|qq!yP0x6M&ri9`zfHS@adE5)R57ao4SdZU?-30BOZNB9g#_P~4wL_Gt> z{mOqCbN^3GkN7+<{56uB+lpEGGiXvr2sDvI3fliQ?CbYP!JoljKjH)fqd&jzVni3c zfp`*j^@yJff)`fiAZb+Hg#g|yLMt)Z!a;Zg1O;Z?mV}^AzJ5BgWFsG=m3i z8DN=Kop~(MbqH2-9xS87((%OTPt&)jLdeNUh4sg1V8B%eDUv;6cYF6NR7b%U$MEee zNQSvF4&H|2O_Y_GTV3cu*D=V|pVDr5sRwZJDrr6)MR^hNSm$<(NnDHvO1_DC$Co4V zW>xB|%loCYQI;{e17vxo+7fgiT)c!gYw%-WxIqT9 z(lLB7t(>`*SbT<$3u$VF*@^7!sIPag%Kf|SBVp(R+aagRwIf#e$xY>pen`oRGREx2 zad%D8X677?iMzL(4ig6@@H@@2_nGWXBB-d$MAb_CS=hY|7T=#o06p<_$f0E=5^-@B+9r0 z$GXc`gYb7ZP|FdFjKj@I9*AuCC*COh>EYpmf(+cq_>Qdf8jwksyE_mf#pv*KOjZ8S zSey}uvuC|9m^@03M=;U$@ihCa=8qYljXS^h zp})?3l_`Vt^+96vfuCD0e%dqQZpop@hjQX}$68?MLn%1bWUbxRkcXQrrY-*2@u%~@ zRgF{$qt|Sp*Ix#0uR$BgIBf0BKp9H*%0`ZkKNeGd`Jag%Xl4z3mj%yQ!&tQphD+?3 z>E{>g7q5@`30C}NOz#--=N_0m(&S{nJkkKzpl>m`1R&ghZTSE9Co}(lda_=>LnABb zb8~`Lk5EAI!iF{m3idX(4h#l1_C~)gqJk1U{u3q)`e+e9oB(p*4=3OO|Em&O+yL7ga^sfYCIn+W1WHDX61>Fy{sH1E$Y5O7<) zy@Xih(yC8(h04oJ+V68Y8(nk}`Wmciou_(3Z>hYsdD5QG90c8J^s2Z{58-JAANCFxsa(3|-T?H-?a^gLNwj+=Cm8F00T}sQ{UM7K5jQ|u4iu`9))3>$#kEVfC?2nQjC-_^~ zg6IvHJG5V^BZ{)~%UniED8c2rL}Uc=WK2Xs6P$S|Xbk@nimjvE$h!RA4%zqg(ZGo@mgB^-v z#rB0_t3t&Z^0svMttsM0b&K;Ge59$vgw;k4v1r)<8k;^lJd` zuK>S>5&Z;E0wqU)0DcA){VMuv=*3S_O}rnX|71{q=1#w({QK4IpC~+pKTv*M>;APG zzY_bO0RBur0DjB=`Qvl^EzSQG@K>Jv6EKkZ{{r}vHUA3uE4lm$n8otfhWa;D^H;!M zNz+fjOx7QOzmTwBW{@0H4 h&*D!Ue-i(r8&!~o1bKnq*c=L=2o<%=O!U{|Du@0A~OI literal 0 HcmV?d00001 From 86e9d669c60edb57bec05b02ff457e4d959c9e4e Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sat, 23 May 2020 22:07:45 +0200 Subject: [PATCH 055/659] Range Operator Tests (#1486) * Range Operator Tests --- .../Calculation/Engine/RangeTest.php | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php diff --git a/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php new file mode 100644 index 0000000000..7dfda9cac6 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php @@ -0,0 +1,53 @@ +spreadSheet = new Spreadsheet(); + $this->spreadSheet->getActiveSheet() + ->setCellValue('A1', 1) + ->setCellValue('B1', 2) + ->setCellValue('C1', 3) + ->setCellValue('A2', 4) + ->setCellValue('B2', 5) + ->setCellValue('C2', 6) + ->setCellValue('A3', 7) + ->setCellValue('B3', 8) + ->setCellValue('C3', 9); + } + + /** + * @dataProvider providerRangeEvaluation + * + * @param mixed $formula + * @param int $expectedResult + */ + public function testRangeEvaluation($formula, $expectedResult): void + { + $workSheet = $this->spreadSheet->getActiveSheet(); + $workSheet->setCellValue('E1', $formula); + + $actualRresult = $workSheet->getCell('E1')->getCalculatedValue(); + self::assertSame($expectedResult, $actualRresult); + } + + public function providerRangeEvaluation() + { + return[ + ['=SUM(A1:B3,A1:C2)', 48], + ['=SUM(A1:B3 A1:C2)', 12], + ['=SUM(A1:A3,C1:C3)', 30], + ['=SUM(A1:A3 C1:C3)', 0], + ['=SUM(A1:B2,B2:C3)', 40], + ['=SUM(A1:B2 B2:C3)', 5], + ]; + } +} From 8ca7bfe53c093ea2a5f443081ffa20953422ebbb Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sun, 24 May 2020 00:25:54 +0200 Subject: [PATCH 056/659] Range operator tests (#1487) * Range Operator Tests * Correct handling for range intersections that result in an empty array --- .../Calculation/Calculation.php | 70 +++++++++++-------- src/PhpSpreadsheet/Calculation/MathTrig.php | 2 + .../Calculation/Engine/RangeTest.php | 3 +- 3 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 0be9ab6f6e..cdfe7b53ae 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -37,6 +37,10 @@ class Calculation const RETURN_ARRAY_AS_VALUE = 'value'; const RETURN_ARRAY_AS_ARRAY = 'array'; + const FORMULA_OPEN_FUNCTION_BRACE = '{'; + const FORMULA_CLOSE_FUNCTION_BRACE = '}'; + const FORMULA_STRING_QUOTE = '"'; + private static $returnArrayAsType = self::RETURN_ARRAY_AS_VALUE; /** @@ -2593,11 +2597,11 @@ public static function translateSeparator($fromSeparator, $toSeparator, $formula for ($i = 0; $i < $strlen; ++$i) { $chr = mb_substr($formula, $i, 1); switch ($chr) { - case '{': + case self::FORMULA_OPEN_FUNCTION_BRACE: $inBraces = true; break; - case '}': + case self::FORMULA_CLOSE_FUNCTION_BRACE: $inBraces = false; break; @@ -2626,10 +2630,10 @@ private static function translateFormula(array $from, array $to, $formula, $from if (self::$localeLanguage !== 'en_us') { $inBraces = false; // If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators - if (strpos($formula, '"') !== false) { + if (strpos($formula, self::FORMULA_STRING_QUOTE) !== false) { // So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded // the formula - $temp = explode('"', $formula); + $temp = explode(self::FORMULA_STRING_QUOTE, $formula); $i = false; foreach ($temp as &$value) { // Only count/replace in alternating array entries @@ -2640,7 +2644,7 @@ private static function translateFormula(array $from, array $to, $formula, $from } unset($value); // Then rebuild the formula string - $formula = implode('"', $temp); + $formula = implode(self::FORMULA_STRING_QUOTE, $temp); } else { // If there's no quoted strings, then we do a simple count/replace $formula = preg_replace($from, $to, $formula); @@ -2741,7 +2745,7 @@ public static function wrapResult($value) return $value; } // Return strings wrapped in quotes - return '"' . $value . '"'; + return self::FORMULA_STRING_QUOTE . $value . self::FORMULA_STRING_QUOTE; // Convert numeric errors to NaN error } elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) { return Functions::NAN(); @@ -2760,7 +2764,7 @@ public static function wrapResult($value) public static function unwrapResult($value) { if (is_string($value)) { - if ((isset($value[0])) && ($value[0] == '"') && (substr($value, -1) == '"')) { + if ((isset($value[0])) && ($value[0] == self::FORMULA_STRING_QUOTE) && (substr($value, -1) == self::FORMULA_STRING_QUOTE)) { return substr($value, 1, -1); } // Convert numeric errors to NAN error @@ -3227,8 +3231,8 @@ private function showValue($value) } return '{ ' . implode($rpad, $returnMatrix) . ' }'; - } elseif (is_string($value) && (trim($value, '"') == $value)) { - return '"' . $value . '"'; + } elseif (is_string($value) && (trim($value, self::FORMULA_STRING_QUOTE) == $value)) { + return self::FORMULA_STRING_QUOTE . $value . self::FORMULA_STRING_QUOTE; } elseif (is_bool($value)) { return ($value) ? self::$localeBoolean['TRUE'] : self::$localeBoolean['FALSE']; } @@ -3282,34 +3286,34 @@ private function showTypeDetails($value) */ private function convertMatrixReferences($formula) { - static $matrixReplaceFrom = ['{', ';', '}']; + static $matrixReplaceFrom = [self::FORMULA_OPEN_FUNCTION_BRACE, ';', self::FORMULA_CLOSE_FUNCTION_BRACE]; static $matrixReplaceTo = ['MKMATRIX(MKMATRIX(', '),MKMATRIX(', '))']; // Convert any Excel matrix references to the MKMATRIX() function - if (strpos($formula, '{') !== false) { + if (strpos($formula, self::FORMULA_OPEN_FUNCTION_BRACE) !== false) { // If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators - if (strpos($formula, '"') !== false) { + if (strpos($formula, self::FORMULA_STRING_QUOTE) !== false) { // So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded // the formula - $temp = explode('"', $formula); + $temp = explode(self::FORMULA_STRING_QUOTE, $formula); // Open and Closed counts used for trapping mismatched braces in the formula $openCount = $closeCount = 0; $i = false; foreach ($temp as &$value) { // Only count/replace in alternating array entries if ($i = !$i) { - $openCount += substr_count($value, '{'); - $closeCount += substr_count($value, '}'); + $openCount += substr_count($value, self::FORMULA_OPEN_FUNCTION_BRACE); + $closeCount += substr_count($value, self::FORMULA_CLOSE_FUNCTION_BRACE); $value = str_replace($matrixReplaceFrom, $matrixReplaceTo, $value); } } unset($value); // Then rebuild the formula string - $formula = implode('"', $temp); + $formula = implode(self::FORMULA_STRING_QUOTE, $temp); } else { // If there's no quoted strings, then we do a simple count/replace - $openCount = substr_count($formula, '{'); - $closeCount = substr_count($formula, '}'); + $openCount = substr_count($formula, self::FORMULA_OPEN_FUNCTION_BRACE); + $closeCount = substr_count($formula, self::FORMULA_CLOSE_FUNCTION_BRACE); $formula = str_replace($matrixReplaceFrom, $matrixReplaceTo, $formula); } // Trap for mismatched braces and trigger an appropriate error @@ -3715,9 +3719,9 @@ private function _parseFormula($formula, ?Cell $pCell = null) } $localeConstant = false; - if ($opCharacter == '"') { + if ($opCharacter == self::FORMULA_STRING_QUOTE) { // UnEscape any quotes within the string - $val = self::wrapResult(str_replace('""', '"', self::unwrapResult($val))); + $val = self::wrapResult(str_replace('""', self::FORMULA_STRING_QUOTE, self::unwrapResult($val))); } elseif (is_numeric($val)) { if ((strpos($val, '.') !== false) || (stripos($val, 'e') !== false) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) { $val = (float) $val; @@ -4058,7 +4062,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $pCell = null) $result = '#VALUE!'; } } else { - $result = '"' . str_replace('""', '"', self::unwrapResult($operand1) . self::unwrapResult($operand2)) . '"'; + $result = self::FORMULA_STRING_QUOTE . str_replace('""', self::FORMULA_STRING_QUOTE, self::unwrapResult($operand1) . self::unwrapResult($operand2)) . self::FORMULA_STRING_QUOTE; } $this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($result)); $stack->push('Value', $result); @@ -4078,9 +4082,15 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $pCell = null) $cellIntersect[$row] = array_intersect_key($operand1[$row], $operand2[$row]); } } - $cellRef = Coordinate::stringFromColumnIndex(min($oCol) + 1) . min($oRow) . ':' . Coordinate::stringFromColumnIndex(max($oCol) + 1) . max($oRow); - $this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($cellIntersect)); - $stack->push('Value', $cellIntersect, $cellRef); + if (count(Functions::flattenArray($cellIntersect)) === 0) { + $this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($cellIntersect)); + $stack->push('Error', Functions::null(), null); + } else { + $cellRef = Coordinate::stringFromColumnIndex(min($oCol) + 1) . min($oRow) . ':' . + Coordinate::stringFromColumnIndex(max($oCol) + 1) . max($oRow); + $this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($cellIntersect)); + $stack->push('Value', $cellIntersect, $cellRef); + } break; } @@ -4284,7 +4294,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $pCell = null) $branchStore[$storeKey] = self::$excelConstants[$excelConstant]; } $this->debugLog->writeDebugLog('Evaluating Constant ', $excelConstant, ' as ', $this->showTypeDetails(self::$excelConstants[$excelConstant])); - } elseif ((is_numeric($token)) || ($token === null) || (is_bool($token)) || ($token == '') || ($token[0] == '"') || ($token[0] == '#')) { + } elseif ((is_numeric($token)) || ($token === null) || (is_bool($token)) || ($token == '') || ($token[0] == self::FORMULA_STRING_QUOTE) || ($token[0] == '#')) { $stack->push('Value', $token); if (isset($storeKey)) { $branchStore[$storeKey] = $token; @@ -4329,7 +4339,7 @@ private function validateBinaryOperand(&$operand, &$stack) if (is_string($operand)) { // We only need special validations for the operand if it is a string // Start by stripping off the quotation marks we use to identify true excel string values internally - if ($operand > '' && $operand[0] == '"') { + if ($operand > '' && $operand[0] == self::FORMULA_STRING_QUOTE) { $operand = self::unwrapResult($operand); } // If the string is a numeric value, we treat it as a numeric, so no further testing @@ -4342,7 +4352,7 @@ private function validateBinaryOperand(&$operand, &$stack) return false; } elseif (!Shared\StringHelper::convertToNumberIfFraction($operand)) { // If not a numeric or a fraction, then it's a text string, and so can't be used in mathematical binary operations - $stack->push('Value', '#VALUE!'); + $stack->push('Error', '#VALUE!'); $this->debugLog->writeDebugLog('Evaluation Result is a ', $this->showTypeDetails('#VALUE!')); return false; @@ -4402,10 +4412,10 @@ private function executeBinaryComparisonOperation($cellID, $operand1, $operand2, } // Simple validate the two operands if they are string values - if (is_string($operand1) && $operand1 > '' && $operand1[0] == '"') { + if (is_string($operand1) && $operand1 > '' && $operand1[0] == self::FORMULA_STRING_QUOTE) { $operand1 = self::unwrapResult($operand1); } - if (is_string($operand2) && $operand2 > '' && $operand2[0] == '"') { + if (is_string($operand2) && $operand2 > '' && $operand2[0] == self::FORMULA_STRING_QUOTE) { $operand2 = self::unwrapResult($operand2); } @@ -4570,7 +4580,7 @@ private function executeNumericBinaryOperation($operand1, $operand2, $operation, case '/': if ($operand2 == 0) { // Trap for Divide by Zero error - $stack->push('Value', '#DIV/0!'); + $stack->push('Error', '#DIV/0!'); $this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails('#DIV/0!')); return false; diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index d92ba4048a..85f94cc200 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -1339,6 +1339,8 @@ public static function SUM(...$args) // Is it a numeric value? if ((is_numeric($arg)) && (!is_string($arg))) { $returnValue += $arg; + } elseif (Functions::isError($arg)) { + return $arg; } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php index 7dfda9cac6..84cac74772 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php @@ -2,6 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Engine; +use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PHPUnit\Framework\TestCase; @@ -45,7 +46,7 @@ public function providerRangeEvaluation() ['=SUM(A1:B3,A1:C2)', 48], ['=SUM(A1:B3 A1:C2)', 12], ['=SUM(A1:A3,C1:C3)', 30], - ['=SUM(A1:A3 C1:C3)', 0], + ['=SUM(A1:A3 C1:C3)', Functions::null()], ['=SUM(A1:B2,B2:C3)', 40], ['=SUM(A1:B2 B2:C3)', 5], ]; From 84e03da5c7faba00034d5f4189ba7c16d58ca721 Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 24 May 2020 03:51:28 -0700 Subject: [PATCH 057/659] Code Coverage for Shared\CodePage (#1491) While investigating something else in Shared, I noticed that CodePage had poor test coverage and a high complexity rating. This change addresses both; Scrutinizer would love it, although its interface on GitHub seems broken at the moment (all PRs show "Waiting for External Code Coverage"). --- src/PhpSpreadsheet/Shared/CodePage.php | 184 +++++++----------- .../Shared/CodePageTest.php | 16 ++ tests/data/Shared/CodePage.php | 65 ++++++- 3 files changed, 146 insertions(+), 119 deletions(-) diff --git a/src/PhpSpreadsheet/Shared/CodePage.php b/src/PhpSpreadsheet/Shared/CodePage.php index b395293ced..97cbfbbef0 100644 --- a/src/PhpSpreadsheet/Shared/CodePage.php +++ b/src/PhpSpreadsheet/Shared/CodePage.php @@ -6,6 +6,65 @@ class CodePage { + private static $pageArray = [ + 0 => 'CP1252', // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program + 367 => 'ASCII', // ASCII + 437 => 'CP437', // OEM US + //720 => 'notsupported', // OEM Arabic + 737 => 'CP737', // OEM Greek + 775 => 'CP775', // OEM Baltic + 850 => 'CP850', // OEM Latin I + 852 => 'CP852', // OEM Latin II (Central European) + 855 => 'CP855', // OEM Cyrillic + 857 => 'CP857', // OEM Turkish + 858 => 'CP858', // OEM Multilingual Latin I with Euro + 860 => 'CP860', // OEM Portugese + 861 => 'CP861', // OEM Icelandic + 862 => 'CP862', // OEM Hebrew + 863 => 'CP863', // OEM Canadian (French) + 864 => 'CP864', // OEM Arabic + 865 => 'CP865', // OEM Nordic + 866 => 'CP866', // OEM Cyrillic (Russian) + 869 => 'CP869', // OEM Greek (Modern) + 874 => 'CP874', // ANSI Thai + 932 => 'CP932', // ANSI Japanese Shift-JIS + 936 => 'CP936', // ANSI Chinese Simplified GBK + 949 => 'CP949', // ANSI Korean (Wansung) + 950 => 'CP950', // ANSI Chinese Traditional BIG5 + 1200 => 'UTF-16LE', // UTF-16 (BIFF8) + 1250 => 'CP1250', // ANSI Latin II (Central European) + 1251 => 'CP1251', // ANSI Cyrillic + 1252 => 'CP1252', // ANSI Latin I (BIFF4-BIFF7) + 1253 => 'CP1253', // ANSI Greek + 1254 => 'CP1254', // ANSI Turkish + 1255 => 'CP1255', // ANSI Hebrew + 1256 => 'CP1256', // ANSI Arabic + 1257 => 'CP1257', // ANSI Baltic + 1258 => 'CP1258', // ANSI Vietnamese + 1361 => 'CP1361', // ANSI Korean (Johab) + 10000 => 'MAC', // Apple Roman + 10001 => 'CP932', // Macintosh Japanese + 10002 => 'CP950', // Macintosh Chinese Traditional + 10003 => 'CP1361', // Macintosh Korean + 10004 => 'MACARABIC', // Apple Arabic + 10005 => 'MACHEBREW', // Apple Hebrew + 10006 => 'MACGREEK', // Macintosh Greek + 10007 => 'MACCYRILLIC', // Macintosh Cyrillic + 10008 => 'CP936', // Macintosh - Simplified Chinese (GB 2312) + 10010 => 'MACROMANIA', // Macintosh Romania + 10017 => 'MACUKRAINE', // Macintosh Ukraine + 10021 => 'MACTHAI', // Macintosh Thai + 10029 => 'MACCENTRALEUROPE', // Macintosh Central Europe + 10079 => 'MACICELAND', // Macintosh Icelandic + 10081 => 'MACTURKISH', // Macintosh Turkish + 10082 => 'MACCROATIAN', // Macintosh Croatian + 21010 => 'UTF-16LE', // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE + 32768 => 'MAC', // Apple Roman + //32769 => 'unsupported', // ANSI Latin I (BIFF2-BIFF3) + 65000 => 'UTF-7', // Unicode (UTF-7) + 65001 => 'UTF-8', // Unicode (UTF-8) + ]; + /** * Convert Microsoft Code Page Identifier to Code Page Name which iconv * and mbstring understands. @@ -14,123 +73,20 @@ class CodePage * * @return string Code Page Name */ - public static function numberToName($codePage) + public static function numberToName(int $codePage): string { - switch ($codePage) { - case 367: - return 'ASCII'; // ASCII - case 437: - return 'CP437'; // OEM US - case 720: - throw new PhpSpreadsheetException('Code page 720 not supported.'); // OEM Arabic - case 737: - return 'CP737'; // OEM Greek - case 775: - return 'CP775'; // OEM Baltic - case 850: - return 'CP850'; // OEM Latin I - case 852: - return 'CP852'; // OEM Latin II (Central European) - case 855: - return 'CP855'; // OEM Cyrillic - case 857: - return 'CP857'; // OEM Turkish - case 858: - return 'CP858'; // OEM Multilingual Latin I with Euro - case 860: - return 'CP860'; // OEM Portugese - case 861: - return 'CP861'; // OEM Icelandic - case 862: - return 'CP862'; // OEM Hebrew - case 863: - return 'CP863'; // OEM Canadian (French) - case 864: - return 'CP864'; // OEM Arabic - case 865: - return 'CP865'; // OEM Nordic - case 866: - return 'CP866'; // OEM Cyrillic (Russian) - case 869: - return 'CP869'; // OEM Greek (Modern) - case 874: - return 'CP874'; // ANSI Thai - case 932: - return 'CP932'; // ANSI Japanese Shift-JIS - case 936: - return 'CP936'; // ANSI Chinese Simplified GBK - case 949: - return 'CP949'; // ANSI Korean (Wansung) - case 950: - return 'CP950'; // ANSI Chinese Traditional BIG5 - case 1200: - return 'UTF-16LE'; // UTF-16 (BIFF8) - case 1250: - return 'CP1250'; // ANSI Latin II (Central European) - case 1251: - return 'CP1251'; // ANSI Cyrillic - case 0: - // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program - case 1252: - return 'CP1252'; // ANSI Latin I (BIFF4-BIFF7) - case 1253: - return 'CP1253'; // ANSI Greek - case 1254: - return 'CP1254'; // ANSI Turkish - case 1255: - return 'CP1255'; // ANSI Hebrew - case 1256: - return 'CP1256'; // ANSI Arabic - case 1257: - return 'CP1257'; // ANSI Baltic - case 1258: - return 'CP1258'; // ANSI Vietnamese - case 1361: - return 'CP1361'; // ANSI Korean (Johab) - case 10000: - return 'MAC'; // Apple Roman - case 10001: - return 'CP932'; // Macintosh Japanese - case 10002: - return 'CP950'; // Macintosh Chinese Traditional - case 10003: - return 'CP1361'; // Macintosh Korean - case 10004: - return 'MACARABIC'; // Apple Arabic - case 10005: - return 'MACHEBREW'; // Apple Hebrew - case 10006: - return 'MACGREEK'; // Macintosh Greek - case 10007: - return 'MACCYRILLIC'; // Macintosh Cyrillic - case 10008: - return 'CP936'; // Macintosh - Simplified Chinese (GB 2312) - case 10010: - return 'MACROMANIA'; // Macintosh Romania - case 10017: - return 'MACUKRAINE'; // Macintosh Ukraine - case 10021: - return 'MACTHAI'; // Macintosh Thai - case 10029: - return 'MACCENTRALEUROPE'; // Macintosh Central Europe - case 10079: - return 'MACICELAND'; // Macintosh Icelandic - case 10081: - return 'MACTURKISH'; // Macintosh Turkish - case 10082: - return 'MACCROATIAN'; // Macintosh Croatian - case 21010: - return 'UTF-16LE'; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE - case 32768: - return 'MAC'; // Apple Roman - case 32769: - throw new PhpSpreadsheetException('Code page 32769 not supported.'); // ANSI Latin I (BIFF2-BIFF3) - case 65000: - return 'UTF-7'; // Unicode (UTF-7) - case 65001: - return 'UTF-8'; // Unicode (UTF-8) + if (array_key_exists($codePage, self::$pageArray)) { + return self::$pageArray[$codePage]; + } + if ($codePage == 720 || $codePage == 32769) { + throw new PhpSpreadsheetException("Code page $codePage not supported."); // OEM Arabic } throw new PhpSpreadsheetException('Unknown codepage: ' . $codePage); } + + public static function getEncodings(): array + { + return self::$pageArray; + } } diff --git a/tests/PhpSpreadsheetTests/Shared/CodePageTest.php b/tests/PhpSpreadsheetTests/Shared/CodePageTest.php index b86f9015d6..2bdbda72f7 100644 --- a/tests/PhpSpreadsheetTests/Shared/CodePageTest.php +++ b/tests/PhpSpreadsheetTests/Shared/CodePageTest.php @@ -24,6 +24,22 @@ public function providerCodePage() return require 'tests/data/Shared/CodePage.php'; } + public function testCoverage(): void + { + $covered = []; + $expected = CodePage::getEncodings(); + foreach ($expected as $key => $val) { + $covered[$key] = 0; + } + $tests = $this->providerCodePage(); + foreach ($tests as $test) { + $covered[$test[1]] = 1; + } + foreach ($covered as $key => $val) { + self::assertEquals(1, $val, "Codepage $key not tested"); + } + } + public function testNumberToNameWithInvalidCodePage(): void { $invalidCodePage = 12345; diff --git a/tests/data/Shared/CodePage.php b/tests/data/Shared/CodePage.php index 1cf09d882e..82bb23e4a5 100644 --- a/tests/data/Shared/CodePage.php +++ b/tests/data/Shared/CodePage.php @@ -1,6 +1,11 @@ Date: Sun, 24 May 2020 03:54:59 -0700 Subject: [PATCH 058/659] Restore working directory if test fails (#1490) This test changes directory then performs an assertion. No problem if the assertion succeeds. I was a little concerned about what would happen if the assertion fails, leaving us in the new directory. So I have changed test to use setUp/tearDown to ensure that we end up where we started. --- .../Writer/Html/ImagesRootTest.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/PhpSpreadsheetTests/Writer/Html/ImagesRootTest.php b/tests/PhpSpreadsheetTests/Writer/Html/ImagesRootTest.php index 5c887d531c..6cc7f18f55 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/ImagesRootTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/ImagesRootTest.php @@ -9,6 +9,18 @@ class ImagesRootTest extends Functional\AbstractFunctional { + private $curdir; + + protected function setUp(): void + { + $this->curdir = getcwd(); + } + + protected function tearDown(): void + { + chdir($this->curdir); + } + public function testImagesRoot(): void { $spreadsheet = new Spreadsheet(); @@ -20,7 +32,6 @@ public function testImagesRoot(): void $newdir = __DIR__ . '/../../../data/Reader/HTML'; $stub = 'image.jpg'; $imagePath = "./$stub"; - $curdir = getcwd(); chdir($newdir); self::assertFileExists($imagePath); $drawing->setPath($imagePath); @@ -34,7 +45,6 @@ public function testImagesRoot(): void $writer = new Html($spreadsheet); $writer->setImagesRoot($root); $html = $writer->generateHTMLAll(); - chdir($curdir); $dom = new DOMDocument(); $dom->loadHTML($html); $body = $dom->getElementsByTagName('body')[0]; From 41b95c15422a3a2cc4dc35dd25214c1b07353bb1 Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 24 May 2020 03:57:39 -0700 Subject: [PATCH 059/659] CSV Sample File Was Miscoded (#1489) File author erroneously assumed that backslash was used to escape quotes in CSV; in fact, doubling the quote is used for escape. The test still worked, but mainly because the content of the cell with the escape wasn't tested. The file is now fixed, and a new test added. --- tests/PhpSpreadsheetTests/Reader/CsvTest.php | 31 +++++++++++++++++ .../Reader/CSV/line_break_escaped_32le.csv | Bin 0 -> 2120 bytes ...break_in_enclosure_with_escaped_quotes.csv | 32 +++++++++--------- 3 files changed, 47 insertions(+), 16 deletions(-) create mode 100644 tests/data/Reader/CSV/line_break_escaped_32le.csv diff --git a/tests/PhpSpreadsheetTests/Reader/CsvTest.php b/tests/PhpSpreadsheetTests/Reader/CsvTest.php index cb2b619672..e4ccd93114 100644 --- a/tests/PhpSpreadsheetTests/Reader/CsvTest.php +++ b/tests/PhpSpreadsheetTests/Reader/CsvTest.php @@ -200,6 +200,37 @@ public function testUtf16LineBreak(): void self::assertEquals($expected, $sheet->getCell('B3')->getValue()); } + public function testLineBreakEscape(): void + { + $reader = new Csv(); + $spreadsheet = $reader->load('tests/data/Reader/CSV/line_break_in_enclosure_with_escaped_quotes.csv'); + $sheet = $spreadsheet->getActiveSheet(); + $expected = <<getCell('B3')->getValue()); + } + + public function testUtf32LineBreakEscape(): void + { + $reader = new Csv(); + $reader->setInputEncoding('UTF-32LE'); + $spreadsheet = $reader->load('tests/data/Reader/CSV/line_break_escaped_32le.csv'); + $sheet = $spreadsheet->getActiveSheet(); + $expected = <<getCell('B3')->getValue()); + } + public function testSeparatorLine(): void { $reader = new Csv(); diff --git a/tests/data/Reader/CSV/line_break_escaped_32le.csv b/tests/data/Reader/CSV/line_break_escaped_32le.csv new file mode 100644 index 0000000000000000000000000000000000000000..8e0f0243ecadcb1773684cf9c78913d7dbcc310a GIT binary patch literal 2120 zcmeH_NeTin5Jj{06v4IV-mP14A?*R$S)6CQz3+hqjo=B);?YUv*H2ZtMk%El_OO5s z4B!YSc!9AAj9~~Zs6hP{ZlIfX@CGy6u+9Jg literal 0 HcmV?d00001 diff --git a/tests/data/Reader/CSV/line_break_in_enclosure_with_escaped_quotes.csv b/tests/data/Reader/CSV/line_break_in_enclosure_with_escaped_quotes.csv index e84db1b555..01ce36a60b 100644 --- a/tests/data/Reader/CSV/line_break_in_enclosure_with_escaped_quotes.csv +++ b/tests/data/Reader/CSV/line_break_in_enclosure_with_escaped_quotes.csv @@ -1,21 +1,21 @@ Name,Copy,URL -Test,"This is a \"test csv file\" -with both \"line breaks\" -and \"escaped -quotes\" that breaks +Test,"This is a ""test csv file"" +with both ""line breaks"" +and ""escaped +quotes"" that breaks the delimiters",http://google.com -Test,"This is a \"test csv file\" -with both \"line breaks\" -and \"escaped -quotes\" that breaks +Test,"This is a ""test csv file"" +with both ""line breaks"" +and ""escaped +quotes"" that breaks the delimiters",http://google.com -Test,"This is a \"test csv file\" -with both \"line breaks\" -and \"escaped -quotes\" that breaks +Test,"This is a ""test csv file"" +with both ""line breaks"" +and ""escaped +quotes"" that breaks the delimiters",http://google.com -Test,"This is a \"test csv file\" -with both \"line breaks\" -and \"escaped -quotes\" that breaks +Test,"This is a ""test csv file"" +with both ""line breaks"" +and ""escaped +quotes"" that breaks the delimiters",http://google.com From 585409a9496912983f6722c58f19fbd7527b4227 Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 24 May 2020 04:03:07 -0700 Subject: [PATCH 060/659] Testing - Delete Temp Files When No Longer Needed (#1488) No code changes. The tests in all of these scripts write to at least one temporary file, which is then read and not used again. The file should be deleted to avoid filling up the disk system. --- samples/Basic/07_Reader.php | 1 + samples/Basic/16_Csv.php | 12 ++++++++---- samples/Basic/20_Read_Xls.php | 1 + samples/Basic/24_Readfilter.php | 4 +++- samples/Basic/28_Iterator.php | 9 +++++---- samples/Basic/44_Worksheet_info.php | 2 ++ samples/Chart/34_Chart_update.php | 12 +++++++----- .../Calculation/DefinedNameConfusedForCellTest.php | 1 + tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php | 10 ++-------- tests/PhpSpreadsheetTests/Reader/XlsxTest.php | 1 + .../Writer/Html/InvalidFileNameTest.php | 13 +++++++++++-- .../Writer/Xls/FormulaErrTest.php | 9 +-------- .../Writer/Xlsx/FloatsRetainedTest.php | 1 + 13 files changed, 44 insertions(+), 32 deletions(-) diff --git a/samples/Basic/07_Reader.php b/samples/Basic/07_Reader.php index 4d9bd79e2f..67b3ae561d 100644 --- a/samples/Basic/07_Reader.php +++ b/samples/Basic/07_Reader.php @@ -17,3 +17,4 @@ // Save $helper->write($spreadsheet, __FILE__); +unlink($filename); diff --git a/samples/Basic/16_Csv.php b/samples/Basic/16_Csv.php index de753d565a..15bbf0d456 100644 --- a/samples/Basic/16_Csv.php +++ b/samples/Basic/16_Csv.php @@ -1,13 +1,15 @@ log('Write to CSV format'); /** @var \PhpOffice\PhpSpreadsheet\Writer\Csv $writer */ -$writer = IOFactory::createWriter($spreadsheet, 'Csv')->setDelimiter(',') +$writer = new CsvWriter($spreadsheet); +$writer->setDelimiter(',') ->setEnclosure('"') ->setSheetIndex(0); @@ -19,13 +21,15 @@ $helper->log('Read from CSV format'); /** @var \PhpOffice\PhpSpreadsheet\Reader\Csv $reader */ -$reader = IOFactory::createReader('Csv')->setDelimiter(',') +$reader = new CsvReader(); +$reader->setDelimiter(',') ->setEnclosure('"') ->setSheetIndex(0); $callStartTime = microtime(true); $spreadsheetFromCSV = $reader->load($filename); $helper->logRead('Csv', $filename, $callStartTime); +unlink($filename); // Write Xlsx $helper->write($spreadsheetFromCSV, __FILE__, ['Xlsx']); @@ -33,7 +37,7 @@ // Write CSV $filenameCSV = $helper->getFilename(__FILE__, 'csv'); /** @var \PhpOffice\PhpSpreadsheet\Writer\Csv $writerCSV */ -$writerCSV = IOFactory::createWriter($spreadsheetFromCSV, 'Csv'); +$writerCSV = new CsvWriter($spreadsheetFromCSV); $writerCSV->setExcelCompatibility(true); $callStartTime = microtime(true); diff --git a/samples/Basic/20_Read_Xls.php b/samples/Basic/20_Read_Xls.php index 9e5fa014ad..daeaf66437 100644 --- a/samples/Basic/20_Read_Xls.php +++ b/samples/Basic/20_Read_Xls.php @@ -17,6 +17,7 @@ $callStartTime = microtime(true); $spreadsheet = IOFactory::load($filename); $helper->logRead('Xls', $filename, $callStartTime); +unlink($filename); // Save $helper->write($spreadsheet, __FILE__); diff --git a/samples/Basic/24_Readfilter.php b/samples/Basic/24_Readfilter.php index 844996f249..ab1c2e411c 100644 --- a/samples/Basic/24_Readfilter.php +++ b/samples/Basic/24_Readfilter.php @@ -3,6 +3,7 @@ namespace PhpOffice\PhpSpreadsheet; use PhpOffice\PhpSpreadsheet\Reader\IReadFilter; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; require __DIR__ . '/../Header.php'; @@ -29,10 +30,11 @@ public function readCell($column, $row, $worksheetName = '') } $helper->log('Load from Xlsx file'); -$reader = IOFactory::createReader('Xlsx'); +$reader = new XlsxReader(); $reader->setReadFilter(new MyReadFilter()); $callStartTime = microtime(true); $spreadsheet = $reader->load($filename); +unlink($filename); $helper->logRead('Xlsx', $filename, $callStartTime); $helper->log('Remove unnecessary rows'); $spreadsheet->getActiveSheet()->removeRow(2, 18); diff --git a/samples/Basic/28_Iterator.php b/samples/Basic/28_Iterator.php index 4aec7a9203..104dc47f36 100644 --- a/samples/Basic/28_Iterator.php +++ b/samples/Basic/28_Iterator.php @@ -1,21 +1,22 @@ getTemporaryFilename(); -$writer = new Xlsx($sampleSpreadsheet); +$writer = new XlsxWriter($sampleSpreadsheet); $callStartTime = microtime(true); $writer->save($filename); $helper->logWrite($writer, $filename, $callStartTime); $callStartTime = microtime(true); -$reader = IOFactory::createReader('Xlsx'); +$reader = new XlsxReader(); $spreadsheet = $reader->load($filename); $helper->logRead('Xlsx', $filename, $callStartTime); +unlink($filename); $helper->log('Iterate worksheets'); foreach ($spreadsheet->getWorksheetIterator() as $worksheet) { $helper->log('Worksheet - ' . $worksheet->getTitle()); diff --git a/samples/Basic/44_Worksheet_info.php b/samples/Basic/44_Worksheet_info.php index 33c0cd0577..578223699c 100644 --- a/samples/Basic/44_Worksheet_info.php +++ b/samples/Basic/44_Worksheet_info.php @@ -24,3 +24,5 @@ $helper->log('Worksheet Names:'); var_dump($sheetInfo); + +unlink($filename); diff --git a/samples/Chart/34_Chart_update.php b/samples/Chart/34_Chart_update.php index a428792776..5d725c4947 100644 --- a/samples/Chart/34_Chart_update.php +++ b/samples/Chart/34_Chart_update.php @@ -1,20 +1,22 @@ getTemporaryFilename(); -$writer = new Xlsx($sampleSpreadsheet); +$writer = new XlsxWriter($sampleSpreadsheet); +$writer->setIncludeCharts(true); $writer->save($filename); $helper->log('Load from Xlsx file'); -$reader = IOFactory::createReader('Xlsx'); +$reader = new XlsxReader(); $reader->setIncludeCharts(true); $spreadsheet = $reader->load($filename); +unlink($filename); $helper->log('Update cell data values that are displayed in the chart'); $worksheet = $spreadsheet->getActiveSheet(); @@ -31,7 +33,7 @@ // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = new XlsxWriter($spreadsheet); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/tests/PhpSpreadsheetTests/Calculation/DefinedNameConfusedForCellTest.php b/tests/PhpSpreadsheetTests/Calculation/DefinedNameConfusedForCellTest.php index 12d73356ae..76886c235f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/DefinedNameConfusedForCellTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/DefinedNameConfusedForCellTest.php @@ -18,5 +18,6 @@ public function testDefinedName(): void $filename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); $writer->save($filename); self::assertTrue(true); + unlink($filename); } } diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php index 4d0b6a8a1f..1220c3784d 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php @@ -11,14 +11,6 @@ class Xlsx2Test extends TestCase { - protected function tearDown(): void - { - $outfile = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); - if (file_exists($outfile)) { - unlink($outfile); - } - } - public function testLoadXlsxConditionalFormatting2(): void { // Make sure Conditionals are read correctly from existing file @@ -63,6 +55,7 @@ public function testReloadXlsxConditionalFormatting2(): void $writer = IOFactory::createWriter($spreadshee1, 'Xlsx'); $writer->save($outfile); $spreadsheet = $reader->load($outfile); + unlink($outfile); $worksheet = $spreadsheet->getActiveSheet(); $conditionalStyle = $worksheet->getConditionalStyles('A2:A8'); @@ -110,6 +103,7 @@ public function testNewXlsxConditionalFormatting2(): void $writer->save($outfile); $reader = IOFactory::createReader('Xlsx'); $spreadsheet = $reader->load($outfile); + unlink($outfile); $worksheet = $spreadsheet->getActiveSheet(); $conditionalStyle = $worksheet->getConditionalStyles('A1:A6'); diff --git a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php index 9e0b5f662a..b326c14249 100644 --- a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php @@ -222,6 +222,7 @@ public function testLoadSaveWithEmptyDrawings(): void $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($excel); $writer->save($resultFilename); $excel = $reader->load($resultFilename); + unlink($resultFilename); // Fake assert. The only thing we need is to ensure the file is loaded without exception self::assertNotNull($excel); } diff --git a/tests/PhpSpreadsheetTests/Writer/Html/InvalidFileNameTest.php b/tests/PhpSpreadsheetTests/Writer/Html/InvalidFileNameTest.php index 7baa233842..36a40e965b 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/InvalidFileNameTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/InvalidFileNameTest.php @@ -30,9 +30,8 @@ public function testEmptyFileNamePdf(): void $writer->save(''); } - public function testEmptyTempdirNamePdf(): void + public function testNotEmptyTempdirNamePdf(): void { - $this->expectException(WriterException::class); $spreadsheet = new Spreadsheet(); $spreadsheet->getActiveSheet()->getCell('A1')->setValue('Cell 1'); $writer = new Mpdf($spreadsheet); @@ -41,6 +40,16 @@ public function testEmptyTempdirNamePdf(): void $writer->setPaperSize(PageSetup::PAPERSIZE_LEDGER); self::assertEquals($writer->getPaperSize(), PageSetup::PAPERSIZE_LEDGER); self::assertEquals(File::sysGetTempDir() . '/phpsppdf', $writer->getTempDir()); + $writer->setTempDir(File::sysGetTempDir()); + self::assertEquals(File::sysGetTempDir(), $writer->getTempDir()); + } + + public function testEmptyTempdirNamePdf(): void + { + $this->expectException(WriterException::class); + $spreadsheet = new Spreadsheet(); + $spreadsheet->getActiveSheet()->getCell('A1')->setValue('Cell 1'); + $writer = new Mpdf($spreadsheet); $writer->setTempDir(''); } diff --git a/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php b/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php index 61c70cb69b..21a7c9281f 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php @@ -9,14 +9,6 @@ class FormulaErrTest extends TestCase { - protected function tearDown(): void - { - $filename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); - if (file_exists($filename)) { - unlink($filename); - } - } - public function testFormulaError(): void { $obj = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); @@ -31,6 +23,7 @@ public function testFormulaError(): void $writer->save($filename); $reader = IOFactory::createReader('Xls'); $robj = $reader->load($filename); + unlink($filename); $sheet0 = $robj->setActiveSheetIndex(0); $a1 = $sheet0->getCell('A1')->getCalculatedValue(); self::assertEquals(2, $a1); diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/FloatsRetainedTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/FloatsRetainedTest.php index aad074de32..746b9846ae 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/FloatsRetainedTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/FloatsRetainedTest.php @@ -28,6 +28,7 @@ public function testIntyFloatsRetainedByWriter($value): void $reader = new Reader(); $sheet = $reader->load($outputFilename); + unlink($outputFilename); self::assertSame($value, $sheet->getActiveSheet()->getCell('A1')->getValue()); } From 5dd7e883c6bd409063882de2cde1a07a556f25be Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 24 May 2020 11:02:39 -0700 Subject: [PATCH 061/659] Fix Issue 1441 (isDateTime and Formulas) (#1480) * Fix Issue 1441 (isDateTime and Formulas) When you have a date-field which is a formula, isDateTime returns false. https://github.com/PHPOffice/PhpSpreadsheet/issues/1441 Report makes sense; fixed as suggested. Also fixed a few minor related issues, and added tests so that Shared/Date and Shared/TimeZone are now completely covered. Date/setDefaultTimeZone and TimeZone/setTimeZone were not consistent about what to do in event of failure - return false or throw. They will now both return false, which is what Date's function said it would do in its doc block anyhow. Date/validateTimeZone will continue to throw; it was protected, but was never called outside Date, so I changed it to private. TimeZone/getTimeZoneAdjustment checked for 'UST' when it probably meant 'UTC', and, as it turns out, the check is not even needed. The most serious problem was that TimeZone/validateTimeZone does not check the backwards-compatible time zones. The timezone project aggressively, and very controversially, "demotes" timezones; such timezones eventually wind up in the PHP backwards-compatible list. We want to make sure to check that list so that our applications do not break when this happens. --- src/PhpSpreadsheet/Shared/Date.php | 25 ++++---- src/PhpSpreadsheet/Shared/TimeZone.php | 6 +- tests/PhpSpreadsheetTests/Shared/DateTest.php | 50 ++++++++++++++++ .../Shared/TimeZoneTest.php | 58 ++++++++++++++++++- tests/data/Shared/Date/FormatCodes.php | 4 ++ 5 files changed, 125 insertions(+), 18 deletions(-) diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index fd49c1ecad..9dc9929269 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -4,10 +4,10 @@ use DateTimeInterface; use DateTimeZone; -use Exception; use PhpOffice\PhpSpreadsheet\Calculation\DateTime; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Cell\Cell; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; class Date @@ -97,17 +97,18 @@ public static function getExcelCalendar() * @param DateTimeZone|string $timeZone The timezone to set for all Excel datetimestamp to PHP DateTime Object conversions * * @return bool Success or failure - * @return bool Success or failure */ public static function setDefaultTimezone($timeZone) { - if ($timeZone = self::validateTimeZone($timeZone)) { + try { + $timeZone = self::validateTimeZone($timeZone); self::$defaultTimeZone = $timeZone; - - return true; + $retval = true; + } catch (PhpSpreadsheetException $e) { + $retval = false; } - return false; + return $retval; } /** @@ -130,17 +131,17 @@ public static function getDefaultTimezone() * @param DateTimeZone|string $timeZone The timezone to validate, either as a timezone string or object * * @return DateTimeZone The timezone as a timezone object - * @return DateTimeZone The timezone as a timezone object */ - protected static function validateTimeZone($timeZone) + private static function validateTimeZone($timeZone) { - if (is_object($timeZone) && $timeZone instanceof DateTimeZone) { + if ($timeZone instanceof DateTimeZone) { return $timeZone; - } elseif (is_string($timeZone)) { + } + if (in_array($timeZone, DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC))) { return new DateTimeZone($timeZone); } - throw new Exception('Invalid timezone'); + throw new PhpSpreadsheetException('Invalid timezone'); } /** @@ -316,7 +317,7 @@ public static function formattedPHPToExcel($year, $month, $day, $hours = 0, $min */ public static function isDateTime(Cell $pCell) { - return is_numeric($pCell->getValue()) && + return is_numeric($pCell->getCalculatedValue()) && self::isDateTimeFormat( $pCell->getWorksheet()->getStyle( $pCell->getCoordinate() diff --git a/src/PhpSpreadsheet/Shared/TimeZone.php b/src/PhpSpreadsheet/Shared/TimeZone.php index a87987dffc..43fd365369 100644 --- a/src/PhpSpreadsheet/Shared/TimeZone.php +++ b/src/PhpSpreadsheet/Shared/TimeZone.php @@ -23,7 +23,7 @@ class TimeZone */ private static function validateTimeZone($timezone) { - return in_array($timezone, DateTimeZone::listIdentifiers()); + return in_array($timezone, DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC)); } /** @@ -73,10 +73,6 @@ public static function getTimeZoneAdjustment($timezone, $timestamp) $timezone = self::$timezone; } - if ($timezone == 'UST') { - return 0; - } - $objTimezone = new DateTimeZone($timezone); $transitions = $objTimezone->getTransitions($timestamp, $timestamp); diff --git a/tests/PhpSpreadsheetTests/Shared/DateTest.php b/tests/PhpSpreadsheetTests/Shared/DateTest.php index 23b310760d..7254635ea3 100644 --- a/tests/PhpSpreadsheetTests/Shared/DateTest.php +++ b/tests/PhpSpreadsheetTests/Shared/DateTest.php @@ -3,10 +3,23 @@ namespace PhpOffice\PhpSpreadsheetTests\Shared; use PhpOffice\PhpSpreadsheet\Shared\Date; +use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PHPUnit\Framework\TestCase; class DateTest extends TestCase { + private $dttimezone; + + protected function setUp(): void + { + $this->dttimezone = Date::getDefaultTimeZone(); + } + + protected function tearDown(): void + { + Date::setDefaultTimeZone($this->dttimezone); + } + public function testSetExcelCalendar(): void { $calendarValues = [ @@ -168,4 +181,41 @@ public function providerDateTimeExcelToTimestamp1900Timezone() { return require 'tests/data/Shared/Date/ExcelToTimestamp1900Timezone.php'; } + + public function testVarious(): void + { + Date::setDefaultTimeZone('UTC'); + self::assertFalse(Date::stringToExcel('2019-02-29')); + self::assertTrue((bool) Date::stringToExcel('2019-02-28')); + self::assertTrue((bool) Date::stringToExcel('2019-02-28 11:18')); + self::assertFalse(Date::stringToExcel('2019-02-28 11:71')); + $date = Date::PHPToExcel('2020-01-01'); + self::assertEquals(43831.0, $date); + $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('B1', 'x'); + $val = $sheet->getCell('B1')->getValue(); + self::assertFalse(Date::timestampToExcel($val)); + $cell = $sheet->getCell('A1'); + self::assertNotNull($cell); + $cell->setValue($date); + $sheet->getStyle('A1') + ->getNumberFormat() + ->setFormatCode(NumberFormat::FORMAT_DATE_DATETIME); + self::assertTrue(null !== $cell && Date::isDateTime($cell)); + $cella2 = $sheet->getCell('A2'); + self::assertNotNull($cella2); + $cella2->setValue('=A1+2'); + $sheet->getStyle('A2') + ->getNumberFormat() + ->setFormatCode(NumberFormat::FORMAT_DATE_DATETIME); + self::assertTrue(null !== $cella2 && Date::isDateTime($cella2)); + $cella3 = $sheet->getCell('A3'); + self::assertNotNull($cella3); + $cella3->setValue('=A1+4'); + $sheet->getStyle('A3') + ->getNumberFormat() + ->setFormatCode('0.00E+00'); + self::assertFalse(null !== $cella3 && Date::isDateTime($cella3)); + } } diff --git a/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php b/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php index f6e2f5d511..ff38badf29 100644 --- a/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php +++ b/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php @@ -2,11 +2,29 @@ namespace PhpOffice\PhpSpreadsheetTests\Shared; +use DateTime; +use PhpOffice\PhpSpreadsheet\Shared\Date; use PhpOffice\PhpSpreadsheet\Shared\TimeZone; use PHPUnit\Framework\TestCase; class TimeZoneTest extends TestCase { + private $tztimezone; + + private $dttimezone; + + protected function setUp(): void + { + $this->tztimezone = TimeZone::getTimeZone(); + $this->dttimezone = Date::getDefaultTimeZone(); + } + + protected function tearDown(): void + { + TimeZone::setTimeZone($this->tztimezone); + Date::setDefaultTimeZone($this->dttimezone); + } + public function testSetTimezone(): void { $timezoneValues = [ @@ -20,13 +38,51 @@ public function testSetTimezone(): void foreach ($timezoneValues as $timezoneValue) { $result = TimeZone::setTimezone($timezoneValue); self::assertTrue($result); + $result = Date::setDefaultTimezone($timezoneValue); + self::assertTrue($result); } } + public function testSetTimezoneBackwardCompatible(): void + { + $bcTimezone = 'Etc/GMT+10'; + $result = TimeZone::setTimezone($bcTimezone); + self::assertTrue($result); + $result = Date::setDefaultTimezone($bcTimezone); + self::assertTrue($result); + } + public function testSetTimezoneWithInvalidValue(): void { - $unsupportedTimezone = 'Etc/GMT+10'; + $unsupportedTimezone = 'XEtc/GMT+10'; $result = TimeZone::setTimezone($unsupportedTimezone); self::assertFalse($result); + $result = Date::setDefaultTimezone($unsupportedTimezone); + self::assertFalse($result); + } + + public function testTimeZoneAdjustmentsInvalidTz(): void + { + $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); + $dtobj = DateTime::createFromFormat('Y-m-d H:i:s', '2008-09-22 00:00:00'); + $tstmp = $dtobj->getTimestamp(); + $unsupportedTimeZone = 'XEtc/GMT+10'; + TimeZone::getTimeZoneAdjustment($unsupportedTimeZone, $tstmp); + } + + public function testTimeZoneAdjustments(): void + { + $dtobj = DateTime::createFromFormat('Y-m-d H:i:s', '2008-01-01 00:00:00'); + $tstmp = $dtobj->getTimestamp(); + $supportedTimeZone = 'UTC'; + $adj = TimeZone::getTimeZoneAdjustment($supportedTimeZone, $tstmp); + self::assertEquals(0, $adj); + $supportedTimeZone = 'America/Toronto'; + $adj = TimeZone::getTimeZoneAdjustment($supportedTimeZone, $tstmp); + self::assertEquals(-18000, $adj); + $supportedTimeZone = 'America/Chicago'; + TimeZone::setTimeZone($supportedTimeZone); + $adj = TimeZone::getTimeZoneAdjustment(null, $tstmp); + self::assertEquals(-21600, $adj); } } diff --git a/tests/data/Shared/Date/FormatCodes.php b/tests/data/Shared/Date/FormatCodes.php index 7245000afd..64810de3a6 100644 --- a/tests/data/Shared/Date/FormatCodes.php +++ b/tests/data/Shared/Date/FormatCodes.php @@ -146,4 +146,8 @@ false, '#,##0.00 "dollars"', ], + [ + true, + '"date " y-m-d', + ], ]; From 5a92a5f6b42e985da6345d996197e9cb27a1d5f9 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 25 May 2020 11:19:13 +0900 Subject: [PATCH 062/659] Scrutinizer wait shorter for coverage Since switching to pcov Travis build are much faster and we don't need to wait that long --- .scrutinizer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 748f3ac3fa..08c6125539 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -18,7 +18,7 @@ build: tools: external_code_coverage: - timeout: 3600 + timeout: 600 build_failure_conditions: - 'elements.rating(<= C).new.exists' # No new classes/methods with a rating of C or worse allowed From 7ed96e0be15ef292bc05283b3f6122fc0f28968b Mon Sep 17 00:00:00 2001 From: Alban Duval Date: Mon, 25 May 2020 21:33:48 +0200 Subject: [PATCH 063/659] Calcualtion - DATEDIF - fix result for Y & YM units (#1466) Bugfix for negative results and too small results 2000-02-02 => 2001-02-01 > DATEDIF with Y unit: 0 year (returned -1 before fix) > DATEDIF with YM unit: 11 months (returned -1 before fix) --- src/PhpSpreadsheet/Calculation/DateTime.php | 30 +++++---------------- tests/data/Calculation/DateTime/DATEDIF.php | 14 +++++++++- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index d08ab54313..198607942f 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -668,30 +668,19 @@ public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') $endMonths = $PHPEndDateObject->format('n'); $endYears = $PHPEndDateObject->format('Y'); + $PHPDiffDateObject = $PHPEndDateObject->diff($PHPStartDateObject); + switch ($unit) { case 'D': $retVal = (int) $difference; break; case 'M': - $retVal = (int) ($endMonths - $startMonths) + ((int) ($endYears - $startYears) * 12); - // We're only interested in full months - if ($endDays < $startDays) { - --$retVal; - } + $retVal = (int) 12 * $PHPDiffDateObject->format('%y') + $PHPDiffDateObject->format('%m'); break; case 'Y': - $retVal = (int) ($endYears - $startYears); - // We're only interested in full months - if ($endMonths < $startMonths) { - --$retVal; - } elseif (($endMonths == $startMonths) && ($endDays < $startDays)) { - // Remove start month - --$retVal; - // Remove end month - --$retVal; - } + $retVal = (int) $PHPDiffDateObject->format('%y'); break; case 'MD': @@ -701,19 +690,12 @@ public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') $adjustDays = $PHPEndDateObject->format('j'); $retVal += ($adjustDays - $startDays); } else { - $retVal = $endDays - $startDays; + $retVal = (int) $PHPDiffDateObject->format('%d'); } break; case 'YM': - $retVal = (int) ($endMonths - $startMonths); - if ($retVal < 0) { - $retVal += 12; - } - // We're only interested in full months - if ($endDays < $startDays) { - --$retVal; - } + $retVal = (int) $PHPDiffDateObject->format('%m'); break; case 'YD': diff --git a/tests/data/Calculation/DateTime/DATEDIF.php b/tests/data/Calculation/DateTime/DATEDIF.php index d113d3aa05..a6d2d76122 100644 --- a/tests/data/Calculation/DateTime/DATEDIF.php +++ b/tests/data/Calculation/DateTime/DATEDIF.php @@ -393,6 +393,10 @@ 1, '19-12-1960', '26-01-2012', 'YM', ], + [ + 11, + '19-12-1960', '26-11-1962', 'YM', + ], [ 38, '19-12-1960', '26-01-2012', 'YD', @@ -402,7 +406,15 @@ '19-12-1960', '26-01-2012', 'MD', ], [ - 50, + 0, + '19-12-1960', '12-12-1961', 'Y', + ], + [ + 1, + '19-12-1960', '12-12-1962', 'Y', + ], + [ + 51, '19-12-1960', '12-12-2012', 'Y', ], [ From b3b0b49b7ccadc899d776c3ff406fa741ff46a4f Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Mon, 25 May 2020 21:41:02 +0200 Subject: [PATCH 064/659] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22fd8c3d74..fe1f159a98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Several improvements in HTML writer [#1464](https://github.com/PHPOffice/PhpSpreadsheet/pull/1464) - Fix incorrect behaviour when saving XLSX file with drawings [#1462](https://github.com/PHPOffice/PhpSpreadsheet/pull/1462), - Fix Crash while trying setting a cell the value "123456\n" [#1476](https://github.com/PHPOffice/PhpSpreadsheet/pull/1481) +- Improved DATEDIF() function and reduced errors for Y and YM units [#1466](https://github.com/PHPOffice/PhpSpreadsheet/pull/1466) ### Changed From 8b2bba9bdb6ca5969730462626d7866bac4bb00c Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Fri, 29 May 2020 21:53:28 +0200 Subject: [PATCH 065/659] Range operator tests (#1498) * Fix intersection operator when working with named ranges --- .../Calculation/Calculation.php | 10 ++-- .../Calculation/Engine/RangeTest.php | 53 ++++++++++++++++++- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index cdfe7b53ae..5aa309c552 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -3456,10 +3456,8 @@ private function _parseFormula($formula, ?Cell $pCell = null) if ((isset(self::$comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset(self::$comparisonOperators[$formula[$index + 1]]))) { $opCharacter .= $formula[++$index]; } - // Find out if we're currently at the beginning of a number, variable, cell reference, function, parenthesis or operand $isOperandOrFunction = preg_match($regexpMatchString, substr($formula, $index), $match); - if ($opCharacter == '-' && !$expectingOperator) { // Is it a negation instead of a minus? // Put a negation on the stack $stack->push('Unary Operator', '~', null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot); @@ -3776,8 +3774,12 @@ private function _parseFormula($formula, ?Cell $pCell = null) } // If we're expecting an operator, but only have a space between the previous and next operands (and both are // Cell References) then we have an INTERSECTION operator - if (($expectingOperator) && (preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '.*/Ui', substr($formula, $index), $match)) && - ($output[count($output) - 1]['type'] == 'Cell Reference')) { + if (($expectingOperator) && + ((preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '.*/Ui', substr($formula, $index), $match)) && + ($output[count($output) - 1]['type'] == 'Cell Reference') || + (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '.*/Ui', substr($formula, $index), $match)) && + ($output[count($output) - 1]['type'] == 'Named Range' || $output[count($output) - 1]['type'] == 'Value') + )) { while ($stack->count() > 0 && ($o2 = $stack->last()) && isset(self::$operators[$o2['value']]) && diff --git a/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php index 84cac74772..d1ad229b6c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php @@ -3,6 +3,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Engine; use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\NamedRange; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PHPUnit\Framework\TestCase; @@ -28,7 +29,7 @@ protected function setUp(): void /** * @dataProvider providerRangeEvaluation * - * @param mixed $formula + * @param string $formula * @param int $expectedResult */ public function testRangeEvaluation($formula, $expectedResult): void @@ -51,4 +52,54 @@ public function providerRangeEvaluation() ['=SUM(A1:B2 B2:C3)', 5], ]; } + + /** + * @dataProvider providerNamedRangeEvaluation + * + * @param string $group1 + * @param string $group2 + * @param string $formula + * @param int $expectedResult + */ + public function testNamedRangeEvaluation($group1, $group2, $formula, $expectedResult): void + { + $workSheet = $this->spreadSheet->getActiveSheet(); + $this->spreadSheet->addNamedRange(new NamedRange('GROUP1', $workSheet, $group1)); + $this->spreadSheet->addNamedRange(new NamedRange('GROUP2', $workSheet, $group2)); + + $workSheet->setCellValue('E1', $formula); + + $actualRresult = $workSheet->getCell('E1')->getCalculatedValue(); + self::assertSame($expectedResult, $actualRresult); + } + + public function providerNamedRangeEvaluation() + { + return[ + [ + 'A1:B3', + 'A1:C2', + '=SUM(GROUP1,GROUP2)', + 48, + ], + [ + 'A1:B3', + 'A1:C2', + '=SUM(GROUP1 GROUP2)', + 12, + ], + [ + 'A1:B2', + 'B2:C3', + '=SUM(GROUP1,GROUP2)', + 40, + ], + [ + 'A1:B2', + 'B2:C3', + '=SUM(GROUP1 GROUP2)', + 5, + ], + ]; + } } From edc411e6dd0ffbd7faf02aea9458f350d5a41574 Mon Sep 17 00:00:00 2001 From: Owen Leibman Date: Sat, 30 May 2020 21:27:35 -0700 Subject: [PATCH 066/659] Add ability to save edited Html/Pdf We give users the ability to edit Html/Pdf, but it's a little cumbersome to use the edited Html for an Html file, and difficult to use it for a Pdf. I believe we could make it fairly painless in both cases by allowing the user to set a callback to edit the generated Html. This can be accomplished with fewer than a dozen lines of very simple code. I think this would be easier than grabbing the Html in pieces, editing it, and reassembling it. I think it would also be simpler than an alternative I considered, namely the addition of a new method (e.g. saveEditedHtml) to each of the Html and Pdf writers. One edit that users might like to make when editing html is to add fallback fonts, something that is not currently available in PhpSpreadsheet, and might be difficult to add. A natural extension to that idea would be the use of webfonts, something which is guaranteed difficult to add. See samples/Basic/17b_Html for an example of this. None of the PDF writers support webfonts yet. That doesn't mean they won't do so in future, but, for now, samples/Pdf/21a_Pdf is a prosaic example of something you could do with this callback. In fact, this opens the door to letting the user replace the entire body with data of their choosing, effectively allowing PhpSpreadsheet (where you can set things like paper size and orientation) to be used as a front-end to the Pdf processor without the user having to be be overly familiar with the vagaries of the PDF processor. I think this is actually a pretty nice idea. YMMV. See samples/Basic/21b_Pdf for an example. --- docs/topics/reading-and-writing-to-file.md | 33 +++++++++++- samples/Basic/17b_Html.php | 27 ++++++++++ samples/Pdf/21a_Pdf.php | 47 ++++++++++++++++ samples/Pdf/21b_Pdf.php | 51 ++++++++++++++++++ src/PhpSpreadsheet/Writer/Html.php | 21 ++++++++ .../Writer/Html/CallbackTest.php | 53 +++++++++++++++++++ 6 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 samples/Basic/17b_Html.php create mode 100644 samples/Pdf/21a_Pdf.php create mode 100644 samples/Pdf/21b_Pdf.php create mode 100644 tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php diff --git a/docs/topics/reading-and-writing-to-file.md b/docs/topics/reading-and-writing-to-file.md index 8f92e1f232..abd7c5f314 100644 --- a/docs/topics/reading-and-writing-to-file.md +++ b/docs/topics/reading-and-writing-to-file.md @@ -693,7 +693,7 @@ $sty = $writer->generateStyles(false); // do not write $newstyle = << $sty -html { +body { background-color: yellow; } @@ -703,6 +703,31 @@ echo $writer->generateSheetData(); echo $writer->generateHTMLFooter(); ``` +#### Editing HTML During Save Via a Callback + +You can also add a callback function to edit the generated html +before saving. For example, you could add a webfont +(not currently supported for Pdf) as follows: + +``` php +function webfont(string $html): string +{ + $linktag = << + +EOF; + $html = preg_replace('@setEditHtmlCallback('webfont'); +$writer->save($filename); +``` + #### Writing UTF-8 HTML files A HTML file can be marked as UTF-8 by writing a BOM file header. This @@ -841,6 +866,12 @@ $writer->setPreCalculateFormulas(false); $writer->save("05featuredemo.pdf"); ``` +#### Editing Pdf During Save Via a Callback + +You can also add a callback function to edit the html used to +generate the Pdf before saving. +[See under Html](#editing-html-during-save-via-a-callback). + #### Decimal and thousands separators See section `\PhpOffice\PhpSpreadsheet\Writer\Csv` how to control the diff --git a/samples/Basic/17b_Html.php b/samples/Basic/17b_Html.php new file mode 100644 index 0000000000..0564931490 --- /dev/null +++ b/samples/Basic/17b_Html.php @@ -0,0 +1,27 @@ +getFilename(__FILE__, 'html'); +$writer = new Html($spreadsheet); + +function webfont(string $html): string +{ + $linktag = << + +EOF; + $html = preg_replace('@setEmbedImages(true); +$writer->setEditHtmlCallback('webfont'); +$writer->save($filename); +$helper->logWrite($writer, $filename, $callStartTime); diff --git a/samples/Pdf/21a_Pdf.php b/samples/Pdf/21a_Pdf.php new file mode 100644 index 0000000000..c4dc2c48e6 --- /dev/null +++ b/samples/Pdf/21a_Pdf.php @@ -0,0 +1,47 @@ +log('Hide grid lines'); +$spreadsheet->getActiveSheet()->setShowGridLines(false); + +$helper->log('Set orientation to landscape'); +$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE); + +function yellowBody(string $html): string +{ + $newstyle = << +body { +background-color: yellow; +} + + +EOF; + + return preg_replace('@@', "$newstyle", $html); +} + +$helper->log('Write to Dompdf'); +$writer = new Dompdf($spreadsheet); +$filename = $helper->getFileName('21a_Pdf_dompdf.xlsx', 'pdf'); +$writer->setEditHtmlCallback('yellowBody'); +$writer->save($filename); + +$helper->log('Write to Mpdf'); +$writer = new Mpdf($spreadsheet); +$filename = $helper->getFileName('21a_Pdf_mpdf.xlsx', 'pdf'); +$writer->setEditHtmlCallback('yellowBody'); +$writer->save($filename); + +$helper->log('Write to Tcpdf'); +$writer = new Tcpdf($spreadsheet); +$filename = $helper->getFileName('21a_Pdf_tcpdf.xlsx', 'pdf'); +$writer->setEditHtmlCallback('yellowBody'); +$writer->save($filename); diff --git a/samples/Pdf/21b_Pdf.php b/samples/Pdf/21b_Pdf.php new file mode 100644 index 0000000000..142fc344cd --- /dev/null +++ b/samples/Pdf/21b_Pdf.php @@ -0,0 +1,51 @@ +.*@ms'; + $bodyrepl = << +

Serif

+

$lorem

+

Sans-Serif

+

$lorem

+

Monospace

+

$lorem

+ +EOF; + + return preg_replace($bodystring, $bodyrepl, $html); +} + +require __DIR__ . '/../Header.php'; +$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php'; + +$helper->log('Hide grid lines'); +$spreadsheet->getActiveSheet()->setShowGridLines(false); + +$helper->log('Set orientation to landscape'); +$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE); + +$helper->log('Write to Dompdf'); +$writer = new Dompdf($spreadsheet); +$filename = $helper->getFileName('21b_Pdf_dompdf.xlsx', 'pdf'); +$writer->setEditHtmlCallback('replaceBody'); +$writer->save($filename); + +$helper->log('Write to Mpdf'); +$writer = new Mpdf($spreadsheet); +$filename = $helper->getFileName('21b_Pdf_mpdf.xlsx', 'pdf'); +$writer->setEditHtmlCallback('replaceBody'); +$writer->save($filename); + +$helper->log('Write to Tcpdf'); +$writer = new Tcpdf($spreadsheet); +$filename = $helper->getFileName('21b_Pdf_tcpdf.xlsx', 'pdf'); +$writer->setEditHtmlCallback('replaceBody'); +$writer->save($filename); diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index c9f2d7cbfd..963b02d77c 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -131,6 +131,13 @@ class Html extends BaseWriter */ private $generateSheetNavigationBlock = true; + /** + * Callback for editing generated html. + * + * @var callable + */ + protected $editHtmlCallback = ''; + /** * Create a new HTML. */ @@ -190,6 +197,10 @@ public function generateHtmlAll() // Write footer $html .= $this->generateHTMLFooter(); + $cbk = $this->editHtmlCallback; + if ($cbk) { + $html = $cbk($html); + } Calculation::setArrayReturnType($saveArrayReturnType); Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); @@ -197,6 +208,16 @@ public function generateHtmlAll() return $html; } + public function setEditHtmlCallback(callable $cbk): void + { + $this->editHtmlCallback = $cbk; + } + + public function resetEditHtmlCallback(): void + { + $this->editHtmlCallback = ''; + } + const VALIGN_ARR = [ Alignment::VERTICAL_BOTTOM => 'bottom', Alignment::VERTICAL_TOP => 'top', diff --git a/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php b/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php new file mode 100644 index 0000000000..f712419cf9 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php @@ -0,0 +1,53 @@ + +body { + background-color: yellow; +} + + +EOF; + + return preg_replace('@@', "$newstyle", $html); + } + + public function testSetAndReset(): void + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('A1', '1'); + + $writer = new Html($spreadsheet); + $html1 = $writer->generateHTMLall(); + $writer->setEditHtmlCallback([$this, 'yellowBody']); + $html2 = $writer->generateHTMLall(); + $writer->resetEditHtmlCallback(); + $html3 = $writer->generateHTMLall(); + + self::assertFalse(strpos($html1, 'background-color: yellow')); + self::assertNotFalse(strpos($html2, 'background-color: yellow')); + self::assertFalse(strpos($html3, 'background-color: yellow')); + self::assertEquals($html3, $html1); + + $writer->setEditHtmlCallback([$this, 'yellowBody']); + $oufil = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); + $writer->save($oufil); + $html4 = file_get_contents($oufil); + unlink($oufil); + self::assertNotFalse(strpos($html4, 'background-color: yellow')); + + $this->writeAndReload($spreadsheet, 'Html'); + } +} From c434e9b13735f82aa76901c52ba5339712fbaf0e Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 31 May 2020 15:58:57 +0900 Subject: [PATCH 067/659] Stricter typing for mergeCells Closes #1494 --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Worksheet/Worksheet.php | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe1f159a98..75eb393cd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Fix incorrect behaviour when saving XLSX file with drawings [#1462](https://github.com/PHPOffice/PhpSpreadsheet/pull/1462), - Fix Crash while trying setting a cell the value "123456\n" [#1476](https://github.com/PHPOffice/PhpSpreadsheet/pull/1481) - Improved DATEDIF() function and reduced errors for Y and YM units [#1466](https://github.com/PHPOffice/PhpSpreadsheet/pull/1466) +- Stricter typing for mergeCells [#1494](https://github.com/PHPOffice/PhpSpreadsheet/pull/1494) ### Changed diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index 1ed77e0560..e2b0dd8771 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -187,7 +187,7 @@ class Worksheet implements IComparable /** * Collection of merged cell ranges. * - * @var array + * @var string[] */ private $mergeCells = []; @@ -1747,7 +1747,7 @@ public function unmergeCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, /** * Get merge cells array. * - * @return array[] + * @return string[] */ public function getMergeCells() { @@ -1758,6 +1758,8 @@ public function getMergeCells() * Set merge cells array for the entire sheet. Use instead mergeCells() to merge * a single cell range. * + * @param string[] $pValue + * * @return $this */ public function setMergeCells(array $pValue) From dfa6f7717801e6738bb266ef3fac25fd8ad5294d Mon Sep 17 00:00:00 2001 From: Reijn Date: Sat, 23 May 2020 20:01:03 +0300 Subject: [PATCH 068/659] Add support protection of worksheet by a specific hash algorithm --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Reader/Xlsx.php | 4 + src/PhpSpreadsheet/Shared/PasswordHasher.php | 91 +++++++++++++- src/PhpSpreadsheet/Worksheet/Protection.php | 124 +++++++++++++++++++ src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 16 +++ tests/data/Shared/PasswordHashes.php | 26 ++++ 6 files changed, 261 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75eb393cd0..dd24e146c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Support writing to streams in all writers [#1292](https://github.com/PHPOffice/PhpSpreadsheet/issues/1292) - Support CSV files with data wrapping a lot of lines [#1468](https://github.com/PHPOffice/PhpSpreadsheet/pull/1468) +- Support protection of worksheet by a specific hash algorithm ### Fixed diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 797e59eafb..f9f20bdd33 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -765,6 +765,10 @@ public function load($pFilename) if (!$this->readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) { $docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection['password'], true); + $docSheet->getProtection()->setAlgorithmName((string) $xmlSheet->sheetProtection['algorithmName']); + $docSheet->getProtection()->setHashValue((string) $xmlSheet->sheetProtection['hashValue']); + $docSheet->getProtection()->setSaltValue((string) $xmlSheet->sheetProtection['saltValue']); + $docSheet->getProtection()->setSpinCount((int) $xmlSheet->sheetProtection['spinCount']); if ($xmlSheet->protectedRanges->protectedRange) { foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) { $docSheet->protectCells((string) $protectedRange['sqref'], (string) $protectedRange['password'], true); diff --git a/src/PhpSpreadsheet/Shared/PasswordHasher.php b/src/PhpSpreadsheet/Shared/PasswordHasher.php index 9b0080b9db..f3c2d3e10c 100644 --- a/src/PhpSpreadsheet/Shared/PasswordHasher.php +++ b/src/PhpSpreadsheet/Shared/PasswordHasher.php @@ -4,6 +4,51 @@ class PasswordHasher { + const ALGORITHM_MD2 = 'MD2'; + const ALGORITHM_MD4 = 'MD4'; + const ALGORITHM_MD5 = 'MD5'; + const ALGORITHM_SHA_1 = 'SHA-1'; + const ALGORITHM_SHA_256 = 'SHA-256'; + const ALGORITHM_SHA_384 = 'SHA-384'; + const ALGORITHM_SHA_512 = 'SHA-512'; + const ALGORITHM_RIPEMD_128 = 'RIPEMD-128'; + const ALGORITHM_RIPEMD_160 = 'RIPEMD-160'; + const ALGORITHM_WHIRLPOOL = 'WHIRLPOOL'; + + /** + * Mapping between algorithm name in Excel and algorithm name in PHP. + * + * @var array + */ + private static $algorithmArray = [ + self::ALGORITHM_MD2 => 'md2', + self::ALGORITHM_MD4 => 'md4', + self::ALGORITHM_MD5 => 'md5', + self::ALGORITHM_SHA_1 => 'sha1', + self::ALGORITHM_SHA_256 => 'sha256', + self::ALGORITHM_SHA_384 => 'sha384', + self::ALGORITHM_SHA_512 => 'sha512', + self::ALGORITHM_RIPEMD_128 => 'ripemd128', + self::ALGORITHM_RIPEMD_160 => 'ripemd160', + self::ALGORITHM_WHIRLPOOL => 'whirlpool', + ]; + + /** + * Get algorithm from self::$algorithmArray. + * + * @param string $pAlgorithmName + * + * @return string + */ + private static function getAlgorithm($pAlgorithmName) + { + if (array_key_exists($pAlgorithmName, self::$algorithmArray)) { + return self::$algorithmArray[$pAlgorithmName]; + } + + return ''; + } + /** * Create a password hash from a given string. * @@ -15,7 +60,7 @@ class PasswordHasher * * @return string Hashed password */ - public static function hashPassword($pPassword) + public static function defaultHashPassword($pPassword) { $password = 0x0000; $charPos = 1; // char position @@ -34,4 +79,48 @@ public static function hashPassword($pPassword) return strtoupper(dechex($password)); } + + /** + * Create a password hash from a given string by a specific algorithm. + * + * 2.4.2.4 ISO Write Protection Method + * + * @see https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-offcrypto/1357ea58-646e-4483-92ef-95d718079d6f + * + * @param string $pPassword Password to hash + * @param string $pAlgorithmName Hash algorithm used to compute the password hash value + * @param string $pSaltValue Pseudorandom string + * @param string $pSpinCount Number of times to iterate on a hash of a password + * + * @return string Hashed password + */ + public static function hashPassword($pPassword, $pAlgorithmName = '', $pSaltValue = '', $pSpinCount = 10000) + { + $algorithmName = self::getAlgorithm($pAlgorithmName); + if (!$pAlgorithmName) { + return self::defaultHashPassword($pPassword); + } + + $saltValue = base64_decode($pSaltValue); + $password = mb_convert_encoding($pPassword, 'UCS-2LE', 'UTF-8'); + + $hashValue = hash($algorithmName, $saltValue . $password, true); + for ($i = 0; $i < $pSpinCount; ++$i) { + $hashValue = hash($algorithmName, $hashValue . pack('L', $i), true); + } + + return base64_encode($hashValue); + } + + /** + * Create a pseudorandom string. + * + * @param int $pSize Length of the output string in bytes + * + * @return string Pseudorandom string + */ + public static function generateSalt($pSize = 16) + { + return base64_encode(random_bytes($pSize)); + } } diff --git a/src/PhpSpreadsheet/Worksheet/Protection.php b/src/PhpSpreadsheet/Worksheet/Protection.php index 2fd3e9195e..3566e2551d 100644 --- a/src/PhpSpreadsheet/Worksheet/Protection.php +++ b/src/PhpSpreadsheet/Worksheet/Protection.php @@ -125,6 +125,34 @@ class Protection */ private $password = ''; + /** + * Algorithm name. + * + * @var string + */ + private $algorithmName = ''; + + /** + * Hash value. + * + * @var string + */ + private $hashValue = ''; + + /** + * Salt value. + * + * @var string + */ + private $saltValue = ''; + + /** + * Spin count. + * + * @var int + */ + private $spinCount = ''; + /** * Create a new Protection. */ @@ -569,6 +597,102 @@ public function setPassword($pValue, $pAlreadyHashed = false) return $this; } + /** + * Get AlgorithmName. + * + * @return string + */ + public function getAlgorithmName() + { + return $this->algorithmName; + } + + /** + * Set AlgorithmName. + * + * @param string $pValue + * + * @return $this + */ + public function setAlgorithmName($pValue) + { + $this->algorithmName = $pValue; + + return $this; + } + + /** + * Get HashValue. + * + * @return string + */ + public function getHashValue() + { + return $this->hashValue; + } + + /** + * Set HashValue. + * + * @param string $pValue + * + * @return $this + */ + public function setHashValue($pValue) + { + $this->hashValue = $pValue; + + return $this; + } + + /** + * Get SaltValue. + * + * @return string + */ + public function getSaltValue() + { + return $this->saltValue; + } + + /** + * Set SaltValue. + * + * @param string $pValue + * + * @return $this + */ + public function setSaltValue($pValue) + { + $this->saltValue = $pValue; + + return $this; + } + + /** + * Get SpinCount. + * + * @return int + */ + public function getSpinCount() + { + return $this->spinCount; + } + + /** + * Set SpinCount. + * + * @param int $pValue + * + * @return $this + */ + public function setSpinCount($pValue) + { + $this->spinCount = $pValue; + + return $this; + } + /** * Implement PHP __clone to create a deep clone, not just a shallow copy. */ diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 3d47eeaa5a..803ade8a49 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -424,6 +424,22 @@ private function writeSheetProtection(XMLWriter $objWriter, PhpspreadsheetWorksh $objWriter->writeAttribute('password', $pSheet->getProtection()->getPassword()); } + if ($pSheet->getProtection()->getHashValue() !== '') { + $objWriter->writeAttribute('hashValue', $pSheet->getProtection()->getHashValue()); + } + + if ($pSheet->getProtection()->getAlgorithmName() !== '') { + $objWriter->writeAttribute('algorithmName', $pSheet->getProtection()->getAlgorithmName()); + } + + if ($pSheet->getProtection()->getSaltValue() !== '') { + $objWriter->writeAttribute('saltValue', $pSheet->getProtection()->getSaltValue()); + } + + if ($pSheet->getProtection()->getSpinCount() !== '') { + $objWriter->writeAttribute('spinCount', $pSheet->getProtection()->getSpinCount()); + } + $objWriter->writeAttribute('sheet', ($pSheet->getProtection()->getSheet() ? 'true' : 'false')); $objWriter->writeAttribute('objects', ($pSheet->getProtection()->getObjects() ? 'true' : 'false')); $objWriter->writeAttribute('scenarios', ($pSheet->getProtection()->getScenarios() ? 'true' : 'false')); diff --git a/tests/data/Shared/PasswordHashes.php b/tests/data/Shared/PasswordHashes.php index b4f348ca17..34c25cefca 100644 --- a/tests/data/Shared/PasswordHashes.php +++ b/tests/data/Shared/PasswordHashes.php @@ -25,4 +25,30 @@ 'CE4B', '', ], + [ + 'O6EXRLpLEDNJDL/AzYtnnA4O4bY=', + '', + 'SHA-1', + ], + [ + 'GYvlIMljDI1Czc4jfWrGaxU5pxl9n5Og0KUzyAfYxwk=', + 'PhpSpreadsheet', + 'SHA-256', + 'Php_salt', + 1000, + ], + [ + 'sSHdxQv9qgpkr4LDT0bYQxM9hOQJFRhJ4D752/NHQtDDR1EVy67NCEW9cPd6oWvCoBGd96MqKpuma1A7pN1nEA==', + 'Mark Baker', + 'SHA-512', + 'Mark_salt', + 10000, + ], + [ + 'r9KVLLCKIYOILvE2rcby+g==', + '!+&=()~§±æþ', + 'MD5', + 'Symbols_salt', + 100000, + ], ]; From 1eaf40be6940a1b639b918a1748a3eafcef080f5 Mon Sep 17 00:00:00 2001 From: Reijn Date: Sun, 24 May 2020 11:26:17 +0300 Subject: [PATCH 069/659] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd24e146c5..28aed38533 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Support writing to streams in all writers [#1292](https://github.com/PHPOffice/PhpSpreadsheet/issues/1292) - Support CSV files with data wrapping a lot of lines [#1468](https://github.com/PHPOffice/PhpSpreadsheet/pull/1468) -- Support protection of worksheet by a specific hash algorithm +- Support protection of worksheet by a specific hash algorithm [#1485](https://github.com/PHPOffice/PhpSpreadsheet/pull/1485) ### Fixed From b9a59660d01c83ff8cbb1667fd4fb3d98c47c36d Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 31 May 2020 20:22:23 +0900 Subject: [PATCH 070/659] Password and hash are exclusive As specified in https://docs.microsoft.com/en-us/openspecs/office_standards/ms-xlsx/85f5567f-2599-41ad-ae26-8cfab23ce754 password and hashValue are exlusive and thus should be treated transparently with a single API in our model. --- docs/topics/recipes.md | 76 +++++++++--- src/PhpSpreadsheet/Reader/Xlsx.php | 38 ++++-- src/PhpSpreadsheet/Shared/PasswordHasher.php | 106 +++++++---------- src/PhpSpreadsheet/Worksheet/Protection.php | 112 ++++++++---------- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 61 ++++------ .../Worksheet/ProtectionTest.php | 39 ++++++ 6 files changed, 240 insertions(+), 192 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/Worksheet/ProtectionTest.php diff --git a/docs/topics/recipes.md b/docs/topics/recipes.md index b0956b6e42..9f8282b9fb 100644 --- a/docs/topics/recipes.md +++ b/docs/topics/recipes.md @@ -919,29 +919,53 @@ disallow inserting rows on a specific sheet, disallow sorting, ... - Cell: offers the option to lock/unlock a cell as well as show/hide the internal formula. +**Make sure you enable worksheet protection if you need any of the +worksheet or cell protection features!** This can be done using the following +code: + +``` php +$spreadsheet->getActiveSheet()->getProtection()->setSheet(true); +``` + +### Document + An example on setting document security: ``` php -$spreadsheet->getSecurity()->setLockWindows(true); -$spreadsheet->getSecurity()->setLockStructure(true); -$spreadsheet->getSecurity()->setWorkbookPassword("PhpSpreadsheet"); +$security = $spreadsheet->getSecurity(); +$security->setLockWindows(true); +$security->setLockStructure(true); +$security->setWorkbookPassword("PhpSpreadsheet"); ``` +### Worksheet + An example on setting worksheet security: ``` php -$spreadsheet->getActiveSheet() - ->getProtection()->setPassword('PhpSpreadsheet'); -$spreadsheet->getActiveSheet() - ->getProtection()->setSheet(true); -$spreadsheet->getActiveSheet() - ->getProtection()->setSort(true); -$spreadsheet->getActiveSheet() - ->getProtection()->setInsertRows(true); -$spreadsheet->getActiveSheet() - ->getProtection()->setFormatCells(true); +$protection = $spreadsheet->getActiveSheet()->getProtection(); +$protection->setPassword('PhpSpreadsheet'); +$protection->setSheet(true); +$protection->setSort(true); +$protection->setInsertRows(true); +$protection->setFormatCells(true); ``` +If writing Xlsx files you can specify the algorithm used to hash the password +before calling `setPassword()` like so: + +```php +$protection = $spreadsheet->getActiveSheet()->getProtection(); +$protection->setAlgorithm(Protection::ALGORITHM_SHA_512); +$protection->setSpinCount(20000); +$protection->setPassword('PhpSpreadsheet'); +``` + +The salt should **not** be set manually and will be automatically generated +when setting a new password. + +### Cell + An example on setting cell security: ``` php @@ -950,14 +974,30 @@ $spreadsheet->getActiveSheet()->getStyle('B1') ->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED); ``` -**Make sure you enable worksheet protection if you need any of the -worksheet protection features!** This can be done using the following -code: +## Reading protected spreadsheet -``` php -$spreadsheet->getActiveSheet()->getProtection()->setSheet(true); +Spreadsheets that are protected the as described above can always be read by +PhpSpreadsheet. There is no need to know the password or do anything special in +order to read a protected file. + +However if you need to implement a password verification mechanism, you can use the +following helper method: + + +```php +$protection = $spreadsheet->getActiveSheet()->getProtection(); +$allowed = $protection->verify('my password'); + +if ($allowed) { + doSomething(); +} else { + throw new Exception('Incorrect password'); +} ``` +If you need to completely prevent reading a file by any tool, including PhpSpreadsheet, +then you are looking for "encryption", not "protection". + ## Setting data validation on a cell Data validation is a powerful feature of Xlsx. It allows to specify an diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index f9f20bdd33..fb7f064585 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -763,17 +763,8 @@ public function load($pFilename) } } - if (!$this->readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) { - $docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection['password'], true); - $docSheet->getProtection()->setAlgorithmName((string) $xmlSheet->sheetProtection['algorithmName']); - $docSheet->getProtection()->setHashValue((string) $xmlSheet->sheetProtection['hashValue']); - $docSheet->getProtection()->setSaltValue((string) $xmlSheet->sheetProtection['saltValue']); - $docSheet->getProtection()->setSpinCount((int) $xmlSheet->sheetProtection['spinCount']); - if ($xmlSheet->protectedRanges->protectedRange) { - foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) { - $docSheet->protectCells((string) $protectedRange['sqref'], (string) $protectedRange['password'], true); - } - } + if ($xmlSheet) { + $this->readSheetProtection($docSheet, $xmlSheet); } if ($xmlSheet && $xmlSheet->autoFilter && !$this->readDataOnly) { @@ -2035,4 +2026,29 @@ private function getWorkbookBaseName(ZipArchive $zip) return $workbookBasename; } + + private function readSheetProtection(Worksheet $docSheet, SimpleXMLElement $xmlSheet): void + { + if ($this->readDataOnly || !$xmlSheet->sheetProtection) { + return; + } + + $algorithmName = (string) $xmlSheet->sheetProtection['algorithmName']; + $protection = $docSheet->getProtection(); + $protection->setAlgorithm($algorithmName); + + if ($algorithmName) { + $protection->setPassword((string) $xmlSheet->sheetProtection['hashValue'], true); + $protection->setSalt((string) $xmlSheet->sheetProtection['saltValue']); + $protection->setSpinCount((int) $xmlSheet->sheetProtection['spinCount']); + } else { + $protection->setPassword((string) $xmlSheet->sheetProtection['password'], true); + } + + if ($xmlSheet->protectedRanges->protectedRange) { + foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) { + $docSheet->protectCells((string) $protectedRange['sqref'], (string) $protectedRange['password'], true); + } + } + } } diff --git a/src/PhpSpreadsheet/Shared/PasswordHasher.php b/src/PhpSpreadsheet/Shared/PasswordHasher.php index f3c2d3e10c..9fefe88fb5 100644 --- a/src/PhpSpreadsheet/Shared/PasswordHasher.php +++ b/src/PhpSpreadsheet/Shared/PasswordHasher.php @@ -2,51 +2,39 @@ namespace PhpOffice\PhpSpreadsheet\Shared; +use PhpOffice\PhpSpreadsheet\Exception; +use PhpOffice\PhpSpreadsheet\Worksheet\Protection; + class PasswordHasher { - const ALGORITHM_MD2 = 'MD2'; - const ALGORITHM_MD4 = 'MD4'; - const ALGORITHM_MD5 = 'MD5'; - const ALGORITHM_SHA_1 = 'SHA-1'; - const ALGORITHM_SHA_256 = 'SHA-256'; - const ALGORITHM_SHA_384 = 'SHA-384'; - const ALGORITHM_SHA_512 = 'SHA-512'; - const ALGORITHM_RIPEMD_128 = 'RIPEMD-128'; - const ALGORITHM_RIPEMD_160 = 'RIPEMD-160'; - const ALGORITHM_WHIRLPOOL = 'WHIRLPOOL'; - /** - * Mapping between algorithm name in Excel and algorithm name in PHP. - * - * @var array + * Get algorithm name for PHP. */ - private static $algorithmArray = [ - self::ALGORITHM_MD2 => 'md2', - self::ALGORITHM_MD4 => 'md4', - self::ALGORITHM_MD5 => 'md5', - self::ALGORITHM_SHA_1 => 'sha1', - self::ALGORITHM_SHA_256 => 'sha256', - self::ALGORITHM_SHA_384 => 'sha384', - self::ALGORITHM_SHA_512 => 'sha512', - self::ALGORITHM_RIPEMD_128 => 'ripemd128', - self::ALGORITHM_RIPEMD_160 => 'ripemd160', - self::ALGORITHM_WHIRLPOOL => 'whirlpool', - ]; - - /** - * Get algorithm from self::$algorithmArray. - * - * @param string $pAlgorithmName - * - * @return string - */ - private static function getAlgorithm($pAlgorithmName) + private static function getAlgorithm(string $algorithmName): string { - if (array_key_exists($pAlgorithmName, self::$algorithmArray)) { - return self::$algorithmArray[$pAlgorithmName]; + if (!$algorithmName) { + return ''; + } + + // Mapping between algorithm name in Excel and algorithm name in PHP + $mapping = [ + Protection::ALGORITHM_MD2 => 'md2', + Protection::ALGORITHM_MD4 => 'md4', + Protection::ALGORITHM_MD5 => 'md5', + Protection::ALGORITHM_SHA_1 => 'sha1', + Protection::ALGORITHM_SHA_256 => 'sha256', + Protection::ALGORITHM_SHA_384 => 'sha384', + Protection::ALGORITHM_SHA_512 => 'sha512', + Protection::ALGORITHM_RIPEMD_128 => 'ripemd128', + Protection::ALGORITHM_RIPEMD_160 => 'ripemd160', + Protection::ALGORITHM_WHIRLPOOL => 'whirlpool', + ]; + + if (array_key_exists($algorithmName, $mapping)) { + return $mapping[$algorithmName]; } - return ''; + throw new Exception('Unsupported password algorithm: ' . $algorithmName); } /** @@ -57,10 +45,8 @@ private static function getAlgorithm($pAlgorithmName) * Spreadsheet_Excel_Writer by Xavier Noguer . * * @param string $pPassword Password to hash - * - * @return string Hashed password */ - public static function defaultHashPassword($pPassword) + private static function defaultHashPassword(string $pPassword): string { $password = 0x0000; $charPos = 1; // char position @@ -87,40 +73,28 @@ public static function defaultHashPassword($pPassword) * * @see https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-offcrypto/1357ea58-646e-4483-92ef-95d718079d6f * - * @param string $pPassword Password to hash - * @param string $pAlgorithmName Hash algorithm used to compute the password hash value - * @param string $pSaltValue Pseudorandom string - * @param string $pSpinCount Number of times to iterate on a hash of a password + * @param string $password Password to hash + * @param string $algorithm Hash algorithm used to compute the password hash value + * @param string $salt Pseudorandom string + * @param int $spinCount Number of times to iterate on a hash of a password * * @return string Hashed password */ - public static function hashPassword($pPassword, $pAlgorithmName = '', $pSaltValue = '', $pSpinCount = 10000) + public static function hashPassword(string $password, string $algorithm = '', string $salt = '', int $spinCount = 10000): string { - $algorithmName = self::getAlgorithm($pAlgorithmName); - if (!$pAlgorithmName) { - return self::defaultHashPassword($pPassword); + $phpAlgorithm = self::getAlgorithm($algorithm); + if (!$phpAlgorithm) { + return self::defaultHashPassword($password); } - $saltValue = base64_decode($pSaltValue); - $password = mb_convert_encoding($pPassword, 'UCS-2LE', 'UTF-8'); + $saltValue = base64_decode($salt); + $encodedPassword = mb_convert_encoding($password, 'UCS-2LE', 'UTF-8'); - $hashValue = hash($algorithmName, $saltValue . $password, true); - for ($i = 0; $i < $pSpinCount; ++$i) { - $hashValue = hash($algorithmName, $hashValue . pack('L', $i), true); + $hashValue = hash($phpAlgorithm, $saltValue . $encodedPassword, true); + for ($i = 0; $i < $spinCount; ++$i) { + $hashValue = hash($phpAlgorithm, $hashValue . pack('L', $i), true); } return base64_encode($hashValue); } - - /** - * Create a pseudorandom string. - * - * @param int $pSize Length of the output string in bytes - * - * @return string Pseudorandom string - */ - public static function generateSalt($pSize = 16) - { - return base64_encode(random_bytes($pSize)); - } } diff --git a/src/PhpSpreadsheet/Worksheet/Protection.php b/src/PhpSpreadsheet/Worksheet/Protection.php index 3566e2551d..81abc0b7fc 100644 --- a/src/PhpSpreadsheet/Worksheet/Protection.php +++ b/src/PhpSpreadsheet/Worksheet/Protection.php @@ -6,6 +6,17 @@ class Protection { + const ALGORITHM_MD2 = 'MD2'; + const ALGORITHM_MD4 = 'MD4'; + const ALGORITHM_MD5 = 'MD5'; + const ALGORITHM_SHA_1 = 'SHA-1'; + const ALGORITHM_SHA_256 = 'SHA-256'; + const ALGORITHM_SHA_384 = 'SHA-384'; + const ALGORITHM_SHA_512 = 'SHA-512'; + const ALGORITHM_RIPEMD_128 = 'RIPEMD-128'; + const ALGORITHM_RIPEMD_160 = 'RIPEMD-160'; + const ALGORITHM_WHIRLPOOL = 'WHIRLPOOL'; + /** * Sheet. * @@ -119,7 +130,7 @@ class Protection private $selectUnlockedCells = false; /** - * Password. + * Hashed password. * * @var string */ @@ -130,28 +141,28 @@ class Protection * * @var string */ - private $algorithmName = ''; + private $algorithm = ''; /** * Hash value. * * @var string */ - private $hashValue = ''; + private $hash = ''; /** * Salt value. * * @var string */ - private $saltValue = ''; + private $salt = ''; /** * Spin count. * * @var int */ - private $spinCount = ''; + private $spinCount = 10000; /** * Create a new Protection. @@ -570,7 +581,7 @@ public function setSelectUnlockedCells($pValue) } /** - * Get Password (hashed). + * Get hashed password. * * @return string */ @@ -590,107 +601,84 @@ public function getPassword() public function setPassword($pValue, $pAlreadyHashed = false) { if (!$pAlreadyHashed) { - $pValue = PasswordHasher::hashPassword($pValue); + $salt = $this->generateSalt(); + $this->setSalt($salt); + $pValue = PasswordHasher::hashPassword($pValue, $this->getAlgorithm(), $this->getSalt(), $this->getSpinCount()); } + $this->password = $pValue; return $this; } /** - * Get AlgorithmName. - * - * @return string + * Create a pseudorandom string. */ - public function getAlgorithmName() + private function generateSalt(): string { - return $this->algorithmName; + return base64_encode(random_bytes(16)); } /** - * Set AlgorithmName. - * - * @param string $pValue - * - * @return $this + * Get algorithm name. */ - public function setAlgorithmName($pValue) + public function getAlgorithm(): string { - $this->algorithmName = $pValue; - - return $this; + return $this->algorithm; } /** - * Get HashValue. - * - * @return string + * Set algorithm name. */ - public function getHashValue() + public function setAlgorithm(string $algorithm): void { - return $this->hashValue; + $this->algorithm = $algorithm; } /** - * Set HashValue. - * - * @param string $pValue - * - * @return $this + * Get salt value. */ - public function setHashValue($pValue) + public function getSalt(): string { - $this->hashValue = $pValue; - - return $this; + return $this->salt; } /** - * Get SaltValue. - * - * @return string + * Set salt value. */ - public function getSaltValue() + public function setSalt(string $salt): void { - return $this->saltValue; + $this->salt = $salt; } /** - * Set SaltValue. - * - * @param string $pValue - * - * @return $this + * Get spin count. */ - public function setSaltValue($pValue) + public function getSpinCount(): int { - $this->saltValue = $pValue; - - return $this; + return $this->spinCount; } /** - * Get SpinCount. - * - * @return int + * Set spin count. */ - public function getSpinCount() + public function setSpinCount(int $spinCount): void { - return $this->spinCount; + $this->spinCount = $spinCount; } /** - * Set SpinCount. - * - * @param int $pValue - * - * @return $this + * Verify that the given non-hashed password can "unlock" the protection. */ - public function setSpinCount($pValue) + public function verify(string $password): bool { - $this->spinCount = $pValue; + if (!$this->isProtectionEnabled()) { + return true; + } - return $this; + $hash = PasswordHasher::hashPassword($password, $this->getAlgorithm(), $this->getSalt(), $this->getSpinCount()); + + return $this->getPassword() === $hash; } /** diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 803ade8a49..d101bb4068 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -420,42 +420,33 @@ private function writeSheetProtection(XMLWriter $objWriter, PhpspreadsheetWorksh // sheetProtection $objWriter->startElement('sheetProtection'); - if ($pSheet->getProtection()->getPassword() !== '') { - $objWriter->writeAttribute('password', $pSheet->getProtection()->getPassword()); + $protection = $pSheet->getProtection(); + + if ($protection->getAlgorithm()) { + $objWriter->writeAttribute('algorithmName', $protection->getAlgorithm()); + $objWriter->writeAttribute('hashValue', $protection->getPassword()); + $objWriter->writeAttribute('saltValue', $protection->getSalt()); + $objWriter->writeAttribute('spinCount', $protection->getSpinCount()); + } elseif ($protection->getPassword() !== '') { + $objWriter->writeAttribute('password', $protection->getPassword()); } - if ($pSheet->getProtection()->getHashValue() !== '') { - $objWriter->writeAttribute('hashValue', $pSheet->getProtection()->getHashValue()); - } - - if ($pSheet->getProtection()->getAlgorithmName() !== '') { - $objWriter->writeAttribute('algorithmName', $pSheet->getProtection()->getAlgorithmName()); - } - - if ($pSheet->getProtection()->getSaltValue() !== '') { - $objWriter->writeAttribute('saltValue', $pSheet->getProtection()->getSaltValue()); - } - - if ($pSheet->getProtection()->getSpinCount() !== '') { - $objWriter->writeAttribute('spinCount', $pSheet->getProtection()->getSpinCount()); - } - - $objWriter->writeAttribute('sheet', ($pSheet->getProtection()->getSheet() ? 'true' : 'false')); - $objWriter->writeAttribute('objects', ($pSheet->getProtection()->getObjects() ? 'true' : 'false')); - $objWriter->writeAttribute('scenarios', ($pSheet->getProtection()->getScenarios() ? 'true' : 'false')); - $objWriter->writeAttribute('formatCells', ($pSheet->getProtection()->getFormatCells() ? 'true' : 'false')); - $objWriter->writeAttribute('formatColumns', ($pSheet->getProtection()->getFormatColumns() ? 'true' : 'false')); - $objWriter->writeAttribute('formatRows', ($pSheet->getProtection()->getFormatRows() ? 'true' : 'false')); - $objWriter->writeAttribute('insertColumns', ($pSheet->getProtection()->getInsertColumns() ? 'true' : 'false')); - $objWriter->writeAttribute('insertRows', ($pSheet->getProtection()->getInsertRows() ? 'true' : 'false')); - $objWriter->writeAttribute('insertHyperlinks', ($pSheet->getProtection()->getInsertHyperlinks() ? 'true' : 'false')); - $objWriter->writeAttribute('deleteColumns', ($pSheet->getProtection()->getDeleteColumns() ? 'true' : 'false')); - $objWriter->writeAttribute('deleteRows', ($pSheet->getProtection()->getDeleteRows() ? 'true' : 'false')); - $objWriter->writeAttribute('selectLockedCells', ($pSheet->getProtection()->getSelectLockedCells() ? 'true' : 'false')); - $objWriter->writeAttribute('sort', ($pSheet->getProtection()->getSort() ? 'true' : 'false')); - $objWriter->writeAttribute('autoFilter', ($pSheet->getProtection()->getAutoFilter() ? 'true' : 'false')); - $objWriter->writeAttribute('pivotTables', ($pSheet->getProtection()->getPivotTables() ? 'true' : 'false')); - $objWriter->writeAttribute('selectUnlockedCells', ($pSheet->getProtection()->getSelectUnlockedCells() ? 'true' : 'false')); + $objWriter->writeAttribute('sheet', ($protection->getSheet() ? 'true' : 'false')); + $objWriter->writeAttribute('objects', ($protection->getObjects() ? 'true' : 'false')); + $objWriter->writeAttribute('scenarios', ($protection->getScenarios() ? 'true' : 'false')); + $objWriter->writeAttribute('formatCells', ($protection->getFormatCells() ? 'true' : 'false')); + $objWriter->writeAttribute('formatColumns', ($protection->getFormatColumns() ? 'true' : 'false')); + $objWriter->writeAttribute('formatRows', ($protection->getFormatRows() ? 'true' : 'false')); + $objWriter->writeAttribute('insertColumns', ($protection->getInsertColumns() ? 'true' : 'false')); + $objWriter->writeAttribute('insertRows', ($protection->getInsertRows() ? 'true' : 'false')); + $objWriter->writeAttribute('insertHyperlinks', ($protection->getInsertHyperlinks() ? 'true' : 'false')); + $objWriter->writeAttribute('deleteColumns', ($protection->getDeleteColumns() ? 'true' : 'false')); + $objWriter->writeAttribute('deleteRows', ($protection->getDeleteRows() ? 'true' : 'false')); + $objWriter->writeAttribute('selectLockedCells', ($protection->getSelectLockedCells() ? 'true' : 'false')); + $objWriter->writeAttribute('sort', ($protection->getSort() ? 'true' : 'false')); + $objWriter->writeAttribute('autoFilter', ($protection->getAutoFilter() ? 'true' : 'false')); + $objWriter->writeAttribute('pivotTables', ($protection->getPivotTables() ? 'true' : 'false')); + $objWriter->writeAttribute('selectUnlockedCells', ($protection->getSelectUnlockedCells() ? 'true' : 'false')); $objWriter->endElement(); } @@ -1149,7 +1140,7 @@ private function writeCellFormula(XMLWriter $objWriter, string $cellValue, Cell $this->getParentWriter()->getOffice2003Compatibility() === false, 'v', ($this->getParentWriter()->getPreCalculateFormulas() && !is_array($calculatedValue) && substr($calculatedValue, 0, 1) !== '#') - ? StringHelper::formatNumber($calculatedValue) : '0' + ? StringHelper::formatNumber($calculatedValue) : '0' ); } diff --git a/tests/PhpSpreadsheetTests/Worksheet/ProtectionTest.php b/tests/PhpSpreadsheetTests/Worksheet/ProtectionTest.php new file mode 100644 index 0000000000..1cc1ed3276 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Worksheet/ProtectionTest.php @@ -0,0 +1,39 @@ +verify('foo'), 'non-protected always pass'); + + $protection->setSheet(true); + self::assertFalse($protection->verify('foo'), 'protected will fail'); + + $protection->setPassword('foo', true); + self::assertSame('foo', $protection->getPassword(), 'was not stored as-is, without hashing'); + self::assertFalse($protection->verify('foo'), 'setting already hashed password will not match'); + + $protection->setPassword('foo'); + self::assertSame('CC40', $protection->getPassword(), 'was hashed'); + self::assertTrue($protection->verify('foo'), 'setting non-hashed password will hash it and not match'); + + $protection->setAlgorithm(Protection::ALGORITHM_MD5); + self::assertFalse($protection->verify('foo'), 'changing algorithm will not match anymore'); + + $protection->setPassword('foo'); + $hash1 = $protection->getPassword(); + $protection->setPassword('foo'); + $hash2 = $protection->getPassword(); + + self::assertSame(24, mb_strlen($hash1)); + self::assertSame(24, mb_strlen($hash2)); + self::assertNotSame($hash1, $hash2, 'was hashed with automatic salt'); + self::assertTrue($protection->verify('foo'), 'setting password again, will hash with proper algorithm and will match'); + } +} From dcf3b9860d93b82278c98679d4362dcbb44e6dc3 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 31 May 2020 22:41:05 +0900 Subject: [PATCH 071/659] Code highlight in docs for PhpStorm --- docs/faq.md | 2 +- docs/topics/accessing-cells.md | 46 +++--- docs/topics/architecture.md | 4 +- docs/topics/autofilters.md | 38 ++--- docs/topics/calculation-engine.md | 96 ++++++------ docs/topics/creating-spreadsheet.md | 6 +- docs/topics/memory_saving.md | 2 +- docs/topics/migration-from-PHPExcel.md | 2 +- docs/topics/reading-and-writing-to-file.md | 102 ++++++------- docs/topics/reading-files.md | 36 ++--- docs/topics/recipes.md | 164 ++++++++++----------- docs/topics/settings.md | 4 +- docs/topics/worksheets.md | 14 +- 13 files changed, 258 insertions(+), 258 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index 19f5f8fc2f..ac69e415fa 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -23,7 +23,7 @@ When you make use of any of the worksheet protection features (e.g. cell range protection, prohibiting deleting rows, ...), make sure you enable worksheet security. This can for example be done like this: -``` php +```php $spreadsheet->getActiveSheet()->getProtection()->setSheet(true); ``` diff --git a/docs/topics/accessing-cells.md b/docs/topics/accessing-cells.md index 4770d72196..edb71514a2 100644 --- a/docs/topics/accessing-cells.md +++ b/docs/topics/accessing-cells.md @@ -8,7 +8,7 @@ topic lists some of the options to access a cell. Setting a cell value by coordinate can be done using the worksheet's `setCellValue()` method. -``` php +```php // Set cell A1 with a string value $spreadsheet->getActiveSheet()->setCellValue('A1', 'PhpSpreadsheet'); @@ -28,7 +28,7 @@ $spreadsheet->getActiveSheet()->setCellValue( Alternatively, you can retrieve the cell object, and then call the cell’s `setValue()` method: -``` php +```php $spreadsheet->getActiveSheet() ->getCell('B8') ->setValue('Some value'); @@ -56,7 +56,7 @@ the cell object will still retain its data values. What does this mean? Consider the following code: -``` +```php $spreadSheet = new Spreadsheet(); $workSheet = $spreadSheet->getActiveSheet(); @@ -74,7 +74,7 @@ $cellA1 = $workSheet->getCell('A1'); echo 'Value: ', $cellA1->getValue(), '; Address: ', $cellA1->getCoordinate(), PHP_EOL; echo 'Value: ', $cellC1->getValue(), '; Address: ', $cellC1->getCoordinate(), PHP_EOL; -``` +``` The call to `getCell('C1')` returns the cell at `C1` containing its value (`3`), together with its link to the collection (used to identify its @@ -153,7 +153,7 @@ was a formula. To do this, you need to "escape" the value by setting it as "quoted text". -``` +```php // Set cell A4 with a formula $spreadsheet->getActiveSheet()->setCellValue( 'A4', @@ -175,7 +175,7 @@ point value), and a number format mask is used to show how that value should be formatted; so if we want to store a date in a cell, we need to calculate the correct Excel timestamp, and set a number format mask. -``` php +```php // Get the current date/time and convert to an Excel date/time $dateTimeNow = time(); $excelDateValue = \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel( $dateTimeNow ); @@ -210,7 +210,7 @@ behaviour. Firstly, you can set the datatype explicitly as a string so that it is not converted to a number. -``` php +```php // Set cell A8 with a numeric value, but tell PhpSpreadsheet it should be treated as a string $spreadsheet->getActiveSheet()->setCellValueExplicit( 'A8', @@ -222,7 +222,7 @@ $spreadsheet->getActiveSheet()->setCellValueExplicit( Alternatively, you can use a number format mask to display the value with leading zeroes. -``` php +```php // Set cell A9 with a numeric value $spreadsheet->getActiveSheet()->setCellValue('A9', 1513789642); // Set a number format mask to display the value as 11 digits with leading zeroes @@ -236,7 +236,7 @@ $spreadsheet->getActiveSheet()->getStyle('A9') With number format masking, you can even break up the digits into groups to make the value more easily readable. -``` php +```php // Set cell A10 with a numeric value $spreadsheet->getActiveSheet()->setCellValue('A10', 1513789642); // Set a number format mask to display the value as 11 digits with leading zeroes @@ -259,7 +259,7 @@ writers (Xlsx and Xls). It is also possible to set a range of cell values in a single call by passing an array of values to the `fromArray()` method. -``` php +```php $arrayData = [ [NULL, 2010, 2011, 2012], ['Q1', 12, 15, 21], @@ -282,7 +282,7 @@ If you pass a 2-d array, then this will be treated as a series of rows and columns. A 1-d array will be treated as a single row, which is particularly useful if you're fetching an array of data from a database. -``` php +```php $rowArray = ['Value1', 'Value2', 'Value3', 'Value4']; $spreadsheet->getActiveSheet() ->fromArray( @@ -299,7 +299,7 @@ If you have a simple 1-d array, and want to write it as a column, then the following will convert it into an appropriately structured 2-d array that can be fed to the `fromArray()` method: -``` php +```php $rowArray = ['Value1', 'Value2', 'Value3', 'Value4']; $columnArray = array_chunk($rowArray, 1); $spreadsheet->getActiveSheet() @@ -319,7 +319,7 @@ To retrieve the value of a cell, the cell should first be retrieved from the worksheet using the `getCell()` method. A cell's value can be read using the `getValue()` method. -``` php +```php // Get the value from cell A1 $cellValue = $spreadsheet->getActiveSheet()->getCell('A1')->getValue(); ``` @@ -331,7 +331,7 @@ value rather than the formula itself, then use the cell's `getCalculatedValue()` method. This is further explained in [the calculation engine](./calculation-engine.md). -``` php +```php // Get the value from cell A4 $cellValue = $spreadsheet->getActiveSheet()->getCell('A4')->getCalculatedValue(); ``` @@ -340,7 +340,7 @@ Alternatively, if you want to see the value with any cell formatting applied (e.g. for a human-readable date or time value), then you can use the cell's `getFormattedValue()` method. -``` php +```php // Get the value from cell A6 $cellValue = $spreadsheet->getActiveSheet()->getCell('A6')->getFormattedValue(); ``` @@ -350,7 +350,7 @@ $cellValue = $spreadsheet->getActiveSheet()->getCell('A6')->getFormattedValue(); Setting a cell value by coordinate can be done using the worksheet's `setCellValueByColumnAndRow()` method. -``` php +```php // Set cell A5 with a string value $spreadsheet->getActiveSheet()->setCellValueByColumnAndRow(1, 5, 'PhpSpreadsheet'); ``` @@ -363,7 +363,7 @@ To retrieve the value of a cell, the cell should first be retrieved from the worksheet using the `getCellByColumnAndRow()` method. A cell’s value can be read again using the following line of code: -``` php +```php // Get the value from cell B5 $cellValue = $spreadsheet->getActiveSheet()->getCellByColumnAndRow(2, 5)->getValue(); ``` @@ -371,7 +371,7 @@ $cellValue = $spreadsheet->getActiveSheet()->getCellByColumnAndRow(2, 5)->getVal If you need the calculated value of a cell, use the following code. This is further explained in [the calculation engine](./calculation-engine.md). -``` php +```php // Get the value from cell A4 $cellValue = $spreadsheet->getActiveSheet()->getCellByColumnAndRow(1, 4)->getCalculatedValue(); ``` @@ -382,7 +382,7 @@ It is also possible to retrieve a range of cell values to an array in a single call using the `toArray()`, `rangeToArray()` or `namedRangeToArray()` methods. -``` php +```php $dataArray = $spreadsheet->getActiveSheet() ->rangeToArray( 'C3:E5', // The worksheet range that we want to retrieve @@ -409,7 +409,7 @@ cells within a row. Below is an example where we read all the values in a worksheet and display them in a table. -``` php +```php $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx'); $reader->setReadDataOnly(TRUE); $spreadsheet = $reader->load("test.xlsx"); @@ -456,7 +456,7 @@ loops. Below is an example where we read all the values in a worksheet and display them in a table. -``` php +```php $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx'); $reader->setReadDataOnly(TRUE); $spreadsheet = $reader->load("test.xlsx"); @@ -482,7 +482,7 @@ echo '
' . PHP_EOL; Alternatively, you can take advantage of PHP's "Perl-style" character incrementors to loop through the cells by coordinate: -``` php +```php $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx'); $reader->setReadDataOnly(TRUE); $spreadsheet = $reader->load("test.xlsx"); @@ -528,7 +528,7 @@ dates entered as strings to the correct format, also setting the cell's style information. The following example demonstrates how to set the value binder in PhpSpreadsheet: -``` php +```php /** PhpSpreadsheet */ require_once 'src/Boostrap.php'; diff --git a/docs/topics/architecture.md b/docs/topics/architecture.md index 0295d672d8..1c544ef746 100644 --- a/docs/topics/architecture.md +++ b/docs/topics/architecture.md @@ -43,7 +43,7 @@ PhpSpreadsheet supports fluent interfaces in most locations. This means that you can easily "chain" calls to specific methods without requiring a new PHP statement. For example, take the following code: -``` php +```php $spreadsheet->getProperties()->setCreator("Maarten Balliauw"); $spreadsheet->getProperties()->setLastModifiedBy("Maarten Balliauw"); $spreadsheet->getProperties()->setTitle("Office 2007 XLSX Test Document"); @@ -55,7 +55,7 @@ $spreadsheet->getProperties()->setCategory("Test result file"); This can be rewritten as: -``` php +```php $spreadsheet->getProperties() ->setCreator("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw") diff --git a/docs/topics/autofilters.md b/docs/topics/autofilters.md index 66321ee9dc..d5a07f8bba 100644 --- a/docs/topics/autofilters.md +++ b/docs/topics/autofilters.md @@ -42,7 +42,7 @@ column, such as "Equals a red cell color" or "Larger than 150". To set an autoFilter on a range of cells. -``` php +```php $spreadsheet->getActiveSheet()->setAutoFilter('A1:E20'); ``` @@ -56,7 +56,7 @@ developer to avoid such errors. If you want to set the whole worksheet as an autofilter region -``` php +```php $spreadsheet->getActiveSheet()->setAutoFilter( $spreadsheet->getActiveSheet() ->calculateWorksheetDimension() @@ -74,7 +74,7 @@ will extend this to other formats. To apply a filter expression to an autoFilter range, you first need to identify which column you're going to be applying this filter to. -``` php +```php $autoFilter = $spreadsheet->getActiveSheet()->getAutoFilter(); $columnFilter = $autoFilter->getColumn('C'); ``` @@ -114,7 +114,7 @@ To create a filter expression, we need to start by identifying the filter type. In this case, we're just going to specify that this filter is a standard filter. -``` php +```php $columnFilter->setFilterType( \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER ); @@ -127,7 +127,7 @@ When creating a simple filter in PhpSpreadsheet, you only need to specify the values for "checked" columns: you do this by creating a filter rule for each value. -``` php +```php $columnFilter->createRule() ->setRule( \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, @@ -152,7 +152,7 @@ standard filters are always treated as being joined by an OR condition. If you want to create a filter to select blank cells, you would use: -``` php +```php $columnFilter->createRule() ->setRule( \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, @@ -170,7 +170,7 @@ within a year, or individual days within each month. DateGroup filters are still applied as a Standard Filter type. -``` php +```php $columnFilter->setFilterType( \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER ); @@ -181,7 +181,7 @@ for "checked" columns as an associative array of year. month, day, hour minute and second. To select a year and month, you need to create a DateGroup rule identifying the selected year and month: -``` php +```php $columnFilter->createRule() ->setRule( \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, @@ -229,7 +229,7 @@ either an AND or an OR. We start by specifying a Filter type, this time a CUSTOMFILTER. -``` php +```php $columnFilter->setFilterType( \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER ); @@ -240,7 +240,7 @@ And then define our rules. The following shows a simple wildcard filter to show all column entries beginning with the letter `U`. -``` php +```php $columnFilter->createRule() ->setRule( \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, @@ -264,7 +264,7 @@ is the \~ itself. To create a "between" condition, we need to define two rules: -``` php +```php $columnFilter->createRule() ->setRule( \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL, @@ -289,7 +289,7 @@ This defined two rules, filtering numbers that are `>= -20` OR `<= 20`, so we also need to modify the join condition to reflect AND rather than OR. -``` php +```php $columnFilter->setAndOr( \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_COLUMN_ANDOR_AND ); @@ -320,7 +320,7 @@ column at a time. Again, we start by specifying a Filter type, this time a DYNAMICFILTER. -``` php +```php $columnFilter->setFilterType( \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER ); @@ -330,7 +330,7 @@ When defining the rule for a dynamic filter, we don't define a value (we can simply set that to NULL) but we do specify the dynamic filter category. -``` php +```php $columnFilter->createRule() ->setRule( \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, @@ -420,7 +420,7 @@ column at a time. We start by specifying a Filter type, this time a DYNAMICFILTER. -``` php +```php $columnFilter->setFilterType( \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER ); @@ -428,7 +428,7 @@ $columnFilter->setFilterType( Then we create the rule: -``` php +```php $columnFilter->createRule() ->setRule( \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT, @@ -444,7 +444,7 @@ This will filter the Top 5 percent of values in the column. To specify the lowest (bottom 2 values), we would specify a rule of: -``` php +```php $columnFilter->createRule() ->setRule( \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE, @@ -490,7 +490,7 @@ If you wish to execute your filter from within a script, you need to do this manually. You can do this using the autofilters `showHideRows()` method. -``` php +```php $autoFilter = $spreadsheet->getActiveSheet()->getAutoFilter(); $autoFilter->showHideRows(); ``` @@ -505,7 +505,7 @@ ever row, whether it matches the filter criteria or not. To selectively access only the filtered rows, you need to test each row’s visibility settings. -``` php +```php foreach ($spreadsheet->getActiveSheet()->getRowIterator() as $row) { if ($spreadsheet->getActiveSheet() ->getRowDimension($row->getRowIndex())->getVisible()) { diff --git a/docs/topics/calculation-engine.md b/docs/topics/calculation-engine.md index 779d73e1af..d15dbb1604 100644 --- a/docs/topics/calculation-engine.md +++ b/docs/topics/calculation-engine.md @@ -13,7 +13,7 @@ evaluates to the sum of values in A1, A2, ..., A10. To calculate a formula, you can call the cell containing the formula’s method `getCalculatedValue()`, for example: -``` php +```php $spreadsheet->getActiveSheet()->getCell('E11')->getCalculatedValue(); ``` @@ -32,7 +32,7 @@ You see that the formula contained in cell E11 is "SUM(E4:E9)". Now, when I write the following line of code, two new product lines are added: -``` php +```php $spreadsheet->getActiveSheet()->insertNewRowBefore(7, 2); ``` @@ -55,7 +55,7 @@ However, there may be times when you don't want this, perhaps you've changed the underlying data and need to re-evaluate the same formula with that new data. -``` +```php Calculation::getInstance($spreadsheet)->disableCalculationCache(); ``` @@ -63,7 +63,7 @@ Will disable calculation caching, and flush the current calculation cache. If you want only to flush the cache, then you can call -``` +```php Calculation::getInstance($spreadsheet)->clearCalculationCache(); ``` @@ -118,7 +118,7 @@ date values by calling the `\PhpOffice\PhpSpreadsheet\Calculation\Functions::setReturnDateType()` method: -``` php +```php \PhpOffice\PhpSpreadsheet\Calculation\Functions::setReturnDateType($returnDateType); ``` @@ -134,7 +134,7 @@ if an invalid value is passed in for the return date type). The `\PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType()` method can be used to determine the current value of this setting: -``` php +```php $returnDateType = \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType(); ``` @@ -172,7 +172,7 @@ It is possible for scripts to change the calendar used for calculating Excel date values by calling the `\PhpOffice\PhpSpreadsheet\Shared\Date::setExcelCalendar()` method: -``` php +```php \PhpOffice\PhpSpreadsheet\Shared\Date::setExcelCalendar($baseDate); ``` @@ -187,7 +187,7 @@ if an invalid value is passed in). The `\PhpOffice\PhpSpreadsheet\Shared\Date::getExcelCalendar()` method can be used to determine the current value of this setting: -``` php +```php $baseDate = \PhpOffice\PhpSpreadsheet\Shared\Date::getExcelCalendar(); ``` @@ -353,7 +353,7 @@ This is the statistical mean. ##### Examples -``` php +```php $database = [ [ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ], [ 'Apple', 18, 20, 14, 105.00 ], @@ -421,7 +421,7 @@ in which you specify a condition for the column. ##### Examples -``` php +```php $database = [ [ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ], [ 'Apple', 18, 20, 14, 105.00 ], @@ -492,7 +492,7 @@ in which you specify a condition for the column. ##### Examples -``` php +```php $database = [ [ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ], [ 'Apple', 18, 20, 14, 105.00 ], @@ -563,7 +563,7 @@ in which you specify a condition for the column. #### Examples -``` php +```php $database = [ [ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ], [ 'Apple', 18, 20, 14, 105.00 ], @@ -631,7 +631,7 @@ in which you specify a condition for the column. ##### Examples -``` php +```php $database = [ [ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ], [ 'Apple', 18, 20, 14, 105.00 ], @@ -699,7 +699,7 @@ in which you specify a condition for the column. ##### Examples -``` php +```php $database = [ [ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ], [ 'Apple', 18, 20, 14, 105.00 ], @@ -767,7 +767,7 @@ in which you specify a condition for the column. ##### Examples -``` php +```php $database = [ [ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ], [ 'Apple', 18, 20, 14, 105.00 ], @@ -836,7 +836,7 @@ in which you specify a condition for the column. ##### Examples -``` php +```php $database = [ [ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ], [ 'Apple', 18, 20, 14, 105.00 ], @@ -905,7 +905,7 @@ in which you specify a condition for the column. ##### Examples -``` php +```php $database = [ [ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ], [ 'Apple', 18, 20, 14, 105.00 ], @@ -973,7 +973,7 @@ in which you specify a condition for the column. ##### Examples -``` php +```php $database = [ [ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ], [ 'Apple', 18, 20, 14, 105.00 ], @@ -1074,7 +1074,7 @@ or an Excel timestamp value (real), depending on the value of ##### Examples -``` php +```php $worksheet->setCellValue('A1', 'Year') ->setCellValue('A2', 'Month') ->setCellValue('A3', 'Day'); @@ -1089,7 +1089,7 @@ $retVal = $worksheet->getCell('D1')->getCalculatedValue(); // $retVal = 1230681600 ``` -``` php +```php // We're going to be calling the same cell calculation multiple times, // and expecting different return values, so disable calculation cacheing \PhpOffice\PhpSpreadsheet\Calculation\Calculation::getInstance()->setCalculationCacheEnabled(FALSE); @@ -1170,7 +1170,7 @@ the third parameter. ##### Examples -``` php +```php $worksheet->setCellValue('A1', 'Year') ->setCellValue('A2', 'Month') ->setCellValue('A3', 'Day'); @@ -1208,7 +1208,7 @@ $retVal = $worksheet->getCell('D6')->getCalculatedValue(); // $retVal = 30 ``` -``` php +```php $date1 = 1193317015; // PHP timestamp for 25-Oct-2007 $date2 = 1449579415; // PHP timestamp for 8-Dec-2015 @@ -1279,7 +1279,7 @@ or an Excel timestamp value (real), depending on the value of ##### Examples -``` php +```php $worksheet->setCellValue('A1', 'Date String'); ->setCellValue('A2', '31-Dec-2008') ->setCellValue('A3', '31/12/2008') @@ -1301,7 +1301,7 @@ $retVal = $worksheet->getCell('B4')->getCalculatedValue(); // $retVal = 39813.0 for all cases ``` -``` php +```php // We're going to be calling the same cell calculation multiple times, // and expecting different return values, so disable calculation cacheing \PhpOffice\PhpSpreadsheet\Calculation\Calculation::getInstance()->setCalculationCacheEnabled(FALSE); @@ -1371,7 +1371,7 @@ This is an integer ranging from 1 to 31. ##### Examples -``` php +```php $worksheet->setCellValue('A1', 'Date String') ->setCellValue('A2', '31-Dec-2008') ->setCellValue('A3', '14-Feb-2008'); @@ -1386,7 +1386,7 @@ $retVal = $worksheet->getCell('B3')->getCalculatedValue(); // $retVal = 14 ``` -``` php +```php $retVal = call_user_func_array( ['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DAYOFMONTH'], ['25-Dec-2008'] @@ -1444,7 +1444,7 @@ day year. ##### Examples -``` php +```php $worksheet->setCellValue('B1', 'Start Date') ->setCellValue('C1', 'End Date') ->setCellValue('A2', 'Year') @@ -1469,7 +1469,7 @@ $retVal = $worksheet->getCell('E4')->getCalculatedValue(); // $retVal = 1557 ``` -``` php +```php $date1 = 37655.0; // Excel timestamp for 25-Oct-2007 $date2 = 39233.0; // Excel timestamp for 8-Dec-2015 @@ -1529,7 +1529,7 @@ or an Excel timestamp value (real), depending on the value of ##### Examples -``` php +```php $worksheet->setCellValue('A1', 'Date String') ->setCellValue('A2', '1-Jan-2008') ->setCellValue('A3', '29-Feb-2008'); @@ -1548,7 +1548,7 @@ $retVal = $worksheet->getCell('B3')->getCalculatedValue(); // $retVal = 39141.0 (28-Feb-2007) ``` -``` php +```php \PhpOffice\PhpSpreadsheet\Calculation\Functions::setReturnDateType( \PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_EXCEL ); @@ -1602,7 +1602,7 @@ or an Excel timestamp value (real), depending on the value of ##### Examples -``` php +```php $worksheet->setCellValue('A1', 'Date String') ->setCellValue('A2', '1-Jan-2000') ->setCellValue('A3', '14-Feb-2009'); @@ -1619,7 +1619,7 @@ $retVal = $worksheet->getCell('B3')->getCalculatedValue(); // $retVal = 39507.0 (29-Feb-2008) ``` -``` php +```php \PhpOffice\PhpSpreadsheet\Calculation\Functions::setReturnDateType( \PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_EXCEL ); @@ -1661,7 +1661,7 @@ This is an integer ranging from 0 to 23. ##### Examples -``` php +```php $worksheet->setCellValue('A1', 'Time String') ->setCellValue('A2', '31-Dec-2008 17:30') ->setCellValue('A3', '14-Feb-2008 4:20 AM') @@ -1681,7 +1681,7 @@ $retVal = $worksheet->getCell('B4')->getCalculatedValue(); // $retVal = 16 ``` -``` php +```php $retVal = call_user_func_array( ['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'HOUROFDAY'], ['09:30'] @@ -1719,7 +1719,7 @@ This is an integer ranging from 0 to 59. ##### Examples -``` php +```php $worksheet->setCellValue('A1', 'Time String') ->setCellValue('A2', '31-Dec-2008 17:30') ->setCellValue('A3', '14-Feb-2008 4:20 AM') @@ -1739,7 +1739,7 @@ $retVal = $worksheet->getCell('B4')->getCalculatedValue(); // $retVal = 45 ``` -``` php +```php $retVal = call_user_func_array( ['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'MINUTE'], ['09:30'] @@ -1777,7 +1777,7 @@ This is an integer ranging from 1 to 12. ##### Examples -``` php +```php $worksheet->setCellValue('A1', 'Date String'); $worksheet->setCellValue('A2', '31-Dec-2008'); $worksheet->setCellValue('A3', '14-Feb-2008'); @@ -1792,7 +1792,7 @@ $retVal = $worksheet->getCell('B3')->getCalculatedValue(); // $retVal = 2 ``` -``` php +```php $retVal = call_user_func_array( ['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'MONTHOFYEAR'], ['14-July-2008'] @@ -1847,10 +1847,10 @@ The number of working days between startDate and endDate. ##### Examples -``` php +```php ``` -``` php +```php ``` ##### Notes @@ -1880,10 +1880,10 @@ or an Excel timestamp value (real), depending on the value of ##### Examples -``` php +```php ``` -``` php +```php ``` ##### Notes @@ -1917,7 +1917,7 @@ This is an integer ranging from 0 to 59. ##### Examples -``` php +```php $worksheet->setCellValue('A1', 'Time String') ->setCellValue('A2', '31-Dec-2008 17:30:20') ->setCellValue('A3', '14-Feb-2008 4:20 AM') @@ -1937,7 +1937,7 @@ $retVal = $worksheet->getCell('B4')->getCalculatedValue(); // $retVal = 59 ``` -``` php +```php $retVal = call_user_func_array( ['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'SECOND'], ['09:30:17'] @@ -2002,7 +2002,7 @@ value of method. ##### Examples -``` php +```php $worksheet->setCellValue('A1', 'Date String') ->setCellValue('A2', '31-Dec-2008') ->setCellValue('A3', '14-Feb-2008'); @@ -2021,7 +2021,7 @@ $retVal = $worksheet->getCell('B4')->getCalculatedValue(); // $retVal = 2 ``` -``` php +```php $retVal = call_user_func_array( ['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'WEEKDAY'], ['14-July-2008'] @@ -2066,7 +2066,7 @@ This is an integer year value. ##### Examples -``` php +```php $worksheet->setCellValue('A1', 'Date String') ->setCellValue('A2', '17-Jul-1982') ->setCellValue('A3', '16-Apr-2009'); @@ -2081,7 +2081,7 @@ $retVal = $worksheet->getCell('B3')->getCalculatedValue(); // $retVal = 2009 ``` -``` php +```php $retVal = call_user_func_array( ['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'YEAR'], ['14-July-2001'] diff --git a/docs/topics/creating-spreadsheet.md b/docs/topics/creating-spreadsheet.md index dceafe4b7c..3a82623edf 100644 --- a/docs/topics/creating-spreadsheet.md +++ b/docs/topics/creating-spreadsheet.md @@ -20,7 +20,7 @@ Details of the different spreadsheet formats supported, and the options available to read them into a Spreadsheet object are described fully in the [Reading Files](./reading-files.md) document. -``` php +```php $inputFileName = './sampleData/example1.xls'; /** Load $inputFileName to a Spreadsheet object **/ @@ -32,7 +32,7 @@ $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName); If you want to create a new workbook, rather than load one from file, then you simply need to instantiate it as a new Spreadsheet object. -``` php +```php /** Create a new Spreadsheet Object **/ $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); ``` @@ -53,7 +53,7 @@ then you also need to "break" these cyclic references before doing so. PhpSpreadsheet provides the `disconnectWorksheets()` method for this purpose. -``` php +```php $spreadsheet->disconnectWorksheets(); unset($spreadsheet); ``` diff --git a/docs/topics/memory_saving.md b/docs/topics/memory_saving.md index 4c9a848f5d..157bb70488 100644 --- a/docs/topics/memory_saving.md +++ b/docs/topics/memory_saving.md @@ -16,7 +16,7 @@ cache usages. To enable cell caching, you must provide your own implementation of cache like so: -``` php +```php $cache = new MyCustomPsr16Implementation(); \PhpOffice\PhpSpreadsheet\Settings::setCache($cache); diff --git a/docs/topics/migration-from-PHPExcel.md b/docs/topics/migration-from-PHPExcel.md index cc46976856..6dc14f1f9c 100644 --- a/docs/topics/migration-from-PHPExcel.md +++ b/docs/topics/migration-from-PHPExcel.md @@ -12,7 +12,7 @@ need to be done. automatically your codebase. Assuming your files to be migrated lives in `src/`, you can run the migration like so: -``` sh +```sh composer require rector/rector --dev vendor/bin/rector process src --set phpexcel-to-phpspreadsheet composer remove rector/rector diff --git a/docs/topics/reading-and-writing-to-file.md b/docs/topics/reading-and-writing-to-file.md index 8f92e1f232..020e063418 100644 --- a/docs/topics/reading-and-writing-to-file.md +++ b/docs/topics/reading-and-writing-to-file.md @@ -33,7 +33,7 @@ You can create a `\PhpOffice\PhpSpreadsheet\Reader\IReader` instance using `\PhpOffice\PhpSpreadsheet\IOFactory` in automatic file type resolving mode using the following code sample: -``` php +```php $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load("05featuredemo.xlsx"); ``` @@ -45,7 +45,7 @@ If you need to set some properties on the reader, (e.g. to only read data, see more about this later), then you may instead want to use this variant: -``` php +```php $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile("05featuredemo.xlsx"); $reader->setReadDataOnly(true); $reader->load("05featuredemo.xlsx"); @@ -55,7 +55,7 @@ You can create a `\PhpOffice\PhpSpreadsheet\Reader\IReader` instance using `\PhpOffice\PhpSpreadsheet\IOFactory` in explicit mode using the following code sample: -``` php +```php $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader("Xlsx"); $spreadsheet = $reader->load("05featuredemo.xlsx"); ``` @@ -68,7 +68,7 @@ mode. You can create a `\PhpOffice\PhpSpreadsheet\Writer\IWriter` instance using `\PhpOffice\PhpSpreadsheet\IOFactory`: -``` php +```php $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, "Xlsx"); $writer->save("05featuredemo.xlsx"); ``` @@ -84,7 +84,7 @@ outputting the in-memory spreadsheet to a .xlsx file. You can read an .xlsx file using the following code: -``` php +```php $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); $spreadsheet = $reader->load("05featuredemo.xlsx"); ``` @@ -94,7 +94,7 @@ $spreadsheet = $reader->load("05featuredemo.xlsx"); You can set the option setReadDataOnly on the reader, to instruct the reader to ignore styling, data validation, … and just read cell data: -``` php +```php $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); $reader->setReadDataOnly(true); $spreadsheet = $reader->load("05featuredemo.xlsx"); @@ -105,7 +105,7 @@ $spreadsheet = $reader->load("05featuredemo.xlsx"); You can set the option setLoadSheetsOnly on the reader, to instruct the reader to only load the sheets with a given name: -``` php +```php $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); $reader->setLoadSheetsOnly(["Sheet 1", "My special sheet"]); $spreadsheet = $reader->load("05featuredemo.xlsx"); @@ -122,7 +122,7 @@ read using the `\PhpOffice\PhpSpreadsheet\Reader\DefaultReadFilter`. The following code will only read row 1 and rows 20 – 30 of any sheet in the Excel file: -``` php +```php class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter { public function readCell($column, $row, $worksheetName = '') { @@ -145,7 +145,7 @@ $spreadsheet = $reader->load("06largescale.xlsx"); You can write an .xlsx file using the following code: -``` php +```php $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); $writer->save("05featuredemo.xlsx"); ``` @@ -156,7 +156,7 @@ By default, this writer pre-calculates all formulas in the spreadsheet. This can be slow on large spreadsheets, and maybe even unwanted. You can however disable formula pre-calculation: -``` php +```php $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); $writer->setPreCalculateFormulas(false); $writer->save("05featuredemo.xlsx"); @@ -201,7 +201,7 @@ PHP. You can read an .xls file using the following code: -``` php +```php $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls(); $spreadsheet = $reader->load("05featuredemo.xls"); ``` @@ -211,7 +211,7 @@ $spreadsheet = $reader->load("05featuredemo.xls"); You can set the option setReadDataOnly on the reader, to instruct the reader to ignore styling, data validation, … and just read cell data: -``` php +```php $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls(); $reader->setReadDataOnly(true); $spreadsheet = $reader->load("05featuredemo.xls"); @@ -222,7 +222,7 @@ $spreadsheet = $reader->load("05featuredemo.xls"); You can set the option setLoadSheetsOnly on the reader, to instruct the reader to only load the sheets with a given name: -``` php +```php $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls(); $reader->setLoadSheetsOnly(["Sheet 1", "My special sheet"]); $spreadsheet = $reader->load("05featuredemo.xls"); @@ -239,7 +239,7 @@ read using the `\PhpOffice\PhpSpreadsheet\Reader\DefaultReadFilter`. The following code will only read row 1 and rows 20 to 30 of any sheet in the Excel file: -``` php +```php class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter { public function readCell($column, $row, $worksheetName = '') { @@ -262,7 +262,7 @@ $spreadsheet = $reader->load("06largescale.xls"); You can write an .xls file using the following code: -``` php +```php $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xls($spreadsheet); $writer->save("05featuredemo.xls"); ``` @@ -282,7 +282,7 @@ spreadsheets via PHP. You can read an Excel 2003 .xml file using the following code: -``` php +```php $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xml(); $spreadsheet = $reader->load("05featuredemo.xml"); ``` @@ -298,7 +298,7 @@ read using the `\PhpOffice\PhpSpreadsheet\Reader\DefaultReadFilter`. The following code will only read row 1 and rows 20 to 30 of any sheet in the Excel file: -``` php +```php class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter { public function readCell($column, $row, $worksheetName = '') { @@ -333,7 +333,7 @@ regarding to styling cells and handling large spreadsheets via PHP. You can read an .slk file using the following code: -``` php +```php $reader = new \PhpOffice\PhpSpreadsheet\Reader\Slk(); $spreadsheet = $reader->load("05featuredemo.slk"); ``` @@ -349,7 +349,7 @@ read using the `\PhpOffice\PhpSpreadsheet\Reader\DefaultReadFilter`. The following code will only read row 1 and rows 20 to 30 of any sheet in the SYLK file: -``` php +```php class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter { public function readCell($column, $row, $worksheetName = '') { @@ -378,7 +378,7 @@ Open Office or Libre Office Calc files. You can read an .ods file using the following code: -``` php +```php $reader = new \PhpOffice\PhpSpreadsheet\Reader\Ods(); $spreadsheet = $reader->load("05featuredemo.ods"); ``` @@ -394,7 +394,7 @@ read using the `\PhpOffice\PhpSpreadsheet\Reader\DefaultReadFilter`. The following code will only read row 1 and rows 20 to 30 of any sheet in the Calc file: -``` php +```php class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter { public function readCell($column, $row, $worksheetName = '') { @@ -427,7 +427,7 @@ regarding to styling cells, number formatting, ... You can read a .csv file using the following code: -``` php +```php $reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv(); $spreadsheet = $reader->load("sample.csv"); ``` @@ -449,7 +449,7 @@ were created in Microsoft Office Excel the correct input encoding may rather be Windows-1252 (CP1252). Always make sure that the input encoding is set appropriately. -``` php +```php $reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv(); $reader->setInputEncoding('CP1252'); $reader->setDelimiter(';'); @@ -464,7 +464,7 @@ $spreadsheet = $reader->load("sample.csv"); CSV files can only contain one worksheet. Therefore, you can specify which sheet to read from CSV: -``` php +```php $reader->setSheetIndex(0); ``` @@ -475,7 +475,7 @@ data into an existing `Spreadsheet` object. The following code loads a CSV file into an existing `$spreadsheet` containing some sheets, and imports onto the 6th sheet: -``` php +```php $reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv(); $reader->setDelimiter(';'); $reader->setEnclosure(''); @@ -490,7 +490,7 @@ $reader->loadIntoExisting("05featuredemo.csv", $spreadsheet); You can write a .csv file using the following code: -``` php +```php $writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet); $writer->save("05featuredemo.csv"); ``` @@ -502,7 +502,7 @@ as a separator. You can instruct `\PhpOffice\PhpSpreadsheet\Writer\Csv` some options before writing a CSV file: -``` php +```php $writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet); $writer->setDelimiter(';'); $writer->setEnclosure(''); @@ -517,7 +517,7 @@ $writer->save("05featuredemo.csv"); CSV files can only contain one worksheet. Therefore, you can specify which sheet to write to CSV: -``` php +```php $writer->setSheetIndex(0); ``` @@ -527,7 +527,7 @@ By default, this writer pre-calculates all formulas in the spreadsheet. This can be slow on large spreadsheets, and maybe even unwanted. You can however disable formula pre-calculation: -``` php +```php $writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet); $writer->setPreCalculateFormulas(false); $writer->save("05featuredemo.csv"); @@ -542,7 +542,7 @@ it should explicitly include a BOM file header; if it doesn't, Excel will not interpret those characters correctly. This can be enabled by using the following code: -``` php +```php $writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet); $writer->setUseBOM(true); $writer->save("05featuredemo.csv"); @@ -560,14 +560,14 @@ to set the characters explicitly as shown below. English users will want to use this before doing the export: -``` php +```php \PhpOffice\PhpSpreadsheet\Shared\StringHelper::setDecimalSeparator('.'); \PhpOffice\PhpSpreadsheet\Shared\StringHelper::setThousandsSeparator(','); ``` German users will want to use the opposite values. -``` php +```php \PhpOffice\PhpSpreadsheet\Shared\StringHelper::setDecimalSeparator(','); \PhpOffice\PhpSpreadsheet\Shared\StringHelper::setThousandsSeparator('.'); ``` @@ -592,7 +592,7 @@ regarding to styling cells, number formatting, ... You can read an .html or .htm file using the following code: -``` php +```php $reader = new \PhpOffice\PhpSpreadsheet\Reader\Html(); $spreadsheet = $reader->load("05featuredemo.html"); @@ -610,7 +610,7 @@ first worksheet by default. You can write a .htm file using the following code: -``` php +```php $writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet); $writer->save("05featuredemo.htm"); @@ -621,7 +621,7 @@ $writer->save("05featuredemo.htm"); HTML files can contain one or more worksheets. If you want to write all sheets into a single HTML file, use the following code: -``` php +```php $writer->writeAllSheets(); ``` @@ -630,7 +630,7 @@ $writer->writeAllSheets(); HTML files can contain one or more worksheets. Therefore, you can specify which sheet to write to HTML: -``` php +```php $writer->setSheetIndex(0); ``` @@ -639,19 +639,19 @@ $writer->setSheetIndex(0); There might be situations where you want to explicitly set the included images root. For example, instead of: - ``` html + ```html ``` You might want to see: -``` html +```html ``` You can use the following code to achieve this result: -``` php +```php $writer->setImagesRoot('http://www.example.com'); ``` @@ -661,7 +661,7 @@ By default, this writer pre-calculates all formulas in the spreadsheet. This can be slow on large spreadsheets, and maybe even unwanted. You can however disable formula pre-calculation: -``` php +```php $writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet); $writer->setPreCalculateFormulas(false); @@ -686,7 +686,7 @@ Supported methods: Here's an example which retrieves all parts independently and merges them into a resulting HTML page: -``` php +```php $writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet); $hdr = $writer->generateHTMLHeader(); $sty = $writer->generateStyles(false); // do not write @@ -708,7 +708,7 @@ echo $writer->generateHTMLFooter(); A HTML file can be marked as UTF-8 by writing a BOM file header. This can be enabled by using the following code: -``` php +```php $writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet); $writer->setUseBOM(true); @@ -751,7 +751,7 @@ own circumstances. You can instantiate a writer with its specific name, like so: -``` php +```php $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Mpdf'); ``` @@ -759,7 +759,7 @@ Or you can register which writer you are using with a more generic name, so you don't need to remember which library you chose, only that you want to write PDF files: -``` php +```php $class = \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf::class; \PhpOffice\PhpSpreadsheet\IOFactory::registerWriter('Pdf', $class); $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Pdf'); @@ -767,7 +767,7 @@ $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Pdf') Or you can instantiate directly the writer of your choice like so: -``` php +```php $writer = \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf($spreadsheet); ``` @@ -776,7 +776,7 @@ $writer = \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf($spreadsheet); If you need a custom implementation, or custom configuration, of a supported PDF library. You can extends the PDF library, and the PDF writer like so: -``` php +```php class My_Custom_TCPDF extends TCPDF { // ... @@ -802,7 +802,7 @@ class My_Custom_TCPDF_Writer extends \PhpOffice\PhpSpreadsheet\Writer\Pdf\Tcpdf Once you have identified the Renderer that you wish to use for PDF generation, you can write a .pdf file using the following code: -``` php +```php $writer = new \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf($spreadsheet); $writer->save("05featuredemo.pdf"); ``` @@ -815,7 +815,7 @@ first worksheet by default. PDF files can contain one or more worksheets. If you want to write all sheets into a single PDF file, use the following code: -``` php +```php $writer->writeAllSheets(); ``` @@ -824,7 +824,7 @@ $writer->writeAllSheets(); PDF files can contain one or more worksheets. Therefore, you can specify which sheet to write to PDF: -``` php +```php $writer->setSheetIndex(0); ``` @@ -834,7 +834,7 @@ By default, this writer pre-calculates all formulas in the spreadsheet. This can be slow on large spreadsheets, and maybe even unwanted. You can however disable formula pre-calculation: -``` php +```php $writer = new \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf($spreadsheet); $writer->setPreCalculateFormulas(false); @@ -856,7 +856,7 @@ page setup properties, headers etc. Here is an example how to open a template file, fill in a couple of fields and save it again: -``` php +```php $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load('template.xlsx'); $worksheet = $spreadsheet->getActiveSheet(); diff --git a/docs/topics/reading-files.md b/docs/topics/reading-files.md index 779082dc85..1451f2ab47 100644 --- a/docs/topics/reading-files.md +++ b/docs/topics/reading-files.md @@ -22,7 +22,7 @@ The simplest way to load a workbook file is to let PhpSpreadsheet's IO Factory identify the file type and load it, calling the static `load()` method of the `\PhpOffice\PhpSpreadsheet\IOFactory` class. -``` php +```php $inputFileName = './sampleData/example1.xls'; /** Load $inputFileName to a Spreadsheet Object **/ @@ -59,7 +59,7 @@ supported filetype by name. However, you may get unpredictable results if the file isn't of the right type (e.g. it is a CSV with an extension of .xls), although this type of exception should normally be trapped. -``` php +```php $inputFileName = './sampleData/example1.xls'; /** Create a new Xls Reader **/ @@ -81,7 +81,7 @@ Alternatively, you can use the IO Factory's `createReader()` method to instantiate the reader object for you, simply telling it the file type of the reader that you want instantiating. -``` php +```php $inputFileType = 'Xls'; // $inputFileType = 'Xlsx'; // $inputFileType = 'Xml'; @@ -104,7 +104,7 @@ If you're uncertain of the filetype, you can use the `IOFactory::identify()` method to identify the reader that you need, before using the `createReader()` method to instantiate the reader object. -``` php +```php $inputFileName = './sampleData/example1.xls'; /** Identify the type of $inputFileName **/ @@ -131,7 +131,7 @@ need any of the cell formatting information, then you can set the reader to read only the data values and any formulae from each cell using the `setReadDataOnly()` method. -``` php +```php $inputFileType = 'Xls'; $inputFileName = './sampleData/example1.xls'; @@ -176,7 +176,7 @@ in reading. To read a single sheet, you can pass that sheet name as a parameter to the `setLoadSheetsOnly()` method. -``` php +```php $inputFileType = 'Xls'; $inputFileName = './sampleData/example1.xls'; $sheetname = 'Data Sheet #2'; @@ -195,7 +195,7 @@ for a working example of this code. If you want to read more than just a single sheet, you can pass a list of sheet names as an array parameter to the `setLoadSheetsOnly()` method. -``` php +```php $inputFileType = 'Xls'; $inputFileName = './sampleData/example1.xls'; $sheetnames = ['Data Sheet #1','Data Sheet #3']; @@ -214,7 +214,7 @@ for a working example of this code. To reset this option to the default, you can call the `setLoadAllSheets()` method. -``` php +```php $inputFileType = 'Xls'; $inputFileName = './sampleData/example1.xls'; @@ -248,7 +248,7 @@ should be read by the loader. A read filter must implement the whether a workbook cell identified by those arguments should be read or not. -``` php +```php $inputFileType = 'Xls'; $inputFileName = './sampleData/example1.xls'; $sheetname = 'Data Sheet #3'; @@ -286,7 +286,7 @@ a very specific circumstance (when you only want cells in the range A1:E7 from your worksheet. A generic Read Filter would probably be more useful: -``` php +```php /** Define a Read Filter class implementing \PhpOffice\PhpSpreadsheet\Reader\IReadFilter */ class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter { @@ -324,7 +324,7 @@ to read and process a large workbook in "chunks": an example of this usage might be when transferring data from an Excel worksheet to a database. -``` php +```php $inputFileType = 'Xls'; $inputFileName = './sampleData/example2.xls'; @@ -393,7 +393,7 @@ the `setSheetIndex()` method of the `$reader`, then use the `loadIntoExisting()` method rather than the `load()` method to actually read the file into that worksheet. -``` php +```php $inputFileType = 'Csv'; $inputFileNames = [ './sampleData/example1.csv', @@ -452,7 +452,7 @@ Class that we defined in [the above section](#reading-only-specific-columns-and- and the `setSheetIndex()` method of the `$reader`, we can split the CSV file across several individual worksheets. -``` php +```php $inputFileType = 'Csv'; $inputFileName = './sampleData/example2.csv'; @@ -523,7 +523,7 @@ cannot auto-detect, it will default to the comma. If this does not fit your use-case, you can manually specify a separator by using the `setDelimiter()` method. -``` php +```php $inputFileType = 'Csv'; $inputFileName = './sampleData/example1.tsv'; @@ -585,7 +585,7 @@ it encountered a hyperlink, or HTML markup within a CSV file. So using a Value Binder allows a great deal more flexibility in the loader logic when reading unformatted text files. -``` php +```php /** Tell PhpSpreadsheet that we want to use the Advanced Value Binder **/ \PhpOffice\PhpSpreadsheet\Cell\Cell::setValueBinder( new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder() ); @@ -619,7 +619,7 @@ manner. The PhpSpreadsheet Readers throw a `\PhpOffice\PhpSpreadsheet\Reader\Exception`. -``` php +```php $inputFileName = './sampleData/example-1.xls'; try { @@ -646,7 +646,7 @@ whole file. The `listWorksheetNames()` method returns a simple array listing each worksheet name within the workbook: -``` php +```php $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); $worksheetNames = $reader->listWorksheetNames($inputFileName); @@ -667,7 +667,7 @@ for a working example of this code. The `listWorksheetInfo()` method returns a nested array, with each entry listing the name and dimensions for a worksheet: -``` php +```php $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); $worksheetData = $reader->listWorksheetInfo($inputFileName); diff --git a/docs/topics/recipes.md b/docs/topics/recipes.md index 9f8282b9fb..45dd19bc5e 100644 --- a/docs/topics/recipes.md +++ b/docs/topics/recipes.md @@ -20,7 +20,7 @@ metadata to search for a specific document in its document lists. Setting spreadsheet metadata is done as follows: -``` php +```php $spreadsheet->getProperties() ->setCreator("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw") @@ -38,13 +38,13 @@ $spreadsheet->getProperties() The following line of code sets the active sheet index to the first sheet: -``` php +```php $spreadsheet->setActiveSheetIndex(0); ``` You can also set the active sheet by its name/title -``` php +```php $spreadsheet->setActiveSheetIndexByName('DataSheet') ``` @@ -68,7 +68,7 @@ UST. Writing a date value in a cell consists of 2 lines of code. Select the method that suits you the best. Here are some examples: -``` php +```php // MySQL-like timestamp '2008-12-31' or date string \PhpOffice\PhpSpreadsheet\Cell\Cell::setValueBinder( new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder() ); @@ -136,14 +136,14 @@ The following line of code writes the formula formula must start with `=` to make PhpSpreadsheet recognise this as a formula. -``` php +```php $spreadsheet->getActiveSheet()->setCellValue('B8','=IF(C4>500,"profit","loss")'); ``` If you want to write a string beginning with an `=` character to a cell, then you should use the `setCellValueExplicit()` method. -``` php +```php $spreadsheet->getActiveSheet() ->setCellValueExplicit( 'B8', @@ -154,14 +154,14 @@ $spreadsheet->getActiveSheet() A cell's formula can be read again using the following line of code: -``` php +```php $formula = $spreadsheet->getActiveSheet()->getCell('B8')->getValue(); ``` If you need the calculated value of a cell, use the following code. This is further explained in [the calculation engine](./calculation-engine.md). -``` php +```php $value = $spreadsheet->getActiveSheet()->getCell('B8')->getCalculatedValue(); ``` @@ -171,7 +171,7 @@ Some localisation elements have been included in PhpSpreadsheet. You can set a locale by changing the settings. To set the locale to Russian you would use: -``` php +```php $locale = 'ru'; $validLocale = \PhpOffice\PhpSpreadsheet\Settings::setLocale($locale); if (!$validLocale) { @@ -185,7 +185,7 @@ will return an error, and English settings will be used throughout. Once you have set a locale, you can translate a formula from its internal English coding. -``` php +```php $formula = $spreadsheet->getActiveSheet()->getCell('B8')->getValue(); $translatedFormula = \PhpOffice\PhpSpreadsheet\Calculation\Calculation::getInstance()->_translateFormulaToLocale($formula); ``` @@ -194,7 +194,7 @@ You can also create a formula using the function names and argument separators appropriate to the defined locale; then translate it to English before setting the cell value: -``` php +```php $formula = '=ДНЕЙ360(ДАТА(2010;2;5);ДАТА(2010;12;31);ИСТИНА)'; $internalFormula = \PhpOffice\PhpSpreadsheet\Calculation\Calculation::getInstance()->translateFormulaToEnglish($formula); $spreadsheet->getActiveSheet()->setCellValue('B8',$internalFormula); @@ -232,7 +232,7 @@ the cell. Here is how to achieve this in PhpSpreadsheet: -``` php +```php $spreadsheet->getActiveSheet()->getCell('A1')->setValue("hello\nworld"); $spreadsheet->getActiveSheet()->getStyle('A1')->getAlignment()->setWrapText(true); ``` @@ -247,7 +247,7 @@ AdvancedValuebinder.php automatically turns on "wrap text" for the cell when it sees a newline character in a string that you are inserting in a cell. Just like Microsoft Office Excel. Try this: -``` php +```php \PhpOffice\PhpSpreadsheet\Cell\Cell::setValueBinder( new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder() ); $spreadsheet->getActiveSheet()->getCell('A1')->setValue("hello\nworld"); @@ -261,7 +261,7 @@ You can set a cell's datatype explicitly by using the cell's setValueExplicit method, or the setCellValueExplicit method of a worksheet. Here's an example: -``` php +```php $spreadsheet->getActiveSheet()->getCell('A1') ->setValueExplicit( '25', @@ -273,7 +273,7 @@ $spreadsheet->getActiveSheet()->getCell('A1') You can make a cell a clickable URL by setting its hyperlink property: -``` php +```php $spreadsheet->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net'); $spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('https://www.example.com'); ``` @@ -281,7 +281,7 @@ $spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('https:// If you want to make a hyperlink to another worksheet/cell, use the following code: -``` php +```php $spreadsheet->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net'); $spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl("sheet://'Sheetname'!A1"); ``` @@ -293,7 +293,7 @@ $spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl("sheet:// Setting a worksheet's page orientation and size can be done using the following lines of code: -``` php +```php $spreadsheet->getActiveSheet()->getPageSetup() ->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE); $spreadsheet->getActiveSheet()->getPageSetup() @@ -324,7 +324,7 @@ setFitToHeight(...) | 1 | setFitToPage(TRUE) | value 0 mean Here is how to fit to 1 page wide by infinite pages tall: -``` php +```php $spreadsheet->getActiveSheet()->getPageSetup()->setFitToWidth(1); $spreadsheet->getActiveSheet()->getPageSetup()->setFitToHeight(0); ``` @@ -340,7 +340,7 @@ the initial values. To set page margins for a worksheet, use this code: -``` php +```php $spreadsheet->getActiveSheet()->getPageMargins()->setTop(1); $spreadsheet->getActiveSheet()->getPageMargins()->setRight(0.75); $spreadsheet->getActiveSheet()->getPageMargins()->setLeft(0.75); @@ -356,7 +356,7 @@ Note that the margin values are specified in inches. To center a page horizontally/vertically, you can use the following code: -``` php +```php $spreadsheet->getActiveSheet()->getPageSetup()->setHorizontalCentered(true); $spreadsheet->getActiveSheet()->getPageSetup()->setVerticalCentered(false); ``` @@ -366,7 +366,7 @@ $spreadsheet->getActiveSheet()->getPageSetup()->setVerticalCentered(false); Setting a worksheet's print header and footer can be done using the following lines of code: -``` php +```php $spreadsheet->getActiveSheet()->getHeaderFooter() ->setOddHeader('&C&HPlease treat this document as confidential!'); $spreadsheet->getActiveSheet()->getHeaderFooter() @@ -460,13 +460,13 @@ $spreadsheet->getActiveSheet()->getHeaderFooter()->addImage($drawing, \PhpOffice To set a print break, use the following code, which sets a row break on row 10. -``` php +```php $spreadsheet->getActiveSheet()->setBreak('A10', \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::BREAK_ROW); ``` The following line of code sets a print break on column D: -``` php +```php $spreadsheet->getActiveSheet()->setBreak('D10', \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::BREAK_COLUMN); ``` @@ -484,7 +484,7 @@ PhpSpreadsheet can repeat specific rows/cells at top/left of a page. The following code is an example of how to repeat row 1 to 5 on each printed page of a specific worksheet: -``` php +```php $spreadsheet->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 5); ``` @@ -492,13 +492,13 @@ $spreadsheet->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEn To specify a worksheet's printing area, use the following code: -``` php +```php $spreadsheet->getActiveSheet()->getPageSetup()->setPrintArea('A1:E5'); ``` There can also be multiple printing areas in a single worksheet: -``` php +```php $spreadsheet->getActiveSheet()->getPageSetup()->setPrintArea('A1:E5,G4:M20'); ``` @@ -511,7 +511,7 @@ For example, one can set the foreground colour of a cell to red, aligned to the right, and the border to black and thick border style. Let's do that on cell B2: -``` php +```php $spreadsheet->getActiveSheet()->getStyle('B2') ->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_RED); $spreadsheet->getActiveSheet()->getStyle('B2') @@ -533,7 +533,7 @@ $spreadsheet->getActiveSheet()->getStyle('B2') `getStyle()` also accepts a cell range as a parameter. For example, you can set a red background color on a range of cells: -``` php +```php $spreadsheet->getActiveSheet()->getStyle('B3:B7')->getFill() ->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID) ->getStartColor()->setARGB('FFFF0000'); @@ -548,7 +548,7 @@ There is also an alternative manner to set styles. The following code sets a cell's style to font bold, alignment right, top border thin and a gradient fill: -``` php +```php $styleArray = [ 'font' => [ 'bold' => true, @@ -578,7 +578,7 @@ $spreadsheet->getActiveSheet()->getStyle('A3')->applyFromArray($styleArray); Or with a range of cells: -``` php +```php $spreadsheet->getActiveSheet()->getStyle('B3:B7')->applyFromArray($styleArray); ``` @@ -602,7 +602,7 @@ number format code unless you need a custom number format. In PhpSpreadsheet, you can also apply various predefined number formats. Example: -``` php +```php $spreadsheet->getActiveSheet()->getStyle('A1')->getNumberFormat() ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1); ``` @@ -614,7 +614,7 @@ up as 1.587,20) You can achieve exactly the same as the above by using this: -``` php +```php $spreadsheet->getActiveSheet()->getStyle('A1')->getNumberFormat() ->setFormatCode('#,##0.00'); ``` @@ -623,7 +623,7 @@ In Microsoft Office Excel, as well as in PhpSpreadsheet, you will have to interact with raw number format codes whenever you need some special custom number format. Example: -``` php +```php $spreadsheet->getActiveSheet()->getStyle('A1')->getNumberFormat() ->setFormatCode('[Blue][>=3000]$#,##0;[Red][<0]$#,##0;$#,##0'); ``` @@ -631,7 +631,7 @@ $spreadsheet->getActiveSheet()->getStyle('A1')->getNumberFormat() Another example is when you want numbers zero-padded with leading zeros to a fixed length: -``` php +```php $spreadsheet->getActiveSheet()->getCell('A1')->setValue(19); $spreadsheet->getActiveSheet()->getStyle('A1')->getNumberFormat() ->setFormatCode('0000'); // will show as 0019 in Excel @@ -646,7 +646,7 @@ The readers shipped with PhpSpreadsheet come to the rescue. Load your template workbook using e.g. Xlsx reader to reveal the number format code. Example how read a number format code for cell A1: -``` php +```php $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx'); $spreadsheet = $reader->load('template.xlsx'); var_dump($spreadsheet->getActiveSheet()->getStyle('A1')->getNumberFormat()->getFormatCode()); @@ -661,14 +661,14 @@ code in *xl/styles.xml*. Let's set vertical alignment to the top for cells A1:D4 -``` php +```php $spreadsheet->getActiveSheet()->getStyle('A1:D4') ->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_TOP); ``` Here is how to achieve wrap text: -``` php +```php $spreadsheet->getActiveSheet()->getStyle('A1:D4') ->getAlignment()->setWrapText(true); ``` @@ -678,7 +678,7 @@ $spreadsheet->getActiveSheet()->getStyle('A1:D4') It is possible to set the default style of a workbook. Let's set the default font to Arial size 8: -``` php +```php $spreadsheet->getDefaultStyle()->getFont()->setName('Arial'); $spreadsheet->getDefaultStyle()->getFont()->setSize(8); ``` @@ -689,7 +689,7 @@ In PhpSpreadsheet it is easy to apply various borders on a rectangular selection. Here is how to apply a thick red border outline around cells B2:G8. -``` php +```php $styleArray = [ 'borders' => [ 'outline' => [ @@ -839,7 +839,7 @@ is below zero, and to green if its value is zero or more. One can set a conditional style ruleset to a cell using the following code: -``` php +```php $conditional1 = new \PhpOffice\PhpSpreadsheet\Style\Conditional(); $conditional1->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS); $conditional1->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_LESSTHAN); @@ -864,7 +864,7 @@ $spreadsheet->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditiona If you want to copy the ruleset to other cells, you can duplicate the style object: -``` php +```php $spreadsheet->getActiveSheet() ->duplicateStyle( $spreadsheet->getActiveSheet()->getStyle('B2'), @@ -877,7 +877,7 @@ $spreadsheet->getActiveSheet() To add a comment to a cell, use the following code. The example below adds a comment to cell E11: -``` php +```php $spreadsheet->getActiveSheet() ->getComment('E11') ->setAuthor('Mark Baker'); @@ -899,7 +899,7 @@ $spreadsheet->getActiveSheet() To apply an autofilter to a range of cells, use the following code: -``` php +```php $spreadsheet->getActiveSheet()->setAutoFilter('A1:C9'); ``` @@ -923,7 +923,7 @@ the internal formula. worksheet or cell protection features!** This can be done using the following code: -``` php +```php $spreadsheet->getActiveSheet()->getProtection()->setSheet(true); ``` @@ -931,7 +931,7 @@ $spreadsheet->getActiveSheet()->getProtection()->setSheet(true); An example on setting document security: -``` php +```php $security = $spreadsheet->getSecurity(); $security->setLockWindows(true); $security->setLockStructure(true); @@ -942,7 +942,7 @@ $security->setWorkbookPassword("PhpSpreadsheet"); An example on setting worksheet security: -``` php +```php $protection = $spreadsheet->getActiveSheet()->getProtection(); $protection->setPassword('PhpSpreadsheet'); $protection->setSheet(true); @@ -968,7 +968,7 @@ when setting a new password. An example on setting cell security: -``` php +```php $spreadsheet->getActiveSheet()->getStyle('B1') ->getProtection() ->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED); @@ -1008,7 +1008,7 @@ filter can be a range (i.e. value must be between 0 and 10), a list The following piece of code only allows numbers between 10 and 20 to be entered in cell B3: -``` php +```php $validation = $spreadsheet->getActiveSheet()->getCell('B3') ->getDataValidation(); $validation->setType( \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_WHOLE ); @@ -1027,7 +1027,7 @@ $validation->setFormula2(20); The following piece of code only allows an item picked from a list of data to be entered in cell B5: -``` php +```php $validation = $spreadsheet->getActiveSheet()->getCell('B5') ->getDataValidation(); $validation->setType( \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST ); @@ -1057,7 +1057,7 @@ the item values themselves can contain the comma `,` character itself. If you need data validation on multiple cells, one can clone the ruleset: -``` php +```php $spreadsheet->getActiveSheet()->getCell('B8')->setDataValidation(clone $validation); ``` @@ -1065,7 +1065,7 @@ $spreadsheet->getActiveSheet()->getCell('B8')->setDataValidation(clone $validati A column's width can be set using the following code: -``` php +```php $spreadsheet->getActiveSheet()->getColumnDimension('D')->setWidth(12); ``` @@ -1073,7 +1073,7 @@ If you want PhpSpreadsheet to perform an automatic width calculation, use the following code. PhpSpreadsheet will approximate the column with to the width of the widest column value. -``` php +```php $spreadsheet->getActiveSheet()->getColumnDimension('B')->setAutoSize(true); ``` @@ -1110,7 +1110,7 @@ To set a worksheet's column visibility, you can use the following code. The first line explicitly shows the column C, the second line hides column D. -``` php +```php $spreadsheet->getActiveSheet()->getColumnDimension('C')->setVisible(true); $spreadsheet->getActiveSheet()->getColumnDimension('D')->setVisible(false); ``` @@ -1119,7 +1119,7 @@ $spreadsheet->getActiveSheet()->getColumnDimension('D')->setVisible(false); To group/outline a column, you can use the following code: -``` php +```php $spreadsheet->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1); ``` @@ -1127,7 +1127,7 @@ You can also collapse the column. Note that you should also set the column invisible, otherwise the collapse will not be visible in Excel 2007. -``` php +```php $spreadsheet->getActiveSheet()->getColumnDimension('E')->setCollapsed(true); $spreadsheet->getActiveSheet()->getColumnDimension('E')->setVisible(false); ``` @@ -1138,7 +1138,7 @@ on collapsing. You can instruct PhpSpreadsheet to add a summary to the right (default), or to the left. The following code adds the summary to the left: -``` php +```php $spreadsheet->getActiveSheet()->setShowSummaryRight(false); ``` @@ -1146,7 +1146,7 @@ $spreadsheet->getActiveSheet()->setShowSummaryRight(false); A row's height can be set using the following code: -``` php +```php $spreadsheet->getActiveSheet()->getRowDimension('10')->setRowHeight(100); ``` @@ -1159,7 +1159,7 @@ of values is between 0 and 409 pts, where 0 pts is a hidden row. To set a worksheet''s row visibility, you can use the following code. The following example hides row number 10. -``` php +```php $spreadsheet->getActiveSheet()->getRowDimension('10')->setVisible(false); ``` @@ -1171,21 +1171,21 @@ AutoFilter range if you save the file. To group/outline a row, you can use the following code: -``` php +```php $spreadsheet->getActiveSheet()->getRowDimension('5')->setOutlineLevel(1); ``` You can also collapse the row. Note that you should also set the row invisible, otherwise the collapse will not be visible in Excel 2007. -``` php +```php $spreadsheet->getActiveSheet()->getRowDimension('5')->setCollapsed(true); $spreadsheet->getActiveSheet()->getRowDimension('5')->setVisible(false); ``` Here's an example which collapses rows 50 to 80: -``` php +```php for ($i = 51; $i <= 80; $i++) { $spreadsheet->getActiveSheet()->setCellValue('A' . $i, "FName $i"); $spreadsheet->getActiveSheet()->setCellValue('B' . $i, "LName $i"); @@ -1202,7 +1202,7 @@ $spreadsheet->getActiveSheet()->getRowDimension(81)->setCollapsed(true); You can instruct PhpSpreadsheet to add a summary below the collapsible rows (default), or above. The following code adds the summary above: -``` php +```php $spreadsheet->getActiveSheet()->setShowSummaryBelow(false); ``` @@ -1212,13 +1212,13 @@ If you have a big piece of data you want to display in a worksheet, you can merge two or more cells together, to become one cell. This can be done using the following code: -``` php +```php $spreadsheet->getActiveSheet()->mergeCells('A18:E22'); ``` Removing a merge can be done using the unmergeCells method: -``` php +```php $spreadsheet->getActiveSheet()->unmergeCells('A18:E22'); ``` @@ -1227,7 +1227,7 @@ $spreadsheet->getActiveSheet()->unmergeCells('A18:E22'); You can insert/remove rows/columns at a specific position. The following code inserts 2 new rows, right before row 7: -``` php +```php $spreadsheet->getActiveSheet()->insertNewRowBefore(7, 2); ``` @@ -1238,7 +1238,7 @@ to a worksheet. Therefore, you must first instantiate a new `\PhpOffice\PhpSpreadsheet\Worksheet\Drawing`, and assign its properties a meaningful value: -``` php +```php $drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing(); $drawing->setName('Logo'); $drawing->setDescription('Logo'); @@ -1250,13 +1250,13 @@ To add the above drawing to the worksheet, use the following snippet of code. PhpSpreadsheet creates the link between the drawing and the worksheet: -``` php +```php $drawing->setWorksheet($spreadsheet->getActiveSheet()); ``` You can set numerous properties on a drawing, here are some examples: -``` php +```php $drawing->setName('Paid'); $drawing->setDescription('Paid'); $drawing->setPath('./images/paid.png'); @@ -1270,7 +1270,7 @@ $drawing->getShadow()->setDirection(45); You can also add images created using GD functions without needing to save them to disk first as In-Memory drawings. -``` php +```php // Use GD to create an in-memory image $gdImage = @imagecreatetruecolor(120, 20) or die('Cannot Initialize new GD image stream'); $textColor = imagecolorallocate($gdImage, 255, 255, 255); @@ -1298,7 +1298,7 @@ that has been loaded, and save them as individual image files to disk. The following code extracts images from the current active worksheet, and writes each as a separate file. -``` php +```php $i = 0; foreach ($spreadsheet->getActiveSheet()->getDrawingCollection() as $drawing) { if ($drawing instanceof \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing) { @@ -1343,7 +1343,7 @@ creates the following rich text string: > This invoice is ***payable within thirty days after the end of the > month*** unless specified otherwise on the invoice. -``` php +```php $richText = new \PhpOffice\PhpSpreadsheet\RichText\RichText(); $richText->createText('This invoice is '); $payable = $richText->createTextRun('payable within thirty days after the end of the month'); @@ -1359,7 +1359,7 @@ $spreadsheet->getActiveSheet()->getCell('A18')->setValue($richText); PhpSpreadsheet supports the definition of named ranges. These can be defined using the following code: -``` php +```php // Add some data $spreadsheet->setActiveSheetIndex(0); $spreadsheet->getActiveSheet()->setCellValue('A1', 'Firstname:'); @@ -1402,7 +1402,7 @@ your document is needed, it is recommended not to use `php://output`. Example of a script redirecting an Excel 2007 file to the client's browser: -``` php +```php /* Here there will be some code where you create $spreadsheet */ // redirect output to client browser @@ -1416,7 +1416,7 @@ $writer->save('php://output'); Example of a script redirecting an Xls file to the client's browser: -``` php +```php /* Here there will be some code where you create $spreadsheet */ // redirect output to client browser @@ -1444,7 +1444,7 @@ at the client browser, and/or that headers cannot be set by PHP Default column width can be set using the following code: -``` php +```php $spreadsheet->getActiveSheet()->getDefaultColumnDimension()->setWidth(12); ``` @@ -1452,7 +1452,7 @@ $spreadsheet->getActiveSheet()->getDefaultColumnDimension()->setWidth(12); Default row height can be set using the following code: -``` php +```php $spreadsheet->getActiveSheet()->getDefaultRowDimension()->setRowHeight(15); ``` @@ -1465,7 +1465,7 @@ file to a temporary location. Here''s an example which generates an image in memory and adds it to the active worksheet: -``` php +```php // Generate an image $gdImage = @imagecreatetruecolor(120, 20) or die('Cannot Initialize new GD image stream'); $textColor = imagecolorallocate($gdImage, 255, 255, 255); @@ -1486,7 +1486,7 @@ $drawing->setWorksheet($spreadsheet->getActiveSheet()); To set a worksheet's zoom level, the following code can be used: -``` php +```php $spreadsheet->getActiveSheet()->getSheetView()->setZoomScale(75); ``` @@ -1497,7 +1497,7 @@ Note that zoom level should be in range 10 - 400. Sometimes you want to set a color for sheet tab. For example you can have a red sheet tab: -``` php +```php $worksheet->getTabColor()->setRGB('FF0000'); ``` @@ -1505,7 +1505,7 @@ $worksheet->getTabColor()->setRGB('FF0000'); If you need to create more worksheets in the workbook, here is how: -``` php +```php $worksheet1 = $spreadsheet->createSheet(); $worksheet1->setTitle('Another sheet'); ``` @@ -1518,7 +1518,7 @@ worksheets in the workbook. Set a worksheet to be **hidden** using this code: -``` php +```php $spreadsheet->getActiveSheet() ->setSheetState(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_HIDDEN); ``` @@ -1540,7 +1540,7 @@ Worksheets can be set individually whether column `A` should start at left or right side. Default is left. Here is how to set columns from right-to-left. -``` php +```php // right-to-left worksheet $spreadsheet->getActiveSheet()->setRightToLeft(true); ``` diff --git a/docs/topics/settings.md b/docs/topics/settings.md index a9aae9f923..4463ceebb3 100644 --- a/docs/topics/settings.md +++ b/docs/topics/settings.md @@ -13,7 +13,7 @@ Read more about [memory saving](./memory_saving.md). To enable cell caching, you must provide your own implementation of cache like so: -``` php +```php $cache = new MyCustomPsr16Implementation(); \PhpOffice\PhpSpreadsheet\Settings::setCache($cache); @@ -25,7 +25,7 @@ Some localisation elements have been included in PhpSpreadsheet. You can set a locale by changing the settings. To set the locale to Brazilian Portuguese you would use: -``` php +```php $locale = 'pt_br'; $validLocale = \PhpOffice\PhpSpreadsheet\Settings::setLocale($locale); if (!$validLocale) { diff --git a/docs/topics/worksheets.md b/docs/topics/worksheets.md index f97a00665d..0199f13c6a 100644 --- a/docs/topics/worksheets.md +++ b/docs/topics/worksheets.md @@ -25,7 +25,7 @@ each worksheet "tab" is shown when the workbook is opened in MS Excel (or other appropriate Spreadsheet program). To access a sheet by its index, use the `getSheet()` method. -``` php +```php // Get the second sheet in the workbook // Note that sheets are indexed from 0 $spreadsheet->getSheet(1); @@ -38,7 +38,7 @@ workbook. To access a sheet by name, use the `getSheetByName()` method, specifying the name of the worksheet that you want to access. -``` php +```php // Retrieve the worksheet called 'Worksheet 1' $spreadsheet->getSheetByName('Worksheet 1'); ``` @@ -48,7 +48,7 @@ and you can access that directly. The currently active worksheet is the one that will be active when the workbook is opened in MS Excel (or other appropriate Spreadsheet program). -``` php +```php // Retrieve the current active worksheet $spreadsheet->getActiveSheet(); ``` @@ -64,7 +64,7 @@ a new "last" sheet; but you can also specify an index position as an argument, and the worksheet will be inserted at that position, shuffling all subsequent worksheets in the collection down a place. -``` php +```php $spreadsheet->createSheet(); ``` @@ -76,7 +76,7 @@ Alternatively, you can instantiate a new worksheet (setting the title to whatever you choose) and then insert it into your workbook using the `addSheet()` method. -``` php +```php // Create a new worksheet called "My Data" $myWorkSheet = new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet($spreadsheet, 'My Data'); @@ -93,7 +93,7 @@ Sheets within the same workbook can be copied by creating a clone of the worksheet you wish to copy, and then using the `addSheet()` method to insert the clone into the workbook. -``` php +```php $clonedWorksheet = clone $spreadsheet->getSheetByName('Worksheet 1'); $clonedWorksheet->setTitle('Copy of Worksheet 1'); $spreadsheet->addSheet($clonedWorksheet); @@ -117,7 +117,7 @@ duplicate name. You can delete a worksheet from a workbook, identified by its index position, using the `removeSheetByIndex()` method -``` php +```php $sheetIndex = $spreadsheet->getIndex( $spreadsheet->getSheetByName('Worksheet 1') ); From 21bfb5b3243b8ceb9eda499a4d699fc42c11a9d1 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 31 May 2020 22:49:28 +0900 Subject: [PATCH 072/659] 1.13.0 ### Added - Support writing to streams in all writers [#1292](https://github.com/PHPOffice/PhpSpreadsheet/issues/1292) - Support CSV files with data wrapping a lot of lines [#1468](https://github.com/PHPOffice/PhpSpreadsheet/pull/1468) - Support protection of worksheet by a specific hash algorithm [#1485](https://github.com/PHPOffice/PhpSpreadsheet/pull/1485) ### Fixed - Fix Chart samples by updating chart parameter from 0 to DataSeries::EMPTY_AS_GAP [#1448](https://github.com/PHPOffice/PhpSpreadsheet/pull/1448) - Fix return type in docblock for the Cells::get() [#1398](https://github.com/PHPOffice/PhpSpreadsheet/pull/1398) - Fix RATE, PRICE, XIRR, and XNPV Functions [#1456](https://github.com/PHPOffice/PhpSpreadsheet/pull/1456) - Save Excel 2010+ functions properly in XLSX [#1461](https://github.com/PHPOffice/PhpSpreadsheet/pull/1461) - Several improvements in HTML writer [#1464](https://github.com/PHPOffice/PhpSpreadsheet/pull/1464) - Fix incorrect behaviour when saving XLSX file with drawings [#1462](https://github.com/PHPOffice/PhpSpreadsheet/pull/1462), - Fix Crash while trying setting a cell the value "123456\n" [#1476](https://github.com/PHPOffice/PhpSpreadsheet/pull/1481) - Improved DATEDIF() function and reduced errors for Y and YM units [#1466](https://github.com/PHPOffice/PhpSpreadsheet/pull/1466) - Stricter typing for mergeCells [#1494](https://github.com/PHPOffice/PhpSpreadsheet/pull/1494) ### Changed - Drop support for PHP 7.1, according to https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support - Drop partial migration tool in favor of complete migration via RectorPHP [#1445](https://github.com/PHPOffice/PhpSpreadsheet/issues/1445) - Limit composer package to `src/` [#1424](https://github.com/PHPOffice/PhpSpreadsheet/pull/1424) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28aed38533..0c13985021 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com) and this project adheres to [Semantic Versioning](https://semver.org). -## [Unreleased] +## [1.13.0] - 2020-05-31 ### Added From ac7fb4a31d16cec9ee8313cd7ffe357bc9039447 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 31 May 2020 23:11:40 +0900 Subject: [PATCH 073/659] Generate API doc on master It seems we can't be both on a tag and on master at the same time --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 31ae804ea2..05e964a1b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ jobs: - php ocular.phar code-coverage:upload --format=php-clover tests/coverage-clover.xml - stage: API documentations - if: tag is present AND branch = master + if: branch = master php: 7.4 before_script: - curl -LO https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.0.0-rc/phpDocumentor.phar From d7efe9f67151c68eddfdbe9660a26696cb7cc4ea Mon Sep 17 00:00:00 2001 From: Reijn Date: Sun, 31 May 2020 19:03:19 +0300 Subject: [PATCH 074/659] Delete unnecessary class member --- src/PhpSpreadsheet/Worksheet/Protection.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/PhpSpreadsheet/Worksheet/Protection.php b/src/PhpSpreadsheet/Worksheet/Protection.php index 81abc0b7fc..ba3af0a799 100644 --- a/src/PhpSpreadsheet/Worksheet/Protection.php +++ b/src/PhpSpreadsheet/Worksheet/Protection.php @@ -143,13 +143,6 @@ class Protection */ private $algorithm = ''; - /** - * Hash value. - * - * @var string - */ - private $hash = ''; - /** * Salt value. * From 9ba8db761b71b1d0dea43cac98ec18a60ae1911b Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 10:51:53 -0700 Subject: [PATCH 075/659] Update docs/topics/reading-and-writing-to-file.md Co-authored-by: Adrien Crivelli --- docs/topics/reading-and-writing-to-file.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/topics/reading-and-writing-to-file.md b/docs/topics/reading-and-writing-to-file.md index abd7c5f314..aa885f61e9 100644 --- a/docs/topics/reading-and-writing-to-file.md +++ b/docs/topics/reading-and-writing-to-file.md @@ -703,7 +703,7 @@ echo $writer->generateSheetData(); echo $writer->generateHTMLFooter(); ``` -#### Editing HTML During Save Via a Callback +#### Editing HTML during save via a callback You can also add a callback function to edit the generated html before saving. For example, you could add a webfont From 7e87a9f8d8cdd25dfec07ee2a9a12b791183bf09 Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 10:54:30 -0700 Subject: [PATCH 076/659] Update samples/Pdf/21a_Pdf.php Co-authored-by: Adrien Crivelli --- samples/Pdf/21a_Pdf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Pdf/21a_Pdf.php b/samples/Pdf/21a_Pdf.php index c4dc2c48e6..6ab1938f7b 100644 --- a/samples/Pdf/21a_Pdf.php +++ b/samples/Pdf/21a_Pdf.php @@ -25,7 +25,7 @@ function yellowBody(string $html): string EOF; - return preg_replace('@@', "$newstyle", $html); + return preg_replace('~~', "$newstyle", $html); } $helper->log('Write to Dompdf'); From 32b01148f438d534d09739c62c5a8162cfce1ebf Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 10:56:27 -0700 Subject: [PATCH 077/659] Update src/PhpSpreadsheet/Writer/Html.php Co-authored-by: Adrien Crivelli --- src/PhpSpreadsheet/Writer/Html.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 963b02d77c..2796de50f9 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -197,9 +197,9 @@ public function generateHtmlAll() // Write footer $html .= $this->generateHTMLFooter(); - $cbk = $this->editHtmlCallback; - if ($cbk) { - $html = $cbk($html); + $callback = $this->editHtmlCallback; + if ($callback) { + $html = $callback($html); } Calculation::setArrayReturnType($saveArrayReturnType); From 68002815ec436157e851d863d4968e9b0417f59a Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 10:59:10 -0700 Subject: [PATCH 078/659] Update src/PhpSpreadsheet/Writer/Html.php Co-authored-by: Adrien Crivelli --- src/PhpSpreadsheet/Writer/Html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 2796de50f9..1403d9be37 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -134,9 +134,9 @@ class Html extends BaseWriter /** * Callback for editing generated html. * - * @var callable + * @var null|callable */ - protected $editHtmlCallback = ''; + protected $editHtmlCallback = null; /** * Create a new HTML. From f42c3ef5a093571f22922c9e708896313e8109a2 Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 10:59:52 -0700 Subject: [PATCH 079/659] Update src/PhpSpreadsheet/Writer/Html.php Co-authored-by: Adrien Crivelli --- src/PhpSpreadsheet/Writer/Html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 1403d9be37..fceec67800 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -208,7 +208,7 @@ public function generateHtmlAll() return $html; } - public function setEditHtmlCallback(callable $cbk): void + public function setEditHtmlCallback(?callable $cbk): void { $this->editHtmlCallback = $cbk; } From 39eeef5ec658b796a689694a3ea66d95de596910 Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 11:01:14 -0700 Subject: [PATCH 080/659] Update src/PhpSpreadsheet/Writer/Html.php Co-authored-by: Adrien Crivelli --- src/PhpSpreadsheet/Writer/Html.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index fceec67800..942685f62d 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -213,11 +213,6 @@ public function setEditHtmlCallback(?callable $cbk): void $this->editHtmlCallback = $cbk; } - public function resetEditHtmlCallback(): void - { - $this->editHtmlCallback = ''; - } - const VALIGN_ARR = [ Alignment::VERTICAL_BOTTOM => 'bottom', Alignment::VERTICAL_TOP => 'top', From 48c65cff7fe76dc587757ce3e29d482af9055be0 Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 11:11:18 -0700 Subject: [PATCH 081/659] Update CallbackTest.php resetEditHtmlCallback was removed per suggestions from PowerKiki --- tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php b/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php index f712419cf9..388dbd0e6d 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php @@ -33,7 +33,7 @@ public function testSetAndReset(): void $html1 = $writer->generateHTMLall(); $writer->setEditHtmlCallback([$this, 'yellowBody']); $html2 = $writer->generateHTMLall(); - $writer->resetEditHtmlCallback(); + $writer->setEditHtmlCallback(null); $html3 = $writer->generateHTMLall(); self::assertFalse(strpos($html1, 'background-color: yellow')); From bbaf03c2efec48720c67dbaa8f3b2aab6a112786 Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 11:18:47 -0700 Subject: [PATCH 082/659] Update Html.php Travis says no need to initialize private class variable to null. --- src/PhpSpreadsheet/Writer/Html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 942685f62d..752f286f08 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -136,7 +136,7 @@ class Html extends BaseWriter * * @var null|callable */ - protected $editHtmlCallback = null; + protected $editHtmlCallback; /** * Create a new HTML. From 5c18bb5798be3c186e89b534de691a20beab21a7 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Tue, 2 Jun 2020 07:38:35 +0200 Subject: [PATCH 083/659] Range operator tests (#1501) * Improved handling of named ranges, although there are still some issues (names ranges using a union type with an overlap don't handle the overlap twice, which as the MS Excel approach to set overlaps as opposed to the mathematical approach which only applies overlap values once) * Fix tests that misused space and comma as simple separators in cell ranges --- .../Calculation/Calculation.php | 12 ++- src/PhpSpreadsheet/Cell/Coordinate.php | 73 ++++++++++++----- .../Calculation/Engine/RangeTest.php | 80 +++++++++++++------ .../Cell/CoordinateTest.php | 49 +++++++----- .../CellExtractAllCellReferencesInRange.php | 25 +----- 5 files changed, 151 insertions(+), 88 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 5aa309c552..2d67a1347a 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -3625,7 +3625,6 @@ private function _parseFormula($formula, ?Cell $pCell = null) $expectingOperand = false; $val = $match[1]; $length = strlen($val); - if (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $val, $matches)) { $val = preg_replace('/\s/u', '', $val); if (isset(self::$phpSpreadsheetFunctions[strtoupper($matches[1])]) || isset(self::$controlFunctions[strtoupper($matches[1])])) { // it's a function @@ -3660,7 +3659,6 @@ private function _parseFormula($formula, ?Cell $pCell = null) } elseif (preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $val, $matches)) { // Watch for this case-change when modifying to allow cell references in different worksheets... // Should only be applied to the actual cell column, not the worksheet name - // If the last entry on the stack was a : operator, then we have a cell range reference $testPrevOp = $stack->last(1); if ($testPrevOp !== null && $testPrevOp['value'] == ':') { @@ -3717,6 +3715,8 @@ private function _parseFormula($formula, ?Cell $pCell = null) } $localeConstant = false; + $stackItemType = 'Value'; + $stackItemReference = null; if ($opCharacter == self::FORMULA_STRING_QUOTE) { // UnEscape any quotes within the string $val = self::wrapResult(str_replace('""', self::FORMULA_STRING_QUOTE, self::unwrapResult($val))); @@ -3727,12 +3727,17 @@ private function _parseFormula($formula, ?Cell $pCell = null) $val = (int) $val; } } elseif (isset(self::$excelConstants[trim(strtoupper($val))])) { + $stackItemType = 'Constant'; $excelConstant = trim(strtoupper($val)); $val = self::$excelConstants[$excelConstant]; } elseif (($localeConstant = array_search(trim(strtoupper($val)), self::$localeBoolean)) !== false) { + $stackItemType = 'Constant'; $val = self::$excelConstants[$localeConstant]; + } elseif (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '.*/Ui', $val, $match)) { + $stackItemType = 'Named Range'; + $stackItemReference = $val; } - $details = $stack->getStackItem('Value', $val, null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot); + $details = $stack->getStackItem($stackItemType, $val, $stackItemReference, $currentCondition, $currentOnlyIf, $currentOnlyIfNot); if ($localeConstant) { $details['localeValue'] = $localeConstant; } @@ -3842,7 +3847,6 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $pCell = null) $fakedForBranchPruning = []; // help us to know when pruning ['branchTestId' => true/false] $branchStore = []; - // Loop through each token in turn foreach ($tokens as $tokenData) { $token = $tokenData['value']; diff --git a/src/PhpSpreadsheet/Cell/Coordinate.php b/src/PhpSpreadsheet/Cell/Coordinate.php index 8c67991371..2afeebe9dd 100644 --- a/src/PhpSpreadsheet/Cell/Coordinate.php +++ b/src/PhpSpreadsheet/Cell/Coordinate.php @@ -312,32 +312,59 @@ public static function stringFromColumnIndex($columnIndex) /** * Extract all cell references in range, which may be comprised of multiple cell ranges. * - * @param string $pRange Range (e.g. A1 or A1:C10 or A1:E10 A20:E25) + * @param string $cellRange Range: e.g. 'A1' or 'A1:C10' or 'A1:E10,A20:E25' or 'A1:E5 C3:G7' or 'A1:C1,A3:C3 B1:C3' * * @return array Array containing single cell references */ - public static function extractAllCellReferencesInRange($pRange) + public static function extractAllCellReferencesInRange($cellRange): array { - $returnValue = []; + [$ranges, $operators] = self::getCellBlocksFromRangeString($cellRange); + + $cells = []; + foreach ($ranges as $range) { + $cells[] = self::getReferencesForCellBlock($range); + } + + $cells = self::processRangeSetOperators($operators, $cells); + + if (empty($cells)) { + return []; + } + + $cellList = array_merge(...$cells); + $cellList = self::sortCellReferenceArray($cellList); + + return $cellList; + } - // Explode spaces - $cellBlocks = self::getCellBlocksFromRangeString($pRange); - foreach ($cellBlocks as $cellBlock) { - $returnValue = array_merge($returnValue, self::getReferencesForCellBlock($cellBlock)); + private static function processRangeSetOperators(array $operators, array $cells): array + { + for ($offset = 0; $offset < count($operators); ++$offset) { + $operator = $operators[$offset]; + if ($operator !== ' ') { + continue; + } + + $cells[$offset] = array_intersect($cells[$offset], $cells[$offset + 1]); + unset($operators[$offset], $cells[$offset + 1]); + $operators = array_values($operators); + $cells = array_values($cells); + --$offset; } + return $cells; + } + + private static function sortCellReferenceArray(array $cellList): array + { // Sort the result by column and row $sortKeys = []; - foreach (array_unique($returnValue) as $coord) { - $column = ''; - $row = 0; - - sscanf($coord, '%[A-Z]%d', $column, $row); + foreach ($cellList as $coord) { + [$column, $row] = sscanf($coord, '%[A-Z]%d'); $sortKeys[sprintf('%3s%09d', $column, $row)] = $coord; } ksort($sortKeys); - // Return value return array_values($sortKeys); } @@ -482,15 +509,25 @@ public static function mergeRangesInCollection(array $pCoordCollection) } /** - * Get the individual cell blocks from a range string, splitting by space and removing any $ characters. + * Get the individual cell blocks from a range string, removing any $ characters. + * then splitting by operators and returning an array with ranges and operators. * - * @param string $pRange + * @param string $rangeString * - * @return string[] + * @return array[] */ - private static function getCellBlocksFromRangeString($pRange) + private static function getCellBlocksFromRangeString($rangeString) { - return explode(' ', str_replace('$', '', strtoupper($pRange))); + $rangeString = str_replace('$', '', strtoupper($rangeString)); + + // split range sets on intersection (space) or union (,) operators + $tokens = preg_split('/([ ,])/', $rangeString, -1, PREG_SPLIT_DELIM_CAPTURE); + // separate the range sets and the operators into arrays + $split = array_chunk($tokens, 2); + $ranges = array_column($split, 0); + $operators = array_column($split, 1); + + return [$ranges, $operators]; } /** diff --git a/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php index d1ad229b6c..ee566db26b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php @@ -45,11 +45,21 @@ public function providerRangeEvaluation() { return[ ['=SUM(A1:B3,A1:C2)', 48], + ['=COUNT(A1:B3,A1:C2)', 12], ['=SUM(A1:B3 A1:C2)', 12], + ['=COUNT(A1:B3 A1:C2)', 4], ['=SUM(A1:A3,C1:C3)', 30], + ['=COUNT(A1:A3,C1:C3)', 6], ['=SUM(A1:A3 C1:C3)', Functions::null()], + ['=COUNT(A1:A3 C1:C3)', 0], ['=SUM(A1:B2,B2:C3)', 40], + ['=COUNT(A1:B2,B2:C3)', 8], ['=SUM(A1:B2 B2:C3)', 5], + ['=COUNT(A1:B2 B2:C3)', 1], + ['=SUM(A1:C1,A3:C3,B1:C3)', 63], + ['=COUNT(A1:C1,A3:C3,B1:C3)', 12], + ['=SUM(A1:C1,A3:C3 B1:C3)', 23], + ['=COUNT(A1:C1,A3:C3 B1:C3)', 5], ]; } @@ -69,35 +79,57 @@ public function testNamedRangeEvaluation($group1, $group2, $formula, $expectedRe $workSheet->setCellValue('E1', $formula); - $actualRresult = $workSheet->getCell('E1')->getCalculatedValue(); - self::assertSame($expectedResult, $actualRresult); + $sumRresult = $workSheet->getCell('E1')->getCalculatedValue(); + self::assertSame($expectedResult, $sumRresult); } public function providerNamedRangeEvaluation() { return[ - [ - 'A1:B3', - 'A1:C2', - '=SUM(GROUP1,GROUP2)', - 48, - ], - [ - 'A1:B3', - 'A1:C2', - '=SUM(GROUP1 GROUP2)', - 12, - ], - [ - 'A1:B2', - 'B2:C3', - '=SUM(GROUP1,GROUP2)', - 40, - ], - [ - 'A1:B2', - 'B2:C3', - '=SUM(GROUP1 GROUP2)', + ['A1:B3', 'A1:C2', '=SUM(GROUP1,GROUP2)', 48], + ['A1:B3', 'A1:C2', '=COUNT(GROUP1,GROUP2)', 12], + ['A1:B3', 'A1:C2', '=SUM(GROUP1 GROUP2)', 12], + ['A1:B3', 'A1:C2', '=COUNT(GROUP1 GROUP2)', 4], + ['A1:B2', 'B2:C3', '=SUM(GROUP1,GROUP2)', 40], + ['A1:B2', 'B2:C3', '=COUNT(GROUP1,GROUP2)', 8], + ['A1:B2', 'B2:C3', '=SUM(GROUP1 GROUP2)', 5], + ['A1:B2', 'B2:C3', '=COUNT(GROUP1 GROUP2)', 1], + ]; + } + + /** + * @dataProvider providerCompositeNamedRangeEvaluation + * + * @param string $composite + * @param int $expectedSum + * @param int $expectedCount + */ + public function testCompositeNamedRangeEvaluation($composite, $expectedSum, $expectedCount): void + { + $workSheet = $this->spreadSheet->getActiveSheet(); + $this->spreadSheet->addNamedRange(new NamedRange('COMPOSITE', $workSheet, $composite)); + + $workSheet->setCellValue('E1', '=SUM(COMPOSITE)'); + $workSheet->setCellValue('E2', '=COUNT(COMPOSITE)'); + + $actualSum = $workSheet->getCell('E1')->getCalculatedValue(); + self::assertSame($expectedSum, $actualSum); + $actualCount = $workSheet->getCell('E2')->getCalculatedValue(); + self::assertSame($expectedCount, $actualCount); + } + + public function providerCompositeNamedRangeEvaluation() + { + return[ + // Calculation engine doesn't yet handle union ranges with overlap + // 'Union with overlap' => [ + // 'A1:C1,A3:C3,B1:C3', + // 63, + // 12, + // ], + 'Intersection' => [ + 'A1:C1,A3:C3 B1:C3', + 23, 5, ], ]; diff --git a/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php b/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php index 37579e80c6..8e0e98a90d 100644 --- a/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php @@ -83,10 +83,11 @@ public function providerColumnIndex() * @dataProvider providerCoordinates * * @param mixed $expectedResult + * @param string $rangeSet */ - public function testCoordinateFromString($expectedResult, ...$args): void + public function testCoordinateFromString($expectedResult, $rangeSet): void { - $result = Coordinate::coordinateFromString(...$args); + $result = Coordinate::coordinateFromString($rangeSet); self::assertEquals($expectedResult, $result); } @@ -143,11 +144,12 @@ public function testCoordinateFromStringWithInvalidAddress(): void /** * @dataProvider providerAbsoluteCoordinates * - * @param mixed $expectedResult + * @param string $expectedResult + * @param string $rangeSet */ - public function testAbsoluteCoordinateFromString($expectedResult, ...$args): void + public function testAbsoluteCoordinateFromString($expectedResult, $rangeSet): void { - $result = Coordinate::absoluteCoordinate(...$args); + $result = Coordinate::absoluteCoordinate($rangeSet); self::assertEquals($expectedResult, $result); } @@ -175,10 +177,11 @@ public function testAbsoluteCoordinateFromStringWithRangeAddress(): void * @dataProvider providerAbsoluteReferences * * @param mixed $expectedResult + * @param string $rangeSet */ - public function testAbsoluteReferenceFromString($expectedResult, ...$args): void + public function testAbsoluteReferenceFromString($expectedResult, $rangeSet): void { - $result = Coordinate::absoluteReference(...$args); + $result = Coordinate::absoluteReference($rangeSet); self::assertEquals($expectedResult, $result); } @@ -206,10 +209,11 @@ public function testAbsoluteReferenceFromStringWithRangeAddress(): void * @dataProvider providerSplitRange * * @param mixed $expectedResult + * @param string $rangeSet */ - public function testSplitRange($expectedResult, ...$args): void + public function testSplitRange($expectedResult, $rangeSet): void { - $result = Coordinate::splitRange(...$args); + $result = Coordinate::splitRange($rangeSet); foreach ($result as $key => $split) { if (!is_array($expectedResult[$key])) { self::assertEquals($expectedResult[$key], $split[0]); @@ -252,10 +256,11 @@ public function testBuildRangeInvalid(): void * @dataProvider providerRangeBoundaries * * @param mixed $expectedResult + * @param string $rangeSet */ - public function testRangeBoundaries($expectedResult, ...$args): void + public function testRangeBoundaries($expectedResult, $rangeSet): void { - $result = Coordinate::rangeBoundaries(...$args); + $result = Coordinate::rangeBoundaries($rangeSet); self::assertEquals($expectedResult, $result); } @@ -268,10 +273,11 @@ public function providerRangeBoundaries() * @dataProvider providerRangeDimension * * @param mixed $expectedResult + * @param string $rangeSet */ - public function testRangeDimension($expectedResult, ...$args): void + public function testRangeDimension($expectedResult, $rangeSet): void { - $result = Coordinate::rangeDimension(...$args); + $result = Coordinate::rangeDimension($rangeSet); self::assertEquals($expectedResult, $result); } @@ -284,10 +290,11 @@ public function providerRangeDimension() * @dataProvider providerGetRangeBoundaries * * @param mixed $expectedResult + * @param string $rangeSet */ - public function testGetRangeBoundaries($expectedResult, ...$args): void + public function testGetRangeBoundaries($expectedResult, $rangeSet): void { - $result = Coordinate::getRangeBoundaries(...$args); + $result = Coordinate::getRangeBoundaries($rangeSet); self::assertEquals($expectedResult, $result); } @@ -299,11 +306,12 @@ public function providerGetRangeBoundaries() /** * @dataProvider providerExtractAllCellReferencesInRange * - * @param mixed $expectedResult + * @param array $expectedResult + * @param string $rangeSet */ - public function testExtractAllCellReferencesInRange($expectedResult, ...$args): void + public function testExtractAllCellReferencesInRange($expectedResult, $rangeSet): void { - $result = Coordinate::extractAllCellReferencesInRange(...$args); + $result = Coordinate::extractAllCellReferencesInRange($rangeSet); self::assertEquals($expectedResult, $result); } @@ -350,10 +358,11 @@ public function providerMergeRangesInCollection() * @dataProvider providerCoordinateIsRange * * @param mixed $expectedResult + * @param string $rangeSet */ - public function testCoordinateIsRange($expectedResult, ...$args): void + public function testCoordinateIsRange($expectedResult, $rangeSet): void { - $result = Coordinate::coordinateIsRange(...$args); + $result = Coordinate::coordinateIsRange($rangeSet); self::assertEquals($expectedResult, $result); } diff --git a/tests/data/CellExtractAllCellReferencesInRange.php b/tests/data/CellExtractAllCellReferencesInRange.php index cf093289a2..b005b1fe82 100644 --- a/tests/data/CellExtractAllCellReferencesInRange.php +++ b/tests/data/CellExtractAllCellReferencesInRange.php @@ -22,12 +22,6 @@ ], [ [ - 'B4', - 'B5', - 'B6', - 'D4', - 'D5', - 'D6', ], 'B4:B6 D4:D6', ], @@ -66,20 +60,10 @@ ], [ [ - 'B4', - 'B5', - 'B6', - 'C4', 'C5', 'C6', - 'C7', - 'D4', 'D5', 'D6', - 'D7', - 'E5', - 'E6', - 'E7', ], 'B4:D6 C5:E7', ], @@ -105,7 +89,7 @@ 'F5', 'F6', ], - 'B2:D4 C5:D5 E3:E5 D6:E6 F4:F6', + 'B2:D4,C5:D5,E3:E5,D6:E6,F4:F6', ], [ [ @@ -129,16 +113,13 @@ 'F5', 'F6', ], - 'B2:D4 C3:E5 D4:F6', + 'B2:D4,C3:E5,D4:F6', ], [ [ - 'B4', 'B5', - 'B6', - 'B8', ], - 'B4:B6 B8', + 'B4:B6 B5', ], [ [ From 7ab920de5bf96d75298c17434998eebd49f3e0b4 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Wed, 3 Jun 2020 09:13:29 +0900 Subject: [PATCH 084/659] Typo --- docs/topics/recipes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/topics/recipes.md b/docs/topics/recipes.md index 45dd19bc5e..f85576a234 100644 --- a/docs/topics/recipes.md +++ b/docs/topics/recipes.md @@ -976,7 +976,7 @@ $spreadsheet->getActiveSheet()->getStyle('B1') ## Reading protected spreadsheet -Spreadsheets that are protected the as described above can always be read by +Spreadsheets that are protected as described above can always be read by PhpSpreadsheet. There is no need to know the password or do anything special in order to read a protected file. From c47b407e3995c27ecc285a2cc09f9a5798fffeac Mon Sep 17 00:00:00 2001 From: Owen Leibman Date: Tue, 9 Jun 2020 00:22:22 -0700 Subject: [PATCH 085/659] Different Example for Callback Replace default gridlines with different style. Usable in PDF as well as HTML. Documentation mentioned use of setUseBOM with Html, but that method does not exist, and there is no real reason to support it. Removed it from documentation. --- docs/topics/reading-and-writing-to-file.md | 35 +++++-------------- samples/Basic/17b_Html.php | 13 ++----- samples/Pdf/21a_Pdf.php | 30 +++------------- src/PhpSpreadsheet/Writer/Html.php | 17 ++++----- .../Writer/Html/CallbackTest.php | 2 +- 5 files changed, 22 insertions(+), 75 deletions(-) diff --git a/docs/topics/reading-and-writing-to-file.md b/docs/topics/reading-and-writing-to-file.md index abd7c5f314..13b62e0149 100644 --- a/docs/topics/reading-and-writing-to-file.md +++ b/docs/topics/reading-and-writing-to-file.md @@ -703,43 +703,24 @@ echo $writer->generateSheetData(); echo $writer->generateHTMLFooter(); ``` -#### Editing HTML During Save Via a Callback +#### Editing HTML during save via a callback You can also add a callback function to edit the generated html -before saving. For example, you could add a webfont -(not currently supported for Pdf) as follows: +before saving. For example, you could change the gridlines +from a thin solid black line: ``` php -function webfont(string $html): string +function changeGridlines(string $html): string { - $linktag = << - -EOF; - $html = preg_replace('@setEditHtmlCallback('webfont'); +$writer->setEditHtmlCallback('changeGridlines'); $writer->save($filename); ``` -#### Writing UTF-8 HTML files - -A HTML file can be marked as UTF-8 by writing a BOM file header. This -can be enabled by using the following code: - -``` php -$writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet); -$writer->setUseBOM(true); - -$writer->save("05featuredemo.htm"); -``` - #### Decimal and thousands separators See section `\PhpOffice\PhpSpreadsheet\Writer\Csv` how to control the @@ -866,7 +847,7 @@ $writer->setPreCalculateFormulas(false); $writer->save("05featuredemo.pdf"); ``` -#### Editing Pdf During Save Via a Callback +#### Editing Pdf during save via a callback You can also add a callback function to edit the html used to generate the Pdf before saving. diff --git a/samples/Basic/17b_Html.php b/samples/Basic/17b_Html.php index 0564931490..97bb29a337 100644 --- a/samples/Basic/17b_Html.php +++ b/samples/Basic/17b_Html.php @@ -8,20 +8,13 @@ $filename = $helper->getFilename(__FILE__, 'html'); $writer = new Html($spreadsheet); -function webfont(string $html): string +function changeGridlines(string $html): string { - $linktag = << - -EOF; - $html = preg_replace('@setEmbedImages(true); -$writer->setEditHtmlCallback('webfont'); +$writer->setEditHtmlCallback('changeGridlines'); $writer->save($filename); $helper->logWrite($writer, $filename, $callStartTime); diff --git a/samples/Pdf/21a_Pdf.php b/samples/Pdf/21a_Pdf.php index c4dc2c48e6..b5572afe41 100644 --- a/samples/Pdf/21a_Pdf.php +++ b/samples/Pdf/21a_Pdf.php @@ -1,9 +1,7 @@ log('Set orientation to landscape'); $spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE); +$spreadsheet->setActiveSheetIndex(0)->setPrintGridlines(true); -function yellowBody(string $html): string +function changeGridlines(string $html): string { - $newstyle = << -body { -background-color: yellow; + return str_replace('{border: 1px solid black;}', '{border: 2px dashed red;}', $html); } - - -EOF; - - return preg_replace('@@', "$newstyle", $html); -} - -$helper->log('Write to Dompdf'); -$writer = new Dompdf($spreadsheet); -$filename = $helper->getFileName('21a_Pdf_dompdf.xlsx', 'pdf'); -$writer->setEditHtmlCallback('yellowBody'); -$writer->save($filename); $helper->log('Write to Mpdf'); $writer = new Mpdf($spreadsheet); $filename = $helper->getFileName('21a_Pdf_mpdf.xlsx', 'pdf'); -$writer->setEditHtmlCallback('yellowBody'); -$writer->save($filename); - -$helper->log('Write to Tcpdf'); -$writer = new Tcpdf($spreadsheet); -$filename = $helper->getFileName('21a_Pdf_tcpdf.xlsx', 'pdf'); -$writer->setEditHtmlCallback('yellowBody'); +$writer->setEditHtmlCallback('changeGridlines'); $writer->save($filename); diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 963b02d77c..752f286f08 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -134,9 +134,9 @@ class Html extends BaseWriter /** * Callback for editing generated html. * - * @var callable + * @var null|callable */ - protected $editHtmlCallback = ''; + protected $editHtmlCallback; /** * Create a new HTML. @@ -197,9 +197,9 @@ public function generateHtmlAll() // Write footer $html .= $this->generateHTMLFooter(); - $cbk = $this->editHtmlCallback; - if ($cbk) { - $html = $cbk($html); + $callback = $this->editHtmlCallback; + if ($callback) { + $html = $callback($html); } Calculation::setArrayReturnType($saveArrayReturnType); @@ -208,16 +208,11 @@ public function generateHtmlAll() return $html; } - public function setEditHtmlCallback(callable $cbk): void + public function setEditHtmlCallback(?callable $cbk): void { $this->editHtmlCallback = $cbk; } - public function resetEditHtmlCallback(): void - { - $this->editHtmlCallback = ''; - } - const VALIGN_ARR = [ Alignment::VERTICAL_BOTTOM => 'bottom', Alignment::VERTICAL_TOP => 'top', diff --git a/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php b/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php index f712419cf9..388dbd0e6d 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php @@ -33,7 +33,7 @@ public function testSetAndReset(): void $html1 = $writer->generateHTMLall(); $writer->setEditHtmlCallback([$this, 'yellowBody']); $html2 = $writer->generateHTMLall(); - $writer->resetEditHtmlCallback(); + $writer->setEditHtmlCallback(null); $html3 = $writer->generateHTMLall(); self::assertFalse(strpos($html1, 'background-color: yellow')); From 12dd92bafe75d6fa19a19604156a06ae9ebb346c Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sat, 13 Jun 2020 17:35:29 +0200 Subject: [PATCH 086/659] Resolve utf-8 named ranges in calculation engine (#1522) * Resolve use of UTF-8 in defined names in the calculation engine --- CHANGELOG.md | 6 ++++ .../Calculation/Calculation.php | 20 ++++++------- .../Calculation/Engine/RangeTest.php | 30 +++++++++++++++++++ 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c13985021..37f4f3dc15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com) and this project adheres to [Semantic Versioning](https://semver.org). +## [Unreleased] + +### Fixed + +- Resolve evaluation of utf-8 named ranges in calculation engine [#1522](https://github.com/PHPOffice/PhpSpreadsheet/pull/1522) + ## [1.13.0] - 2020-05-31 ### Added diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 2d67a1347a..848f9068f9 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -24,11 +24,11 @@ class Calculation // Opening bracket const CALCULATION_REGEXP_OPENBRACE = '\('; // Function (allow for the old @ symbol that could be used to prefix a function, but we'll ignore it) - const CALCULATION_REGEXP_FUNCTION = '@?(?:_xlfn\.)?([A-Z][A-Z0-9\.]*)[\s]*\('; + const CALCULATION_REGEXP_FUNCTION = '@?(?:_xlfn\.)?([\p{L}][\p{L}\p{N}\.]*)[\s]*\('; // Cell reference (cell or range of cells, with or without a sheet reference) const CALCULATION_REGEXP_CELLREF = '((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?\b([a-z]{1,3})\$?(\d{1,7})(?![\w.])'; // Named Range of cells - const CALCULATION_REGEXP_NAMEDRANGE = '((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?([_A-Z][_A-Z0-9\.]*)'; + const CALCULATION_REGEXP_NAMEDRANGE = '((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?([_\p{L}][_\p{L}\p{N}\.]*)'; // Error const CALCULATION_REGEXP_ERROR = '\#[A-Z][A-Z0_\/]*[!\?]?'; @@ -3395,7 +3395,7 @@ private function _parseFormula($formula, ?Cell $pCell = null) '|' . self::CALCULATION_REGEXP_OPENBRACE . '|' . self::CALCULATION_REGEXP_NAMEDRANGE . '|' . self::CALCULATION_REGEXP_ERROR . - ')/si'; + ')/sui'; // Start with initialisation $index = 0; @@ -3499,7 +3499,7 @@ private function _parseFormula($formula, ?Cell $pCell = null) --$parenthesisDepthMap[$pendingStoreKey]; } - if (is_array($d) && 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 . '$/miu', $d['value'], $matches)) { // Did this parenthesis just close a function? if (!empty($pendingStoreKey) && $parenthesisDepthMap[$pendingStoreKey] == -1) { // we are closing an IF( if ($d['value'] != 'IF(') { @@ -3602,7 +3602,7 @@ private function _parseFormula($formula, ?Cell $pCell = null) } // make sure there was a function $d = $stack->last(2); - if (!preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $d['value'], $matches)) { + if (!preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/miu', $d['value'], $matches)) { return $this->raiseFormulaError('Formula Error: Unexpected ,'); } $d = $stack->pop(); @@ -3625,7 +3625,7 @@ private function _parseFormula($formula, ?Cell $pCell = null) $expectingOperand = false; $val = $match[1]; $length = strlen($val); - if (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $val, $matches)) { + if (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/miu', $val, $matches)) { $val = preg_replace('/\s/u', '', $val); if (isset(self::$phpSpreadsheetFunctions[strtoupper($matches[1])]) || isset(self::$controlFunctions[strtoupper($matches[1])])) { // it's a function $valToUpper = strtoupper($val); @@ -3733,7 +3733,7 @@ private function _parseFormula($formula, ?Cell $pCell = null) } elseif (($localeConstant = array_search(trim(strtoupper($val)), self::$localeBoolean)) !== false) { $stackItemType = 'Constant'; $val = self::$excelConstants[$localeConstant]; - } elseif (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '.*/Ui', $val, $match)) { + } elseif (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '.*/miu', $val, $match)) { $stackItemType = 'Named Range'; $stackItemReference = $val; } @@ -3782,7 +3782,7 @@ private function _parseFormula($formula, ?Cell $pCell = null) if (($expectingOperator) && ((preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '.*/Ui', substr($formula, $index), $match)) && ($output[count($output) - 1]['type'] == 'Cell Reference') || - (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '.*/Ui', substr($formula, $index), $match)) && + (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '.*/miu', substr($formula, $index), $match)) && ($output[count($output) - 1]['type'] == 'Named Range' || $output[count($output) - 1]['type'] == 'Value') )) { while ($stack->count() > 0 && @@ -4208,7 +4208,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $pCell = null) } // if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on - } elseif (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $token, $matches)) { + } elseif (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/miu', $token, $matches)) { if ($pCellParent) { $pCell->attach($pCellParent); } @@ -4306,7 +4306,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $pCell = null) $branchStore[$storeKey] = $token; } // if the token is a named range, push the named range name onto the stack - } elseif (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $token, $matches)) { + } elseif (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '$/miu', $token, $matches)) { $namedRange = $matches[6]; $this->debugLog->writeDebugLog('Evaluating Named Range ', $namedRange); diff --git a/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php index ee566db26b..e2e6e11d23 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php @@ -97,6 +97,36 @@ public function providerNamedRangeEvaluation() ]; } + /** + * @dataProvider providerUTF8NamedRangeEvaluation + * + * @param string $names + * @param string $ranges + * @param string $formula + * @param int $expectedResult + */ + public function testUTF8NamedRangeEvaluation($names, $ranges, $formula, $expectedResult): void + { + $workSheet = $this->spreadSheet->getActiveSheet(); + foreach ($names as $index => $name) { + $range = $ranges[$index]; + $this->spreadSheet->addNamedRange(new NamedRange($name, $workSheet, $range)); + } + $workSheet->setCellValue('E1', $formula); + + $sumRresult = $workSheet->getCell('E1')->getCalculatedValue(); + self::assertSame($expectedResult, $sumRresult); + } + + public function providerUTF8NamedRangeEvaluation() + { + return[ + [['Γειά', 'σου', 'Κόσμε'], ['A1', 'B1:B2', 'C1:C3'], '=SUM(Γειά,σου,Κόσμε)', 26], + [['Γειά', 'σου', 'Κόσμε'], ['A1', 'B1:B2', 'C1:C3'], '=COUNT(Γειά,σου,Κόσμε)', 6], + [['Здравствуй', 'мир'], ['A1:A3', 'C1:C3'], '=SUM(Здравствуй,мир)', 30], + ]; + } + /** * @dataProvider providerCompositeNamedRangeEvaluation * From 82ea1d559647f357b5ce04e60a0bb33ccaa6de77 Mon Sep 17 00:00:00 2001 From: oleibman Date: Fri, 19 Jun 2020 11:26:02 -0700 Subject: [PATCH 087/659] Fix for #1516 (#1530) This problem is that ZipStream, in contrast to ZipArchive, is saving 2 files with the same path. I have opened an issue with ZipStream, who agree that this appears to be a bug. For the case in question, PhpSpreadsheet is attempting to save a file with the same path twice (and unexpectedly succeeding) because of a clone operation. This fix attempts to rectify the problem by keeping track of all the paths being saved in the zip file, and not attempting to save any duplicate paths. The problem case attempted to save printersettings1.bin twice, but there are other possible exposures, e.g. by cloning a sheet with a drawing.The new test cases clone an existing sample which has both printer settings and drawings. --- src/PhpSpreadsheet/Writer/Xlsx.php | 88 +++++++++------ .../Writer/Xlsx/UnparsedDataCloneTest.php | 101 ++++++++++++++++++ 2 files changed, 154 insertions(+), 35 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataCloneTest.php diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index bfcde049c1..4cb102873e 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -107,6 +107,13 @@ class Xlsx extends BaseWriter */ private $drawingHashTable; + /** + * Private handle for zip stream. + * + * @var ZipStream + */ + private $zip; + /** * Create a new Xlsx Writer. */ @@ -173,6 +180,7 @@ public function save($pFilename): void { if ($this->spreadSheet !== null) { // garbage collect + $this->pathNames = []; $this->spreadSheet->garbageCollect(); $this->openFileHandle($pFilename); @@ -203,73 +211,73 @@ public function save($pFilename): void $options->setEnableZip64(false); $options->setOutputStream($this->fileHandle); - $zip = new ZipStream(null, $options); + $this->zip = new ZipStream(null, $options); // Add [Content_Types].xml to ZIP file - $zip->addFile('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->spreadSheet, $this->includeCharts)); + $this->addZipFile('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->spreadSheet, $this->includeCharts)); //if hasMacros, add the vbaProject.bin file, Certificate file(if exists) if ($this->spreadSheet->hasMacros()) { $macrosCode = $this->spreadSheet->getMacrosCode(); if ($macrosCode !== null) { // we have the code ? - $zip->addFile('xl/vbaProject.bin', $macrosCode); //allways in 'xl', allways named vbaProject.bin + $this->addZipFile('xl/vbaProject.bin', $macrosCode); //allways in 'xl', allways named vbaProject.bin if ($this->spreadSheet->hasMacrosCertificate()) { //signed macros ? // Yes : add the certificate file and the related rels file - $zip->addFile('xl/vbaProjectSignature.bin', $this->spreadSheet->getMacrosCertificate()); - $zip->addFile('xl/_rels/vbaProject.bin.rels', $this->getWriterPart('RelsVBA')->writeVBARelationships($this->spreadSheet)); + $this->addZipFile('xl/vbaProjectSignature.bin', $this->spreadSheet->getMacrosCertificate()); + $this->addZipFile('xl/_rels/vbaProject.bin.rels', $this->getWriterPart('RelsVBA')->writeVBARelationships($this->spreadSheet)); } } } //a custom UI in this workbook ? add it ("base" xml and additional objects (pictures) and rels) if ($this->spreadSheet->hasRibbon()) { $tmpRibbonTarget = $this->spreadSheet->getRibbonXMLData('target'); - $zip->addFile($tmpRibbonTarget, $this->spreadSheet->getRibbonXMLData('data')); + $this->addZipFile($tmpRibbonTarget, $this->spreadSheet->getRibbonXMLData('data')); if ($this->spreadSheet->hasRibbonBinObjects()) { $tmpRootPath = dirname($tmpRibbonTarget) . '/'; $ribbonBinObjects = $this->spreadSheet->getRibbonBinObjects('data'); //the files to write foreach ($ribbonBinObjects as $aPath => $aContent) { - $zip->addFile($tmpRootPath . $aPath, $aContent); + $this->addZipFile($tmpRootPath . $aPath, $aContent); } //the rels for files - $zip->addFile($tmpRootPath . '_rels/' . basename($tmpRibbonTarget) . '.rels', $this->getWriterPart('RelsRibbonObjects')->writeRibbonRelationships($this->spreadSheet)); + $this->addZipFile($tmpRootPath . '_rels/' . basename($tmpRibbonTarget) . '.rels', $this->getWriterPart('RelsRibbonObjects')->writeRibbonRelationships($this->spreadSheet)); } } // Add relationships to ZIP file - $zip->addFile('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->spreadSheet)); - $zip->addFile('xl/_rels/workbook.xml.rels', $this->getWriterPart('Rels')->writeWorkbookRelationships($this->spreadSheet)); + $this->addZipFile('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->spreadSheet)); + $this->addZipFile('xl/_rels/workbook.xml.rels', $this->getWriterPart('Rels')->writeWorkbookRelationships($this->spreadSheet)); // Add document properties to ZIP file - $zip->addFile('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->spreadSheet)); - $zip->addFile('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->spreadSheet)); + $this->addZipFile('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->spreadSheet)); + $this->addZipFile('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->spreadSheet)); $customPropertiesPart = $this->getWriterPart('DocProps')->writeDocPropsCustom($this->spreadSheet); if ($customPropertiesPart !== null) { - $zip->addFile('docProps/custom.xml', $customPropertiesPart); + $this->addZipFile('docProps/custom.xml', $customPropertiesPart); } // Add theme to ZIP file - $zip->addFile('xl/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->spreadSheet)); + $this->addZipFile('xl/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->spreadSheet)); // Add string table to ZIP file - $zip->addFile('xl/sharedStrings.xml', $this->getWriterPart('StringTable')->writeStringTable($this->stringTable)); + $this->addZipFile('xl/sharedStrings.xml', $this->getWriterPart('StringTable')->writeStringTable($this->stringTable)); // Add styles to ZIP file - $zip->addFile('xl/styles.xml', $this->getWriterPart('Style')->writeStyles($this->spreadSheet)); + $this->addZipFile('xl/styles.xml', $this->getWriterPart('Style')->writeStyles($this->spreadSheet)); // Add workbook to ZIP file - $zip->addFile('xl/workbook.xml', $this->getWriterPart('Workbook')->writeWorkbook($this->spreadSheet, $this->preCalculateFormulas)); + $this->addZipFile('xl/workbook.xml', $this->getWriterPart('Workbook')->writeWorkbook($this->spreadSheet, $this->preCalculateFormulas)); $chartCount = 0; // Add worksheets for ($i = 0; $i < $this->spreadSheet->getSheetCount(); ++$i) { - $zip->addFile('xl/worksheets/sheet' . ($i + 1) . '.xml', $this->getWriterPart('Worksheet')->writeWorksheet($this->spreadSheet->getSheet($i), $this->stringTable, $this->includeCharts)); + $this->addZipFile('xl/worksheets/sheet' . ($i + 1) . '.xml', $this->getWriterPart('Worksheet')->writeWorksheet($this->spreadSheet->getSheet($i), $this->stringTable, $this->includeCharts)); if ($this->includeCharts) { $charts = $this->spreadSheet->getSheet($i)->getChartCollection(); if (count($charts) > 0) { foreach ($charts as $chart) { - $zip->addFile('xl/charts/chart' . ($chartCount + 1) . '.xml', $this->getWriterPart('Chart')->writeChart($chart, $this->preCalculateFormulas)); + $this->addZipFile('xl/charts/chart' . ($chartCount + 1) . '.xml', $this->getWriterPart('Chart')->writeChart($chart, $this->preCalculateFormulas)); ++$chartCount; } } @@ -280,19 +288,19 @@ public function save($pFilename): void // Add worksheet relationships (drawings, ...) for ($i = 0; $i < $this->spreadSheet->getSheetCount(); ++$i) { // Add relationships - $zip->addFile('xl/worksheets/_rels/sheet' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeWorksheetRelationships($this->spreadSheet->getSheet($i), ($i + 1), $this->includeCharts)); + $this->addZipFile('xl/worksheets/_rels/sheet' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeWorksheetRelationships($this->spreadSheet->getSheet($i), ($i + 1), $this->includeCharts)); // Add unparsedLoadedData $sheetCodeName = $this->spreadSheet->getSheet($i)->getCodeName(); $unparsedLoadedData = $this->spreadSheet->getUnparsedLoadedData(); if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['ctrlProps'])) { foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['ctrlProps'] as $ctrlProp) { - $zip->addFile($ctrlProp['filePath'], $ctrlProp['content']); + $this->addZipFile($ctrlProp['filePath'], $ctrlProp['content']); } } if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['printerSettings'])) { foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['printerSettings'] as $ctrlProp) { - $zip->addFile($ctrlProp['filePath'], $ctrlProp['content']); + $this->addZipFile($ctrlProp['filePath'], $ctrlProp['content']); } } @@ -305,13 +313,13 @@ public function save($pFilename): void // Add drawing and image relationship parts if (($drawingCount > 0) || ($chartCount > 0)) { // Drawing relationships - $zip->addFile('xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeDrawingRelationships($this->spreadSheet->getSheet($i), $chartRef1, $this->includeCharts)); + $this->addZipFile('xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeDrawingRelationships($this->spreadSheet->getSheet($i), $chartRef1, $this->includeCharts)); // Drawings - $zip->addFile('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts)); + $this->addZipFile('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts)); } elseif (isset($unparsedLoadedData['sheets'][$sheetCodeName]['drawingAlternateContents'])) { // Drawings - $zip->addFile('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts)); + $this->addZipFile('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts)); } // Add unparsed drawings @@ -320,7 +328,7 @@ public function save($pFilename): void $drawingFile = array_search($relId, $unparsedLoadedData['sheets'][$sheetCodeName]['drawingOriginalIds']); if ($drawingFile !== false) { $drawingFile = ltrim($drawingFile, '.'); - $zip->addFile('xl' . $drawingFile, $drawingXml); + $this->addZipFile('xl' . $drawingFile, $drawingXml); } } } @@ -328,30 +336,30 @@ public function save($pFilename): void // Add comment relationship parts if (count($this->spreadSheet->getSheet($i)->getComments()) > 0) { // VML Comments - $zip->addFile('xl/drawings/vmlDrawing' . ($i + 1) . '.vml', $this->getWriterPart('Comments')->writeVMLComments($this->spreadSheet->getSheet($i))); + $this->addZipFile('xl/drawings/vmlDrawing' . ($i + 1) . '.vml', $this->getWriterPart('Comments')->writeVMLComments($this->spreadSheet->getSheet($i))); // Comments - $zip->addFile('xl/comments' . ($i + 1) . '.xml', $this->getWriterPart('Comments')->writeComments($this->spreadSheet->getSheet($i))); + $this->addZipFile('xl/comments' . ($i + 1) . '.xml', $this->getWriterPart('Comments')->writeComments($this->spreadSheet->getSheet($i))); } // Add unparsed relationship parts if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['vmlDrawings'])) { foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['vmlDrawings'] as $vmlDrawing) { - $zip->addFile($vmlDrawing['filePath'], $vmlDrawing['content']); + $this->addZipFile($vmlDrawing['filePath'], $vmlDrawing['content']); } } // Add header/footer relationship parts if (count($this->spreadSheet->getSheet($i)->getHeaderFooter()->getImages()) > 0) { // VML Drawings - $zip->addFile('xl/drawings/vmlDrawingHF' . ($i + 1) . '.vml', $this->getWriterPart('Drawing')->writeVMLHeaderFooterImages($this->spreadSheet->getSheet($i))); + $this->addZipFile('xl/drawings/vmlDrawingHF' . ($i + 1) . '.vml', $this->getWriterPart('Drawing')->writeVMLHeaderFooterImages($this->spreadSheet->getSheet($i))); // VML Drawing relationships - $zip->addFile('xl/drawings/_rels/vmlDrawingHF' . ($i + 1) . '.vml.rels', $this->getWriterPart('Rels')->writeHeaderFooterDrawingRelationships($this->spreadSheet->getSheet($i))); + $this->addZipFile('xl/drawings/_rels/vmlDrawingHF' . ($i + 1) . '.vml.rels', $this->getWriterPart('Rels')->writeHeaderFooterDrawingRelationships($this->spreadSheet->getSheet($i))); // Media foreach ($this->spreadSheet->getSheet($i)->getHeaderFooter()->getImages() as $image) { - $zip->addFile('xl/media/' . $image->getIndexedFilename(), file_get_contents($image->getPath())); + $this->addZipFile('xl/media/' . $image->getIndexedFilename(), file_get_contents($image->getPath())); } } } @@ -374,7 +382,7 @@ public function save($pFilename): void $imageContents = file_get_contents($imagePath); } - $zip->addFile('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); + $this->addZipFile('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); } elseif ($this->getDrawingHashTable()->getByIndex($i) instanceof MemoryDrawing) { ob_start(); call_user_func( @@ -384,7 +392,7 @@ public function save($pFilename): void $imageContents = ob_get_contents(); ob_end_clean(); - $zip->addFile('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); + $this->addZipFile('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); } } @@ -393,7 +401,7 @@ public function save($pFilename): void // Close file try { - $zip->finish(); + $this->zip->finish(); } catch (OverflowException $e) { throw new WriterException('Could not close resource.'); } @@ -535,4 +543,14 @@ public function setOffice2003Compatibility($pValue) return $this; } + + private $pathNames = []; + + private function addZipFile(string $path, string $content): void + { + if (!in_array($path, $this->pathNames)) { + $this->pathNames[] = $path; + $this->zip->addFile($path, $content); + } + } } diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataCloneTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataCloneTest.php new file mode 100644 index 0000000000..d2afb4239c --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataCloneTest.php @@ -0,0 +1,101 @@ +load($sampleFilename); + $spreadsheet->setActiveSheetIndex(1); + $sheet = $spreadsheet->getActiveSheet(); + $drawings = $sheet->getDrawingCollection(); + self::assertCount(1, $drawings); + $sheetCodeName = $sheet->getCodeName(); + $unparsedLoadedData = $spreadsheet->getUnparsedLoadedData(); + self::assertArrayHasKey('printerSettings', $unparsedLoadedData['sheets'][$sheetCodeName]); + self::assertCount(1, $unparsedLoadedData['sheets'][$sheetCodeName]['printerSettings']); + + $clonedSheet = clone $spreadsheet->getActiveSheet(); + $clonedSheet->setTitle('Clone'); + $spreadsheet->addSheet($clonedSheet); + + $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); + $writer->save($resultFilename); + $dupname = 'Unable to open saved file'; + $zip = zip_open($resultFilename); + if (is_resource($zip)) { + $names = []; + $dupname = ''; + while ($zip_entry = zip_read($zip)) { + $zipname = zip_entry_name($zip_entry); + if (in_array($zipname, $names)) { + $dupname .= "$zipname,"; + } else { + $names[] = $zipname; + } + } + zip_close($zip); + } + unlink($resultFilename); + self::assertEquals('', $dupname); + } + + /** + * Test that saving twice with same writer works. + */ + public function testSaveTwice(): void + { + $sampleFilename = 'tests/data/Writer/XLSX/drawing_on_2nd_page.xlsx'; + $resultFilename1 = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test1'); + $resultFilename2 = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test2'); + self::assertNotEquals($resultFilename1, $resultFilename2); + Settings::setLibXmlLoaderOptions(null); // reset to default options + $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); + $spreadsheet = $reader->load($sampleFilename); + $sheet = $spreadsheet->setActiveSheetIndex(1); + $sheet->setTitle('Original'); + + $clonedSheet = clone $spreadsheet->getActiveSheet(); + $clonedSheet->setTitle('Clone'); + $spreadsheet->addSheet($clonedSheet); + $clonedSheet->getCell('A8')->setValue('cloned'); + $sheet->getCell('A8')->setValue('original'); + + $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); + $writer->save($resultFilename1); + $reader1 = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); + $spreadsheet1 = $reader1->load($resultFilename1); + unlink($resultFilename1); + $sheet1c = $spreadsheet1->getSheetByName('Clone'); + $sheet1o = $spreadsheet1->getSheetByName('Original'); + + $writer->save($resultFilename2); + $reader2 = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); + $spreadsheet2 = $reader2->load($resultFilename2); + unlink($resultFilename2); + $sheet2c = $spreadsheet2->getSheetByName('Clone'); + $sheet2o = $spreadsheet2->getSheetByName('Original'); + + self::assertEquals($spreadsheet1->getSheetCount(), $spreadsheet2->getSheetCount()); + self::assertCount(1, $sheet1c->getDrawingCollection()); + self::assertCount(1, $sheet1o->getDrawingCollection()); + self::assertCount(1, $sheet2c->getDrawingCollection()); + self::assertCount(1, $sheet2o->getDrawingCollection()); + self::assertEquals('original', $sheet1o->getCell('A8')->getValue()); + self::assertEquals('original', $sheet2o->getCell('A8')->getValue()); + self::assertEquals('cloned', $sheet1c->getCell('A8')->getValue()); + self::assertEquals('cloned', $sheet2c->getCell('A8')->getValue()); + } +} From ce6ac1f0404ae5bd9155faeba4d1f5816b354e34 Mon Sep 17 00:00:00 2001 From: oleibman Date: Fri, 19 Jun 2020 11:28:57 -0700 Subject: [PATCH 088/659] Fix For #1509 (#1518) * Fix For #1509 User expected no CSV enclosures after $writer->setEnclosure(''), which had been changed to be consistent with $reader->setEnclosure(''). Writer will now omit enclosures after code above; no change to Reader. Tests have been added for this condition. * Add Option to Write CSV Enclosure Only When Required Allowing the user to specify no enclosure when writing a CSV can lead to a situation where PhpSpreadsheet (likewise Excel) will not read the resulting file as intended, e.g. if any cell contains a delimiter character. This is demonstrated in new test TestBadReread. No existing setting will rectify this situation. A better choice would be to add an option to write the enclosure only when it is needed, which is what Excel does. The RFC4180 spec at https://tools.ietf.org/html/rfc4180 states when it is needed - when the cell contains the delimiter, or the enclosure, or a newline. New test TestGoodReread demonstrates that the file is read as intended. The documentation has been updated to describe the new function, and to change the write example where the enclosure is set to null. * Scrutinizer Suggestions 3 minor changes, all in tests. --- docs/topics/reading-and-writing-to-file.md | 18 +- src/PhpSpreadsheet/Writer/Csv.php | 42 +++- .../Writer/Csv/CsvEnclosureTest.php | 216 ++++++++++++++++++ .../Writer/Csv/CsvWriteTest.php | 4 +- 4 files changed, 265 insertions(+), 15 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/Writer/Csv/CsvEnclosureTest.php diff --git a/docs/topics/reading-and-writing-to-file.md b/docs/topics/reading-and-writing-to-file.md index 020e063418..f8ba084b4f 100644 --- a/docs/topics/reading-and-writing-to-file.md +++ b/docs/topics/reading-and-writing-to-file.md @@ -478,7 +478,7 @@ imports onto the 6th sheet: ```php $reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv(); $reader->setDelimiter(';'); -$reader->setEnclosure(''); +$reader->setEnclosure('"'); $reader->setSheetIndex(5); $reader->loadIntoExisting("05featuredemo.csv", $spreadsheet); @@ -505,13 +505,26 @@ file: ```php $writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet); $writer->setDelimiter(';'); -$writer->setEnclosure(''); +$writer->setEnclosure('"'); $writer->setLineEnding("\r\n"); $writer->setSheetIndex(0); $writer->save("05featuredemo.csv"); ``` +#### CSV enclosures + +By default, all CSV fields are wrapped in the enclosure character, +which defaults to double-quote. +You can change to use the enclosure character only when required: + +``` php +$writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet); +$writer->setEnclosureRequired(false); + +$writer->save("05featuredemo.csv"); +``` + #### Write a specific worksheet CSV files can only contain one worksheet. Therefore, you can specify @@ -538,6 +551,7 @@ $writer->save("05featuredemo.csv"); CSV files are written in UTF-8. If they do not contain characters outside the ASCII range, nothing else need be done. However, if such characters are in the file, +or if the file starts with the 2 characters 'ID', it should explicitly include a BOM file header; if it doesn't, Excel will not interpret those characters correctly. This can be enabled by using the following code: diff --git a/src/PhpSpreadsheet/Writer/Csv.php b/src/PhpSpreadsheet/Writer/Csv.php index 414bdf906f..74f286361b 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -168,9 +168,9 @@ public function getEnclosure() * * @return $this */ - public function setEnclosure($pValue) + public function setEnclosure($pValue = '"') { - $this->enclosure = $pValue ? $pValue : '"'; + $this->enclosure = $pValue; return $this; } @@ -296,6 +296,20 @@ public function setSheetIndex($pValue) return $this; } + private $enclosureRequired = true; + + public function setEnclosureRequired(bool $value): self + { + $this->enclosureRequired = $value; + + return $this; + } + + public function getEnclosureRequired(): bool + { + return $this->enclosureRequired; + } + /** * Write line to CSV file. * @@ -305,24 +319,28 @@ public function setSheetIndex($pValue) private function writeLine($pFileHandle, array $pValues): void { // No leading delimiter - $writeDelimiter = false; + $delimiter = ''; // Build the line $line = ''; foreach ($pValues as $element) { - // Escape enclosures - $element = str_replace($this->enclosure, $this->enclosure . $this->enclosure, $element); - // Add delimiter - if ($writeDelimiter) { - $line .= $this->delimiter; - } else { - $writeDelimiter = true; + $line .= $delimiter; + $delimiter = $this->delimiter; + // Escape enclosures + $enclosure = $this->enclosure; + if ($enclosure) { + // If enclosure is not required, use enclosure only if + // element contains newline, delimiter, or enclosure. + if (!$this->enclosureRequired && strpbrk($element, "$delimiter$enclosure\n") === false) { + $enclosure = ''; + } else { + $element = str_replace($enclosure, $enclosure . $enclosure, $element); + } } - // Add enclosed string - $line .= $this->enclosure . $element . $this->enclosure; + $line .= $enclosure . $element . $enclosure; } // Add line ending diff --git a/tests/PhpSpreadsheetTests/Writer/Csv/CsvEnclosureTest.php b/tests/PhpSpreadsheetTests/Writer/Csv/CsvEnclosureTest.php new file mode 100644 index 0000000000..d048183c37 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Csv/CsvEnclosureTest.php @@ -0,0 +1,216 @@ + '2020-06-03', + 'B1' => '000123', + 'C1' => '06.53', + 'D1' => '14.22', + 'A2' => '2020-06-04', + 'B2' => '000234', + 'C2' => '07.12', + 'D2' => '15.44', + ]; + + public function testNormalEnclosure(): void + { + $delimiter = ';'; + $enclosure = '"'; + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + foreach (self::$cellValues as $key => $value) { + $sheet->setCellValue($key, $value); + } + $writer = new CsvWriter($spreadsheet); + $writer->setDelimiter($delimiter); + $writer->setEnclosure($enclosure); + $filename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); + $writer->save($filename); + $filedata = file_get_contents($filename); + $filedata = preg_replace('/\\r?\\n/', $delimiter, $filedata); + $reader = new CsvReader(); + $reader->setDelimiter($delimiter); + $reader->setEnclosure($enclosure); + $newspreadsheet = $reader->load($filename); + unlink($filename); + $sheet = $newspreadsheet->getActiveSheet(); + $expected = ''; + foreach (self::$cellValues as $key => $value) { + self::assertEquals($value, $sheet->getCell($key)->getValue()); + $expected .= "$enclosure$value$enclosure$delimiter"; + } + self::assertEquals($expected, $filedata); + } + + public function testNoEnclosure(): void + { + $delimiter = ';'; + $enclosure = ''; + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + foreach (self::$cellValues as $key => $value) { + $sheet->setCellValue($key, $value); + } + $writer = new CsvWriter($spreadsheet); + $writer->setDelimiter($delimiter); + $writer->setEnclosure($enclosure); + self::assertEquals('', $writer->getEnclosure()); + $filename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); + $writer->save($filename); + $filedata = file_get_contents($filename); + $filedata = preg_replace('/\\r?\\n/', $delimiter, $filedata); + $reader = new CsvReader(); + $reader->setDelimiter($delimiter); + $reader->setEnclosure($enclosure); + self::assertEquals('"', $reader->getEnclosure()); + $newspreadsheet = $reader->load($filename); + unlink($filename); + $sheet = $newspreadsheet->getActiveSheet(); + $expected = ''; + foreach (self::$cellValues as $key => $value) { + self::assertEquals($value, $sheet->getCell($key)->getValue()); + $expected .= "$enclosure$value$enclosure$delimiter"; + } + self::assertEquals($expected, $filedata); + } + + public function testNotRequiredEnclosure1(): void + { + $delimiter = ';'; + $enclosure = '"'; + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + foreach (self::$cellValues as $key => $value) { + $sheet->setCellValue($key, $value); + } + $writer = new CsvWriter($spreadsheet); + self::assertTrue($writer->getEnclosureRequired()); + $writer->setEnclosureRequired(false)->setDelimiter($delimiter)->setEnclosure($enclosure); + $filename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); + $writer->save($filename); + $filedata = file_get_contents($filename); + $filedata = preg_replace('/\\r?\\n/', $delimiter, $filedata); + $reader = new CsvReader(); + $reader->setDelimiter($delimiter); + $reader->setEnclosure($enclosure); + $newspreadsheet = $reader->load($filename); + unlink($filename); + $sheet = $newspreadsheet->getActiveSheet(); + $expected = ''; + foreach (self::$cellValues as $key => $value) { + self::assertEquals($value, $sheet->getCell($key)->getValue()); + $expected .= "$value$delimiter"; + } + self::assertEquals($expected, $filedata); + } + + public function testNotRequiredEnclosure2(): void + { + $cellValues2 = [ + 'A1' => '2020-06-03', + 'B1' => 'has,separator', + 'C1' => 'has;non-separator', + 'D1' => 'has"enclosure', + 'A2' => 'has space', + 'B2' => "has\nnewline", + 'C2' => '', + 'D2' => '15.44', + 'A3' => ' leadingspace', + 'B3' => 'trailingspace ', + 'C3' => '=D2*2', + 'D3' => ',leadingcomma', + 'A4' => 'trailingquote"', + 'B4' => 'unused', + 'C4' => 'unused', + 'D4' => 'unused', + ]; + $calcc3 = '30.88'; + $expected1 = '2020-06-03,"has,separator",has;non-separator,"has""enclosure"'; + $expected2 = 'has space,"has' . "\n" . 'newline",,15.44'; + $expected3 = ' leadingspace,trailingspace ,' . $calcc3 . ',",leadingcomma"'; + $expected4 = '"trailingquote""",unused,unused,unused'; + $expectedfile = "$expected1\n$expected2\n$expected3\n$expected4\n"; + $delimiter = ','; + $enclosure = '"'; + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + foreach ($cellValues2 as $key => $value) { + $sheet->setCellValue($key, $value); + } + $writer = new CsvWriter($spreadsheet); + self::assertTrue($writer->getEnclosureRequired()); + $writer->setEnclosureRequired(false)->setDelimiter($delimiter)->setEnclosure($enclosure); + $filename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); + $writer->save($filename); + $filedata = file_get_contents($filename); + $filedata = preg_replace('/\\r/', '', $filedata); + $reader = new CsvReader(); + $reader->setDelimiter($delimiter); + $reader->setEnclosure($enclosure); + $newspreadsheet = $reader->load($filename); + unlink($filename); + $sheet = $newspreadsheet->getActiveSheet(); + foreach ($cellValues2 as $key => $value) { + self::assertEquals(($key === 'C3') ? $calcc3 : $value, $sheet->getCell($key)->getValue()); + } + self::assertEquals($expectedfile, $filedata); + } + + public function testGoodReread(): void + { + $delimiter = ','; + $enclosure = '"'; + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('A1', '1'); + $sheet->setCellValue('B1', '2,3'); + $sheet->setCellValue('C1', '4'); + $writer = new CsvWriter($spreadsheet); + $writer->setEnclosureRequired(false)->setDelimiter($delimiter)->setEnclosure($enclosure); + $filename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); + $writer->save($filename); + $reader = new CsvReader(); + $reader->setDelimiter($delimiter); + $reader->setEnclosure($enclosure); + $newspreadsheet = $reader->load($filename); + unlink($filename); + $sheet = $newspreadsheet->getActiveSheet(); + self::assertEquals('1', $sheet->getCell('A1')->getValue()); + self::assertEquals('2,3', $sheet->getCell('B1')->getValue()); + self::assertEquals('4', $sheet->getCell('C1')->getValue()); + } + + public function testBadReread(): void + { + $delimiter = ','; + $enclosure = ''; + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('A1', '1'); + $sheet->setCellValue('B1', '2,3'); + $sheet->setCellValue('C1', '4'); + $writer = new CsvWriter($spreadsheet); + $writer->setDelimiter($delimiter)->setEnclosure($enclosure); + $filename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); + $writer->save($filename); + $reader = new CsvReader(); + $reader->setDelimiter($delimiter); + $reader->setEnclosure($enclosure); + $newspreadsheet = $reader->load($filename); + unlink($filename); + $sheet = $newspreadsheet->getActiveSheet(); + self::assertEquals('1', $sheet->getCell('A1')->getValue()); + self::assertEquals('2', $sheet->getCell('B1')->getValue()); + self::assertEquals('3', $sheet->getCell('C1')->getValue()); + self::assertEquals('4', $sheet->getCell('D1')->getValue()); + } +} diff --git a/tests/PhpSpreadsheetTests/Writer/Csv/CsvWriteTest.php b/tests/PhpSpreadsheetTests/Writer/Csv/CsvWriteTest.php index 7252ecf970..7fe1902b9a 100644 --- a/tests/PhpSpreadsheetTests/Writer/Csv/CsvWriteTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Csv/CsvWriteTest.php @@ -1,6 +1,6 @@ setEnclosure('\''); self::assertEquals('\'', $writer->getEnclosure()); $writer->setEnclosure(''); + self::assertEquals('', $writer->getEnclosure()); + $writer->setEnclosure(); self::assertEquals('"', $writer->getEnclosure()); self::assertEquals(PHP_EOL, $writer->getLineEnding()); self::assertFalse($writer->getUseBOM()); From 73379cdfb1034db66167ae2c01e0b339366b4ddd Mon Sep 17 00:00:00 2001 From: oleibman Date: Fri, 19 Jun 2020 11:34:02 -0700 Subject: [PATCH 089/659] Improve Coverage for Gnumeric (#1517) * Improve Coverage for Gnumeric I believe that both BaseReader and Gnumeric Reader are now 100% covered. My goal was to use PhpSpreadsheet to load the test file, save it as Xlsx, and visually compare the two, then add a test loaded with assertions. Results were generally pretty good, but there were no tests with assertions. I added a few cells to exercise some previously uncovered code. Code was extensively refactored; logic changes are noted below. Code allowed for specifying document properties in an old format. I considered removing that, but I found the original spec at http://www.jfree.org/jworkbook/download/gnumeric-xml.pdf This allowed me to create an old file, which was not handled correctly because of namespace differences. The code was corrected to allow for this difference. Added support for textRotation. Mapping of fill types was not correct. * PHP7.2 Error One assertion failed under PHP7.2. Apparently there was some change in the handling of SimpleXMLElement between 7.2 and 7.3. Casting to string before use eliminates the problem. * Scrutinizer Recommendations All minor, solved (hopefully) mostly by casts. * One Last Scrutinizer Fix ... I hope. --- samples/templates/GnumericTest.gnumeric | Bin 7823 -> 8064 bytes samples/templates/old.gnumeric | Bin 0 -> 1276 bytes src/PhpSpreadsheet/Reader/BaseReader.php | 23 +- src/PhpSpreadsheet/Reader/Gnumeric.php | 1103 ++++++++--------- tests/PhpSpreadsheetTests/IOFactoryTest.php | 1 + .../Reader/Gnumeric/GnumericFilter.php | 14 + .../Reader/Gnumeric/GnumericInfoTest.php | 47 + .../Reader/Gnumeric/GnumericLoadTest.php | 162 +++ .../Reader/Gnumeric/GnumericStylesTest.php | 269 ++++ 9 files changed, 1050 insertions(+), 569 deletions(-) create mode 100644 samples/templates/old.gnumeric create mode 100644 tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php create mode 100644 tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericInfoTest.php create mode 100644 tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericLoadTest.php create mode 100644 tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericStylesTest.php diff --git a/samples/templates/GnumericTest.gnumeric b/samples/templates/GnumericTest.gnumeric index ea2fac379e51e707060c8c8d5314899c60bad287..0493e762360924353d0d60a1709528637db0224b 100644 GIT binary patch literal 8064 zcmV-`AAjH_ zKoQ4pz@#^&X%NgC2M4#ex0Q*rm;uikS6pv$@KF*gW?+`0ym!8p%6qHeT(T%i2Y)_0 z9gL@7W|S?*4-97vppAHW}V}Q(AaV!!>-%$0hI^!MNehfwL58By%^ggNSU}wwxQ1 zRZI1H{Q%!xW;MrgzWKtlaV~Rw0BnGs;2%IEJXq#MC1foW%9|{b>$>rSQ1-CUOIM>F zgx4h@dYOdVlS@&(Mz@gW7z}gV7<<47T(5a%csD}ZxB<|H63L02rUBuQMOiG1dRf$l zqSlbKhAe%+0{Ct+H-JWI%@GZo19t`lNK0HNf^p?80wI_J;qv6Ndp8EQa2&Zkp$`lb zcz-8^DibP}nsLS4fcsn5Gn+JdVF>&{_%X}{jWH#Z(zNh_S2n@5x!CDey|+4b0JUa6gB)eMm)TQi=-@JtCQ`tFO^5 z2UcK%W?pQF(y>sOgXzU4{&fSkJ7D5^_Y5yauGvncVBKp!Sc;k97?ZWNduAA30366l z+qR6w?SqfQq=jrLM^u#{RqJI@9?D`vtu>VThe$;_V@d}wtpGl~JiZ^>(AB7sL?)Ri zVlF(awRt%d#S>9Ilf^+sJkF9*FaZwmu(@48+rC)Ywo;M4`pI$>SxDbN9v0E$K#|0m zBz@IhShiWNEA@Kxyp_h(gDeLY!?4RFqbFvFTyn;D#0e?y8}~ChhCN=`_&s3{#aS43 zAHY@`x=QHJx{h&WgI)l#FHRV`HvHxwhb~rNw+i-eY}W|-hH2fs zDaq00p*67rD61)n4$oi;KyVHj*K#Xe!#{jmJfp;(bWSIf#;w!pd5>9|MnFf&C^?H`vewKv7q2%-UN=f zb7ctJxp3)1QN&;w^7_&P*Kc8a_og(Pg?5$7f8_>&JL3|u!F3P|ROJWrd&oX`1g2pp zj6>qug+nnmiKQiEsxR~{u>A%?*gcyAZw%Xf*m)}ntM6g6eUOp+i0;DYV_G0@lFcxE zD8mH$1NvR?5jZ33dgMCx{m2jQVc(3NdFDFqcdo_Ovou-_Iu~UQL8iTz3YY^GA9WKFu-e?BRG0;Mp3jQOv~o85G>d{ zP=CWStYDdYbtf$ox_sdjlK4#t1(ZzFh9&zN8v3_C4_obDNoi2VQ# zYG7-Gn^t_$M{OsLPMXVf_%%w+88p@{Z%ATood&N`Wf}uG?s@>I&ET3Rktj^$Bt9 zK%pzodRbsKqQPnfuutfSHv+6q1XeGA!E_wz0JW*j;a9 z>qLvK?*p)=c`%zD+{4f7>=#QSIY6;P!KcTA`=#)`c<}xA;wyzV5qpvn&=$d`op;C* zIs7E;Mf_eBaLE9MH>oQv4h?nA4R&3P}vQ?P>t`&UBFs$VPC8rh7C zh}G^xn+RD+qO2s)Ey7m2k1jcGB^B|F-G??2;LsA#?nQ*-bwewQG@mT*MTmnDUGcNg z9T<-P!qAfA8*&lf*l}DbYisr*xbbATJ~XGh0bI#zYvdw;!Gr5VQ@R_#l^ng0_ab`n zWVkBZhbwt$ja)=3cyLv>4_9iKLN3A-JKlAwQlWjm^)*rf?MpzLSY0D0aNV)+QwZX2 zc8sIPo!rlXcM9tz+7fr{%udkd+diyWh}Q%Jsq;hT(>XxLDO4N~WH#wN7gxv&cI3T? zXFa%@V;8Mo5owMcoh(rF$aW50iL(DM5y&dylP|RbD|+BNsMicnF2NPOs>Q?Buy=7j z8Vui`cH!R_mnC5s`u=o=;rq)j+CJJlAC}OmE%+3cT&|1DQM)_*soOm-2`$@pZ`-zk z&YVKK-h6QAxpULK4XYP#%70Vponvv~{Owu0+b;=c!1wXC>vw1au`pZsfp7%`!x1be z02AQBtKb#@N04BmDM(qT7`<`#Ztg)<@QuagX$Q%q^&(PJ60F*hcuuv6U&<7K6au$5y3HE9}SKqgRe@mDoe( z+Og2-o)6JLgn;bw)_x<)5WK;a+s>TSnYcf6=gV;@9MeSagI^TA(g9JX9Uf4d6B8S4 zu`M<?KRk12II%0<=hfnXMlrt=BRxm-~{M$cUz>*TNELy84nP&WF^$1!Om(6$ z6)tjn2WfI*)I=Dez0|NL#iHb4U&*n4vF>Thc$6NvZzYu!GL?$SP2sEmcK%-g&8rRya zwB<30#Y{zUy(_%7}$Z*(t9UQO32nio0a58Zi=8jCgjj@1)X3JZdrG*#xw# zll|ah`Oq>Zu4CBCIe(pX+Y!IuORX1BY3l_NgR~8;7f`irWaEx><26b*UMsrsYkkbN zclR_(H(o2c@vOLRWp_`bbmQwqH-0UyTi@N&Xx%-n=?)`=GN{it8C5|0QqU%rRLZ1qLPJcZ4^6tp!mw9j@@T7m5IAzPyvZLKicO+fn@^HS1w z>_x57d_}G3mA@)yQ71#o(<|@yj!($L=mOY{0h{cT*EilLSEOP>`0>EjY0Z1Rn1|Se z%`!IcTiUeOX-#|mMVj`4O)uprsHagrW6Z5U_ZiO`6=^?HCvMTqmh>6W;_H0|RUw1A z@#Q0*18N<9_8nK1jO)gKapH4u4J~%Ran;DUZhUqBBXJcQHL{s_!hQV$oeH zRmq@keAN6%P;sNGz)wSmpZ$imMuv9dL)g#mGu zW|t5R$zerli^7WRxUM3Jg;&m^tB}#%czlr)T{Pw?044#fk^$a$ppg^cWo)qkI18{w z26(61-DQxmKsSr7PDXd*p+~-6RfuDOZWi4t8QmQk?uM3&4Y&X}4{(hP@WvyN+@0sb zg2@2a$pCLW9?1@HNA0MMs#et+l8nwzFEGwxEK#g@<6C2Nc955$s%Q#f{Sup0kNfq4 zEYrdq#cz1c`a4@mYzt_&Z25coXJ4z^vG`r0{jyh*OFI0~bL*!;x) zacN6_;XF;IDw#|>G##>^WKy<~Of@o@iippalS$l0GS$gsDx$;NO{Us5aw%H;oDWzQ zhf8lao3^sgB+R7IfOudDp}ZKTbnQ z@D+XG5L_DzI~Z8Mfy=;uQ&MXcCD{jF=IlAwu5j)~?}6U3u2Rch@ixHDQ6_Y8=>fxy}U0nSNll?5+fo*r( z*$jFpA9YZI!@XFWNdj-IRZwNI^@|H*|+7aq8JXP6zT)4NxqjC+F z%n9JrvK5-Cxwvqox)hd3En#|R*b6YcpQE-DLXN9rfL~aMejp5qJ*Y`aX;Psk9%(rz zt#L@JxwmL>NNYLiE{8P4uzNT6dWU$S&6~FL4;`Ktudl>mSKv)o`r4Syzdd46A+5)- zyhKsv(3MA#M>>z9&LN#gvCSc!NAZY5I)x(1&ePdbs6Ct=xr0pM4&8vEc=CFPzf?GM z(Dm`r1>=VX;O132@Y@ILZ}8si!_1>JX~ehV8S#s#9S-YMl;PaMfdH5?VGI zNBMo^(|DdwU_~2V@o31Cf>#5P6XP3!)4f)ofE-mSIh2a3iOCPkNTEuv=F5c#2j4t8 z@)gamBVX0;49_y)i2hMkUR(2imUF|Sf$(;m8Xlq%gRVM}LfALRvd-cT>ajb>73SiS zLtf97K;)1nnYHKMvUuwH8oTCIu?`WI(JDD?6E?Xl0h3sP4xOYVAFxzmEJH0lV_PMW z!vwe@@$3bU4nkqNcY$XJd_^J;ura$TlBi00;=?lFmFQ#EPyg}h|33ZCr~mx)SK;@6 z{{3Hm|F=*7_33{<{q^^M=TS?HBrL9M!2HJK(G^mJe)5+`L;e;2_OBjrOb~!O7T+SN z>zzwQ)MX}8tJDIW{O!MgHJPeKqgD(44JQ^ACRS=_Bm z4~Ir-R2HL%)#S+(sVVanCtul1J#6KnhcZ_+%|dON9M43G28$~n&jqunp$ETKRocRYXx~C~8Aheu=W-Ja^aE4P9yIwN$<^rPS;Rrt5qY2se&L+CK)5yT1;ZD*cVl4xqtJ3pc+2ty*i94ssk^XE;R*=G zB5<#*K$rq+GL6EVsL2v;J!8&NEj4QWUY=ayXR~ObcdeQ1DehCkp4`NBO$WX|j~p7F zUm2`o3Vp&boOH%@Y+Sh?3EEaE=_$%H;7x!TF1yH1RpNWimRxUiNFTzXM3Z8=r zc5{aobZS_j1x;x%Htbm4#4~37a8(X)d@Ha%TETrku?8So0f5RJCB)ZA@7y--ky}~V zhL6=ic7YGTbK{F+&obi+NXZjmn81ruAX^hDk;aQffSjI>OCMbf?q|^P_-$ZEGj-|o zKJpErQ@4EU%Cg~mgbS_)C*AIF^sYDPwR@+%;rsCGX}2VxqNNrBJvJR zyhLHt@<3E%hm`Xpath5a``x22!dziOHrw1qq;Q>PD=J%@uqsWiULGtVrq5_-128W%8|AYQEZ97doqC29EOW2!q-8>{FNDn>Y`tKw1T{-|InB?* zR{NKd5c%|6v5rEPWkoL`FN9G3vUS{DqhM}8CN&*nWCJvijhqBdOlKU2tHpc)wn}3# z!>evrb=SE#JL{eg2czEk=<>AH>E;RJd9LS&i^jV6d&^I1==S>;{lTa;7#;QoP{sT1 zVRo$;&Hsdkl3MPXOw28CrY-zaA9wK3np5Fk!%t<)%cafIW0y9!Jj<}7_U9Q-loDx& z03~28&f3`0HS6riN*ZlP0_s*42Vm^nPgT&4aFqAWZpDfye*1GDn7^QJ&u_jj_6_J)*Spdw z$X1Kt&@K;$bc$!z_sw8mW3yYOfLq-+a9?SkxkmBHnJxHx0r4(2xQQE2x&>d;EAqMx z)*aGj{AvyD%3haMjrG?m>vL*}t={W%>g z@N9eeAKa0TLRLz)?ET%{@{Xr7!&}GDmrT=}%TMLT2Sv{AFNcm>5o>~2scW(jUx*rg z!+FXskKIYAFPbHT*Z9#{e=+ymIq-se0nM<&@fu!2Q=SKYsi`W}imXeT{N2Ga*LvYw z%M7NWtX{2FRGn2Yn1UH7qwl3=L`GK8xnY`?GYOwst%x;UmsD0^JVRGn)e!bfnHqvp zZn%&DuQMu}hCjtz#aH;1SC`>>sPrDeNXfNj+tHI8*8!10m;l8szl;)As;+VSkkiEa zYKAkOx?ZUnxbrfa2WFN-tst7mDm77wsbVXBc`lk;>r9~m<*P2E{eJHHc%464>u19I zSb(1h;xx$fu<>TbIj;@9PN*bO>ASXNmW1n7&!K_330G0)p|SiEX^wu2>&o5NW*X)iu^bp#6Ug>@t@1B zJIiMPc?MvIbL^KFuoqBjI(RuYdx@bBDfC%HlcoaI^&Wv(GfBD z$`9Au(X^nItRovQ2PB&DlR*syOd~MzO&13R-WL=|X?Z0SARv8a{OWoXr~Ww=|8Ui> zyt-IX#q>vJg5~MDV-F+n7!1}J9EUAl+HR1j^0t8nNI3Cfp4^uWY{%=%nGw2sjL=8J zyDwvUl&|i~a8wm`KBG*QkmLid-H?GdJ8COSXbe_Ywc$)lEFaZwJF#FaB#?x{tyrNZfy)M_e zTJK1YZ~X>XV>F)~k2-lcd3fmZ={kNo-fr{* zO9|-b7qmM(CtW`7#9#UuopME%xsL@?==`e6HI`$h$j5$0{HiIbkIbVm#jl4C=S=a5 z>FCc#oO!Ge`Sb9hmwB#q4q1-YQ>k2GVX8{yic(P&ZeOIX;fh}4DG-S(64Q}GDjzur z=bWx1he{;}OT(dZl7oI)$YGb|2yOZ?pe$~jeC`sKuBhp7Esr_^Icj1Jt&WI&0n5?k z+B&A_nGc6PM&4+AywRw8=iAlS$RW0mGtPC<&bUqiKHyZRH?ktE4t3z z7**HsrdCyWc~f1-8y2&u@)4!VN0cg+C@c*{m6Is+W0sCjdJNC2QHjEGl4FfZlxn4_ zryL9mvNbwU>gcRPPNLM-5v87Pnpk?fH9p?d_;^#J@`k0MsB!X!e6SXdnDl;NcwU{# z8hBr#)!{Yzye7vdi@up7Y4NF5&=j09LbY1kg z-VZ;rgpWijb69LJ7SB@$`iDCApgPu<=ML;x>nbmIVtqvNR5{NdX5venpOG+e{ybw? zT8tHdtdyb0cz^iul;w%^A6{CX0LCUy2=qx6ruZ^Bpc}G8)wzdE5;?9LvLqYmV=@bg zlQV?hbXv<9iOLz4)?$SqD`)7D;U7<#&cI$18fHR#O>kJQ$P#ZKSfWRVRk5bAv~tqA z@UW`YxZ5R(7#?N-g_Sh)05DTaL5={gc^*C7dwO=x@hhk5zlf|VAWVO@zH*JWxAcmunXBh=CJKD=i-bDSR9Ei>5}J-Azb)J&7KCcLYw zb*}T^NzSC6aVAWM`g4YRCC+%SL=X5fwFeJGd{-)14vtl_Ti}j70Dc3Ph68-z$a8-K zPV$sl;jMF>Nz84MbmD(eRp@)8hNt`2%JI74@T_|lGw5%yOHF*51m}zI|b*GMNw-1<^1ew zFa{H=>3Csec>@5YLZ=(z#4~?jMYwL%qRiHPXg7L)5CmM!_wmCBhf{wrhL6+`&aGel z0RDo{cJ6rSr`ZsWX0D4K7*^D5v{UKbC<>gLSp-6qR7{N1lGNy73VP}{?eur{re{q+ zZ{A|>9dOs}hGYM(KlTIXH{Xjaw;v7y-*s=SAXb4TvMN4U?hN#R&7GH z9=ocL6_GP|1r_!D2%w~XWZi_-tE27rty$#v2mWO00z~HO)zJz2(*QQ(AOiN%+8ynl zT`^U!kc7L_H~w(w3;=AA0qnqD)SQ6GN=!t2Yo{>_ysmGBPKav|cB4Vpp8{_#(#_`X zVtbXC7}xP`Nk&F8O|y;f&a>KsG~aXW;fmfD4u{>);Y0-1b z3L@Y^4!W*m&F)qfgeeNS(aaN5zLv$VYIGIzr$j|QV@?OKod}lR96StMXjs%lqL54! zv1b9++Pk9Im&L1sc$y`rU<5o6;Li0H_T;yVo~*Q_FMe=5MHccmkUd4zXe*L9 zk)$v7W{zt&O~o{m@)jC%1vwt9hUGR%U7VO9F~9{&ktXD9Z92`_x7@+Z#m@<+N8ZeG zF996tp<#s9>(H}qTyPqJAenmMIn;fc5Tdyh%$Fuy`!4+DA@eP^;G7Q5u3X=WE-l-+ z-)YFn<$*JDA}FgVnfcb$7=Y*veSH^~Dyt2Aed*u9YhBY6z0td} z(7-AjSdkTvI;re>`YyrL4vOl}~Kd%*SY28pm(W`&TE2hu8i0r&p(Y zr)Q_vKgK`L4jTfh8mtjoBZyu2zecWwapRTPR>Bze6{w>pDe?W}vXBElWluKK9OyEe z<0s#r^b#EL?_xbt14m$5o^2PfE@Sea)`HN@QMCj;b) zDt`IbnICqn5f)Bv!JHx*3xexs? zdVtdodgh7m`GawQX4TX@c3?paskiaOaY+$yr3u%#;!JhOVA{DghuhrpU%gZl{UxEjNH-d_7h zPJDgoN6B;y--PXqf1&w@7w0(h2e-h+O5r#PlW{5>i($?q_=g8HIF}sUCfDh|V7IhT zn|Zmh4~fDif@3D0s=B#{Nl}ATi~F+#%iZ(cxB{n<v^k+*2FvKqEke$5wvjXYD4H({poXs{{OgN-~Zk+*2~XEkhU^P_G@oi;de6KkGG~ z7onG0r}1mzSn;mw`geP9Ds&saqY;9Gz@OUwUEC`870R8)>6`bvXQv0kn|J4XhnEfE z9E2f$N$x#*Crp^k!brFQg5?R07l9E7;8k=7fG0>W(H5lQ$(5v{hxgL}s)7|2=kKOw zla`A}JxMIeNQKsD=bPg>C@v8xzD1L{C*HZMIsWn-m&u!)HOFf+z9|$}h!o$Vjm6rG zZ#>6U@>FGuHill$DWm)xvqRirkXG(67z^aoZAXq_1jdcGSBPbixqt0X=VnW52+8x{ z2Stz6Cd%x^fmljnVs}s66T6zI(IinM3zA$%?17R_$ zCYjXL+AFCzsb9n#$&~fL7A*)q(HYm2UcwtElP9_L@i}JPUIsSuysbXaQ*Gb3Odj9r zecsB!CR4U7$qCQDgIpZ?i_C90i|9qy_gd~&aBD_9)Ras zR_92Pjf;?7R@a;ERqx)}xCmL~wrIjwi4LCk*j2KR%Vef(kpt$n_Hl)bT)n<{-ael7 ztyi*#ljrCg5!_+Jd$>kMZi`N;R-%XJcEKvy#dR`Kw#cpfO1rq6Sz?(Phx`^TvBX#C z*_AWvtL*EwD=qU{rzp%Cx5vUwCwI3kGL)|bHifd0l6~cBdq8_VqgxI)jfmSOOkX!J zByJ8lorqk0psMm+E*n82`)+Z4R-kf2oJtwu)a`z~QL6Z-pH#{#dzsF*MSbn{m`RoL z8d|2iZR4hgRPkwvN_n*^1KXDGcvRm?szlgo_hjYGWcF>LEOPZ%gdX{2#+6$T;6wAk zu|~dUx$~U}o%OvTe!=J3#mJM*Ad{_LbXMI=$mD786S>1xt%}gSl0~ORS#)akqO;1g zV2!eP(dxxZm1n^kW$~ib!&|k7H=SZ8&3gIrih#>5Uv!@3i@ZQidfid5Un_D38M(EM zWsTf3A(veXbe?=IAa^Q>-78rPbZEx1^BBIKy30Kmat0Z>wPX6!$UPTwCKjP)f zMpyGOM%UWqw%+Jk(UH}pjjU$vSg*EyM&^k8Q4gs;KlzG~%f{^#pKlXV`UK?g^)_Rs zkTHAe(_9?K%{cXEp)5x$r_1kZ2!X|bN(b#$msgp5#>Ye_z zF%#>VNTWl>?5UTEYhs26GzI>3b@;d4$Qfkho;rHyC(lRr;oo*6XOfY7>J|5z$Q{7H z?%w|1ez$YbIoNLGvN1h#OYYjWR(RvtS! zYcq4-jjjU+Rc;>%v5f4dl%CH`$qw7XGgcs8J z`6_Gtiuh?{{HhecYwonH!7GBNlfkRjge8Wl2CoQShYVhI*64A+!`-jOuZ*8T#;-cx zMM|cfb^jydM_H^_XRW@k?yKF7*3r6>j6UH}Ls*1RqV&Nhe=A032XXElOLi2NpH<0C zRyP+!+7}e1`oqpuhmIDrS;~0KwlTQKD??5qBUc~FeCD&)`HzQns&Voll+d9J8ru2jcyyp>!rt4I}%OqDA6sJDl_C%$4dm`?r%TVimb!lDSg*GhdV|Mir@&JE@)Z z!__X-7bQz2=PMG;XAZ3Gwo~&(=dsD2;YbTi-VVZ`L;PZvT0T@~{H@b3u0~b-a(@>3;lI>;loTuK< z7vA{EL!d`A^_FU8jeRMrG|w6m_K_f2}QszR6)-smsSIPQ2%PW=EN)ubMwmh$r zFQJ`pQ`CUD7KJn~x2U8Qn-gX$Hz$h1cVY!Ll1n_%_-Tw%4YT4#Dy|?javGM&nX8H| zgOn9tG$LoYXb!i$V0F2?zHY&txuD!>b+oiNWvP@bWviQrlz4z(&+*_2xL|;cQz-1u zg3u4JHAE{gd{x>(&I@Hst4!I7ma{w2h1x6%&(-Pe&95*yEV3QA?!G^nK$|JVIriW~ zLbG**xF4sy9S%c)nm`Z*`2U7*-~@3AakK8uqA@a*=T>mr5MqOU4ZNub`$24 z6$}ad?|aLgf$N7UniE38#jrG+L%K}46Ao!c$|-!5Q|Od?8(7{5@E}uW9ls7T@!HU|wb{&@ zT5c~m!Q2UFlRxfB-97bB96F4w4tgW1X`83z>~obvX#F2yCjX8{N4fR+bHjSrz0xS05 z6_188DR?yyIWf2uIL&M45y;V@l0#{!nwb4#St)er&3rKn;F6a|N4cT-b(EX>y%jhX zT-dMGehjO z$6~3?CHVf;rD;~{hxpT*N^}C z@qa%4?e~ARA6yZNzxhu)P{CtB>5=bpk zRJw}VRh3_oY&g&TaM;zAu5RS=#VL*6sbKrwSCMe*`FDad6pp>w1O(1N2xrr&A4H*W z=?unr+YC7-qcIRdYXXEj>p`$W;qZO{+Rj zV}qYS;HMYIfn%o^ka;J-vO$ohKvHH>5{++X5$fk5u55B~^)P{bE!+ccvN@GczeL?3 zwqs7{+&HciJ?u1&-< z6V2TnOR5-e;bd@#6CS1_wtCi&`_iT9eHK`0FM|P0%P1Uc_fCuA2CYIdqSc4V)KG5k`Q65 z24^7y;6>I5G=#-(Y}86SB_GgTSU#pj#)vJRXjO(0Gzs*(-~;gb&am%$?n6Js$NT7+ zC%)$o#(@tCml6IWVnqL_W$yjC zZKZWj+wKOA&*y?y86+Gmg15V0>@91QZtIxMr?XwDb*mNRn^?L~w z$4%CB+B+qxXx89W8a#*)6+N^Ht>LR0d@^N@B5&9nMQn-U*FRqZ`xo@<>8C2sG{vMv zx>Pm{KHF|iCX?m^{M#7pR0?+LhG91z$BwgZ{GZ80*gbDwoNo+{8fA5^Z5WOlx6IQi zz;$Z3N|pPYPO+Q%hV{2i9P>I9>^d8U-G)v#4YtS~n}FcPjdljjsaXf^sK6pUbK_A1 zcW8P`UKRjhpA?OwW1y%BOwl+rqqRJzmI=kMJg3fHd>Y?DH(L7AoMt|#N6In63x?TP zAma1I0#T$=Yzwxy94n)1Adg!qV#Fm|{0cD_zd|fN$rT}fg-973#O#-KJ|%tyKD-g% zI)+APoDU*#CU<{QM5bVoI>B5L!^r_n-_qPuPqT zAZ78>W3CJ`2EB_6JQ-t<<|c*(qjP!G z>_wuWLxm&+) z_0h0|0=5-dS4^7OD=FLMBE}7zKWD?@xF^OGlpDPeJ zfMkox$`M;IIU2o(rXM&X$K%8t9gv>-E_N6-dhSY__K7{{iD#y`j7Oi`@J(;b{jRxB zpP^!PlnKtG_t?a2Qfgs4kkcV@D4>^ino-I{jz4Idm?Eow8PuPM_OWn>Q1(SolKF?JDAVY$>eA6WcyFn$@Z1*{!?@^ zo+-c?7y*xI;e2OBgK;zGIMG_VZptRtXrAZ^o!Z~s%#-`(R0YP(*% zY}c_P@Z7s;C*dslABGIzK?h0d>z zY_NonBZu=%_+==$Kbc2ij$f;T?&kQ!6w-H%Smp|mKdXb;mbtQjz!EZ3rE-OZsVbE# zN=s3=ZIQZ!E4sl`Are<4rch!kA2|r|ioLTjCmH##40bSiIn;wiK8 zh8}JB=$IvVK0VSf3o;!lZ}gU~a}P$HCA={@3NLRu%Xq`mEjoNe>F^PyLnR8!K+)kO z3O#(<@yRJec?OjzED>4_Dp5MEj-E3xEXW#kqL?U#DJM~kWkfOaLletv*Wlxg!N(he z${Ut}!rjO_>$&lButvW%ovstV*wy5W#~TM@4i1{DUtp`wRxCBHhF@hPiiswm&p#@ zm?f&ty=0Qee%+WQMMob~w~#nFL-e$d^#d{4nj3r@GLMEC15jRw4qUCO5sPF$*{{k;<1;mb50tnm0QRImiY zE`7QAC;;F$aAA2M6pjM_H{fL>XAAGVVIi^n&E`cx`3h7b&UWS!w-2t`yHj*tN4Uao h>jC@Px=D^Q#JPX)gWDV5zwQ0u{{d5_Ag>{D0RRd0E43h@ooB`~7vKcB>JYD9CM>npJEU`_8JlU+rx9pGw6>V9xuGg%b&ckoxocY!b34E{NJP_qyYZ1qgBr zY=X8Qh+vrE@Tz|vkxQu(YBswYD4E(R2S3_Vv)+Tl8G!kMp>9M3%WbglzS{Z1HTr1_ zD6h4$Zsx)j$OMd9ktY_JSugmdeH4&uVDZfKg8ieTpjnQn%K|xPI^}d_H=A*)d%=`) zjhEUri{Kk5SplvTiz>jGsa4%u9K9-3zMka5uJKfO^&$-MSpdY|ZoL2-D8#{s?H!QKH+pNeaCxVlH=@Ncmb>>bgi#talA|<70;_1u0N7wx^!!wpH%@ zwsklrLG{(x%rM=^m(XK{p4mD%mT@W~9nusEvyI9d`^LlBIK@K=$Q_F!j=_GSN&4HL zqm$FW0+Kh=I{u|U+3h6*JQ?EG4Nk5ub}URW57j@(-!ERuDeyvj4Ba7=g$IaHP4F$P z3^u7PrxzaVEN~C}$l;yCLnk===flJO!=UVkT%T|j+y4pz@-_cNf<7slj$mn=t9w^1 zXEK~&nH*@Rs_=SzzCT0c^f<;4b|{WUYuUx$fSl6sxffjGPj~$X+khIZpujw(TATX& zqZeF(07ZGQuC_45_sp;8Px8p8fp2*hy3a?Z_45*{-)a&p$qp=i}?^poyz1`YoJ;@DJ5j-s_P(d54 zvVAyBX~xZveTRV^M+cir4hd4%w>yo}H3%F+%SuhoGNq*|i07r8dE3Ts;Am^Z(DH`Y z;ffsq=elwy-_n)L48ha#U3k*oBrEZ>@lk~{6@2tPWMBMG)BhVUvjX#e4*&o~Cv?65 literal 0 HcmV?d00001 diff --git a/src/PhpSpreadsheet/Reader/BaseReader.php b/src/PhpSpreadsheet/Reader/BaseReader.php index 77a6421b9c..eb0e3ba223 100644 --- a/src/PhpSpreadsheet/Reader/BaseReader.php +++ b/src/PhpSpreadsheet/Reader/BaseReader.php @@ -2,6 +2,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader; +use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException; use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner; use PhpOffice\PhpSpreadsheet\Shared\File; @@ -133,11 +134,7 @@ public function setReadFilter(IReadFilter $pValue) public function getSecurityScanner() { - if (property_exists($this, 'securityScanner')) { - return $this->securityScanner; - } - - return null; + return $this->securityScanner; } /** @@ -147,12 +144,18 @@ public function getSecurityScanner() */ protected function openFile($pFilename): void { - File::assertFile($pFilename); + if ($pFilename) { + File::assertFile($pFilename); - // Open file - $this->fileHandle = fopen($pFilename, 'rb'); - if ($this->fileHandle === false) { - throw new Exception('Could not open file ' . $pFilename . ' for reading.'); + // Open file + $fileHandle = fopen($pFilename, 'rb'); + } else { + $fileHandle = false; + } + if ($fileHandle !== false) { + $this->fileHandle = $fileHandle; + } else { + throw new ReaderException('Could not open file ' . $pFilename . ' for reading.'); } } } diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index f97680291f..810967308c 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -18,6 +18,7 @@ use PhpOffice\PhpSpreadsheet\Style\Fill; use PhpOffice\PhpSpreadsheet\Style\Font; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; +use SimpleXMLElement; use XMLReader; class Gnumeric extends BaseReader @@ -29,8 +30,23 @@ class Gnumeric extends BaseReader */ private $expressions = []; + /** + * Spreadsheet shared across all functions. + * + * @var Spreadsheet + */ + private $spreadsheet; + private $referenceHelper; + /** + * Namespace shared across all functions. + * It is 'gnm', except for really old sheets which use 'gmr'. + * + * @var string + */ + private $gnm = 'gnm'; + /** * Create a new Gnumeric. */ @@ -53,18 +69,22 @@ public function canRead($pFilename) File::assertFile($pFilename); // Check if gzlib functions are available - if (!function_exists('gzread')) { - throw new Exception('gzlib library is not enabled'); + $data = ''; + if (function_exists('gzread')) { + // Read signature data (first 3 bytes) + $fh = fopen($pFilename, 'rb'); + $data = fread($fh, 2); + fclose($fh); } - // Read signature data (first 3 bytes) - $fh = fopen($pFilename, 'rb'); - $data = fread($fh, 2); - fclose($fh); - return $data == chr(0x1F) . chr(0x8B); } + private static function matchXml(string $name, string $field): bool + { + return 1 === preg_match("/^(gnm|gmr):$field$/", $name); + } + /** * Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object. * @@ -82,10 +102,10 @@ public function listWorksheetNames($pFilename) $worksheetNames = []; while ($xml->read()) { - if ($xml->name == 'gnm:SheetName' && $xml->nodeType == XMLReader::ELEMENT) { + if (self::matchXml($xml->name, 'SheetName') && $xml->nodeType == XMLReader::ELEMENT) { $xml->read(); // Move onto the value node $worksheetNames[] = (string) $xml->value; - } elseif ($xml->name == 'gnm:Sheets') { + } elseif (self::matchXml($xml->name, 'Sheets')) { // break out of the loop once we've got our sheet names rather than parse the entire file break; } @@ -111,7 +131,7 @@ public function listWorksheetInfo($pFilename) $worksheetInfo = []; while ($xml->read()) { - if ($xml->name == 'gnm:Sheet' && $xml->nodeType == XMLReader::ELEMENT) { + if (self::matchXml($xml->name, 'Sheet') && $xml->nodeType == XMLReader::ELEMENT) { $tmpInfo = [ 'worksheetName' => '', 'lastColumnLetter' => 'A', @@ -121,18 +141,20 @@ public function listWorksheetInfo($pFilename) ]; while ($xml->read()) { - if ($xml->name == 'gnm:Name' && $xml->nodeType == XMLReader::ELEMENT) { - $xml->read(); // Move onto the value node - $tmpInfo['worksheetName'] = (string) $xml->value; - } elseif ($xml->name == 'gnm:MaxCol' && $xml->nodeType == XMLReader::ELEMENT) { - $xml->read(); // Move onto the value node - $tmpInfo['lastColumnIndex'] = (int) $xml->value; - $tmpInfo['totalColumns'] = (int) $xml->value + 1; - } elseif ($xml->name == 'gnm:MaxRow' && $xml->nodeType == XMLReader::ELEMENT) { - $xml->read(); // Move onto the value node - $tmpInfo['totalRows'] = (int) $xml->value + 1; + if ($xml->nodeType == XMLReader::ELEMENT) { + if (self::matchXml($xml->name, 'Name')) { + $xml->read(); // Move onto the value node + $tmpInfo['worksheetName'] = (string) $xml->value; + } elseif (self::matchXml($xml->name, 'MaxCol')) { + $xml->read(); // Move onto the value node + $tmpInfo['lastColumnIndex'] = (int) $xml->value; + $tmpInfo['totalColumns'] = (int) $xml->value + 1; + } elseif (self::matchXml($xml->name, 'MaxRow')) { + $xml->read(); // Move onto the value node + $tmpInfo['totalRows'] = (int) $xml->value + 1; - break; + break; + } } } $tmpInfo['lastColumnLetter'] = Coordinate::stringFromColumnIndex($tmpInfo['lastColumnIndex'] + 1); @@ -162,42 +184,200 @@ private function gzfileGetContents($filename) return $data; } - /** - * Loads Spreadsheet from file. - * - * @param string $pFilename - * - * @return Spreadsheet - */ - public function load($pFilename) + private static $mappings = [ + 'borderStyle' => [ + '0' => Border::BORDER_NONE, + '1' => Border::BORDER_THIN, + '2' => Border::BORDER_MEDIUM, + '3' => Border::BORDER_SLANTDASHDOT, + '4' => Border::BORDER_DASHED, + '5' => Border::BORDER_THICK, + '6' => Border::BORDER_DOUBLE, + '7' => Border::BORDER_DOTTED, + '8' => Border::BORDER_MEDIUMDASHED, + '9' => Border::BORDER_DASHDOT, + '10' => Border::BORDER_MEDIUMDASHDOT, + '11' => Border::BORDER_DASHDOTDOT, + '12' => Border::BORDER_MEDIUMDASHDOTDOT, + '13' => Border::BORDER_MEDIUMDASHDOTDOT, + ], + 'dataType' => [ + '10' => DataType::TYPE_NULL, + '20' => DataType::TYPE_BOOL, + '30' => DataType::TYPE_NUMERIC, // Integer doesn't exist in Excel + '40' => DataType::TYPE_NUMERIC, // Float + '50' => DataType::TYPE_ERROR, + '60' => DataType::TYPE_STRING, + //'70': // Cell Range + //'80': // Array + ], + 'fillType' => [ + '1' => Fill::FILL_SOLID, + '2' => Fill::FILL_PATTERN_DARKGRAY, + '3' => Fill::FILL_PATTERN_MEDIUMGRAY, + '4' => Fill::FILL_PATTERN_LIGHTGRAY, + '5' => Fill::FILL_PATTERN_GRAY125, + '6' => Fill::FILL_PATTERN_GRAY0625, + '7' => Fill::FILL_PATTERN_DARKHORIZONTAL, // horizontal stripe + '8' => Fill::FILL_PATTERN_DARKVERTICAL, // vertical stripe + '9' => Fill::FILL_PATTERN_DARKDOWN, // diagonal stripe + '10' => Fill::FILL_PATTERN_DARKUP, // reverse diagonal stripe + '11' => Fill::FILL_PATTERN_DARKGRID, // diagoanl crosshatch + '12' => Fill::FILL_PATTERN_DARKTRELLIS, // thick diagonal crosshatch + '13' => Fill::FILL_PATTERN_LIGHTHORIZONTAL, + '14' => Fill::FILL_PATTERN_LIGHTVERTICAL, + '15' => Fill::FILL_PATTERN_LIGHTUP, + '16' => Fill::FILL_PATTERN_LIGHTDOWN, + '17' => Fill::FILL_PATTERN_LIGHTGRID, // thin horizontal crosshatch + '18' => Fill::FILL_PATTERN_LIGHTTRELLIS, // thin diagonal crosshatch + ], + 'horizontal' => [ + '1' => Alignment::HORIZONTAL_GENERAL, + '2' => Alignment::HORIZONTAL_LEFT, + '4' => Alignment::HORIZONTAL_RIGHT, + '8' => Alignment::HORIZONTAL_CENTER, + '16' => Alignment::HORIZONTAL_CENTER_CONTINUOUS, + '32' => Alignment::HORIZONTAL_JUSTIFY, + '64' => Alignment::HORIZONTAL_CENTER_CONTINUOUS, + ], + 'underline' => [ + '1' => Font::UNDERLINE_SINGLE, + '2' => Font::UNDERLINE_DOUBLE, + '3' => Font::UNDERLINE_SINGLEACCOUNTING, + '4' => Font::UNDERLINE_DOUBLEACCOUNTING, + ], + 'vertical' => [ + '1' => Alignment::VERTICAL_TOP, + '2' => Alignment::VERTICAL_BOTTOM, + '4' => Alignment::VERTICAL_CENTER, + '8' => Alignment::VERTICAL_JUSTIFY, + ], + ]; + + public static function gnumericMappings(): array { - // Create new Spreadsheet - $spreadsheet = new Spreadsheet(); + return self::$mappings; + } - // Load into this instance - return $this->loadIntoExisting($pFilename, $spreadsheet); + private function docPropertiesOld(SimpleXMLElement $gnmXML): void + { + $docProps = $this->spreadsheet->getProperties(); + foreach ($gnmXML->Summary->Item as $summaryItem) { + $propertyName = $summaryItem->name; + $propertyValue = $summaryItem->{'val-string'}; + switch ($propertyName) { + case 'title': + $docProps->setTitle(trim($propertyValue)); + + break; + case 'comments': + $docProps->setDescription(trim($propertyValue)); + + break; + case 'keywords': + $docProps->setKeywords(trim($propertyValue)); + + break; + case 'category': + $docProps->setCategory(trim($propertyValue)); + + break; + case 'manager': + $docProps->setManager(trim($propertyValue)); + + break; + case 'author': + $docProps->setCreator(trim($propertyValue)); + $docProps->setLastModifiedBy(trim($propertyValue)); + + break; + case 'company': + $docProps->setCompany(trim($propertyValue)); + + break; + } + } } - /** - * Loads from file into Spreadsheet instance. - * - * @param string $pFilename - * - * @return Spreadsheet - */ - public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) + private function docPropertiesDC(SimpleXMLElement $officePropertyDC): void { - File::assertFile($pFilename); + $docProps = $this->spreadsheet->getProperties(); + foreach ($officePropertyDC as $propertyName => $propertyValue) { + $propertyValue = trim((string) $propertyValue); + switch ($propertyName) { + case 'title': + $docProps->setTitle($propertyValue); + + break; + case 'subject': + $docProps->setSubject($propertyValue); + + break; + case 'creator': + $docProps->setCreator($propertyValue); + $docProps->setLastModifiedBy($propertyValue); + + break; + case 'date': + $creationDate = strtotime($propertyValue); + $docProps->setCreated($creationDate); + $docProps->setModified($creationDate); + + break; + case 'description': + $docProps->setDescription($propertyValue); + + break; + } + } + } - $gFileData = $this->gzfileGetContents($pFilename); + private function docPropertiesMeta(SimpleXMLElement $officePropertyMeta, array $namespacesMeta): void + { + $docProps = $this->spreadsheet->getProperties(); + foreach ($officePropertyMeta as $propertyName => $propertyValue) { + $attributes = $propertyValue->attributes($namespacesMeta['meta']); + $propertyValue = trim((string) $propertyValue); + switch ($propertyName) { + case 'keyword': + $docProps->setKeywords($propertyValue); + + break; + case 'initial-creator': + $docProps->setCreator($propertyValue); + $docProps->setLastModifiedBy($propertyValue); + + break; + case 'creation-date': + $creationDate = strtotime($propertyValue); + $docProps->setCreated($creationDate); + $docProps->setModified($creationDate); + + break; + case 'user-defined': + [, $attrName] = explode(':', $attributes['name']); + switch ($attrName) { + case 'publisher': + $docProps->setCompany($propertyValue); - $xml = simplexml_load_string($this->securityScanner->scan($gFileData), 'SimpleXMLElement', Settings::getLibXmlLoaderOptions()); - $namespacesMeta = $xml->getNamespaces(true); + break; + case 'category': + $docProps->setCategory($propertyValue); + + break; + case 'manager': + $docProps->setManager($propertyValue); + + break; + } - $gnmXML = $xml->children($namespacesMeta['gnm']); + break; + } + } + } - $docProps = $spreadsheet->getProperties(); - // Document Properties are held differently, depending on the version of Gnumeric + private function docProperties(SimpleXMLElement $xml, SimpleXMLElement $gnmXML, array $namespacesMeta): void + { if (isset($namespacesMeta['office'])) { $officeXML = $xml->children($namespacesMeta['office']); $officeDocXML = $officeXML->{'document-meta'}; @@ -208,115 +388,113 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) if (isset($namespacesMeta['dc'])) { $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']); } - foreach ($officePropertyDC as $propertyName => $propertyValue) { - $propertyValue = (string) $propertyValue; - switch ($propertyName) { - case 'title': - $docProps->setTitle(trim($propertyValue)); - - break; - case 'subject': - $docProps->setSubject(trim($propertyValue)); - - break; - case 'creator': - $docProps->setCreator(trim($propertyValue)); - $docProps->setLastModifiedBy(trim($propertyValue)); + $this->docPropertiesDC($officePropertyDC); - break; - case 'date': - $creationDate = strtotime(trim($propertyValue)); - $docProps->setCreated($creationDate); - $docProps->setModified($creationDate); - - break; - case 'description': - $docProps->setDescription(trim($propertyValue)); - - break; - } - } $officePropertyMeta = []; if (isset($namespacesMeta['meta'])) { $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']); } - foreach ($officePropertyMeta as $propertyName => $propertyValue) { - $attributes = $propertyValue->attributes($namespacesMeta['meta']); - $propertyValue = (string) $propertyValue; - switch ($propertyName) { - case 'keyword': - $docProps->setKeywords(trim($propertyValue)); + $this->docPropertiesMeta($officePropertyMeta, $namespacesMeta); + } + } elseif (isset($gnmXML->Summary)) { + $this->docPropertiesOld($gnmXML); + } + } - break; - case 'initial-creator': - $docProps->setCreator(trim($propertyValue)); - $docProps->setLastModifiedBy(trim($propertyValue)); + private function sheetMargin(string $key, float $marginSize): void + { + switch ($key) { + case 'top': + $this->spreadsheet->getActiveSheet()->getPageMargins()->setTop($marginSize); - break; - case 'creation-date': - $creationDate = strtotime(trim($propertyValue)); - $docProps->setCreated($creationDate); - $docProps->setModified($creationDate); + break; + case 'bottom': + $this->spreadsheet->getActiveSheet()->getPageMargins()->setBottom($marginSize); - break; - case 'user-defined': - [, $attrName] = explode(':', $attributes['name']); - switch ($attrName) { - case 'publisher': - $docProps->setCompany(trim($propertyValue)); + break; + case 'left': + $this->spreadsheet->getActiveSheet()->getPageMargins()->setLeft($marginSize); - break; - case 'category': - $docProps->setCategory(trim($propertyValue)); + break; + case 'right': + $this->spreadsheet->getActiveSheet()->getPageMargins()->setRight($marginSize); - break; - case 'manager': - $docProps->setManager(trim($propertyValue)); + break; + case 'header': + $this->spreadsheet->getActiveSheet()->getPageMargins()->setHeader($marginSize); - break; - } + break; + case 'footer': + $this->spreadsheet->getActiveSheet()->getPageMargins()->setFooter($marginSize); - break; - } + break; + } + } + + private function sheetMargins(SimpleXMLElement $sheet): void + { + if (!$this->readDataOnly && isset($sheet->PrintInformation, $sheet->PrintInformation->Margins)) { + foreach ($sheet->PrintInformation->Margins->children($this->gnm, true) as $key => $margin) { + $marginAttributes = $margin->attributes(); + $marginSize = 72 / 100; // Default + switch ($marginAttributes['PrefUnit']) { + case 'mm': + $marginSize = (int) ($marginAttributes['Points']) / 100; + + break; } + $this->sheetMargin($key, (float) $marginSize); } - } elseif (isset($gnmXML->Summary)) { - foreach ($gnmXML->Summary->Item as $summaryItem) { - $propertyName = $summaryItem->name; - $propertyValue = $summaryItem->{'val-string'}; - switch ($propertyName) { - case 'title': - $docProps->setTitle(trim($propertyValue)); + } + } - break; - case 'comments': - $docProps->setDescription(trim($propertyValue)); + private function processComments(SimpleXMLElement $sheet): void + { + if ((!$this->readDataOnly) && (isset($sheet->Objects))) { + foreach ($sheet->Objects->children($this->gnm, true) as $key => $comment) { + $commentAttributes = $comment->attributes(); + // Only comment objects are handled at the moment + if ($commentAttributes->Text) { + $this->spreadsheet->getActiveSheet()->getComment((string) $commentAttributes->ObjectBound)->setAuthor((string) $commentAttributes->Author)->setText($this->parseRichText((string) $commentAttributes->Text)); + } + } + } + } - break; - case 'keywords': - $docProps->setKeywords(trim($propertyValue)); + /** + * Loads Spreadsheet from file. + * + * @param string $pFilename + * + * @return Spreadsheet + */ + public function load($pFilename) + { + // Create new Spreadsheet + $spreadsheet = new Spreadsheet(); + $spreadsheet->removeSheetByIndex(0); - break; - case 'category': - $docProps->setCategory(trim($propertyValue)); + // Load into this instance + return $this->loadIntoExisting($pFilename, $spreadsheet); + } - break; - case 'manager': - $docProps->setManager(trim($propertyValue)); + /** + * Loads from file into Spreadsheet instance. + */ + public function loadIntoExisting(string $pFilename, Spreadsheet $spreadsheet): Spreadsheet + { + $this->spreadsheet = $spreadsheet; + File::assertFile($pFilename); - break; - case 'author': - $docProps->setCreator(trim($propertyValue)); - $docProps->setLastModifiedBy(trim($propertyValue)); + $gFileData = $this->gzfileGetContents($pFilename); - break; - case 'company': - $docProps->setCompany(trim($propertyValue)); + $xml2 = simplexml_load_string($this->securityScanner->scan($gFileData), 'SimpleXMLElement', Settings::getLibXmlLoaderOptions()); + $xml = ($xml2 !== false) ? $xml2 : new SimpleXMLElement(''); + $namespacesMeta = $xml->getNamespaces(true); + $this->gnm = array_key_exists('gmr', $namespacesMeta) ? 'gmr' : 'gnm'; - break; - } - } - } + $gnmXML = $xml->children($namespacesMeta[$this->gnm]); + $this->docProperties($xml, $gnmXML, $namespacesMeta); $worksheetID = 0; foreach ($gnmXML->Sheets->Sheet as $sheet) { @@ -328,53 +506,14 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) $maxRow = $maxCol = 0; // Create new Worksheet - $spreadsheet->createSheet(); - $spreadsheet->setActiveSheetIndex($worksheetID); + $this->spreadsheet->createSheet(); + $this->spreadsheet->setActiveSheetIndex($worksheetID); // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula // cells... during the load, all formulae should be correct, and we're simply bringing the worksheet // name in line with the formula, not the reverse - $spreadsheet->getActiveSheet()->setTitle($worksheetName, false, false); - - if ((!$this->readDataOnly) && (isset($sheet->PrintInformation))) { - if (isset($sheet->PrintInformation->Margins)) { - foreach ($sheet->PrintInformation->Margins->children('gnm', true) as $key => $margin) { - $marginAttributes = $margin->attributes(); - $marginSize = 72 / 100; // Default - switch ($marginAttributes['PrefUnit']) { - case 'mm': - $marginSize = (int) ($marginAttributes['Points']) / 100; - - break; - } - switch ($key) { - case 'top': - $spreadsheet->getActiveSheet()->getPageMargins()->setTop($marginSize); - - break; - case 'bottom': - $spreadsheet->getActiveSheet()->getPageMargins()->setBottom($marginSize); - - break; - case 'left': - $spreadsheet->getActiveSheet()->getPageMargins()->setLeft($marginSize); + $this->spreadsheet->getActiveSheet()->setTitle($worksheetName, false, false); - break; - case 'right': - $spreadsheet->getActiveSheet()->getPageMargins()->setRight($marginSize); - - break; - case 'header': - $spreadsheet->getActiveSheet()->getPageMargins()->setHeader($marginSize); - - break; - case 'footer': - $spreadsheet->getActiveSheet()->getPageMargins()->setFooter($marginSize); - - break; - } - } - } - } + $this->sheetMargins($sheet); foreach ($sheet->Cells->Cell as $cell) { $cellAttributes = $cell->attributes(); @@ -420,48 +559,19 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) } $type = DataType::TYPE_FORMULA; } else { - switch ($ValueType) { - case '10': // NULL - $type = DataType::TYPE_NULL; - - break; - case '20': // Boolean - $type = DataType::TYPE_BOOL; - $cell = $cell == 'TRUE'; - - break; - case '30': // Integer - $cell = (int) $cell; - // Excel 2007+ doesn't differentiate between integer and float, so set the value and dropthru to the next (numeric) case - // no break - case '40': // Float - $type = DataType::TYPE_NUMERIC; - - break; - case '50': // Error - $type = DataType::TYPE_ERROR; - - break; - case '60': // String - $type = DataType::TYPE_STRING; - - break; - case '70': // Cell Range - case '80': // Array + $vtype = (string) $ValueType; + if (array_key_exists($vtype, self::$mappings['dataType'])) { + $type = self::$mappings['dataType'][$vtype]; } - } - $spreadsheet->getActiveSheet()->getCell($column . $row)->setValueExplicit($cell, $type); - } - - if ((!$this->readDataOnly) && (isset($sheet->Objects))) { - foreach ($sheet->Objects->children('gnm', true) as $key => $comment) { - $commentAttributes = $comment->attributes(); - // Only comment objects are handled at the moment - if ($commentAttributes->Text) { - $spreadsheet->getActiveSheet()->getComment((string) $commentAttributes->ObjectBound)->setAuthor((string) $commentAttributes->Author)->setText($this->parseRichText((string) $commentAttributes->Text)); + if ($vtype == '20') { // Boolean + $cell = $cell == 'TRUE'; } } + $this->spreadsheet->getActiveSheet()->getCell($column . $row)->setValueExplicit((string) $cell, $type); } + + $this->processComments($sheet); + foreach ($sheet->Styles->StyleRegion as $styleRegion) { $styleAttributes = $styleRegion->attributes(); if (($styleAttributes['startRow'] <= $maxRow) && @@ -471,306 +581,197 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) $endColumn = ($styleAttributes['endCol'] > $maxCol) ? $maxCol : (int) $styleAttributes['endCol']; $endColumn = Coordinate::stringFromColumnIndex($endColumn + 1); - $endRow = ($styleAttributes['endRow'] > $maxRow) ? $maxRow : $styleAttributes['endRow']; - ++$endRow; + $endRow = 1 + (($styleAttributes['endRow'] > $maxRow) ? $maxRow : $styleAttributes['endRow']); $cellRange = $startColumn . $startRow . ':' . $endColumn . $endRow; $styleAttributes = $styleRegion->Style->attributes(); + $styleArray = []; // We still set the number format mask for date/time values, even if readDataOnly is true - if ((!$this->readDataOnly) || - (Date::isDateTimeFormatCode((string) $styleAttributes['Format']))) { - $styleArray = []; - $styleArray['numberFormat']['formatCode'] = (string) $styleAttributes['Format']; + $formatCode = (string) $styleAttributes['Format']; + if (Date::isDateTimeFormatCode($formatCode)) { + $styleArray['numberFormat']['formatCode'] = $formatCode; + } + if (!$this->readDataOnly) { // If readDataOnly is false, we set all formatting information - if (!$this->readDataOnly) { - switch ($styleAttributes['HAlign']) { - case '1': - $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_GENERAL; - - break; - case '2': - $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_LEFT; - - break; - case '4': - $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_RIGHT; - - break; - case '8': - $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_CENTER; - - break; - case '16': - case '64': - $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_CENTER_CONTINUOUS; - - break; - case '32': - $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_JUSTIFY; - - break; - } - - switch ($styleAttributes['VAlign']) { - case '1': - $styleArray['alignment']['vertical'] = Alignment::VERTICAL_TOP; - - break; - case '2': - $styleArray['alignment']['vertical'] = Alignment::VERTICAL_BOTTOM; - - break; - case '4': - $styleArray['alignment']['vertical'] = Alignment::VERTICAL_CENTER; - - break; - case '8': - $styleArray['alignment']['vertical'] = Alignment::VERTICAL_JUSTIFY; - - break; - } - - $styleArray['alignment']['wrapText'] = $styleAttributes['WrapText'] == '1'; - $styleArray['alignment']['shrinkToFit'] = $styleAttributes['ShrinkToFit'] == '1'; - $styleArray['alignment']['indent'] = ((int) ($styleAttributes['Indent']) > 0) ? $styleAttributes['indent'] : 0; - - $RGB = self::parseGnumericColour($styleAttributes['Fore']); - $styleArray['font']['color']['rgb'] = $RGB; - $RGB = self::parseGnumericColour($styleAttributes['Back']); - $shade = $styleAttributes['Shade']; - if (($RGB != '000000') || ($shade != '0')) { - $styleArray['fill']['color']['rgb'] = $styleArray['fill']['startColor']['rgb'] = $RGB; - $RGB2 = self::parseGnumericColour($styleAttributes['PatternColor']); - $styleArray['fill']['endColor']['rgb'] = $RGB2; - switch ($shade) { - case '1': - $styleArray['fill']['fillType'] = Fill::FILL_SOLID; - - break; - case '2': - $styleArray['fill']['fillType'] = Fill::FILL_GRADIENT_LINEAR; - - break; - case '3': - $styleArray['fill']['fillType'] = Fill::FILL_GRADIENT_PATH; - - break; - case '4': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKDOWN; - - break; - case '5': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKGRAY; - - break; - case '6': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKGRID; - - break; - case '7': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKHORIZONTAL; - - break; - case '8': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKTRELLIS; - - break; - case '9': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKUP; - - break; - case '10': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKVERTICAL; - - break; - case '11': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_GRAY0625; - - break; - case '12': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_GRAY125; - - break; - case '13': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTDOWN; - - break; - case '14': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTGRAY; - - break; - case '15': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTGRID; - - break; - case '16': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTHORIZONTAL; - - break; - case '17': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTTRELLIS; - - break; - case '18': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTUP; - - break; - case '19': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTVERTICAL; - - break; - case '20': - $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_MEDIUMGRAY; - - break; - } - } - - $fontAttributes = $styleRegion->Style->Font->attributes(); - $styleArray['font']['name'] = (string) $styleRegion->Style->Font; - $styleArray['font']['size'] = (int) ($fontAttributes['Unit']); - $styleArray['font']['bold'] = $fontAttributes['Bold'] == '1'; - $styleArray['font']['italic'] = $fontAttributes['Italic'] == '1'; - $styleArray['font']['strikethrough'] = $fontAttributes['StrikeThrough'] == '1'; - switch ($fontAttributes['Underline']) { - case '1': - $styleArray['font']['underline'] = Font::UNDERLINE_SINGLE; - - break; - case '2': - $styleArray['font']['underline'] = Font::UNDERLINE_DOUBLE; - - break; - case '3': - $styleArray['font']['underline'] = Font::UNDERLINE_SINGLEACCOUNTING; - - break; - case '4': - $styleArray['font']['underline'] = Font::UNDERLINE_DOUBLEACCOUNTING; - - break; - default: - $styleArray['font']['underline'] = Font::UNDERLINE_NONE; - - break; - } - switch ($fontAttributes['Script']) { - case '1': - $styleArray['font']['superscript'] = true; - - break; - case '-1': - $styleArray['font']['subscript'] = true; - - break; - } - - if (isset($styleRegion->Style->StyleBorder)) { - if (isset($styleRegion->Style->StyleBorder->Top)) { - $styleArray['borders']['top'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Top->attributes()); - } - if (isset($styleRegion->Style->StyleBorder->Bottom)) { - $styleArray['borders']['bottom'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Bottom->attributes()); - } - if (isset($styleRegion->Style->StyleBorder->Left)) { - $styleArray['borders']['left'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Left->attributes()); - } - if (isset($styleRegion->Style->StyleBorder->Right)) { - $styleArray['borders']['right'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Right->attributes()); - } - if ((isset($styleRegion->Style->StyleBorder->Diagonal)) && (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}))) { - $styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes()); - $styleArray['borders']['diagonalDirection'] = Borders::DIAGONAL_BOTH; - } elseif (isset($styleRegion->Style->StyleBorder->Diagonal)) { - $styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes()); - $styleArray['borders']['diagonalDirection'] = Borders::DIAGONAL_UP; - } elseif (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'})) { - $styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}->attributes()); - $styleArray['borders']['diagonalDirection'] = Borders::DIAGONAL_DOWN; - } - } - if (isset($styleRegion->Style->HyperLink)) { - // TO DO - $hyperlink = $styleRegion->Style->HyperLink->attributes(); - } + $styleArray['numberFormat']['formatCode'] = $formatCode; + + self::addStyle2($styleArray, 'alignment', 'horizontal', $styleAttributes['HAlign']); + self::addStyle2($styleArray, 'alignment', 'vertical', $styleAttributes['VAlign']); + $styleArray['alignment']['wrapText'] = $styleAttributes['WrapText'] == '1'; + $styleArray['alignment']['textRotation'] = $this->calcRotation($styleAttributes); + $styleArray['alignment']['shrinkToFit'] = $styleAttributes['ShrinkToFit'] == '1'; + $styleArray['alignment']['indent'] = ((int) ($styleAttributes['Indent']) > 0) ? $styleAttributes['indent'] : 0; + + $this->addColors($styleArray, $styleAttributes); + + $fontAttributes = $styleRegion->Style->Font->attributes(); + $styleArray['font']['name'] = (string) $styleRegion->Style->Font; + $styleArray['font']['size'] = (int) ($fontAttributes['Unit']); + $styleArray['font']['bold'] = $fontAttributes['Bold'] == '1'; + $styleArray['font']['italic'] = $fontAttributes['Italic'] == '1'; + $styleArray['font']['strikethrough'] = $fontAttributes['StrikeThrough'] == '1'; + self::addStyle2($styleArray, 'font', 'underline', $fontAttributes['Underline']); + + switch ($fontAttributes['Script']) { + case '1': + $styleArray['font']['superscript'] = true; + + break; + case '-1': + $styleArray['font']['subscript'] = true; + + break; } - $spreadsheet->getActiveSheet()->getStyle($cellRange)->applyFromArray($styleArray); - } - } - } - if ((!$this->readDataOnly) && (isset($sheet->Cols))) { - // Column Widths - $columnAttributes = $sheet->Cols->attributes(); - $defaultWidth = $columnAttributes['DefaultSizePts'] / 5.4; - $c = 0; - foreach ($sheet->Cols->ColInfo as $columnOverride) { - $columnAttributes = $columnOverride->attributes(); - $column = $columnAttributes['No']; - $columnWidth = $columnAttributes['Unit'] / 5.4; - $hidden = (isset($columnAttributes['Hidden'])) && ($columnAttributes['Hidden'] == '1'); - $columnCount = (isset($columnAttributes['Count'])) ? $columnAttributes['Count'] : 1; - while ($c < $column) { - $spreadsheet->getActiveSheet()->getColumnDimension(Coordinate::stringFromColumnIndex($c + 1))->setWidth($defaultWidth); - ++$c; - } - while (($c < ($column + $columnCount)) && ($c <= $maxCol)) { - $spreadsheet->getActiveSheet()->getColumnDimension(Coordinate::stringFromColumnIndex($c + 1))->setWidth($columnWidth); - if ($hidden) { - $spreadsheet->getActiveSheet()->getColumnDimension(Coordinate::stringFromColumnIndex($c + 1))->setVisible(false); + if (isset($styleRegion->Style->StyleBorder)) { + $srssb = $styleRegion->Style->StyleBorder; + $this->addBorderStyle($srssb, $styleArray, 'top'); + $this->addBorderStyle($srssb, $styleArray, 'bottom'); + $this->addBorderStyle($srssb, $styleArray, 'left'); + $this->addBorderStyle($srssb, $styleArray, 'right'); + $this->addBorderDiagonal($srssb, $styleArray); + } + if (isset($styleRegion->Style->HyperLink)) { + // TO DO + $hyperlink = $styleRegion->Style->HyperLink->attributes(); } - ++$c; } - } - while ($c <= $maxCol) { - $spreadsheet->getActiveSheet()->getColumnDimension(Coordinate::stringFromColumnIndex($c + 1))->setWidth($defaultWidth); - ++$c; + $this->spreadsheet->getActiveSheet()->getStyle($cellRange)->applyFromArray($styleArray); } } - if ((!$this->readDataOnly) && (isset($sheet->Rows))) { - // Row Heights - $rowAttributes = $sheet->Rows->attributes(); - $defaultHeight = $rowAttributes['DefaultSizePts']; - $r = 0; - - foreach ($sheet->Rows->RowInfo as $rowOverride) { - $rowAttributes = $rowOverride->attributes(); - $row = $rowAttributes['No']; - $rowHeight = $rowAttributes['Unit']; - $hidden = (isset($rowAttributes['Hidden'])) && ($rowAttributes['Hidden'] == '1'); - $rowCount = (isset($rowAttributes['Count'])) ? $rowAttributes['Count'] : 1; - while ($r < $row) { - ++$r; - $spreadsheet->getActiveSheet()->getRowDimension($r)->setRowHeight($defaultHeight); - } - while (($r < ($row + $rowCount)) && ($r < $maxRow)) { - ++$r; - $spreadsheet->getActiveSheet()->getRowDimension($r)->setRowHeight($rowHeight); - if ($hidden) { - $spreadsheet->getActiveSheet()->getRowDimension($r)->setVisible(false); - } - } - } - while ($r < $maxRow) { - ++$r; - $spreadsheet->getActiveSheet()->getRowDimension($r)->setRowHeight($defaultHeight); + $this->processColumnWidths($sheet, $maxCol); + $this->processRowHeights($sheet, $maxRow); + $this->processMergedCells($sheet); + + ++$worksheetID; + } + + $this->processDefinedNames($gnmXML); + + // Return + return $this->spreadsheet; + } + + private function addBorderDiagonal(SimpleXMLElement $srssb, array &$styleArray): void + { + if (isset($srssb->Diagonal, $srssb->{'Rev-Diagonal'})) { + $styleArray['borders']['diagonal'] = self::parseBorderAttributes($srssb->Diagonal->attributes()); + $styleArray['borders']['diagonalDirection'] = Borders::DIAGONAL_BOTH; + } elseif (isset($srssb->Diagonal)) { + $styleArray['borders']['diagonal'] = self::parseBorderAttributes($srssb->Diagonal->attributes()); + $styleArray['borders']['diagonalDirection'] = Borders::DIAGONAL_UP; + } elseif (isset($srssb->{'Rev-Diagonal'})) { + $styleArray['borders']['diagonal'] = self::parseBorderAttributes($srssb->{'Rev-Diagonal'}->attributes()); + $styleArray['borders']['diagonalDirection'] = Borders::DIAGONAL_DOWN; + } + } + + private function addBorderStyle(SimpleXMLElement $srssb, array &$styleArray, string $direction): void + { + $ucDirection = ucfirst($direction); + if (isset($srssb->$ucDirection)) { + $styleArray['borders'][$direction] = self::parseBorderAttributes($srssb->$ucDirection->attributes()); + } + } + + private function processMergedCells(SimpleXMLElement $sheet): void + { + // Handle Merged Cells in this worksheet + if (isset($sheet->MergedRegions)) { + foreach ($sheet->MergedRegions->Merge as $mergeCells) { + if (strpos($mergeCells, ':') !== false) { + $this->spreadsheet->getActiveSheet()->mergeCells($mergeCells); } } + } + } - // Handle Merged Cells in this worksheet - if (isset($sheet->MergedRegions)) { - foreach ($sheet->MergedRegions->Merge as $mergeCells) { - if (strpos($mergeCells, ':') !== false) { - $spreadsheet->getActiveSheet()->mergeCells($mergeCells); - } - } + private function processColumnLoop(int $c, int $maxCol, SimpleXMLElement $columnOverride, float $defaultWidth): int + { + $columnAttributes = $columnOverride->attributes(); + $column = $columnAttributes['No']; + $columnWidth = ((float) $columnAttributes['Unit']) / 5.4; + $hidden = (isset($columnAttributes['Hidden'])) && ((string) $columnAttributes['Hidden'] == '1'); + $columnCount = (isset($columnAttributes['Count'])) ? $columnAttributes['Count'] : 1; + while ($c < $column) { + $this->spreadsheet->getActiveSheet()->getColumnDimension(Coordinate::stringFromColumnIndex($c + 1))->setWidth($defaultWidth); + ++$c; + } + while (($c < ($column + $columnCount)) && ($c <= $maxCol)) { + $this->spreadsheet->getActiveSheet()->getColumnDimension(Coordinate::stringFromColumnIndex($c + 1))->setWidth($columnWidth); + if ($hidden) { + $this->spreadsheet->getActiveSheet()->getColumnDimension(Coordinate::stringFromColumnIndex($c + 1))->setVisible(false); } + ++$c; + } - ++$worksheetID; + return $c; + } + + private function processColumnWidths(SimpleXMLElement $sheet, int $maxCol): void + { + if ((!$this->readDataOnly) && (isset($sheet->Cols))) { + // Column Widths + $columnAttributes = $sheet->Cols->attributes(); + $defaultWidth = $columnAttributes['DefaultSizePts'] / 5.4; + $c = 0; + foreach ($sheet->Cols->ColInfo as $columnOverride) { + $c = $this->processColumnLoop($c, $maxCol, $columnOverride, $defaultWidth); + } + while ($c <= $maxCol) { + $this->spreadsheet->getActiveSheet()->getColumnDimension(Coordinate::stringFromColumnIndex($c + 1))->setWidth($defaultWidth); + ++$c; + } + } + } + + private function processRowLoop(int $r, int $maxRow, SimpleXMLElement $rowOverride, float $defaultHeight): int + { + $rowAttributes = $rowOverride->attributes(); + $row = $rowAttributes['No']; + $rowHeight = (float) $rowAttributes['Unit']; + $hidden = (isset($rowAttributes['Hidden'])) && ((string) $rowAttributes['Hidden'] == '1'); + $rowCount = (isset($rowAttributes['Count'])) ? $rowAttributes['Count'] : 1; + while ($r < $row) { + ++$r; + $this->spreadsheet->getActiveSheet()->getRowDimension($r)->setRowHeight($defaultHeight); + } + while (($r < ($row + $rowCount)) && ($r < $maxRow)) { + ++$r; + $this->spreadsheet->getActiveSheet()->getRowDimension($r)->setRowHeight($rowHeight); + if ($hidden) { + $this->spreadsheet->getActiveSheet()->getRowDimension($r)->setVisible(false); + } + } + + return $r; + } + + private function processRowHeights(SimpleXMLElement $sheet, int $maxRow): void + { + if ((!$this->readDataOnly) && (isset($sheet->Rows))) { + // Row Heights + $rowAttributes = $sheet->Rows->attributes(); + $defaultHeight = (float) $rowAttributes['DefaultSizePts']; + $r = 0; + + foreach ($sheet->Rows->RowInfo as $rowOverride) { + $r = $this->processRowLoop($r, $maxRow, $rowOverride, $defaultHeight); + } + // never executed, I can't figure out any circumstances + // under which it would be executed, and, even if + // such exist, I'm not convinced this is needed. + //while ($r < $maxRow) { + // ++$r; + // $this->spreadsheet->getActiveSheet()->getRowDimension($r)->setRowHeight($defaultHeight); + //} } + } + private function processDefinedNames(SimpleXMLElement $gnmXML): void + { // Loop through definedNames (global named ranges) if (isset($gnmXML->Names)) { foreach ($gnmXML->Names->Name as $namedRange) { @@ -782,15 +783,37 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) $range = Worksheet::extractSheetTitle($range, true); $range[0] = trim($range[0], "'"); - if ($worksheet = $spreadsheet->getSheetByName($range[0])) { + if ($worksheet = $this->spreadsheet->getSheetByName($range[0])) { $extractedRange = str_replace('$', '', $range[1]); - $spreadsheet->addNamedRange(new NamedRange($name, $worksheet, $extractedRange)); + $this->spreadsheet->addNamedRange(new NamedRange($name, $worksheet, $extractedRange)); } } } + } - // Return - return $spreadsheet; + private function calcRotation(SimpleXMLElement $styleAttributes): int + { + $rotation = (int) $styleAttributes->Rotation; + if ($rotation >= 270 && $rotation <= 360) { + $rotation -= 360; + } + $rotation = (abs($rotation) > 90) ? 0 : $rotation; + + return $rotation; + } + + private static function addStyle(array &$styleArray, string $key, string $value): void + { + if (array_key_exists($value, self::$mappings[$key])) { + $styleArray[$key] = self::$mappings[$key][$value]; + } + } + + private static function addStyle2(array &$styleArray, string $key1, string $key, string $value): void + { + if (array_key_exists($value, self::$mappings[$key])) { + $styleArray[$key1][$key] = self::$mappings[$key][$value]; + } } private static function parseBorderAttributes($borderAttributes) @@ -800,64 +823,7 @@ private static function parseBorderAttributes($borderAttributes) $styleArray['color']['rgb'] = self::parseGnumericColour($borderAttributes['Color']); } - switch ($borderAttributes['Style']) { - case '0': - $styleArray['borderStyle'] = Border::BORDER_NONE; - - break; - case '1': - $styleArray['borderStyle'] = Border::BORDER_THIN; - - break; - case '2': - $styleArray['borderStyle'] = Border::BORDER_MEDIUM; - - break; - case '3': - $styleArray['borderStyle'] = Border::BORDER_SLANTDASHDOT; - - break; - case '4': - $styleArray['borderStyle'] = Border::BORDER_DASHED; - - break; - case '5': - $styleArray['borderStyle'] = Border::BORDER_THICK; - - break; - case '6': - $styleArray['borderStyle'] = Border::BORDER_DOUBLE; - - break; - case '7': - $styleArray['borderStyle'] = Border::BORDER_DOTTED; - - break; - case '8': - $styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHED; - - break; - case '9': - $styleArray['borderStyle'] = Border::BORDER_DASHDOT; - - break; - case '10': - $styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHDOT; - - break; - case '11': - $styleArray['borderStyle'] = Border::BORDER_DASHDOTDOT; - - break; - case '12': - $styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHDOTDOT; - - break; - case '13': - $styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHDOTDOT; - - break; - } + self::addStyle($styleArray, 'borderStyle', $borderAttributes['Style']); return $styleArray; } @@ -879,4 +845,23 @@ private static function parseGnumericColour($gnmColour) return $gnmR . $gnmG . $gnmB; } + + private function addColors(array &$styleArray, SimpleXMLElement $styleAttributes): void + { + $RGB = self::parseGnumericColour($styleAttributes['Fore']); + $styleArray['font']['color']['rgb'] = $RGB; + $RGB = self::parseGnumericColour($styleAttributes['Back']); + $shade = (string) $styleAttributes['Shade']; + if (($RGB != '000000') || ($shade != '0')) { + $RGB2 = self::parseGnumericColour($styleAttributes['PatternColor']); + if ($shade == '1') { + $styleArray['fill']['startColor']['rgb'] = $RGB; + $styleArray['fill']['endColor']['rgb'] = $RGB2; + } else { + $styleArray['fill']['endColor']['rgb'] = $RGB; + $styleArray['fill']['startColor']['rgb'] = $RGB2; + } + self::addStyle2($styleArray, 'fill', 'fillType', $shade); + } + } } diff --git a/tests/PhpSpreadsheetTests/IOFactoryTest.php b/tests/PhpSpreadsheetTests/IOFactoryTest.php index 983ba35ef4..906375bd26 100644 --- a/tests/PhpSpreadsheetTests/IOFactoryTest.php +++ b/tests/PhpSpreadsheetTests/IOFactoryTest.php @@ -123,6 +123,7 @@ public function providerIdentify() return [ ['samples/templates/26template.xlsx', 'Xlsx', Reader\Xlsx::class], ['samples/templates/GnumericTest.gnumeric', 'Gnumeric', Reader\Gnumeric::class], + ['samples/templates/old.gnumeric', 'Gnumeric', Reader\Gnumeric::class], ['samples/templates/30template.xls', 'Xls', Reader\Xls::class], ['samples/templates/OOCalcTest.ods', 'Ods', Reader\Ods::class], ['samples/templates/SylkTest.slk', 'Slk', Reader\Slk::class], diff --git a/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php b/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php new file mode 100644 index 0000000000..0904e2d4a6 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php @@ -0,0 +1,14 @@ +listWorksheetNames($filename); + self::assertCount(2, $names); + self::assertEquals('Sample Data', $names[0]); + self::assertEquals('Report Data', $names[1]); + } + + public function testListInfo(): void + { + $filename = __DIR__ + . '/../../../..' + . '/samples/templates/GnumericTest.gnumeric'; + $reader = new Gnumeric(); + $info = $reader->listWorksheetInfo($filename); + $expected = [ + [ + 'worksheetName' => 'Sample Data', + 'lastColumnLetter' => 'N', + 'lastColumnIndex' => 13, + 'totalRows' => 31, + 'totalColumns' => 14, + ], + [ + 'worksheetName' => 'Report Data', + 'lastColumnLetter' => 'K', + 'lastColumnIndex' => 10, + 'totalRows' => 65535, + 'totalColumns' => 11, + ], + ]; + self::assertEquals($expected, $info); + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericLoadTest.php b/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericLoadTest.php new file mode 100644 index 0000000000..e24178e558 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericLoadTest.php @@ -0,0 +1,162 @@ +load($filename); + self::assertEquals(2, $spreadsheet->getSheetCount()); + + $sheet = $spreadsheet->getSheet(1); + self::assertEquals('Report Data', $sheet->getTitle()); + self::assertEquals('BCD', $sheet->getCell('A4')->getValue()); + $props = $spreadsheet->getProperties(); + self::assertEquals('Mark Baker', $props->getCreator()); + + $sheet = $spreadsheet->getSheet(0); + self::assertEquals('Sample Data', $sheet->getTitle()); + self::assertEquals('Test String 1', $sheet->getCell('A1')->getValue()); + self::assertEquals('FFFF0000', $sheet->getCell('A1')->getStyle()->getFont()->getColor()->getARGB()); + self::assertEquals(Font::UNDERLINE_SINGLE, $sheet->getCell('A3')->getStyle()->getFont()->getUnderline()); + self::assertEquals('Test with (") in string', $sheet->getCell('A4')->getValue()); + + self::assertEquals(22269, $sheet->getCell('A10')->getValue()); + self::assertEquals('dd/mm/yyyy', $sheet->getCell('A10')->getStyle()->getNumberFormat()->getFormatCode()); + self::assertEquals('19/12/1960', $sheet->getCell('A10')->getFormattedValue()); + self::assertEquals(1.5, $sheet->getCell('A11')->getValue()); + self::assertEquals('# ?0/??0', $sheet->getCell('A11')->getStyle()->getNumberFormat()->getFormatCode()); + // Same pattern, same value, different display in Gnumeric vs Excel + //self::assertEquals('1 1/2', $sheet->getCell('A11')->getFormattedValue()); + + self::assertEquals('=B1+C1', $sheet->getCell('H1')->getValue()); + self::assertEquals('=E2&F2', $sheet->getCell('J2')->getValue()); + self::assertEquals('=sum(C1:C4)', $sheet->getCell('I5')->getValue()); + + self::assertTrue($sheet->getCell('E1')->getStyle()->getFont()->getBold()); + self::assertTrue($sheet->getCell('E1')->getStyle()->getFont()->getItalic()); + + self::assertFalse($sheet->getCell('E2')->getStyle()->getFont()->getBold()); + self::assertFalse($sheet->getCell('E2')->getStyle()->getFont()->getItalic()); + self::assertEquals(Font::UNDERLINE_NONE, $sheet->getCell('E2')->getStyle()->getFont()->getUnderline()); + self::assertTrue($sheet->getCell('E3')->getStyle()->getFont()->getBold()); + self::assertFalse($sheet->getCell('E3')->getStyle()->getFont()->getItalic()); + self::assertEquals(Font::UNDERLINE_NONE, $sheet->getCell('E3')->getStyle()->getFont()->getUnderline()); + self::assertFalse($sheet->getCell('E4')->getStyle()->getFont()->getBold()); + self::assertTrue($sheet->getCell('E4')->getStyle()->getFont()->getItalic()); + self::assertEquals(Font::UNDERLINE_NONE, $sheet->getCell('E4')->getStyle()->getFont()->getUnderline()); + + self::assertTrue($sheet->getCell('F1')->getStyle()->getFont()->getBold()); + self::assertFalse($sheet->getCell('F1')->getStyle()->getFont()->getItalic()); + self::assertEquals(Font::UNDERLINE_NONE, $sheet->getCell('F1')->getStyle()->getFont()->getUnderline()); + self::assertFalse($sheet->getCell('F2')->getStyle()->getFont()->getBold()); + self::assertFalse($sheet->getCell('F2')->getStyle()->getFont()->getItalic()); + self::assertEquals(Font::UNDERLINE_NONE, $sheet->getCell('F2')->getStyle()->getFont()->getUnderline()); + self::assertTrue($sheet->getCell('F3')->getStyle()->getFont()->getBold()); + self::assertTrue($sheet->getCell('F3')->getStyle()->getFont()->getItalic()); + self::assertEquals(Font::UNDERLINE_NONE, $sheet->getCell('F3')->getStyle()->getFont()->getUnderline()); + self::assertFalse($sheet->getCell('F4')->getStyle()->getFont()->getBold()); + self::assertFalse($sheet->getCell('F4')->getStyle()->getFont()->getItalic()); + self::assertEquals(Font::UNDERLINE_NONE, $sheet->getCell('F4')->getStyle()->getFont()->getUnderline()); + + self::assertEquals(Border::BORDER_MEDIUM, $sheet->getCell('C10')->getStyle()->getBorders()->getTop()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C10')->getStyle()->getBorders()->getRight()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C10')->getStyle()->getBorders()->getBottom()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C10')->getStyle()->getBorders()->getLeft()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C12')->getStyle()->getBorders()->getTop()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C12')->getStyle()->getBorders()->getRight()->getBorderStyle()); + self::assertEquals(Border::BORDER_MEDIUM, $sheet->getCell('C12')->getStyle()->getBorders()->getBottom()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C12')->getStyle()->getBorders()->getLeft()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C14')->getStyle()->getBorders()->getTop()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C14')->getStyle()->getBorders()->getRight()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C14')->getStyle()->getBorders()->getBottom()->getBorderStyle()); + self::assertEquals(Border::BORDER_MEDIUM, $sheet->getCell('C14')->getStyle()->getBorders()->getLeft()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C16')->getStyle()->getBorders()->getTop()->getBorderStyle()); + self::assertEquals(Border::BORDER_MEDIUM, $sheet->getCell('C16')->getStyle()->getBorders()->getRight()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C16')->getStyle()->getBorders()->getBottom()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C16')->getStyle()->getBorders()->getLeft()->getBorderStyle()); + self::assertEquals(Border::BORDER_THICK, $sheet->getCell('C18')->getStyle()->getBorders()->getTop()->getBorderStyle()); + self::assertEquals(Color::COLOR_RED, $sheet->getCell('C18')->getStyle()->getBorders()->getTop()->getColor()->getARGB()); + self::assertEquals(Border::BORDER_THICK, $sheet->getCell('C18')->getStyle()->getBorders()->getRight()->getBorderStyle()); + self::assertEquals(Color::COLOR_YELLOW, $sheet->getCell('C18')->getStyle()->getBorders()->getRight()->getColor()->getARGB()); + self::assertEquals(Border::BORDER_THICK, $sheet->getCell('C18')->getStyle()->getBorders()->getRight()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C18')->getStyle()->getBorders()->getBottom()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C18')->getStyle()->getBorders()->getLeft()->getBorderStyle()); + + self::assertEquals(Fill::FILL_PATTERN_DARKHORIZONTAL, $sheet->getCell('K19')->getStyle()->getFill()->getFillType()); + self::assertEquals('FF00CCFF', $sheet->getCell('K19')->getStyle()->getFill()->getEndColor()->getARGB()); + self::assertEquals(Color::COLOR_BLUE, $sheet->getCell('K19')->getStyle()->getFill()->getStartColor()->getARGB()); + self::assertEquals(Fill::FILL_PATTERN_GRAY0625, $sheet->getCell('L19')->getStyle()->getFill()->getFillType()); + self::assertEquals(Color::COLOR_RED, $sheet->getCell('L19')->getStyle()->getFill()->getEndColor()->getARGB()); + self::assertEquals(Color::COLOR_YELLOW, $sheet->getCell('L19')->getStyle()->getFill()->getStartColor()->getARGB()); + self::assertEquals(Fill::FILL_SOLID, $sheet->getCell('K3')->getStyle()->getFill()->getFillType()); + self::assertEquals(Color::COLOR_RED, $sheet->getCell('K3')->getStyle()->getFill()->getStartColor()->getARGB()); + + self::assertEquals(45, $sheet->getCell('E22')->getStyle()->getAlignment()->getTextRotation()); + self::assertEquals(-90, $sheet->getCell('G22')->getStyle()->getAlignment()->getTextRotation()); + self::assertEquals(Border::BORDER_DOUBLE, $sheet->getCell('N13')->getStyle()->getBorders()->getBottom()->getBorderStyle()); + + self::assertEquals(Borders::DIAGONAL_BOTH, $sheet->getCell('E18')->getStyle()->getBorders()->getDiagonalDirection()); + self::assertEquals(Borders::DIAGONAL_DOWN, $sheet->getCell('I18')->getStyle()->getBorders()->getDiagonalDirection()); + self::assertEquals(Borders::DIAGONAL_UP, $sheet->getCell('J18')->getStyle()->getBorders()->getDiagonalDirection()); + self::assertEquals(Font::UNDERLINE_DOUBLE, $sheet->getCell('A24')->getStyle()->getFont()->getUnderline()); + self::assertTrue($sheet->getCell('B23')->getStyle()->getFont()->getSubScript()); + self::assertTrue($sheet->getCell('B24')->getStyle()->getFont()->getSuperScript()); + self::assertFalse($sheet->getRowDimension(30)->getVisible()); + } + + public function testLoadFilter(): void + { + $filename = __DIR__ + . '/../../../..' + . '/samples/templates/GnumericTest.gnumeric'; + $reader = new Gnumeric(); + $filter = new GnumericFilter(); + $reader->setReadFilter($filter); + $spreadsheet = $reader->load($filename); + self::assertEquals(2, $spreadsheet->getSheetCount()); + $sheet = $spreadsheet->getSheet(1); + self::assertEquals('Report Data', $sheet->getTitle()); + self::assertEquals('', $sheet->getCell('A4')->getValue()); + $props = $spreadsheet->getProperties(); + self::assertEquals('Mark Baker', $props->getCreator()); + } + + public function testLoadOld(): void + { + $filename = __DIR__ + . '/../../../..' + . '/samples/templates/old.gnumeric'; + $reader = new Gnumeric(); + $spreadsheet = $reader->load($filename); + $props = $spreadsheet->getProperties(); + self::assertEquals('David Gilbert', $props->getCreator()); + } + + public function testLoadSelectedSheets(): void + { + $filename = __DIR__ + . '/../../../..' + . '/samples/templates/GnumericTest.gnumeric'; + $reader = new Gnumeric(); + $reader->setLoadSheetsOnly(['Unknown Sheet', 'Report Data']); + $spreadsheet = $reader->load($filename); + self::assertEquals(1, $spreadsheet->getSheetCount()); + $sheet = $spreadsheet->getSheet(0); + self::assertEquals('Report Data', $sheet->getTitle()); + self::assertEquals('Third Heading', $sheet->getCell('C2')->getValue()); + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericStylesTest.php b/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericStylesTest.php new file mode 100644 index 0000000000..fd8d7800db --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericStylesTest.php @@ -0,0 +1,269 @@ + $val) { + $covered[$key] = 0; + } + $tests = $this->providerBorderStyle(); + foreach ($tests as $test) { + $covered[$test[0]] = 1; + } + foreach ($covered as $key => $val) { + self::assertEquals(1, $val, "Borderstyle $key not tested"); + } + } + + /** + * @dataProvider providerfillType + */ + public function testFillType(string $style, string $expectedResult): void + { + $styles = Gnumeric::gnumericMappings(); + $borders = $styles['fillType']; + self::assertEquals($expectedResult, $borders[$style]); + } + + public function testFillTypeCoverage(): void + { + $styles = Gnumeric::gnumericMappings(); + $expected = $styles['fillType']; + $covered = []; + foreach ($expected as $key => $val) { + $covered[$key] = 0; + } + $tests = $this->providerfillType(); + foreach ($tests as $test) { + $covered[$test[0]] = 1; + } + foreach ($covered as $key => $val) { + self::assertEquals(1, $val, "fillType $key not tested"); + } + } + + /** + * @dataProvider providerHorizontal + */ + public function testHorizontal(string $style, string $expectedResult): void + { + $styles = Gnumeric::gnumericMappings(); + $borders = $styles['horizontal']; + self::assertEquals($expectedResult, $borders[$style]); + } + + public function testHorizontalCoverage(): void + { + $styles = Gnumeric::gnumericMappings(); + $expected = $styles['horizontal']; + $covered = []; + foreach ($expected as $key => $val) { + $covered[$key] = 0; + } + $tests = $this->providerHorizontal(); + foreach ($tests as $test) { + $covered[$test[0]] = 1; + } + foreach ($covered as $key => $val) { + self::assertEquals(1, $val, "horizontal $key not tested"); + } + } + + /** + * @dataProvider providerunderline + */ + public function testUnderline(string $style, string $expectedResult): void + { + $styles = Gnumeric::gnumericMappings(); + $borders = $styles['underline']; + self::assertEquals($expectedResult, $borders[$style]); + } + + public function testUnderlineCoverage(): void + { + $styles = Gnumeric::gnumericMappings(); + $expected = $styles['underline']; + $covered = []; + foreach ($expected as $key => $val) { + $covered[$key] = 0; + } + $tests = $this->providerUnderline(); + foreach ($tests as $test) { + $covered[$test[0]] = 1; + } + foreach ($covered as $key => $val) { + self::assertEquals(1, $val, "underline $key not tested"); + } + } + + /** + * @dataProvider providerVertical + */ + public function testVertical(string $style, string $expectedResult): void + { + $styles = Gnumeric::gnumericMappings(); + $borders = $styles['vertical']; + self::assertEquals($expectedResult, $borders[$style]); + } + + public function testVerticalCoverage(): void + { + $styles = Gnumeric::gnumericMappings(); + $expected = $styles['vertical']; + $covered = []; + foreach ($expected as $key => $val) { + $covered[$key] = 0; + } + $tests = $this->providerVertical(); + foreach ($tests as $test) { + $covered[$test[0]] = 1; + } + foreach ($covered as $key => $val) { + self::assertEquals(1, $val, "vertical $key not tested"); + } + } + + /** + * @dataProvider providerDataType + */ + public function testDataType(string $style, string $expectedResult): void + { + $styles = Gnumeric::gnumericMappings(); + $borders = $styles['dataType']; + self::assertEquals($expectedResult, $borders[$style]); + } + + public function testDataTypeCoverage(): void + { + $styles = Gnumeric::gnumericMappings(); + $expected = $styles['dataType']; + self::assertArrayNotHasKey('70', $expected); + self::assertArrayNotHasKey('80', $expected); + $covered = []; + foreach ($expected as $key => $val) { + $covered[$key] = 0; + } + $tests = $this->providerDataType(); + foreach ($tests as $test) { + $covered[$test[0]] = 1; + } + foreach ($covered as $key => $val) { + self::assertEquals(1, $val, "dataType $key not tested"); + } + } + + public function providerBorderStyle(): array + { + return [ + ['0', Border::BORDER_NONE], + ['1', Border::BORDER_THIN], + ['2', Border::BORDER_MEDIUM], + ['3', Border::BORDER_SLANTDASHDOT], + ['4', Border::BORDER_DASHED], + ['5', Border::BORDER_THICK], + ['6', Border::BORDER_DOUBLE], + ['7', Border::BORDER_DOTTED], + ['8', Border::BORDER_MEDIUMDASHED], + ['9', Border::BORDER_DASHDOT], + ['10', Border::BORDER_MEDIUMDASHDOT], + ['11', Border::BORDER_DASHDOTDOT], + ['12', Border::BORDER_MEDIUMDASHDOTDOT], + ['13', Border::BORDER_MEDIUMDASHDOTDOT], + ]; + } + + public function providerFillType(): array + { + return [ + ['1', Fill::FILL_SOLID], + ['2', Fill::FILL_PATTERN_DARKGRAY], + ['3', Fill::FILL_PATTERN_MEDIUMGRAY], + ['4', Fill::FILL_PATTERN_LIGHTGRAY], + ['5', Fill::FILL_PATTERN_GRAY125], + ['6', Fill::FILL_PATTERN_GRAY0625], + ['7', Fill::FILL_PATTERN_DARKHORIZONTAL], + ['8', Fill::FILL_PATTERN_DARKVERTICAL], + ['9', Fill::FILL_PATTERN_DARKDOWN], + ['10', Fill::FILL_PATTERN_DARKUP], + ['11', Fill::FILL_PATTERN_DARKGRID], + ['12', Fill::FILL_PATTERN_DARKTRELLIS], + ['13', Fill::FILL_PATTERN_LIGHTHORIZONTAL], + ['14', Fill::FILL_PATTERN_LIGHTVERTICAL], + ['15', Fill::FILL_PATTERN_LIGHTUP], + ['16', Fill::FILL_PATTERN_LIGHTDOWN], + ['17', Fill::FILL_PATTERN_LIGHTGRID], + ['18', Fill::FILL_PATTERN_LIGHTTRELLIS], + ]; + } + + public function providerHorizontal(): array + { + return [ + ['1', Alignment::HORIZONTAL_GENERAL], + ['2', Alignment::HORIZONTAL_LEFT], + ['4', Alignment::HORIZONTAL_RIGHT], + ['8', Alignment::HORIZONTAL_CENTER], + ['16', Alignment::HORIZONTAL_CENTER_CONTINUOUS], + ['32', Alignment::HORIZONTAL_JUSTIFY], + ['64', Alignment::HORIZONTAL_CENTER_CONTINUOUS], + ]; + } + + public function providerUnderline(): array + { + return [ + ['1', Font::UNDERLINE_SINGLE], + ['2', Font::UNDERLINE_DOUBLE], + ['3', Font::UNDERLINE_SINGLEACCOUNTING], + ['4', Font::UNDERLINE_DOUBLEACCOUNTING], + ]; + } + + public function providerVertical(): array + { + return [ + ['1', Alignment::VERTICAL_TOP], + ['2', Alignment::VERTICAL_BOTTOM], + ['4', Alignment::VERTICAL_CENTER], + ['8', Alignment::VERTICAL_JUSTIFY], + ]; + } + + public function providerDataType(): array + { + return [ + ['10', DataType::TYPE_NULL], + ['20', DataType::TYPE_BOOL], + ['30', DataType::TYPE_NUMERIC], // Integer doesn't exist in Excel + ['40', DataType::TYPE_NUMERIC], // Float + ['50', DataType::TYPE_ERROR], + ['60', DataType::TYPE_STRING], + //'70': // Cell Range + //'80': // Array + ]; + } +} From 262896086a9e60e2cb99cd15e13d1cf94a2ba025 Mon Sep 17 00:00:00 2001 From: oleibman Date: Fri, 19 Jun 2020 11:35:44 -0700 Subject: [PATCH 090/659] Improve Coverage for Sylk (#1514) * Improve Coverage for Sylk I believe that both BaseReader and Sylk Reader are now 100% covered. Documentation available for this format is sparse. It was always incomplete, and in some cases inaccurate. My goal was to use PhpSpreadsheet to load the test file, save it as Xlsx, and visually compare the two, then add a test loaded with assertions. Cell values and calculated values, and border styles were generally handled pretty well without changes. Other types of styling were not handled so well. I added a few cells to exercise some previously uncovered code. Sylk files must be ASCII. I have deprecated the use of the setEncoding and getEncoding functions, which had no test cases. --- samples/templates/SylkTest.slk | 3 +- src/PhpSpreadsheet/Reader/Slk.php | 605 +++++++++++-------- tests/PhpSpreadsheetTests/Reader/CsvTest.php | 4 + tests/PhpSpreadsheetTests/Reader/SlkTest.php | 134 ++++ 4 files changed, 493 insertions(+), 253 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/Reader/SlkTest.php diff --git a/samples/templates/SylkTest.slk b/samples/templates/SylkTest.slk index d5dd5bbe59..95770d042f 100644 --- a/samples/templates/SylkTest.slk +++ b/samples/templates/SylkTest.slk @@ -52,7 +52,7 @@ P;EArial;M200 P;EArial;M200;SI P;EArial;M200;SBI P;EArial;M200;SBU -P;EArial;M200;SBIU +P;EArial;M220;SBIU P;EArial;M200 P;EArial;M200;SI F;P0;DG0G8;M255 @@ -115,6 +115,7 @@ F;P19;FG0G;X4 C;Y7;X2;K2.34 C;X3;KFALSE C;Y8;X2;K3.45 +C;Y9;X2;K2.34;EMEDIAN(R[-3]C:R[-1]C) F;Y9;X1 F;X2 F;X3 diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index f40eba7460..0e147376b6 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -2,8 +2,10 @@ namespace PhpOffice\PhpSpreadsheet\Reader; +use InvalidArgumentException; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; +use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Border; @@ -38,6 +40,20 @@ class Slk extends BaseReader */ private $format = 0; + /** + * Fonts. + * + * @var array + */ + private $fonts = []; + + /** + * Font Count. + * + * @var int + */ + private $fontcount = 0; + /** * Create a new SYLK Reader instance. */ @@ -55,10 +71,9 @@ public function __construct() */ public function canRead($pFilename) { - // Check if file exists try { $this->openFile($pFilename); - } catch (Exception $e) { + } catch (InvalidArgumentException $e) { return false; } @@ -78,12 +93,24 @@ public function canRead($pFilename) return $hasDelimiter && $hasId; } + private function canReadOrBust(string $pFilename): void + { + if (!$this->canRead($pFilename)) { + throw new ReaderException($pFilename . ' is an Invalid SYLK file.'); + } + $this->openFile($pFilename); + } + /** * Set input encoding. * + * @deprecated no use is made of this property + * * @param string $pValue Input encoding, eg: 'ANSI' * * @return $this + * + * @codeCoverageIgnore */ public function setInputEncoding($pValue) { @@ -95,7 +122,11 @@ public function setInputEncoding($pValue) /** * Get input encoding. * + * @deprecated no use is made of this property + * * @return string + * + * @codeCoverageIgnore */ public function getInputEncoding() { @@ -112,22 +143,16 @@ public function getInputEncoding() public function listWorksheetInfo($pFilename) { // Open file - if (!$this->canRead($pFilename)) { - throw new Exception($pFilename . ' is an Invalid Spreadsheet file.'); - } - $this->openFile($pFilename); + $this->canReadOrBust($pFilename); $fileHandle = $this->fileHandle; rewind($fileHandle); $worksheetInfo = []; - $worksheetInfo[0]['worksheetName'] = 'Worksheet'; - $worksheetInfo[0]['lastColumnLetter'] = 'A'; - $worksheetInfo[0]['lastColumnIndex'] = 0; - $worksheetInfo[0]['totalRows'] = 0; - $worksheetInfo[0]['totalColumns'] = 0; + $worksheetInfo[0]['worksheetName'] = basename($pFilename, '.slk'); // loop through one row (line) at a time in the file $rowIndex = 0; + $columnIndex = 0; while (($rowData = fgets($fileHandle)) !== false) { $columnIndex = 0; @@ -139,28 +164,26 @@ public function listWorksheetInfo($pFilename) $rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData))))); $dataType = array_shift($rowData); - if ($dataType == 'C') { - // Read cell value data + if ($dataType == 'B') { foreach ($rowData as $rowDatum) { switch ($rowDatum[0]) { - case 'C': case 'X': $columnIndex = substr($rowDatum, 1) - 1; break; - case 'R': case 'Y': $rowIndex = substr($rowDatum, 1); break; } - - $worksheetInfo[0]['totalRows'] = max($worksheetInfo[0]['totalRows'], $rowIndex); - $worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], $columnIndex); } + + break; } } + $worksheetInfo[0]['lastColumnIndex'] = $columnIndex; + $worksheetInfo[0]['totalRows'] = $rowIndex; $worksheetInfo[0]['lastColumnLetter'] = Coordinate::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex'] + 1); $worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1; @@ -186,6 +209,294 @@ public function load($pFilename) return $this->loadIntoExisting($pFilename, $spreadsheet); } + private $colorArray = [ + 'FF00FFFF', // 0 - cyan + 'FF000000', // 1 - black + 'FFFFFFFF', // 2 - white + 'FFFF0000', // 3 - red + 'FF00FF00', // 4 - green + 'FF0000FF', // 5 - blue + 'FFFFFF00', // 6 - yellow + 'FFFF00FF', // 7 - magenta + ]; + + private $fontStyleMappings = [ + 'B' => 'bold', + 'I' => 'italic', + 'U' => 'underline', + ]; + + private function processFormula(string $rowDatum, bool &$hasCalculatedValue, string &$cellDataFormula, string $row, string $column): void + { + $cellDataFormula = '=' . substr($rowDatum, 1); + // Convert R1C1 style references to A1 style references (but only when not quoted) + $temp = explode('"', $cellDataFormula); + $key = false; + foreach ($temp as &$value) { + // Only count/replace in alternate array entries + if ($key = !$key) { + preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences, PREG_SET_ORDER + PREG_OFFSET_CAPTURE); + // Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way + // through the formula from left to right. Reversing means that we work right to left.through + // the formula + $cellReferences = array_reverse($cellReferences); + // Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent, + // then modify the formula to use that new reference + foreach ($cellReferences as $cellReference) { + $rowReference = $cellReference[2][0]; + // Empty R reference is the current row + if ($rowReference == '') { + $rowReference = $row; + } + // Bracketed R references are relative to the current row + if ($rowReference[0] == '[') { + $rowReference = $row + trim($rowReference, '[]'); + } + $columnReference = $cellReference[4][0]; + // Empty C reference is the current column + if ($columnReference == '') { + $columnReference = $column; + } + // Bracketed C references are relative to the current column + if ($columnReference[0] == '[') { + $columnReference = $column + trim($columnReference, '[]'); + } + $A1CellReference = Coordinate::stringFromColumnIndex($columnReference) . $rowReference; + + $value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0])); + } + } + } + unset($value); + // Then rebuild the formula string + $cellDataFormula = implode('"', $temp); + $hasCalculatedValue = true; + } + + private function processCRecord(array $rowData, Spreadsheet &$spreadsheet, string &$row, string &$column): void + { + // Read cell value data + $hasCalculatedValue = false; + $cellDataFormula = $cellData = ''; + foreach ($rowData as $rowDatum) { + switch ($rowDatum[0]) { + case 'C': + case 'X': + $column = substr($rowDatum, 1); + + break; + case 'R': + case 'Y': + $row = substr($rowDatum, 1); + + break; + case 'K': + $cellData = substr($rowDatum, 1); + + break; + case 'E': + $this->processFormula($rowDatum, $hasCalculatedValue, $cellDataFormula, $row, $column); + + break; + } + } + $columnLetter = Coordinate::stringFromColumnIndex((int) $column); + $cellData = Calculation::unwrapResult($cellData); + + // Set cell value + $this->processCFinal($spreadsheet, $hasCalculatedValue, $cellDataFormula, $cellData, "$columnLetter$row"); + } + + private function processCFinal(Spreadsheet &$spreadsheet, bool $hasCalculatedValue, string $cellDataFormula, string $cellData, string $coordinate): void + { + // Set cell value + $spreadsheet->getActiveSheet()->getCell($coordinate)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData); + if ($hasCalculatedValue) { + $cellData = Calculation::unwrapResult($cellData); + $spreadsheet->getActiveSheet()->getCell($coordinate)->setCalculatedValue($cellData); + } + } + + private function processFRecord(array $rowData, Spreadsheet &$spreadsheet, string &$row, string &$column): void + { + // Read cell formatting + $formatStyle = $columnWidth = ''; + $startCol = $endCol = ''; + $fontStyle = ''; + $styleData = []; + foreach ($rowData as $rowDatum) { + switch ($rowDatum[0]) { + case 'C': + case 'X': + $column = substr($rowDatum, 1); + + break; + case 'R': + case 'Y': + $row = substr($rowDatum, 1); + + break; + case 'P': + $formatStyle = $rowDatum; + + break; + case 'W': + [$startCol, $endCol, $columnWidth] = explode(' ', substr($rowDatum, 1)); + + break; + case 'S': + $this->styleSettings($rowDatum, $styleData, $fontStyle); + + break; + } + } + $this->addFormats($spreadsheet, $formatStyle, $row, $column); + $this->addFonts($spreadsheet, $fontStyle, $row, $column); + $this->addStyle($spreadsheet, $styleData, $row, $column); + $this->addWidth($spreadsheet, $columnWidth, $startCol, $endCol); + } + + private $styleSettingsFont = ['D' => 'bold', 'I' => 'italic']; + + private $styleSettingsBorder = [ + 'B' => 'bottom', + 'L' => 'left', + 'R' => 'right', + 'T' => 'top', + ]; + + private function styleSettings(string $rowDatum, array &$styleData, string &$fontStyle): void + { + $styleSettings = substr($rowDatum, 1); + $iMax = strlen($styleSettings); + for ($i = 0; $i < $iMax; ++$i) { + $char = $styleSettings[$i]; + if (array_key_exists($char, $this->styleSettingsFont)) { + $styleData['font'][$this->styleSettingsFont[$char]] = true; + } elseif (array_key_exists($char, $this->styleSettingsBorder)) { + $styleData['borders'][$this->styleSettingsBorder[$char]]['borderStyle'] = Border::BORDER_THIN; + } elseif ($char == 'S') { + $styleData['fill']['fillType'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY125; + } elseif ($char == 'M') { + if (preg_match('/M([1-9]\\d*)/', $styleSettings, $matches)) { + $fontStyle = $matches[1]; + } + } + } + } + + private function addFormats(Spreadsheet &$spreadsheet, string $formatStyle, string $row, string $column): void + { + if ($formatStyle && $column > '' && $row > '') { + $columnLetter = Coordinate::stringFromColumnIndex((int) $column); + if (isset($this->formats[$formatStyle])) { + $spreadsheet->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($this->formats[$formatStyle]); + } + } + } + + private function addFonts(Spreadsheet &$spreadsheet, string $fontStyle, string $row, string $column): void + { + if ($fontStyle && $column > '' && $row > '') { + $columnLetter = Coordinate::stringFromColumnIndex((int) $column); + if (isset($this->fonts[$fontStyle])) { + $spreadsheet->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($this->fonts[$fontStyle]); + } + } + } + + private function addStyle(Spreadsheet &$spreadsheet, array $styleData, string $row, string $column): void + { + if ((!empty($styleData)) && $column > '' && $row > '') { + $columnLetter = Coordinate::stringFromColumnIndex($column); + $spreadsheet->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($styleData); + } + } + + private function addWidth(Spreadsheet $spreadsheet, string $columnWidth, string $startCol, string $endCol): void + { + if ($columnWidth > '') { + if ($startCol == $endCol) { + $startCol = Coordinate::stringFromColumnIndex((int) $startCol); + $spreadsheet->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth); + } else { + $startCol = Coordinate::stringFromColumnIndex($startCol); + $endCol = Coordinate::stringFromColumnIndex($endCol); + $spreadsheet->getActiveSheet()->getColumnDimension($startCol)->setWidth((float) $columnWidth); + do { + $spreadsheet->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth); + } while ($startCol != $endCol); + } + } + } + + private function processPRecord(array $rowData, Spreadsheet &$spreadsheet): void + { + // Read shared styles + $formatArray = []; + $fromFormats = ['\-', '\ ']; + $toFormats = ['-', ' ']; + foreach ($rowData as $rowDatum) { + switch ($rowDatum[0]) { + case 'P': + $formatArray['numberFormat']['formatCode'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1)); + + break; + case 'E': + case 'F': + $formatArray['font']['name'] = substr($rowDatum, 1); + + break; + case 'M': + $formatArray['font']['size'] = substr($rowDatum, 1) / 20; + + break; + case 'L': + $this->processPColors($rowDatum, $formatArray); + + break; + case 'S': + $this->processPFontStyles($rowDatum, $formatArray); + + break; + } + } + $this->processPFinal($spreadsheet, $formatArray); + } + + private function processPColors(string $rowDatum, array &$formatArray): void + { + if (preg_match('/L([1-9]\\d*)/', $rowDatum, $matches)) { + $fontColor = $matches[1] % 8; + $formatArray['font']['color']['argb'] = $this->colorArray[$fontColor]; + } + } + + private function processPFontStyles(string $rowDatum, array &$formatArray): void + { + $styleSettings = substr($rowDatum, 1); + $iMax = strlen($styleSettings); + for ($i = 0; $i < $iMax; ++$i) { + if (array_key_exists($styleSettings[$i], $this->fontStyleMappings)) { + $formatArray['font'][$this->fontStyleMappings[$styleSettings[$i]]] = true; + } + } + } + + private function processPFinal(Spreadsheet &$spreadsheet, array $formatArray): void + { + if (array_key_exists('numberFormat', $formatArray)) { + $this->formats['P' . $this->format] = $formatArray; + ++$this->format; + } elseif (array_key_exists('font', $formatArray)) { + ++$this->fontcount; + $this->fonts[$this->fontcount] = $formatArray; + if ($this->fontcount === 1) { + $spreadsheet->getDefaultStyle()->applyFromArray($formatArray); + } + } + } + /** * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * @@ -196,10 +507,7 @@ public function load($pFilename) public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) { // Open file - if (!$this->canRead($pFilename)) { - throw new Exception($pFilename . ' is an Invalid Spreadsheet file.'); - } - $this->openFile($pFilename); + $this->canReadOrBust($pFilename); $fileHandle = $this->fileHandle; rewind($fileHandle); @@ -208,251 +516,32 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) $spreadsheet->createSheet(); } $spreadsheet->setActiveSheetIndex($this->sheetIndex); - - $fromFormats = ['\-', '\ ']; - $toFormats = ['-', ' ']; + $spreadsheet->getActiveSheet()->setTitle(basename($pFilename, '.slk')); // Loop through file $column = $row = ''; // loop through one row (line) at a time in the file - while (($rowData = fgets($fileHandle)) !== false) { + while (($rowDataTxt = fgets($fileHandle)) !== false) { // convert SYLK encoded $rowData to UTF-8 - $rowData = StringHelper::SYLKtoUTF8($rowData); + $rowDataTxt = StringHelper::SYLKtoUTF8($rowDataTxt); // explode each row at semicolons while taking into account that literal semicolon (;) // is escaped like this (;;) - $rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData))))); + $rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowDataTxt))))); $dataType = array_shift($rowData); - // Read shared styles if ($dataType == 'P') { - $formatArray = []; - foreach ($rowData as $rowDatum) { - switch ($rowDatum[0]) { - case 'P': - $formatArray['numberFormat']['formatCode'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1)); - - break; - case 'E': - case 'F': - $formatArray['font']['name'] = substr($rowDatum, 1); - - break; - case 'L': - $formatArray['font']['size'] = substr($rowDatum, 1); - - break; - case 'S': - $styleSettings = substr($rowDatum, 1); - $iMax = strlen($styleSettings); - for ($i = 0; $i < $iMax; ++$i) { - switch ($styleSettings[$i]) { - case 'I': - $formatArray['font']['italic'] = true; - - break; - case 'D': - $formatArray['font']['bold'] = true; - - break; - case 'T': - $formatArray['borders']['top']['borderStyle'] = Border::BORDER_THIN; - - break; - case 'B': - $formatArray['borders']['bottom']['borderStyle'] = Border::BORDER_THIN; - - break; - case 'L': - $formatArray['borders']['left']['borderStyle'] = Border::BORDER_THIN; - - break; - case 'R': - $formatArray['borders']['right']['borderStyle'] = Border::BORDER_THIN; - - break; - } - } - - break; - } - } - $this->formats['P' . $this->format++] = $formatArray; - // Read cell value data + // Read shared styles + $this->processPRecord($rowData, $spreadsheet); } elseif ($dataType == 'C') { - $hasCalculatedValue = false; - $cellData = $cellDataFormula = ''; - foreach ($rowData as $rowDatum) { - switch ($rowDatum[0]) { - case 'C': - case 'X': - $column = substr($rowDatum, 1); - - break; - case 'R': - case 'Y': - $row = substr($rowDatum, 1); - - break; - case 'K': - $cellData = substr($rowDatum, 1); - - break; - case 'E': - $cellDataFormula = '=' . substr($rowDatum, 1); - // Convert R1C1 style references to A1 style references (but only when not quoted) - $temp = explode('"', $cellDataFormula); - $key = false; - foreach ($temp as &$value) { - // Only count/replace in alternate array entries - if ($key = !$key) { - preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences, PREG_SET_ORDER + PREG_OFFSET_CAPTURE); - // Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way - // through the formula from left to right. Reversing means that we work right to left.through - // the formula - $cellReferences = array_reverse($cellReferences); - // Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent, - // then modify the formula to use that new reference - foreach ($cellReferences as $cellReference) { - $rowReference = $cellReference[2][0]; - // Empty R reference is the current row - if ($rowReference == '') { - $rowReference = $row; - } - // Bracketed R references are relative to the current row - if ($rowReference[0] == '[') { - $rowReference = $row + trim($rowReference, '[]'); - } - $columnReference = $cellReference[4][0]; - // Empty C reference is the current column - if ($columnReference == '') { - $columnReference = $column; - } - // Bracketed C references are relative to the current column - if ($columnReference[0] == '[') { - $columnReference = $column + trim($columnReference, '[]'); - } - $A1CellReference = Coordinate::stringFromColumnIndex($columnReference) . $rowReference; - - $value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0])); - } - } - } - unset($value); - // Then rebuild the formula string - $cellDataFormula = implode('"', $temp); - $hasCalculatedValue = true; - - break; - } - } - $columnLetter = Coordinate::stringFromColumnIndex($column); - $cellData = Calculation::unwrapResult($cellData); - - // Set cell value - $spreadsheet->getActiveSheet()->getCell($columnLetter . $row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData); - if ($hasCalculatedValue) { - $cellData = Calculation::unwrapResult($cellData); - $spreadsheet->getActiveSheet()->getCell($columnLetter . $row)->setCalculatedValue($cellData); - } - // Read cell formatting + // Read cell value data + $this->processCRecord($rowData, $spreadsheet, $row, $column); } elseif ($dataType == 'F') { - $formatStyle = $columnWidth = $styleSettings = ''; - $styleData = []; - foreach ($rowData as $rowDatum) { - switch ($rowDatum[0]) { - case 'C': - case 'X': - $column = substr($rowDatum, 1); - - break; - case 'R': - case 'Y': - $row = substr($rowDatum, 1); - - break; - case 'P': - $formatStyle = $rowDatum; - - break; - case 'W': - [$startCol, $endCol, $columnWidth] = explode(' ', substr($rowDatum, 1)); - - break; - case 'S': - $styleSettings = substr($rowDatum, 1); - $iMax = strlen($styleSettings); - for ($i = 0; $i < $iMax; ++$i) { - switch ($styleSettings[$i]) { - case 'I': - $styleData['font']['italic'] = true; - - break; - case 'D': - $styleData['font']['bold'] = true; - - break; - case 'T': - $styleData['borders']['top']['borderStyle'] = Border::BORDER_THIN; - - break; - case 'B': - $styleData['borders']['bottom']['borderStyle'] = Border::BORDER_THIN; - - break; - case 'L': - $styleData['borders']['left']['borderStyle'] = Border::BORDER_THIN; - - break; - case 'R': - $styleData['borders']['right']['borderStyle'] = Border::BORDER_THIN; - - break; - } - } - - break; - } - } - if (($formatStyle > '') && ($column > '') && ($row > '')) { - $columnLetter = Coordinate::stringFromColumnIndex($column); - if (isset($this->formats[$formatStyle])) { - $spreadsheet->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($this->formats[$formatStyle]); - } - } - if ((!empty($styleData)) && ($column > '') && ($row > '')) { - $columnLetter = Coordinate::stringFromColumnIndex($column); - $spreadsheet->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($styleData); - } - if ($columnWidth > '') { - if ($startCol == $endCol) { - $startCol = Coordinate::stringFromColumnIndex($startCol); - $spreadsheet->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth); - } else { - $startCol = Coordinate::stringFromColumnIndex($startCol); - $endCol = Coordinate::stringFromColumnIndex($endCol); - $spreadsheet->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth); - do { - $spreadsheet->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth); - } while ($startCol != $endCol); - } - } + // Read cell formatting + $this->processFRecord($rowData, $spreadsheet, $row, $column); } else { - foreach ($rowData as $rowDatum) { - switch ($rowDatum[0]) { - case 'C': - case 'X': - $column = substr($rowDatum, 1); - - break; - case 'R': - case 'Y': - $row = substr($rowDatum, 1); - - break; - } - } + $this->columnRowFromRowData($rowData, $column, $row); } } @@ -463,6 +552,18 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) return $spreadsheet; } + private function columnRowFromRowData(array $rowData, string &$column, string &$row): void + { + foreach ($rowData as $rowDatum) { + $char0 = $rowDatum[0]; + if ($char0 === 'X' || $char0 == 'C') { + $column = substr($rowDatum, 1); + } elseif ($char0 === 'Y' || $char0 == 'R') { + $row = substr($rowDatum, 1); + } + } + } + /** * Get sheet index. * diff --git a/tests/PhpSpreadsheetTests/Reader/CsvTest.php b/tests/PhpSpreadsheetTests/Reader/CsvTest.php index e4ccd93114..e11e0ff7b2 100644 --- a/tests/PhpSpreadsheetTests/Reader/CsvTest.php +++ b/tests/PhpSpreadsheetTests/Reader/CsvTest.php @@ -255,6 +255,10 @@ public function testDefaultSettings(): void self::assertEquals('\'', $reader->getEnclosure()); $reader->setEnclosure(''); self::assertEquals('"', $reader->getEnclosure()); + // following tests from BaseReader + self::assertTrue($reader->getReadEmptyCells()); + self::assertFalse($reader->getIncludeCharts()); + self::assertNull($reader->getLoadSheetsOnly()); } public function testReadEmptyFileName(): void diff --git a/tests/PhpSpreadsheetTests/Reader/SlkTest.php b/tests/PhpSpreadsheetTests/Reader/SlkTest.php new file mode 100644 index 0000000000..4c7cc5139a --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/SlkTest.php @@ -0,0 +1,134 @@ +listWorkSheetInfo(self::$testbook); + $info0 = $workSheetInfo[0]; + self::assertEquals('SylkTest', $info0['worksheetName']); + self::assertEquals('J', $info0['lastColumnLetter']); + self::assertEquals(9, $info0['lastColumnIndex']); + self::assertEquals(18, $info0['totalRows']); + self::assertEquals(10, $info0['totalColumns']); + } + + public function testBadFileName(): void + { + $this->expectException(ReaderException::class); + $reader = new Slk(); + self::assertNull($reader->setLoadSheetsOnly(null)->getLoadSheetsOnly()); + $reader->listWorkSheetInfo(self::$testbook . 'xxx'); + } + + public function testBadFileName2(): void + { + $reader = new Slk(); + self::assertFalse($reader->canRead(self::$testbook . 'xxx')); + } + + public function testNotSylkFile(): void + { + $this->expectException(ReaderException::class); + $reader = new Slk(); + $reader->listWorkSheetInfo(__FILE__); + } + + public function testLoadSlk(): void + { + $reader = new Slk(); + $spreadsheet = $reader->load(self::$testbook); + $sheet = $spreadsheet->getActiveSheet(); + self::assertEquals('SylkTest', $sheet->getTitle()); + + self::assertEquals('FFFF0000', $sheet->getCell('A1')->getStyle()->getFont()->getColor()->getARGB()); + self::assertEquals(Fill::FILL_PATTERN_GRAY125, $sheet->getCell('A2')->getStyle()->getFill()->getFillType()); + self::assertEquals(Font::UNDERLINE_SINGLE, $sheet->getCell('A4')->getStyle()->getFont()->getUnderline()); + self::assertEquals('Test with (;) in string', $sheet->getCell('A4')->getValue()); + + self::assertEquals(22269, $sheet->getCell('A10')->getValue()); + self::assertEquals('dd/mm/yyyy', $sheet->getCell('A10')->getStyle()->getNumberFormat()->getFormatCode()); + self::assertEquals('19/12/1960', $sheet->getCell('A10')->getFormattedValue()); + self::assertEquals(1.5, $sheet->getCell('A11')->getValue()); + self::assertEquals('# ?/?', $sheet->getCell('A11')->getStyle()->getNumberFormat()->getFormatCode()); + self::assertEquals('1 1/2', $sheet->getCell('A11')->getFormattedValue()); + + self::assertEquals('=B1+C1', $sheet->getCell('H1')->getValue()); + self::assertEquals('=E2&F2', $sheet->getCell('J2')->getValue()); + self::assertEquals('=SUM(C1:C4)', $sheet->getCell('I5')->getValue()); + self::assertEquals('=MEDIAN(B6:B8)', $sheet->getCell('B9')->getValue()); + + self::assertEquals(11, $sheet->getCell('E1')->getStyle()->getFont()->getSize()); + self::assertTrue($sheet->getCell('E1')->getStyle()->getFont()->getBold()); + self::assertTrue($sheet->getCell('E1')->getStyle()->getFont()->getItalic()); + self::assertEquals(Font::UNDERLINE_SINGLE, $sheet->getCell('E1')->getStyle()->getFont()->getUnderline()); + self::assertFalse($sheet->getCell('E2')->getStyle()->getFont()->getBold()); + self::assertFalse($sheet->getCell('E2')->getStyle()->getFont()->getItalic()); + self::assertEquals(Font::UNDERLINE_NONE, $sheet->getCell('E2')->getStyle()->getFont()->getUnderline()); + self::assertTrue($sheet->getCell('E3')->getStyle()->getFont()->getBold()); + self::assertFalse($sheet->getCell('E3')->getStyle()->getFont()->getItalic()); + self::assertEquals(Font::UNDERLINE_NONE, $sheet->getCell('E3')->getStyle()->getFont()->getUnderline()); + self::assertFalse($sheet->getCell('E4')->getStyle()->getFont()->getBold()); + self::assertTrue($sheet->getCell('E4')->getStyle()->getFont()->getItalic()); + self::assertEquals(Font::UNDERLINE_NONE, $sheet->getCell('E4')->getStyle()->getFont()->getUnderline()); + + self::assertTrue($sheet->getCell('F1')->getStyle()->getFont()->getBold()); + self::assertFalse($sheet->getCell('F1')->getStyle()->getFont()->getItalic()); + self::assertEquals(Font::UNDERLINE_SINGLE, $sheet->getCell('F1')->getStyle()->getFont()->getUnderline()); + self::assertFalse($sheet->getCell('F2')->getStyle()->getFont()->getBold()); + self::assertFalse($sheet->getCell('F2')->getStyle()->getFont()->getItalic()); + self::assertEquals(Font::UNDERLINE_NONE, $sheet->getCell('F2')->getStyle()->getFont()->getUnderline()); + self::assertTrue($sheet->getCell('F3')->getStyle()->getFont()->getBold()); + self::assertTrue($sheet->getCell('F3')->getStyle()->getFont()->getItalic()); + self::assertEquals(Font::UNDERLINE_NONE, $sheet->getCell('F3')->getStyle()->getFont()->getUnderline()); + self::assertFalse($sheet->getCell('F4')->getStyle()->getFont()->getBold()); + self::assertFalse($sheet->getCell('F4')->getStyle()->getFont()->getItalic()); + self::assertEquals(Font::UNDERLINE_NONE, $sheet->getCell('F4')->getStyle()->getFont()->getUnderline()); + + self::assertEquals(Border::BORDER_THIN, $sheet->getCell('C10')->getStyle()->getBorders()->getTop()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C10')->getStyle()->getBorders()->getRight()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C10')->getStyle()->getBorders()->getBottom()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C10')->getStyle()->getBorders()->getLeft()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C12')->getStyle()->getBorders()->getTop()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C12')->getStyle()->getBorders()->getRight()->getBorderStyle()); + self::assertEquals(Border::BORDER_THIN, $sheet->getCell('C12')->getStyle()->getBorders()->getBottom()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C12')->getStyle()->getBorders()->getLeft()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C14')->getStyle()->getBorders()->getTop()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C14')->getStyle()->getBorders()->getRight()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C14')->getStyle()->getBorders()->getBottom()->getBorderStyle()); + self::assertEquals(Border::BORDER_THIN, $sheet->getCell('C14')->getStyle()->getBorders()->getLeft()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C16')->getStyle()->getBorders()->getTop()->getBorderStyle()); + self::assertEquals(Border::BORDER_THIN, $sheet->getCell('C16')->getStyle()->getBorders()->getRight()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C16')->getStyle()->getBorders()->getBottom()->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $sheet->getCell('C16')->getStyle()->getBorders()->getLeft()->getBorderStyle()); + self::assertEquals(Border::BORDER_THIN, $sheet->getCell('C18')->getStyle()->getBorders()->getTop()->getBorderStyle()); + self::assertEquals(Border::BORDER_THIN, $sheet->getCell('C18')->getStyle()->getBorders()->getRight()->getBorderStyle()); + self::assertEquals(Border::BORDER_THIN, $sheet->getCell('C18')->getStyle()->getBorders()->getBottom()->getBorderStyle()); + self::assertEquals(Border::BORDER_THIN, $sheet->getCell('C18')->getStyle()->getBorders()->getLeft()->getBorderStyle()); + // Have not yet figured out how C6/C7 are centred + } + + public function testSheetIndex(): void + { + $reader = new Slk(); + $sheetIndex = 2; + $reader->setSheetIndex($sheetIndex); + self::assertEquals($sheetIndex, $reader->getSheetIndex()); + $spreadsheet = $reader->load(self::$testbook); + $sheet = $spreadsheet->setActiveSheetIndex($sheetIndex); + self::assertEquals('SylkTest', $sheet->getTitle()); + + self::assertEquals('FFFF0000', $sheet->getCell('A1')->getStyle()->getFont()->getColor()->getARGB()); + } +} From 35c04964cf63a06561a5aeb199853f4b8e59b135 Mon Sep 17 00:00:00 2001 From: tyomitch Date: Fri, 19 Jun 2020 20:38:06 +0200 Subject: [PATCH 091/659] #1504: Using non-UTC timezone corrupts dates imported from XML spreadsheet (#1506) --- src/PhpSpreadsheet/Reader/Xml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Reader/Xml.php b/src/PhpSpreadsheet/Reader/Xml.php index 15fb34ad91..f9ad5475d8 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -516,7 +516,7 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) break; case 'DateTime': $type = DataType::TYPE_NUMERIC; - $cellValue = Date::PHPToExcel(strtotime($cellValue)); + $cellValue = Date::PHPToExcel(strtotime($cellValue . ' UTC')); break; case 'Error': From d8b4c3b26e4905efb4cc89b44abf3c3541c4cc72 Mon Sep 17 00:00:00 2001 From: oleibman Date: Fri, 19 Jun 2020 11:40:28 -0700 Subject: [PATCH 092/659] Fix for #1533 (#1534) Code assumes that formula whose result starts with # indicates error. Change to check entire result against error list in Functions. --- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 2 +- .../Writer/Xlsx/StartsWithHashTest.php | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 tests/PhpSpreadsheetTests/Writer/Xlsx/StartsWithHashTest.php diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index d101bb4068..be064256db 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -1112,7 +1112,7 @@ private function writeCellFormula(XMLWriter $objWriter, string $cellValue, Cell { $calculatedValue = $this->getParentWriter()->getPreCalculateFormulas() ? $pCell->getCalculatedValue() : $cellValue; if (is_string($calculatedValue)) { - if (substr($calculatedValue, 0, 1) === '#') { + if (\PhpOffice\PhpSpreadsheet\Calculation\Functions::isError($calculatedValue)) { $this->writeCellError($objWriter, 'e', $cellValue, $calculatedValue); return; diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/StartsWithHashTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/StartsWithHashTest.php new file mode 100644 index 0000000000..d4fe5b2282 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/StartsWithHashTest.php @@ -0,0 +1,62 @@ +getActiveSheet(); + $sheet->setCellValueExplicit('A1', '#define M', DataType::TYPE_STRING); + $sheet->setCellValue('A2', '=A1'); + $sheet->setCellValue('A3', '=UNKNOWNFUNC()'); + + $writer = new Writer($spreadsheet); + $writer->save($outputFilename); + + $reader = new Reader(); + $sheet = $reader->load($outputFilename); + unlink($outputFilename); + + self::assertSame('#define M', $sheet->getActiveSheet()->getCell('A1')->getValue()); + self::assertSame('#define M', $sheet->getActiveSheet()->getCell('A2')->getCalculatedValue()); + self::assertSame('f', $sheet->getActiveSheet()->getCell('A3')->getDataType()); + self::assertSame('#NAME?', $sheet->getActiveSheet()->getCell('A3')->getCalculatedValue()); + self::assertSame('f', $sheet->getActiveSheet()->getCell('A3')->getDataType()); + } + + public function testStartWithHashReadRaw(): void + { + // Make sure raw data indicates A3 is an error, but A2 isn't. + $outputFilename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test'); + Settings::setLibXmlLoaderOptions(null); + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValueExplicit('A1', '#define M', DataType::TYPE_STRING); + $sheet->setCellValue('A2', '=A1'); + $sheet->setCellValue('A3', '=UNKNOWNFUNC()'); + + $writer = new Writer($spreadsheet); + $writer->save($outputFilename); + $zip = new ZipArchive(); + $zip->open($outputFilename); + $resultSheet1Raw = $zip->getFromName('xl/worksheets/sheet1.xml'); + $zip->close(); + unlink($outputFilename); + + self::assertStringContainsString('', $resultSheet1Raw); + self::assertStringContainsString('', $resultSheet1Raw); + } +} From 73c336ac96cbdbf7a3cd092849603a1ef6894c2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Fri, 19 Jun 2020 20:51:46 +0200 Subject: [PATCH 093/659] Fix exact MATCH on ranges with empty cells (#1520) Fixes a bug when doing exact match on ranges with empty cells. ```php getActiveSheet(); // Row: 1, null, 4, null, 8. $sheet->getCell('A1')->setValue(1); $sheet->getCell('A3')->setValue(4); $sheet->getCell('A5')->setValue(8); $sheet->getCell('B1')->setValue('=MATCH(4, A1:A5, 1)'); // Should echo 3, but echos '#N/A'. echo $sheet->getCell('B1')->getCalculatedValue() . PHP_EOL; // Row: 1, null, 4, null, null. $sheet->getCell('C1')->setValue(1); $sheet->getCell('C3')->setValue(4); $sheet->getCell('D1')->setValue('=MATCH(5, C1:C5, 1)'); // Should echo 3, but echos '#N/A'. echo $sheet->getCell('D1')->getCalculatedValue() . PHP_EOL; ``` --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Calculation/LookupRef.php | 16 ++++++++-------- tests/data/Calculation/LookupRef/MATCH.php | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37f4f3dc15..fba9738fff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Fixed - Resolve evaluation of utf-8 named ranges in calculation engine [#1522](https://github.com/PHPOffice/PhpSpreadsheet/pull/1522) +- Fix exact MATCH on ranges with empty cells [#1520](https://github.com/PHPOffice/PhpSpreadsheet/pull/1520) ## [1.13.0] - 2020-05-31 diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index f82724044b..09042e2c6d 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -485,6 +485,13 @@ public static function MATCH($lookupValue, $lookupArray, $matchType = 1) return Functions::NA(); } + if ($matchType == 1) { + // If match_type is 1 the list has to be processed from last to first + + $lookupArray = array_reverse($lookupArray); + $keySet = array_reverse(array_keys($lookupArray)); + } + // Lookup_array should contain only number, text, or logical values, or empty (null) cells foreach ($lookupArray as $i => $lookupArrayValue) { // check the type of the value @@ -498,17 +505,10 @@ public static function MATCH($lookupValue, $lookupArray, $matchType = 1) $lookupArray[$i] = StringHelper::strToLower($lookupArrayValue); } if (($lookupArrayValue === null) && (($matchType == 1) || ($matchType == -1))) { - $lookupArray = array_slice($lookupArray, 0, $i - 1); + unset($lookupArray[$i]); } } - if ($matchType == 1) { - // If match_type is 1 the list has to be processed from last to first - - $lookupArray = array_reverse($lookupArray); - $keySet = array_reverse(array_keys($lookupArray)); - } - // ** // find the match // ** diff --git a/tests/data/Calculation/LookupRef/MATCH.php b/tests/data/Calculation/LookupRef/MATCH.php index b39edb9f49..d9f0a83de6 100644 --- a/tests/data/Calculation/LookupRef/MATCH.php +++ b/tests/data/Calculation/LookupRef/MATCH.php @@ -97,6 +97,20 @@ -1, ], + // match on ranges with empty cells + [ + 3, // Expected + 4, // Input + [1, null, 4, null, 8], + 1, + ], + [ + 3, // Expected + 5, // Input + [1, null, 4, null, null], + 1, + ], + // 0s are causing errors, because things like 0 == 'x' is true. Thanks PHP! [ 3, From 1a44ef91095ea4923b63c29d16887923760f6d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Fri, 19 Jun 2020 20:54:04 +0200 Subject: [PATCH 094/659] Fix MATCH when comparing different numeric types (#1521) Let MATCH compare numerics of different type (e.g. integers and floats). ```php getActiveSheet(); // Row: 1, 2, 3, 4, 5. MATCH for 4.6. $sheet->getCell('A1')->setValue(1); $sheet->getCell('A2')->setValue(2); $sheet->getCell('A3')->setValue(3); $sheet->getCell('A4')->setValue(4); $sheet->getCell('A5')->setValue(5); $sheet->getCell('B1')->setValue('=MATCH(4.6, A1:A5, 1)'); // Should echo 4, but echos '#N/A'. echo $sheet->getCell('B1')->getCalculatedValue() . PHP_EOL; // Row: 1, 2, 3, 3.8, 5. MATCH for 4. $sheet->getCell('C1')->setValue(1); $sheet->getCell('C2')->setValue(2); $sheet->getCell('C3')->setValue(3); $sheet->getCell('C4')->setValue(3.8); $sheet->getCell('C5')->setValue(5); $sheet->getCell('D1')->setValue('=MATCH(4, C1:C5, 1)'); // Should echo 4, but echos 3. echo $sheet->getCell('D1')->getCalculatedValue() . PHP_EOL; ``` Co-authored-by: Mark Baker --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Calculation/LookupRef.php | 2 +- tests/data/Calculation/LookupRef/MATCH.php | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fba9738fff..aee163807c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Fixed - Resolve evaluation of utf-8 named ranges in calculation engine [#1522](https://github.com/PHPOffice/PhpSpreadsheet/pull/1522) +- Fix MATCH when comparing different numeric types [#1521](https://github.com/PHPOffice/PhpSpreadsheet/pull/1521) - Fix exact MATCH on ranges with empty cells [#1520](https://github.com/PHPOffice/PhpSpreadsheet/pull/1520) ## [1.13.0] - 2020-05-31 diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index 09042e2c6d..904eb24b34 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -515,7 +515,7 @@ public static function MATCH($lookupValue, $lookupArray, $matchType = 1) if ($matchType === 0 || $matchType === 1) { foreach ($lookupArray as $i => $lookupArrayValue) { - $typeMatch = gettype($lookupValue) === gettype($lookupArrayValue); + $typeMatch = ((gettype($lookupValue) === gettype($lookupArrayValue)) || (is_numeric($lookupValue) && is_numeric($lookupArrayValue))); $exactTypeMatch = $typeMatch && $lookupArrayValue === $lookupValue; $nonOnlyNumericExactMatch = !$typeMatch && $lookupArrayValue === $lookupValue; $exactMatch = $exactTypeMatch || $nonOnlyNumericExactMatch; diff --git a/tests/data/Calculation/LookupRef/MATCH.php b/tests/data/Calculation/LookupRef/MATCH.php index d9f0a83de6..671056dd6f 100644 --- a/tests/data/Calculation/LookupRef/MATCH.php +++ b/tests/data/Calculation/LookupRef/MATCH.php @@ -179,6 +179,19 @@ [true, false, 'a', 'z', 222222, 2, 99999999], -1, ], + // when mixing numeric types + [ + 4, // Expected + 4.6, + [1, 2, 3, 4, 5], + 1, + ], + [ + 4, // Expected + 4, + [1, 2, 3, 3.8, 5], + 1, + ], // if element of same data type met and it is < than searched one #N/A - no further processing [ '#N/A', // Expected From 38441863971872e5d291d80223697c28bd5a95eb Mon Sep 17 00:00:00 2001 From: oleibman Date: Fri, 19 Jun 2020 11:57:20 -0700 Subject: [PATCH 095/659] Fix for Issue 1495 (#1500) #1495 reports that ActiveSheet can change when calculation involves jumping around between sheets. Save index before calculation, restore after, add test. --- src/PhpSpreadsheet/Cell/Cell.php | 2 ++ tests/PhpSpreadsheetTests/Cell/CellTest.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/PhpSpreadsheet/Cell/Cell.php b/src/PhpSpreadsheet/Cell/Cell.php index 0bca2fc03e..74ed92681b 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -251,9 +251,11 @@ public function getCalculatedValue($resetLog = true) { if ($this->dataType == DataType::TYPE_FORMULA) { try { + $index = $this->getWorksheet()->getParent()->getActiveSheetIndex(); $result = Calculation::getInstance( $this->getWorksheet()->getParent() )->calculateCellValue($this, $resetLog); + $this->getWorksheet()->getParent()->setActiveSheetIndex($index); // We don't yet handle array returns if (is_array($result)) { while (is_array($result)) { diff --git a/tests/PhpSpreadsheetTests/Cell/CellTest.php b/tests/PhpSpreadsheetTests/Cell/CellTest.php index 8c95e86458..0d9ce33729 100644 --- a/tests/PhpSpreadsheetTests/Cell/CellTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CellTest.php @@ -46,4 +46,23 @@ public function providerSetValueExplicitException() { return require 'tests/data/Cell/SetValueExplicitException.php'; } + + public function testNoChangeToActiveSheet(): void + { + $spreadsheet = new Spreadsheet(); + $sheet1 = $spreadsheet->getActiveSheet(); + $sheet1->setTitle('Sheet 1'); + $sheet3 = $spreadsheet->createSheet(); + $sheet3->setTitle('Sheet 3'); + $sheet1->setCellValue('C1', 123); + $sheet1->setCellValue('D1', 124); + $sheet3->setCellValue('A1', "='Sheet 1'!C1+'Sheet 1'!D1"); + $sheet1->setCellValue('A1', "='Sheet 3'!A1"); + $cell = 'A1'; + $spreadsheet->setActiveSheetIndex(0); + self::assertEquals(0, $spreadsheet->getActiveSheetIndex()); + $value = $spreadsheet->getActiveSheet()->getCell($cell)->getCalculatedValue(); + self::assertEquals(0, $spreadsheet->getActiveSheetIndex()); + self::assertEquals(247, $value); + } } From 38fab4e6329df8ba857afa24fd686bc5369a116b Mon Sep 17 00:00:00 2001 From: oleibman Date: Fri, 19 Jun 2020 12:01:18 -0700 Subject: [PATCH 096/659] Fix for #1505 (#1525) This problem is the same as #1238, which was resolved by #1239. For that issue, the fix was to check in one place whether $this->mapCellXfIndex[$xfIndex] was set before using it. The sample spreadsheet supplied as a description for this problem had exactly the same problem in 2 other places in the code. In addition, there were 7 other places in the code where that particular item was used unchecked. This fix corrects all 9 locations. The spreadsheet supplied with the problem is used as the basis for some new tests, which particularly test column dimensions and styles, the problems involved in this case. --- src/PhpSpreadsheet/Reader/Xls.php | 22 ++++++++------ tests/PhpSpreadsheetTests/Reader/XlsTest.php | 30 +++++++++++++++++-- tests/data/Reader/XLS/bug1505.xls | Bin 0 -> 20992 bytes 3 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 tests/data/Reader/XLS/bug1505.xls diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index b206f8ac36..3f383b9ecf 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -3622,7 +3622,9 @@ private function readColInfo(): void $this->phpSheet->getColumnDimensionByColumn($i)->setVisible(!$isHidden); $this->phpSheet->getColumnDimensionByColumn($i)->setOutlineLevel($level); $this->phpSheet->getColumnDimensionByColumn($i)->setCollapsed($isCollapsed); - $this->phpSheet->getColumnDimensionByColumn($i)->setXfIndex($this->mapCellXfIndex[$xfIndex]); + if (isset($this->mapCellXfIndex[$xfIndex])) { + $this->phpSheet->getColumnDimensionByColumn($i)->setXfIndex($this->mapCellXfIndex[$xfIndex]); + } } } } @@ -3731,7 +3733,7 @@ private function readRk(): void $numValue = self::getIEEE754($rknum); $cell = $this->phpSheet->getCell($columnString . ($row + 1)); - if (!$this->readDataOnly) { + if (!$this->readDataOnly && isset($this->mapCellXfIndex[$xfIndex])) { // add style information $cell->setXfIndex($this->mapCellXfIndex[$xfIndex]); } @@ -3866,7 +3868,7 @@ private function readMulRk(): void // offset: var; size: 4; RK value $numValue = self::getIEEE754(self::getInt4d($recordData, $offset + 2)); $cell = $this->phpSheet->getCell($columnString . ($row + 1)); - if (!$this->readDataOnly) { + if (!$this->readDataOnly && isset($this->mapCellXfIndex[$xfIndex])) { // add style $cell->setXfIndex($this->mapCellXfIndex[$xfIndex]); } @@ -3910,7 +3912,7 @@ private function readNumber(): void $numValue = self::extractNumber(substr($recordData, 6, 8)); $cell = $this->phpSheet->getCell($columnString . ($row + 1)); - if (!$this->readDataOnly) { + if (!$this->readDataOnly && isset($this->mapCellXfIndex[$xfIndex])) { // add cell style $cell->setXfIndex($this->mapCellXfIndex[$xfIndex]); } @@ -4018,7 +4020,7 @@ private function readFormula(): void } $cell = $this->phpSheet->getCell($columnString . ($row + 1)); - if (!$this->readDataOnly) { + if (!$this->readDataOnly && isset($this->mapCellXfIndex[$xfIndex])) { // add cell style $cell->setXfIndex($this->mapCellXfIndex[$xfIndex]); } @@ -4156,7 +4158,7 @@ private function readBoolErr(): void break; } - if (!$this->readDataOnly) { + if (!$this->readDataOnly && isset($this->mapCellXfIndex[$xfIndex])) { // add cell style $cell->setXfIndex($this->mapCellXfIndex[$xfIndex]); } @@ -4194,7 +4196,9 @@ private function readMulBlank(): void // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { $xfIndex = self::getUInt2d($recordData, 4 + 2 * $i); - $this->phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->mapCellXfIndex[$xfIndex]); + if (isset($this->mapCellXfIndex[$xfIndex])) { + $this->phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->mapCellXfIndex[$xfIndex]); + } } } } @@ -4245,7 +4249,7 @@ private function readLabel(): void $cell = $this->phpSheet->getCell($columnString . ($row + 1)); $cell->setValueExplicit($value, DataType::TYPE_STRING); - if (!$this->readDataOnly) { + if (!$this->readDataOnly && isset($this->mapCellXfIndex[$xfIndex])) { // add cell style $cell->setXfIndex($this->mapCellXfIndex[$xfIndex]); } @@ -4277,7 +4281,7 @@ private function readBlank(): void $xfIndex = self::getUInt2d($recordData, 4); // add style information - if (!$this->readDataOnly && $this->readEmptyCells) { + if (!$this->readDataOnly && $this->readEmptyCells && isset($this->mapCellXfIndex[$xfIndex])) { $this->phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->mapCellXfIndex[$xfIndex]); } } diff --git a/tests/PhpSpreadsheetTests/Reader/XlsTest.php b/tests/PhpSpreadsheetTests/Reader/XlsTest.php index 77ad91fab2..da39f8b2a3 100644 --- a/tests/PhpSpreadsheetTests/Reader/XlsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XlsTest.php @@ -3,9 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Reader; use PhpOffice\PhpSpreadsheet\Reader\Xls; -use PHPUnit\Framework\TestCase; +use PhpOffice\PhpSpreadsheetTests\Functional\AbstractFunctional; -class XlsTest extends TestCase +class XlsTest extends AbstractFunctional { /** * Test load Xls file. @@ -17,4 +17,30 @@ public function testLoadXlsSample(): void $spreadsheet = $reader->load($filename); self::assertEquals('Title', $spreadsheet->getSheet(0)->getCell('A1')->getValue()); } + + /** + * Test load Xls file with invalid xfIndex. + */ + public function testLoadXlsBug1505(): void + { + $filename = 'tests/data/Reader/XLS/bug1505.xls'; + $reader = new Xls(); + $spreadsheet = $reader->load($filename); + $sheet = $spreadsheet->getActiveSheet(); + $col = $sheet->getHighestColumn(); + $row = $sheet->getHighestRow(); + + $newspreadsheet = $this->writeAndReload($spreadsheet, 'Xlsx'); + $newsheet = $newspreadsheet->getActiveSheet(); + $newcol = $newsheet->getHighestColumn(); + $newrow = $newsheet->getHighestRow(); + + self::assertEquals($spreadsheet->getSheetCount(), $newspreadsheet->getSheetCount()); + self::assertEquals($sheet->getTitle(), $newsheet->getTitle()); + self::assertEquals($sheet->getColumnDimensions(), $newsheet->getColumnDimensions()); + self::assertEquals($col, $newcol); + self::assertEquals($row, $newrow); + self::assertEquals($sheet->getCell('A1')->getFormattedValue(), $newsheet->getCell('A1')->getFormattedValue()); + self::assertEquals($sheet->getCell("$col$row")->getFormattedValue(), $newsheet->getCell("$col$row")->getFormattedValue()); + } } diff --git a/tests/data/Reader/XLS/bug1505.xls b/tests/data/Reader/XLS/bug1505.xls new file mode 100644 index 0000000000000000000000000000000000000000..3440ceb911192e86029bfd95eb2a8d7093765865 GIT binary patch literal 20992 zcmeI)du$cieFyM!uiw}PY=bezkBcApfo+T*7%;{**ch)vX-Rw41qg3sx`^PG)ZbI9rt@2m@=r)^%UHbd|=AJ$C zz2|JTRZ_K$a<9hs&TnS!XXea#&D`Vr&flawf8+Nv|6WBr4yq{i$;$*4>x&2I{SH09 zQPJ|3FL_qK7SVeO{qphuCmt2jBebiz|rklr@X>k2({>w63K%A$Ze z9n6zuyH%$8ONzy-S2dX%N_i?yWt){MD)Dn@odF6Su-$TVsL!?xw5_;06{_RRb{*6jQutlRPQ~MF~jsQK`H6Pj7 zXwW@sC!Irs>g_*u^~OT`x7@D2s@AK(4dp${)to9 zicY2d%S2fl)e? z5!zysRve>RFwm;5(c5`ibWF9VWEJS8jrh|zIp%3vr1h8Sbxcv(wa^Dts#>PHRF7=Z zN}DyS4th4zzQn7*fb1I|H6KkiXNZ?-9W5!O%)x2BjwY{B+6awOVz7Xgc#l`YucK7g z&lV}QRHxLfHl=FY6=jKds=c%MOsYc4I{`ZP_vws&D`}gY*G&2Q2G`xR*8%w?t}pcC zd87C4d1D~l5cbg)3F?mQol;+3?=9zfHvIEJTJtF%06lnl6g~aRqbZdRY&FYcDCc*0 znO4@1rIV(YtDpyY#~Mc)#RsXWrbnE5xhijH=Q+m55Exwu5e zc%LF;@s1cDVB~t7NRhEbM~rhs5dp>UTfP7M~pK}q><@}ZF9t^vtw;beH$y5hSn0U(*urCwG>;{f+`D3M8&E%rQk-QWQv0A{BjQ^B1(l>1`yg{Y>gb zgA@%C*G!mt(I7>Ol=G~jPD`A&Mv4I`2Ba8}Vl0VkL35sBMEb4d+=)~QY=WZmJ|yT*S6{EE%l?1#aU7uNO2;iz2E-ZTH?H5 zBx)CZQaniUAjMl!JV@~({W$ggU(ph$l#voZN&qPVqy$S!0Eur6q^tMarxvv2HGDdk zdnH+)C$F^WlDiJ1b(XXaq;(=4$!PjGHhiAAB${KQ?gq_iDG`n-5u`**N(3oUq>}Ex zey$~Me~iQ}zLAnZ;?~}j+$2j%0x3zPn)1xJBfz2^(0BHkA8$jA%NgF`gAkyF$ z->TJ;*E7<`TLvRBS;%9X(LD*MXGye`t6u--s9eaIi?girWBA;KuWQs6p&Ix z%1rp^nU=T@Vx&}%yjwK7Jf(t^YDuXerHb@P^W!I4;+~C>(m+asV@d-l&63hUN)u^o z?Ta}rdDs5>Jb73A`aEp{X%k4BEQzlgO{=j8HQ>s~KA29;1=A zfaG1Z>SNjh(iThF0@4qkABKL`~tP;6*j_Gd%fPKScW*c`dlz5zBML z@*S}PN375h+u?{6Iby|*ScxN6>WJ-h#L678a!0Jf5!>a6RXSpHtJ_Lbx?OL@_-0jP z+SfQ@wT{>xM~rS-S)a#Wv_u;F95K4XZ>?AFh#hdm8XU2Mju_tv^Y05^GlwW6@>wq-%+5HX{{*R0L8HNJW-Z1X7VmPv4FGk3cx}xV|(}F-XNA6@yf4 zNyQ))i}Wz*wGXt!wXl&&Kq>*L1f&v6DgmiPq^Z{YZ)u6^b|aO7R0>ilNTrrk3R0;^ z8SQtkB!p9sTMQ%Z1ZgKoJ3-oMNjpK>DN;@9zkWeW+zuJ345TuU%0Mc!q%x4oMC$(D z$nR*0TQ?(>gH#SuIY{M}R1Q+PNOMo${R=H|n`xv9kSai`0I9-~DnP0b>B(g4KWd3v zVk7MWX%|SlK-y(VyFl6{(zA*`e5oaF-;GoWQYA>0AXQpYB}kPbz5QWv*1B-s<6eW2 zc7wDVq}?Fxwxr!4?H1_=fBO1fEpcDONL3(Jfm8)jl_gbyR3*|+*OL0Q#627%RfALw zQZ-1`mQ)Q=wMe7i+0~yIPCf278L0-O8jxy0s1mFZxJPcJdXVZtst2jwlIlUK7pd{x zlzJ_3Ki^0PKso@@0gw(@(gBbTh;;P3AHAw2zIrfH14s=ZHGtG$Nev)1h&2ACnXhY! zuStw_5Tt`3@nA)B@BN@99R%s1NcYeD-FLL)edVw3K{bNZ2vQ?Rjh561Qlm&;37z~W zmiRuvn{prEXSoY7Bj5Qq(ee7P&G_CxvmWCe4#Ev^+ z?T%Q7BX+_OJL!mZI$~XpShpkA;G*f~dR&=EWD zh+S~Rh9Y8oAE1e1rffDriD`lo(*z}^$tp2TP-2>-#QgC;|5IN!)e@H#BOLiP;Fj1(ogj6B)Cp3j zC3S+-DUyFQ1-I`;>H?_?q%M%UEU62mE|L7BDY(~Qq;8P9LFxvn+mgCL>K4gAnu7Zx zM(P2n2c#a5dMv32q#lv{qbazDW293codW3;NT)366iBB;@{gwAev^@ULFxsm7o=WG z>IJD+B>!j%?u{9#4NdD0j z+;cS207wHM4S+OYNdq7ah~ytl!TnJqod)SNNT)$MZAqs=IxUiaGzIr^jdTX2Ga#J- z>5L_v0qKlL{?QcNcQ(>lkj{d17NoP5bQYwuBKb#CaF5(b=Ri6K(m9aMS<*R>&WYq7 zO~L(qBMpKy2+|-(gO)T1(x6EG(G-03V5IXPod@YWNaro-JV@t7@{gwAYZ4<}0O!0fuRRBku!@IARwau~A2C z%n=)R#3mfENk?qT5u0|zW*o6uN9>X#Hs^@VJ7Not*kwoTiX*n@h%Gr{%Z}JpN9>v- zcHI$Mal~#oVmBSJTaMUmN9>LxcGnTR7ZKz80K*hBC1w~(%rKOgVJI=fR*4yg5;H6% z#y={EbG4C1KpFvQ1f&s58UblUB>$)&E-Oa52+~E6E`oH?k}iUDQ6xPoh*OVCppiyF z8U<+-q)|&61!+_y|7Z#>*GBUG?@3>skAXA>(wHTUfixzPe>4Tx7DgI}V;To(9Hene z8V8C0zb#$)M^kVeWTXj@CP111X~L2wK$;NAKbnGTHX}`fGzroqNRyT{3DTrU{?Qa% zUm9r&q$!Z5K$^0oDUhZ_@{gwATG&X_AWefb4brqFO@lNol7BP>*X>4{0ci%L8IWcy zX$GVjk^G}6xWzEiEJ(8;&4M&*NwXl$isTC(G=Wf8fhM+d64Eonzy8RkoaFw)0KZT1-HaTS^#MQqy>-` zENKCx1(E!tDY$(%(q)h?gLE0B%a(K*q{|}tM^kXG!AMs?x&qP_kgizL6_Boo_sETO3#3~h-2&;BCEWt)mPr25 z6x`1@(ru7#gLE6D+m>`2q}w9-M^o_CgOTolbO)q6AlKcuStw_7o@u& z-395cCEW$-u1NmT6nv#)qD~wF zz9roU>Apz*5h9#!MtT6!1CSno^uUrHfb>8lJwk+2kI#mY)<9YVX$_<`OIibIO(g#} z>wJ!l^bn+nAUy=>p(Q;8>7hveZ`L{I80is6k3f0^(j!ZH1kxjs{NJo|el*f!kRF5d z7^KIR^cbYaBI$3|-=kj!S&UNjQ!xIKJO_iR>JMVsZ{k1n>mvMkN}oJN&vi2Qf9_8Y z{bI}l{e(-1evO8I=Vg(8y6M03;D1@vKX(@RoEz%ji{sS?NMBU5>Z0t2cLDb~KSoyL ze}vUOzkc3r=e+NXKkw?lu-{u4 Date: Fri, 19 Jun 2020 21:06:41 +0200 Subject: [PATCH 097/659] Fix HLOOKUP on single row (#1512) Fixes a bug when doing a HLOOKUP on a single row. ```php getActiveSheet(); /** * Single row. */ $singleRow = "=HLOOKUP(10, {5, 10, 15}, 1, 0)"; $sheet->getCell('A1')->setValue($singleRow); // Should echo 10, but echos '#N/A' and some PHP notices and warnings. echo $sheet->getCell('A1')->getCalculatedValue() . PHP_EOL; /** * Multiple rows. */ $multipleRows = "=HLOOKUP(10, {5, 10, 15; 20, 25, 30}, 1, 0)"; $sheet->getCell('A2')->setValue($multipleRows); // Should echo: 10 and also does. echo $sheet->getCell('A2')->getCalculatedValue() . PHP_EOL; ``` Co-authored-by: Mark Baker --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Calculation/LookupRef.php | 2 +- tests/data/Calculation/LookupRef/HLOOKUP.php | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aee163807c..11a8b2ffb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Fixed - Resolve evaluation of utf-8 named ranges in calculation engine [#1522](https://github.com/PHPOffice/PhpSpreadsheet/pull/1522) +- Fix HLOOKUP on single row [#1512](https://github.com/PHPOffice/PhpSpreadsheet/pull/1512) - Fix MATCH when comparing different numeric types [#1521](https://github.com/PHPOffice/PhpSpreadsheet/pull/1521) - Fix exact MATCH on ranges with empty cells [#1520](https://github.com/PHPOffice/PhpSpreadsheet/pull/1520) diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index 904eb24b34..6e817006c4 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -807,7 +807,7 @@ public static function HLOOKUP($lookup_value, $lookup_array, $index_number, $not return Functions::REF(); } $f = array_keys($lookup_array); - $firstRow = array_pop($f); + $firstRow = reset($f); if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array))) { return Functions::REF(); } diff --git a/tests/data/Calculation/LookupRef/HLOOKUP.php b/tests/data/Calculation/LookupRef/HLOOKUP.php index 644ddeba7c..b880f24705 100644 --- a/tests/data/Calculation/LookupRef/HLOOKUP.php +++ b/tests/data/Calculation/LookupRef/HLOOKUP.php @@ -275,6 +275,19 @@ 2, true, ], + [ + 3, + 3, + [ + [ + 1, + 2, + 3, + ], + ], + 1, + true, + ], [ 5, 'x', From b3d30f4cbc30c45eb83111ac9d23b05afe10cab3 Mon Sep 17 00:00:00 2001 From: oleibman Date: Fri, 19 Jun 2020 12:08:36 -0700 Subject: [PATCH 098/659] Xls Writer - Correct Timestamp Bug, Improve Coverage (#1493) * Xls Writer - Correct Timestamp Bug, Improve Coverage I believe that Xls Writer is 100% covered now. The Xls Writer sets its timestamp incorrectly. The problem is actually in Shared/Ole::localDateToOLE, which converts its timestamp using gmmktime; mktime is correct. If I save a file at 3:00 p.m. in San Francisco, this bug means the time is actually recorded as 3:00 p.m. UTC. A consequence of this is that if you use Phpspreadsheet to read the file and save it as a new Xls, the creation timestamp goes further and further back in time with each generation (or further forward if east of Greenwich). One of the tests added confirms that the creation timestamp is consistent with the start and end times of the test. The major change in coverage is adding tests to save GIF and BMP images, which aren't supported in Xls, but are converted to PNG in the PhpSpreadsheet code. --- samples/images/bmp.bmp | Bin 0 -> 30186 bytes samples/images/gif.gif | Bin 0 -> 1578 bytes src/PhpSpreadsheet/Shared/OLE.php | 9 +- src/PhpSpreadsheet/Writer/Xls.php | 339 ++++++++---------- .../Writer/Xls/XlsGifBmpTest.php | 84 +++++ 5 files changed, 235 insertions(+), 197 deletions(-) create mode 100644 samples/images/bmp.bmp create mode 100644 samples/images/gif.gif create mode 100644 tests/PhpSpreadsheetTests/Writer/Xls/XlsGifBmpTest.php diff --git a/samples/images/bmp.bmp b/samples/images/bmp.bmp new file mode 100644 index 0000000000000000000000000000000000000000..01fee85ebcd7ca3dda1783f0d0b2c59494e34ac6 GIT binary patch literal 30186 zcmeHQEpHu35cILYKtsboqr=gmkdu5Y(9kgC&;djLguuW+lamY$1N}219WgY_mECcv z)HBmNA3GcSX`hsr*_rO@>e`;!*?BqLAAkP$_tDemcYMFYpMUV@FZ}uK=osHeNB{mD zf4cbj^<)2Rs{nN0HsBuZ$FBMIMX+nWYree#+eh5%eAj$?1-6g4*ZHpb_6lqtaj)}T z^X(PbKH}lk`PJ1GlDfFK*j~)ah=-^7n>TNe)Jx9mC3CAR8)x>U_pZ59W$xwiu^piv zU0+|%jns>Ncy<2i(&lRp$B~p61`be>crvY-%r-*hr~S^M{9r5u8cB2dO!i z^p77uHtDv_KJy?o|NQwgOT9_+ZT6W5sX27+)4b2C>9!iTR+m>{-=|)mSF0e1((3Xm z?EBQ~^J*1j*IX6bHCHuS+kNWwd3A7Wb$J!`ed^I`>airEyb29lNm9KgM|w?_Wh!`6 zzUvxOy(U>8`}JTOh6PjfvS8|RR+vYtS5Gq}9GB!6wJ zzJvYx^{dK0SZ1u))?eu8xTs7?(#8H7RIR_zX{lGnYBj6T z9GG9ee9;Qu$`)h?6X#NbRWXB72O6uwA&*~<>^%^@+g(d8%>uA# zXH!o}bAV9Hz(&oQ;#L}yL#4el>vpH3o8wlBXJ=<4+lD|-#tm$cBh6gCt6UC(ce~Tk z&2jgV()WA^cu5?_4Qz0`X;#7+=^q5|cBdm6%3qfqvvCtajZ1BZsb;0PYQyIgwwKz! zR+}990Qod*Rfdir;Fb~hO5X9}HljJma3_z~s6JU@FXrAVn!&Op+!7H7#i-VE_U&Wj z#jRU&2o5qH!?gX?f6gtT^Ys1l!`&#{RAe0sj z(gu`gX9pkpTBC%Z3p*?q7a7=;pfsYh(M;XY>X)REMdk`%&vCbrqi>LA7S=k|9qnN0 z(1m?5R$!njl_Q3K4gp7e=IvM*(E{O{J=);HqR;WH^6FLDRs}#H-kcz4OqD@Pxxj!W zg1 z5f*uNx`96p0P^kIw^oL?x3`RLjTnLRBAyX|3UC;aHn@XK1O?Cjc?~Aw-Us!Wf_a@K zfVbDyO@+f@^cv0eVH%WrljgwL;N8<@t%+#;aOukyIYCP9G>98|*J7;+WO>c1tKc+#pPVm|9o+(>0;ZWMc zA=jWK8g8iOQlD!zk1&>c>0BzM>v_ZC<$iGBz5F-;K3F%xH%gV7D{Ur=#^QS} z6CZ3asNt}d;s>Z1<4A<=Xw<9^DO<>{An}dURXvp*I4M4R7)3$YX^l8Kp#~caYB-#C ziw{t>3!Y3skGa<@ESk<>TQ@M^Q`(kjl&tKPnrF=v z5C&5V9{Bb_My(5riZIyL<)ySOaUoPCTal26v(d}vL?8dwezx6$Gf#FhL1=B0$u^Dj z)Qe;)8^%9it2lv~-bz#gh~ac7u zQ%&VyZ8AxRDtnqVN4|@j6G-6}J*+mBWCAm0Y7LvDf&IK8K1OTyEm;~(npf^@xtBA2 zD!sDwtW($UwJ?Kl@es31_s_8-M=LeQqJgD@Ue-X(^M_HB!hL7G97xS2*Kotfv!ljq zl8qjx^o58u=R9&^)?BVQ{olQN{C|qsXGPdP#o&eA%lr55ySE2OBna(ZHlOoe{+rL} z0K9&PZvpGV))QFQGS(cim~U3-wN{UHlX~H3i<-Z1{;!eVuKD(NZP$F)e0v49kBB<| EA4~Nmpa1{> literal 0 HcmV?d00001 diff --git a/samples/images/gif.gif b/samples/images/gif.gif new file mode 100644 index 0000000000000000000000000000000000000000..4cf06035b8a0e830eafd83733c77eee7bcb06d0b GIT binary patch literal 1578 zcmXYwdr;8F5yzJpThh!p0w!rhQSCJ1q)yiEP-XP0#?BRI0Q%F7@UAp@Bkjc z6L%G&w15`T5?V$p zXcZlxLv)0W(Fr<559kp+p=b1hUNHa$#6TDrgJ4ipKt)tSWmG|pbVOq#0TD2PM6$>L z86-nwn2eB7vOpHe5?LlIWR)C{Lvlop$q6|n59E2OWAVpFl zWl|xH5Jbe0ff$%UA|h;n4YDCN%tqKKTVRW9i7m4gw#p9JAv%3OqGA*U18PtW zsbMvuM%98^R7+}Et*BLXpbpiMI#ws@R6VFi^`xHFi+a@n8c+jiU=5<-ezPcOk=qgS zXzu?u|9|eIZQz{;V*u{Lp!-+%{{+M;bU*ZD=HcCqC9w%9Q$9Jo=fv8+iQ}p=kG$Qq z;m0_y?UN(br#3x3di|4G@4eGpnKaQ)X?}0-={JVH(o&UmwC2oP!7~{89!TQ+x6@KnKYVGy#>!>$Rr;SIo-=<4{e(~msGhgPu zu=9fn-!E$4cWqkLt3`K`|5knW)6K6fzKeJEZFY}m+es^GV~ReX25qf7R=DJX&u7B; zmAeb#x1W4^ReD_M=C!@)LVW2DDvB!Bb^PYvJ4zq&MG5PBHNN@O2GiWIX=D7>+<^tp z))Y;ArO(aTiRJNeg>hxuzq1LpH8$(3(JxP}Kll33>jeYH%v+J$UfE~qob!drFa87eN^uyt9_byvOUc)^%y54fa^ozJIK?mhHs z{&2f%Kz;GdioFA7n@wd`9_y(1Q_rROyXW4#@b&1V&X$B-@o~5{=C5NEwV)k`U z@f`^zt=mr3)U7Ej{(H`aEj=AIjgQt%-t)qpH4EPF&9U<= 0.0 ? PHP_INT_MAX : PHP_INT_MIN; + // Overflow conditions can't happen on 64-bit system + return ($iTimestamp == $unixTimestamp) ? $iTimestamp : ($unixTimestamp >= 0.0 ? PHP_INT_MAX : PHP_INT_MIN); } } diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index cf87d5beee..4f4b256a34 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -23,7 +23,6 @@ use PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing; use PhpOffice\PhpSpreadsheet\Worksheet\Drawing; use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing; -use RuntimeException; class Xls extends BaseWriter { @@ -389,13 +388,94 @@ private function buildWorksheetEschers(): void } } - /** - * Build the Escher object corresponding to the MSODRAWINGGROUP record. - */ - private function buildWorkbookEscher(): void + private function processMemoryDrawing(BstoreContainer &$bstoreContainer, BaseDrawing $drawing, string $renderingFunctionx): void + { + switch ($renderingFunctionx) { + case MemoryDrawing::RENDERING_JPEG: + $blipType = BSE::BLIPTYPE_JPEG; + $renderingFunction = 'imagejpeg'; + + break; + default: + $blipType = BSE::BLIPTYPE_PNG; + $renderingFunction = 'imagepng'; + + break; + } + + ob_start(); + call_user_func($renderingFunction, $drawing->getImageResource()); + $blipData = ob_get_contents(); + ob_end_clean(); + + $blip = new Blip(); + $blip->setData($blipData); + + $BSE = new BSE(); + $BSE->setBlipType($blipType); + $BSE->setBlip($blip); + + $bstoreContainer->addBSE($BSE); + } + + private function processDrawing(BstoreContainer &$bstoreContainer, BaseDrawing $drawing): void + { + $blipData = ''; + $filename = $drawing->getPath(); + + [$imagesx, $imagesy, $imageFormat] = getimagesize($filename); + + switch ($imageFormat) { + case 1: // GIF, not supported by BIFF8, we convert to PNG + $blipType = BSE::BLIPTYPE_PNG; + ob_start(); + imagepng(imagecreatefromgif($filename)); + $blipData = ob_get_contents(); + ob_end_clean(); + + break; + case 2: // JPEG + $blipType = BSE::BLIPTYPE_JPEG; + $blipData = file_get_contents($filename); + + break; + case 3: // PNG + $blipType = BSE::BLIPTYPE_PNG; + $blipData = file_get_contents($filename); + + break; + case 6: // Windows DIB (BMP), we convert to PNG + $blipType = BSE::BLIPTYPE_PNG; + ob_start(); + imagepng(SharedDrawing::imagecreatefrombmp($filename)); + $blipData = ob_get_contents(); + ob_end_clean(); + + break; + } + if ($blipData) { + $blip = new Blip(); + $blip->setData($blipData); + + $BSE = new BSE(); + $BSE->setBlipType($blipType); + $BSE->setBlip($blip); + + $bstoreContainer->addBSE($BSE); + } + } + + private function processBaseDrawing(BstoreContainer &$bstoreContainer, BaseDrawing $drawing): void { - $escher = null; + if ($drawing instanceof Drawing) { + $this->processDrawing($bstoreContainer, $drawing); + } elseif ($drawing instanceof MemoryDrawing) { + $this->processMemoryDrawing($bstoreContainer, $drawing, $drawing->getRenderingFunction()); + } + } + private function checkForDrawings(): bool + { // any drawings in this workbook? $found = false; foreach ($this->spreadsheet->getAllSheets() as $sheet) { @@ -406,8 +486,16 @@ private function buildWorkbookEscher(): void } } + return $found; + } + + /** + * Build the Escher object corresponding to the MSODRAWINGGROUP record. + */ + private function buildWorkbookEscher(): void + { // nothing to do if there are no drawings - if (!$found) { + if (!$this->checkForDrawings()) { return; } @@ -429,17 +517,16 @@ private function buildWorkbookEscher(): void foreach ($this->spreadsheet->getAllsheets() as $sheet) { $sheetCountShapes = 0; // count number of shapes (minus group shape), in sheet - if (count($sheet->getDrawingCollection()) > 0) { - ++$countDrawings; - - foreach ($sheet->getDrawingCollection() as $drawing) { - ++$sheetCountShapes; - ++$totalCountShapes; + $addCount = 0; + foreach ($sheet->getDrawingCollection() as $drawing) { + $addCount = 1; + ++$sheetCountShapes; + ++$totalCountShapes; - $spId = $sheetCountShapes | ($this->spreadsheet->getIndex($sheet) + 1) << 10; - $spIdMax = max($spId, $spIdMax); - } + $spId = $sheetCountShapes | ($this->spreadsheet->getIndex($sheet) + 1) << 10; + $spIdMax = max($spId, $spIdMax); } + $countDrawings += $addCount; } $dggContainer->setSpIdMax($spIdMax + 1); @@ -453,83 +540,7 @@ private function buildWorkbookEscher(): void // the BSE's (all the images) foreach ($this->spreadsheet->getAllsheets() as $sheet) { foreach ($sheet->getDrawingCollection() as $drawing) { - if (!extension_loaded('gd')) { - throw new RuntimeException('Saving images in xls requires gd extension'); - } - if ($drawing instanceof Drawing) { - $filename = $drawing->getPath(); - - [$imagesx, $imagesy, $imageFormat] = getimagesize($filename); - - switch ($imageFormat) { - case 1: // GIF, not supported by BIFF8, we convert to PNG - $blipType = BSE::BLIPTYPE_PNG; - ob_start(); - imagepng(imagecreatefromgif($filename)); - $blipData = ob_get_contents(); - ob_end_clean(); - - break; - case 2: // JPEG - $blipType = BSE::BLIPTYPE_JPEG; - $blipData = file_get_contents($filename); - - break; - case 3: // PNG - $blipType = BSE::BLIPTYPE_PNG; - $blipData = file_get_contents($filename); - - break; - case 6: // Windows DIB (BMP), we convert to PNG - $blipType = BSE::BLIPTYPE_PNG; - ob_start(); - imagepng(SharedDrawing::imagecreatefrombmp($filename)); - $blipData = ob_get_contents(); - ob_end_clean(); - - break; - default: - continue 2; - } - - $blip = new Blip(); - $blip->setData($blipData); - - $BSE = new BSE(); - $BSE->setBlipType($blipType); - $BSE->setBlip($blip); - - $bstoreContainer->addBSE($BSE); - } elseif ($drawing instanceof MemoryDrawing) { - switch ($drawing->getRenderingFunction()) { - case MemoryDrawing::RENDERING_JPEG: - $blipType = BSE::BLIPTYPE_JPEG; - $renderingFunction = 'imagejpeg'; - - break; - case MemoryDrawing::RENDERING_GIF: - case MemoryDrawing::RENDERING_PNG: - case MemoryDrawing::RENDERING_DEFAULT: - $blipType = BSE::BLIPTYPE_PNG; - $renderingFunction = 'imagepng'; - - break; - } - - ob_start(); - call_user_func($renderingFunction, $drawing->getImageResource()); - $blipData = ob_get_contents(); - ob_end_clean(); - - $blip = new Blip(); - $blip->setData($blipData); - - $BSE = new BSE(); - $BSE->setBlipType($blipType); - $BSE->setBlip($blip); - - $bstoreContainer->addBSE($BSE); - } + $this->processBaseDrawing($bstoreContainer, $drawing); } } @@ -578,8 +589,8 @@ private function writeDocumentSummaryInformation() ++$dataSection_NumProps; // GKPIDDSI_CATEGORY : Category - if ($this->spreadsheet->getProperties()->getCategory()) { - $dataProp = $this->spreadsheet->getProperties()->getCategory(); + $dataProp = $this->spreadsheet->getProperties()->getCategory(); + if ($dataProp) { $dataSection[] = [ 'summary' => ['pack' => 'V', 'data' => 0x02], 'offset' => ['pack' => 'V'], @@ -707,11 +718,7 @@ private function writeDocumentSummaryInformation() $dataSection_Content_Offset += 4 + 4; } elseif ($dataProp['type']['data'] == 0x0B) { // Boolean - if ($dataProp['data']['data'] == false) { - $dataSection_Content .= pack('V', 0x0000); - } else { - $dataSection_Content .= pack('V', 0x0001); - } + $dataSection_Content .= pack('V', (int) $dataProp['data']['data']); $dataSection_Content_Offset += 4 + 4; } elseif ($dataProp['type']['data'] == 0x1E) { // null-terminated string prepended by dword string length // Null-terminated string @@ -725,12 +732,12 @@ private function writeDocumentSummaryInformation() $dataSection_Content .= $dataProp['data']['data']; $dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']); - } elseif ($dataProp['type']['data'] == 0x40) { // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) - $dataSection_Content .= $dataProp['data']['data']; + // Condition below can never be true + //} elseif ($dataProp['type']['data'] == 0x40) { // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) + // $dataSection_Content .= $dataProp['data']['data']; - $dataSection_Content_Offset += 4 + 8; + // $dataSection_Content_Offset += 4 + 8; } else { - // Data Type Not Used at the moment $dataSection_Content .= $dataProp['data']['data']; $dataSection_Content_Offset += 4 + $dataProp['data']['length']; @@ -752,6 +759,32 @@ private function writeDocumentSummaryInformation() return $data; } + private function writeSummaryPropOle(int $dataProp, int &$dataSection_NumProps, array &$dataSection, int $sumdata, int $typdata): void + { + if ($dataProp) { + $dataSection[] = [ + 'summary' => ['pack' => 'V', 'data' => $sumdata], + 'offset' => ['pack' => 'V'], + 'type' => ['pack' => 'V', 'data' => $typdata], // null-terminated string prepended by dword string length + 'data' => ['data' => OLE::localDateToOLE($dataProp)], + ]; + ++$dataSection_NumProps; + } + } + + private function writeSummaryProp(string $dataProp, int &$dataSection_NumProps, array &$dataSection, int $sumdata, int $typdata): void + { + if ($dataProp) { + $dataSection[] = [ + 'summary' => ['pack' => 'V', 'data' => $sumdata], + 'offset' => ['pack' => 'V'], + 'type' => ['pack' => 'V', 'data' => $typdata], // null-terminated string prepended by dword string length + 'data' => ['data' => $dataProp, 'length' => strlen($dataProp)], + ]; + ++$dataSection_NumProps; + } + } + /** * Build the OLE Part for Summary Information. * @@ -792,94 +825,16 @@ private function writeSummaryInformation() ]; ++$dataSection_NumProps; - // Title - if ($this->spreadsheet->getProperties()->getTitle()) { - $dataProp = $this->spreadsheet->getProperties()->getTitle(); - $dataSection[] = [ - 'summary' => ['pack' => 'V', 'data' => 0x02], - 'offset' => ['pack' => 'V'], - 'type' => ['pack' => 'V', 'data' => 0x1E], // null-terminated string prepended by dword string length - 'data' => ['data' => $dataProp, 'length' => strlen($dataProp)], - ]; - ++$dataSection_NumProps; - } - // Subject - if ($this->spreadsheet->getProperties()->getSubject()) { - $dataProp = $this->spreadsheet->getProperties()->getSubject(); - $dataSection[] = [ - 'summary' => ['pack' => 'V', 'data' => 0x03], - 'offset' => ['pack' => 'V'], - 'type' => ['pack' => 'V', 'data' => 0x1E], // null-terminated string prepended by dword string length - 'data' => ['data' => $dataProp, 'length' => strlen($dataProp)], - ]; - ++$dataSection_NumProps; - } - // Author (Creator) - if ($this->spreadsheet->getProperties()->getCreator()) { - $dataProp = $this->spreadsheet->getProperties()->getCreator(); - $dataSection[] = [ - 'summary' => ['pack' => 'V', 'data' => 0x04], - 'offset' => ['pack' => 'V'], - 'type' => ['pack' => 'V', 'data' => 0x1E], // null-terminated string prepended by dword string length - 'data' => ['data' => $dataProp, 'length' => strlen($dataProp)], - ]; - ++$dataSection_NumProps; - } - // Keywords - if ($this->spreadsheet->getProperties()->getKeywords()) { - $dataProp = $this->spreadsheet->getProperties()->getKeywords(); - $dataSection[] = [ - 'summary' => ['pack' => 'V', 'data' => 0x05], - 'offset' => ['pack' => 'V'], - 'type' => ['pack' => 'V', 'data' => 0x1E], // null-terminated string prepended by dword string length - 'data' => ['data' => $dataProp, 'length' => strlen($dataProp)], - ]; - ++$dataSection_NumProps; - } - // Comments (Description) - if ($this->spreadsheet->getProperties()->getDescription()) { - $dataProp = $this->spreadsheet->getProperties()->getDescription(); - $dataSection[] = [ - 'summary' => ['pack' => 'V', 'data' => 0x06], - 'offset' => ['pack' => 'V'], - 'type' => ['pack' => 'V', 'data' => 0x1E], // null-terminated string prepended by dword string length - 'data' => ['data' => $dataProp, 'length' => strlen($dataProp)], - ]; - ++$dataSection_NumProps; - } - // Last Saved By (LastModifiedBy) - if ($this->spreadsheet->getProperties()->getLastModifiedBy()) { - $dataProp = $this->spreadsheet->getProperties()->getLastModifiedBy(); - $dataSection[] = [ - 'summary' => ['pack' => 'V', 'data' => 0x08], - 'offset' => ['pack' => 'V'], - 'type' => ['pack' => 'V', 'data' => 0x1E], // null-terminated string prepended by dword string length - 'data' => ['data' => $dataProp, 'length' => strlen($dataProp)], - ]; - ++$dataSection_NumProps; - } - // Created Date/Time - if ($this->spreadsheet->getProperties()->getCreated()) { - $dataProp = $this->spreadsheet->getProperties()->getCreated(); - $dataSection[] = [ - 'summary' => ['pack' => 'V', 'data' => 0x0C], - 'offset' => ['pack' => 'V'], - 'type' => ['pack' => 'V', 'data' => 0x40], // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) - 'data' => ['data' => OLE::localDateToOLE($dataProp)], - ]; - ++$dataSection_NumProps; - } - // Modified Date/Time - if ($this->spreadsheet->getProperties()->getModified()) { - $dataProp = $this->spreadsheet->getProperties()->getModified(); - $dataSection[] = [ - 'summary' => ['pack' => 'V', 'data' => 0x0D], - 'offset' => ['pack' => 'V'], - 'type' => ['pack' => 'V', 'data' => 0x40], // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) - 'data' => ['data' => OLE::localDateToOLE($dataProp)], - ]; - ++$dataSection_NumProps; - } + $props = $this->spreadsheet->getProperties(); + $this->writeSummaryProp($props->getTitle(), $dataSection_NumProps, $dataSection, 0x02, 0x1e); + $this->writeSummaryProp($props->getSubject(), $dataSection_NumProps, $dataSection, 0x03, 0x1e); + $this->writeSummaryProp($props->getCreator(), $dataSection_NumProps, $dataSection, 0x04, 0x1e); + $this->writeSummaryProp($props->getKeywords(), $dataSection_NumProps, $dataSection, 0x05, 0x1e); + $this->writeSummaryProp($props->getDescription(), $dataSection_NumProps, $dataSection, 0x06, 0x1e); + $this->writeSummaryProp($props->getLastModifiedBy(), $dataSection_NumProps, $dataSection, 0x08, 0x1e); + $this->writeSummaryPropOle($props->getCreated(), $dataSection_NumProps, $dataSection, 0x0c, 0x40); + $this->writeSummaryPropOle($props->getModified(), $dataSection_NumProps, $dataSection, 0x0d, 0x40); + // Security $dataSection[] = [ 'summary' => ['pack' => 'V', 'data' => 0x13], diff --git a/tests/PhpSpreadsheetTests/Writer/Xls/XlsGifBmpTest.php b/tests/PhpSpreadsheetTests/Writer/Xls/XlsGifBmpTest.php new file mode 100644 index 0000000000..ceba7e54a1 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Xls/XlsGifBmpTest.php @@ -0,0 +1,84 @@ +filename) { + unlink($this->filename); + } + $this->filename = ''; + } + + public function testBmp(): void + { + $pgmstart = time(); + $spreadsheet = new Spreadsheet(); + $filstart = $spreadsheet->getProperties()->getModified(); + self::assertLessThanOrEqual($filstart, $pgmstart); + + // Add a drawing to the worksheet + $drawing = new Drawing(); + $drawing->setName('Letters B, M, and P'); + $drawing->setDescription('Handwritten B, M, and P'); + $drawing->setPath(__DIR__ . '/../../../../samples/images/bmp.bmp'); + $drawing->setHeight(36); + $drawing->setWorksheet($spreadsheet->getActiveSheet()); + $drawing->setCoordinates('A1'); + + $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, 'Xls'); + $creationDatestamp = $reloadedSpreadsheet->getProperties()->getCreated(); + $filstart = $creationDatestamp; + $pSheet = $reloadedSpreadsheet->getActiveSheet(); + $drawings = $pSheet->getDrawingCollection(); + self::assertCount(1, $drawings); + foreach ($pSheet->getDrawingCollection() as $drawing) { + // See if Scrutinizer approves this + $mimeType = ($drawing instanceof MemoryDrawing) ? $drawing->getMimeType() : 'notmemorydrawing'; + self::assertEquals('image/png', $mimeType); + } + $pgmend = time(); + + self::assertLessThanOrEqual($pgmend, $pgmstart); + self::assertLessThanOrEqual($pgmend, $filstart); + self::assertLessThanOrEqual($filstart, $pgmstart); + } + + public function testGif(): void + { + $spreadsheet = new Spreadsheet(); + + // Add a drawing to the worksheet + $drawing = new Drawing(); + $drawing->setName('Letters G, I, and G'); + $drawing->setDescription('Handwritten G, I, and F'); + $drawing->setPath(__DIR__ . '/../../../../samples/images/gif.gif'); + $drawing->setHeight(36); + $drawing->setWorksheet($spreadsheet->getActiveSheet()); + $drawing->setCoordinates('A1'); + + $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, 'Xls'); + $pSheet = $reloadedSpreadsheet->getActiveSheet(); + $drawings = $pSheet->getDrawingCollection(); + self::assertCount(1, $drawings); + foreach ($pSheet->getDrawingCollection() as $drawing) { + $mimeType = ($drawing instanceof MemoryDrawing) ? $drawing->getMimeType() : 'notmemorydrawing'; + self::assertEquals('image/png', $mimeType); + } + } + + public function testInvalidTimestamp(): void + { + $this->expectException(\PhpOffice\PhpSpreadsheet\Reader\Exception::class); + \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE2LocalDate(' '); + } +} From c04d0185d969814cf792180b49b0a156d249e041 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Fri, 19 Jun 2020 22:11:07 +0200 Subject: [PATCH 099/659] Updates to changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11a8b2ffb6..1b89e71a6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Fix HLOOKUP on single row [#1512](https://github.com/PHPOffice/PhpSpreadsheet/pull/1512) - Fix MATCH when comparing different numeric types [#1521](https://github.com/PHPOffice/PhpSpreadsheet/pull/1521) - Fix exact MATCH on ranges with empty cells [#1520](https://github.com/PHPOffice/PhpSpreadsheet/pull/1520) +- Fix for Issue [#1516](https://github.com/PHPOffice/PhpSpreadsheet/issues/1516) (Cloning worksheet makes corrupted Xlsx) [#1530](https://github.com/PHPOffice/PhpSpreadsheet/pull/1530) +- Fix For Issue [#1509](https://github.com/PHPOffice/PhpSpreadsheet/issues/1509) (Can not set empty enclosure for CSV) [#1518](https://github.com/PHPOffice/PhpSpreadsheet/pull/1518) +- Fix for Issue [#1505](https://github.com/PHPOffice/PhpSpreadsheet/issues/1505) (TypeError : Argument 4 passed to PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet::writeAttributeIf() must be of the type string) [#1525](https://github.com/PHPOffice/PhpSpreadsheet/pull/1525) +- Fix for Issue [#1495](https://github.com/PHPOffice/PhpSpreadsheet/issues/1495) (Sheet index being changed when multiple sheets are used in formula) [#1500]((https://github.com/PHPOffice/PhpSpreadsheet/pull/1500)) +- Fix for Issue [#1533](https://github.com/PHPOffice/PhpSpreadsheet/issues/1533) (A reference to a cell containing a string starting with "#" leads to errors in the generated xlsx.) [#1534]((https://github.com/PHPOffice/PhpSpreadsheet/pull/1534) +- Xls Writer - Correct Timestamp Bug [#1493](https://github.com/PHPOffice/PhpSpreadsheet/pull/1493) ## [1.13.0] - 2020-05-31 From acd2ba01dfeac09e5e2b03d62c3175b36e05fe54 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Fri, 19 Jun 2020 22:38:31 +0200 Subject: [PATCH 100/659] Updates to changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b89e71a6a..061b1ff81c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Fix For Issue [#1509](https://github.com/PHPOffice/PhpSpreadsheet/issues/1509) (Can not set empty enclosure for CSV) [#1518](https://github.com/PHPOffice/PhpSpreadsheet/pull/1518) - Fix for Issue [#1505](https://github.com/PHPOffice/PhpSpreadsheet/issues/1505) (TypeError : Argument 4 passed to PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet::writeAttributeIf() must be of the type string) [#1525](https://github.com/PHPOffice/PhpSpreadsheet/pull/1525) - Fix for Issue [#1495](https://github.com/PHPOffice/PhpSpreadsheet/issues/1495) (Sheet index being changed when multiple sheets are used in formula) [#1500]((https://github.com/PHPOffice/PhpSpreadsheet/pull/1500)) -- Fix for Issue [#1533](https://github.com/PHPOffice/PhpSpreadsheet/issues/1533) (A reference to a cell containing a string starting with "#" leads to errors in the generated xlsx.) [#1534]((https://github.com/PHPOffice/PhpSpreadsheet/pull/1534) +- Fix for Issue [#1533](https://github.com/PHPOffice/PhpSpreadsheet/issues/1533) (A reference to a cell containing a string starting with "#" leads to errors in the generated xlsx.) [#1534](https://github.com/PHPOffice/PhpSpreadsheet/pull/1534) - Xls Writer - Correct Timestamp Bug [#1493](https://github.com/PHPOffice/PhpSpreadsheet/pull/1493) ## [1.13.0] - 2020-05-31 From ca506ba87f0cc06a127a25d694e6408c6acfe20b Mon Sep 17 00:00:00 2001 From: Christoph Ziegenberg Date: Sat, 20 Jun 2020 17:15:38 +0200 Subject: [PATCH 101/659] Corrected date time detection (#1492) * Corrected date time detection German and Swiss ZIP codes (special formats provided in German Excel versions) were detected as date time value, because the regular expression for date time formats falsely matched their formats ("\C\H\-00000" and "\D-00000"). --- src/PhpSpreadsheet/Shared/Date.php | 5 +++++ tests/data/Shared/Date/FormatCodes.php | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index 9dc9929269..cb37515da4 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -387,6 +387,11 @@ public static function isDateTimeFormatCode($pFormatCode) if ((substr($pFormatCode, 0, 1) == '_') || (substr($pFormatCode, 0, 2) == '0 ')) { return false; } + // Some "special formats" provided in German Excel versions were detected as date time value, + // so filter them out here - "\C\H\-00000" (Switzerland) and "\D-00000" (Germany). + if (\strpos($pFormatCode, '-00000') !== false) { + return false; + } // Try checking for any of the date formatting characters that don't appear within square braces if (preg_match('/(^|\])[^\[]*[' . self::$possibleDateFormatCharacters . ']/i', $pFormatCode)) { // We might also have a format mask containing quoted strings... diff --git a/tests/data/Shared/Date/FormatCodes.php b/tests/data/Shared/Date/FormatCodes.php index 64810de3a6..b558874c52 100644 --- a/tests/data/Shared/Date/FormatCodes.php +++ b/tests/data/Shared/Date/FormatCodes.php @@ -150,4 +150,12 @@ true, '"date " y-m-d', ], + [ + false, + '\C\H\-00000', + ], + [ + false, + '\D-00000', + ], ]; From 859bef1901d072d771efadf521e9d75f427cd852 Mon Sep 17 00:00:00 2001 From: Dawid Warmuz Date: Sat, 20 Jun 2020 18:21:19 +0200 Subject: [PATCH 102/659] Add support for IFS() logical function (#1442) * Add support for IFS() logical function * Use Exception as false value in IFS logical function, so it never collides with string in spreadsheet --- docs/references/function-list-by-category.md | 2 +- docs/references/function-list-by-name.md | 2 +- .../Calculation/Calculation.php | 2 +- src/PhpSpreadsheet/Calculation/Logical.php | 35 +++++++++++++ .../Calculation/functionlist.txt | 1 + .../Calculation/Functions/Logical/IfsTest.php | 32 ++++++++++++ tests/data/Calculation/Logical/IFS.php | 50 +++++++++++++++++++ 7 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php create mode 100644 tests/data/Calculation/Logical/IFS.php diff --git a/docs/references/function-list-by-category.md b/docs/references/function-list-by-category.md index 49bb66c0ed..3cc1c2b8bc 100644 --- a/docs/references/function-list-by-category.md +++ b/docs/references/function-list-by-category.md @@ -213,7 +213,7 @@ FALSE | \PhpOffice\PhpSpreadsheet\Calculation\Logical::FALSE IF | \PhpOffice\PhpSpreadsheet\Calculation\Logical::statementIf IFERROR | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFERROR IFNA | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFNA -IFS | **Not yet Implemented** +IFS | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFS NOT | \PhpOffice\PhpSpreadsheet\Calculation\Logical::NOT OR | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalOr SWITCH | \PhpOffice\PhpSpreadsheet\Calculation\Logical::statementSwitch diff --git a/docs/references/function-list-by-name.md b/docs/references/function-list-by-name.md index f5493d039c..c787ee0095 100644 --- a/docs/references/function-list-by-name.md +++ b/docs/references/function-list-by-name.md @@ -212,7 +212,7 @@ Excel Function | Category | PhpSpreadsheet Function IF | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::statementIf IFERROR | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFERROR IFNA | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFNA -IFS | CATEGORY_LOGICAL | **Not yet Implemented** +IFS | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFS IMABS | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMABS IMAGINARY | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMAGINARY IMARGUMENT | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMARGUMENT diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 848f9068f9..e65cd42511 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -1059,7 +1059,7 @@ class Calculation ], 'IFS' => [ 'category' => Category::CATEGORY_LOGICAL, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Logical::class, 'IFS'], 'argumentCount' => '2+', ], 'IMABS' => [ diff --git a/src/PhpSpreadsheet/Calculation/Logical.php b/src/PhpSpreadsheet/Calculation/Logical.php index a362a27533..69c543cef9 100644 --- a/src/PhpSpreadsheet/Calculation/Logical.php +++ b/src/PhpSpreadsheet/Calculation/Logical.php @@ -352,4 +352,39 @@ public static function IFNA($testValue = '', $napart = '') return self::statementIf(Functions::isNa($testValue), $napart, $testValue); } + + /** + * IFS. + * + * Excel Function: + * =IFS(testValue1;returnIfTrue1;testValue2;returnIfTrue2;...;testValue_n;returnIfTrue_n) + * + * testValue1 ... testValue_n + * Conditions to Evaluate + * returnIfTrue1 ... returnIfTrue_n + * Value returned if corresponding testValue (nth) was true + * + * @param mixed ...$arguments Statement arguments + * + * @return mixed|string The value of returnIfTrue_n, if testValue_n was true. #N/A if none of testValues was true + */ + public static function IFS(...$arguments) + { + if (count($arguments) % 2 != 0) { + return Functions::NA(); + } + // We use instance of Exception as a falseValue in order to prevent string collision with value in cell + $falseValueException = new Exception(); + for ($i = 0; $i < count($arguments); $i += 2) { + $testValue = ($arguments[$i] === null) ? '' : Functions::flattenSingleValue($arguments[$i]); + $returnIfTrue = ($arguments[$i + 1] === null) ? '' : Functions::flattenSingleValue($arguments[$i + 1]); + $result = self::statementIf($testValue, $returnIfTrue, $falseValueException); + + if ($result !== $falseValueException) { + return $result; + } + } + + return Functions::NA(); + } } diff --git a/src/PhpSpreadsheet/Calculation/functionlist.txt b/src/PhpSpreadsheet/Calculation/functionlist.txt index 2556ec9028..e71d18f454 100644 --- a/src/PhpSpreadsheet/Calculation/functionlist.txt +++ b/src/PhpSpreadsheet/Calculation/functionlist.txt @@ -163,6 +163,7 @@ HYPERLINK HYPGEOMDIST IF IFERROR +IFS IMABS IMAGINARY IMARGUMENT diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php new file mode 100644 index 0000000000..15687cd6a5 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php @@ -0,0 +1,32 @@ + Date: Sat, 20 Jun 2020 20:27:17 +0200 Subject: [PATCH 103/659] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 061b1ff81c..02179db6fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Fix for Issue [#1533](https://github.com/PHPOffice/PhpSpreadsheet/issues/1533) (A reference to a cell containing a string starting with "#" leads to errors in the generated xlsx.) [#1534](https://github.com/PHPOffice/PhpSpreadsheet/pull/1534) - Xls Writer - Correct Timestamp Bug [#1493](https://github.com/PHPOffice/PhpSpreadsheet/pull/1493) +### Added +- Add support for IFS() logical function [#1442](https://github.com/PHPOffice/PhpSpreadsheet/pull/1442) + ## [1.13.0] - 2020-05-31 ### Added From 10a4a95d678d674a612c9126f912acab2013f294 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sun, 21 Jun 2020 14:41:51 +0200 Subject: [PATCH 104/659] Handle Ranges formatted as 3-d ranges, as long as the references are both to the same worksheet (#1540) --- src/PhpSpreadsheet/Calculation/Calculation.php | 14 +++++++++----- .../Calculation/Engine/RangeTest.php | 11 +++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index e65cd42511..ed630354dd 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -3666,13 +3666,17 @@ private function _parseFormula($formula, ?Cell $pCell = null) if ($matches[2] == '') { // Otherwise, we 'inherit' the worksheet reference from the start cell reference // The start of the cell range reference should be the last entry in $output - $startCellRef = $output[count($output) - 1]['value']; - preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $startCellRef, $startMatches); - if ($startMatches[2] > '') { - $val = $startMatches[2] . '!' . $val; + $rangeStartCellRef = $output[count($output) - 1]['value']; + preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $rangeStartCellRef, $rangeStartMatches); + if ($rangeStartMatches[2] > '') { + $val = $rangeStartMatches[2] . '!' . $val; } } else { - return $this->raiseFormulaError('3D Range references are not yet supported'); + $rangeStartCellRef = $output[count($output) - 1]['value']; + preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $rangeStartCellRef, $rangeStartMatches); + if ($rangeStartMatches[2] !== $matches[2]) { + return $this->raiseFormulaError('3D Range references are not yet supported'); + } } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php index e2e6e11d23..9dfa4bf00a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php @@ -60,9 +60,20 @@ public function providerRangeEvaluation() ['=COUNT(A1:C1,A3:C3,B1:C3)', 12], ['=SUM(A1:C1,A3:C3 B1:C3)', 23], ['=COUNT(A1:C1,A3:C3 B1:C3)', 5], + ['=SUM(Worksheet!A1:B3,Worksheet!A1:C2)', 48], + ['=SUM(Worksheet!A1:Worksheet!B3,Worksheet!A1:Worksheet!C2)', 48], ]; } + public function test3dRangeEvaluation(): void + { + $workSheet = $this->spreadSheet->getActiveSheet(); + $workSheet->setCellValue('E1', '=SUM(Worksheet!A1:Worksheet2!B3)'); + + $this->expectExceptionMessage('3D Range references are not yet supported'); + $workSheet->getCell('E1')->getCalculatedValue(); + } + /** * @dataProvider providerNamedRangeEvaluation * From 6080c4561d69caafb71c1799b0ea77e04ad856fe Mon Sep 17 00:00:00 2001 From: Owen Leibman Date: Thu, 25 Jun 2020 22:42:38 -0700 Subject: [PATCH 105/659] Improve Coverage for HTML Reader Reader/Html is now covered except for 1 statement. There is some coverage of RichText when you know in advance that the html will expand into a single cell. It is a tougher nut, one that I have not yet cracked, to try to handle rich text while converting unkown html to multiple cells. The original author left this as a TODO, and so for now must I. It made sense to restructure some of the code. There are some changes. - Issue #1532 is fixed (links are now saved when using rowspan). - Colors can now be specified as html color name. To accomplish this, Helper/Html function colourNameLookup was changed from protected to public, and changed to static. - Superfluous empty lines were eliminated in a number of places, e.g.
  • A
  • B
  • C
had formerly caused a wrapped cell to be created with 2 empty lines followed by A, B, and C on separate lines; it will now just have the 3 A/B/C lines, which seems like a more sensible interpretation. - Img alt tag, which had been cast to float, is now used as a string. Private member "encoding" is not used. Functions getEncoding and setEncoding have therefore been marked deprecated. In fact, I was unable to get SecurityScanner to pass *any* html which is not UTF-8. There are possibly ways of getting around this (in Reader/Html - I have no intention of messing with Security Scanner), as can be seen in my companion pull request for Excel2003 Xml Reader. Doing this would be easier for ASCII-compatible character sets (like ISO-8859-1), than for non-compatible charsets (like UTF-16). I am not convinced that the effort is worth it, but am willing to investigate further. I added a number of tests, creating an Html directory, and moving HtmlTest to that directory. --- samples/Basic/42_RichText.php | 2 +- src/PhpSpreadsheet/Helper/Html.php | 4 +- src/PhpSpreadsheet/Reader/BaseReader.php | 23 +- src/PhpSpreadsheet/Reader/Html.php | 615 ++++++++++-------- .../Reader/Html/HtmlBorderTest.php | 110 ++++ .../Reader/Html/HtmlHelper.php | 28 + .../Reader/Html/HtmlImageTest.php | 84 +++ .../Reader/Html/HtmlLoadStringTest.php | 92 +++ .../Reader/Html/HtmlTagsTest.php | 236 +++++++ .../Reader/{ => Html}/HtmlTest.php | 251 ++----- tests/data/Reader/HTML/badhtml.html | 1 + 11 files changed, 955 insertions(+), 491 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/Reader/Html/HtmlBorderTest.php create mode 100644 tests/PhpSpreadsheetTests/Reader/Html/HtmlHelper.php create mode 100644 tests/PhpSpreadsheetTests/Reader/Html/HtmlImageTest.php create mode 100644 tests/PhpSpreadsheetTests/Reader/Html/HtmlLoadStringTest.php create mode 100644 tests/PhpSpreadsheetTests/Reader/Html/HtmlTagsTest.php rename tests/PhpSpreadsheetTests/Reader/{ => Html}/HtmlTest.php (53%) create mode 100644 tests/data/Reader/HTML/badhtml.html diff --git a/samples/Basic/42_RichText.php b/samples/Basic/42_RichText.php index 43b35a62c1..d5fa85b4a7 100644 --- a/samples/Basic/42_RichText.php +++ b/samples/Basic/42_RichText.php @@ -30,7 +30,7 @@ while this block uses an underline.

-

+

I want to eat healthy food pizza. '; diff --git a/src/PhpSpreadsheet/Helper/Html.php b/src/PhpSpreadsheet/Helper/Html.php index 252e14a51d..6c4cbf9bbb 100644 --- a/src/PhpSpreadsheet/Helper/Html.php +++ b/src/PhpSpreadsheet/Helper/Html.php @@ -694,9 +694,9 @@ protected function rgbToColour($rgb) return implode('', $values[0]); } - protected function colourNameLookup($rgb) + public static function colourNameLookup(string $rgb): string { - return self::$colourMap[$rgb]; + return self::$colourMap[$rgb] ?? ''; } protected function startFontTag($tag): void diff --git a/src/PhpSpreadsheet/Reader/BaseReader.php b/src/PhpSpreadsheet/Reader/BaseReader.php index 77a6421b9c..eb0e3ba223 100644 --- a/src/PhpSpreadsheet/Reader/BaseReader.php +++ b/src/PhpSpreadsheet/Reader/BaseReader.php @@ -2,6 +2,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader; +use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException; use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner; use PhpOffice\PhpSpreadsheet\Shared\File; @@ -133,11 +134,7 @@ public function setReadFilter(IReadFilter $pValue) public function getSecurityScanner() { - if (property_exists($this, 'securityScanner')) { - return $this->securityScanner; - } - - return null; + return $this->securityScanner; } /** @@ -147,12 +144,18 @@ public function getSecurityScanner() */ protected function openFile($pFilename): void { - File::assertFile($pFilename); + if ($pFilename) { + File::assertFile($pFilename); - // Open file - $this->fileHandle = fopen($pFilename, 'rb'); - if ($this->fileHandle === false) { - throw new Exception('Could not open file ' . $pFilename . ' for reading.'); + // Open file + $fileHandle = fopen($pFilename, 'rb'); + } else { + $fileHandle = false; + } + if ($fileHandle !== false) { + $this->fileHandle = $fileHandle; + } else { + throw new ReaderException('Could not open file ' . $pFilename . ' for reading.'); } } } diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 2fe85b6f32..7cb14f49c6 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -16,6 +16,7 @@ use PhpOffice\PhpSpreadsheet\Style\Style; use PhpOffice\PhpSpreadsheet\Worksheet\Drawing; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; +use Throwable; /** PhpSpreadsheet root directory */ class Html extends BaseReader @@ -219,9 +220,13 @@ public function load($pFilename) /** * Set input encoding. * + * @deprecated no use is made of this property + * * @param string $pValue Input encoding, eg: 'ANSI' * * @return $this + * + * @codeCoverageIgnore */ public function setInputEncoding($pValue) { @@ -233,7 +238,11 @@ public function setInputEncoding($pValue) /** * Get input encoding. * + * @deprecated no use is made of this property + * * @return string + * + * @codeCoverageIgnore */ public function getInputEncoding() { @@ -289,284 +298,331 @@ protected function flushCell(Worksheet $sheet, $column, $row, &$cellContent): vo $cellContent = (string) ''; } - /** - * @param int $row - * @param string $column - * @param string $cellContent - */ - protected function processDomElement(DOMNode $element, Worksheet $sheet, &$row, &$column, &$cellContent): void + private function processDomElementBody(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child): void { - foreach ($element->childNodes as $child) { - if ($child instanceof DOMText) { - $domText = preg_replace('/\s+/u', ' ', trim($child->nodeValue)); - if (is_string($cellContent)) { - // simply append the text if the cell content is a plain text string - $cellContent .= $domText; - } - // but if we have a rich text run instead, we need to append it correctly - // TODO - } elseif ($child instanceof DOMElement) { - $attributeArray = []; - foreach ($child->attributes as $attribute) { - $attributeArray[$attribute->name] = $attribute->value; - } + $attributeArray = []; + foreach ($child->attributes as $attribute) { + $attributeArray[$attribute->name] = $attribute->value; + } - switch ($child->nodeName) { - case 'meta': - foreach ($attributeArray as $attributeName => $attributeValue) { - // Extract character set, so we can convert to UTF-8 if required - if ($attributeName === 'charset') { - $this->setInputEncoding($attributeValue); - } - } - $this->processDomElement($child, $sheet, $row, $column, $cellContent); + if ($child->nodeName === 'body') { + $row = 1; + $column = 'A'; + $cellContent = ''; + $this->tableLevel = 0; + $this->processDomElement($child, $sheet, $row, $column, $cellContent); + } else { + $this->processDomElementTitle($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + } + } - break; - case 'title': - $this->processDomElement($child, $sheet, $row, $column, $cellContent); - $sheet->setTitle($cellContent, true, false); - $cellContent = ''; + private function processDomElementTitle(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + { + if ($child->nodeName === 'title') { + $this->processDomElement($child, $sheet, $row, $column, $cellContent); + $sheet->setTitle($cellContent, true, false); + $cellContent = ''; + } else { + $this->processDomElementSpanEtc($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + } + } - break; - case 'span': - case 'div': - case 'font': - case 'i': - case 'em': - case 'strong': - case 'b': - if (isset($attributeArray['class']) && $attributeArray['class'] === 'comment') { - $sheet->getComment($column . $row) - ->getText() - ->createTextRun($child->textContent); + private static $spanEtc = ['span', 'div', 'font', 'i', 'em', 'strong', 'b']; - break; - } + private function processDomElementSpanEtc(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + { + if (in_array($child->nodeName, self::$spanEtc)) { + if (isset($attributeArray['class']) && $attributeArray['class'] === 'comment') { + $sheet->getComment($column . $row) + ->getText() + ->createTextRun($child->textContent); + } + $this->processDomElement($child, $sheet, $row, $column, $cellContent); - if ($cellContent > '') { - $cellContent .= ' '; - } - $this->processDomElement($child, $sheet, $row, $column, $cellContent); - if ($cellContent > '') { - $cellContent .= ' '; - } + if (isset($this->formats[$child->nodeName])) { + $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); + } + } else { + $this->processDomElementHr($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + } + } - if (isset($this->formats[$child->nodeName])) { - $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); - } + private function processDomElementHr(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + { + if ($child->nodeName === 'hr') { + $this->flushCell($sheet, $column, $row, $cellContent); + ++$row; + if (isset($this->formats[$child->nodeName])) { + $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); + } + ++$row; + } + // fall through to br + $this->processDomElementBr($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + } - break; - case 'hr': - $this->flushCell($sheet, $column, $row, $cellContent); - ++$row; + private function processDomElementBr(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + { + if ($child->nodeName === 'br' || $child->nodeName === 'hr') { + if ($this->tableLevel > 0) { + // If we're inside a table, replace with a \n and set the cell to wrap + $cellContent .= "\n"; + $sheet->getStyle($column . $row)->getAlignment()->setWrapText(true); + } else { + // Otherwise flush our existing content and move the row cursor on + $this->flushCell($sheet, $column, $row, $cellContent); + ++$row; + } + } else { + $this->processDomElementA($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + } + } + + private function processDomElementA(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + { + if ($child->nodeName === 'a') { + foreach ($attributeArray as $attributeName => $attributeValue) { + switch ($attributeName) { + case 'href': + $sheet->getCell($column . $row)->getHyperlink()->setUrl($attributeValue); if (isset($this->formats[$child->nodeName])) { $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); - } else { - $cellContent = '----------'; - $this->flushCell($sheet, $column, $row, $cellContent); - } - ++$row; - // Add a break after a horizontal rule, simply by allowing the code to dropthru - // no break - case 'br': - if ($this->tableLevel > 0) { - // If we're inside a table, replace with a \n and set the cell to wrap - $cellContent .= "\n"; - $sheet->getStyle($column . $row)->getAlignment()->setWrapText(true); - } else { - // Otherwise flush our existing content and move the row cursor on - $this->flushCell($sheet, $column, $row, $cellContent); - ++$row; } break; - case 'a': - foreach ($attributeArray as $attributeName => $attributeValue) { - switch ($attributeName) { - case 'href': - $sheet->getCell($column . $row)->getHyperlink()->setUrl($attributeValue); - if (isset($this->formats[$child->nodeName])) { - $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); - } - - break; - case 'class': - if ($attributeValue === 'comment-indicator') { - break; // Ignore - it's just a red square. - } - } + case 'class': + if ($attributeValue === 'comment-indicator') { + break; // Ignore - it's just a red square. } - $cellContent .= ' '; - $this->processDomElement($child, $sheet, $row, $column, $cellContent); + } + } + // no idea why this should be needed + //$cellContent .= ' '; + $this->processDomElement($child, $sheet, $row, $column, $cellContent); + } else { + $this->processDomElementH1Etc($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + } + } - break; - case 'h1': - case 'h2': - case 'h3': - case 'h4': - case 'h5': - case 'h6': - case 'ol': - case 'ul': - case 'p': - if ($this->tableLevel > 0) { - // If we're inside a table, replace with a \n - $cellContent .= "\n"; - $this->processDomElement($child, $sheet, $row, $column, $cellContent); - } else { - if ($cellContent > '') { - $this->flushCell($sheet, $column, $row, $cellContent); - ++$row; - } - $this->processDomElement($child, $sheet, $row, $column, $cellContent); - $this->flushCell($sheet, $column, $row, $cellContent); - - if (isset($this->formats[$child->nodeName])) { - $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); - } - - ++$row; - $column = 'A'; - } + private static $h1Etc = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul', 'p']; - break; - case 'li': - if ($this->tableLevel > 0) { - // If we're inside a table, replace with a \n - $cellContent .= "\n"; - $this->processDomElement($child, $sheet, $row, $column, $cellContent); - } else { - if ($cellContent > '') { - $this->flushCell($sheet, $column, $row, $cellContent); - } - ++$row; - $this->processDomElement($child, $sheet, $row, $column, $cellContent); - $this->flushCell($sheet, $column, $row, $cellContent); - $column = 'A'; - } + private function processDomElementH1Etc(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + { + if (in_array($child->nodeName, self::$h1Etc)) { + if ($this->tableLevel > 0) { + // If we're inside a table, replace with a \n + $cellContent .= $cellContent ? "\n" : ''; + $sheet->getStyle($column . $row)->getAlignment()->setWrapText(true); + $this->processDomElement($child, $sheet, $row, $column, $cellContent); + } else { + if ($cellContent > '') { + $this->flushCell($sheet, $column, $row, $cellContent); + ++$row; + } + $this->processDomElement($child, $sheet, $row, $column, $cellContent); + $this->flushCell($sheet, $column, $row, $cellContent); - break; - case 'img': - $this->insertImage($sheet, $column, $row, $attributeArray); + if (isset($this->formats[$child->nodeName])) { + $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); + } - break; - case 'table': - $this->flushCell($sheet, $column, $row, $cellContent); - $column = $this->setTableStartColumn($column); - if ($this->tableLevel > 1) { - --$row; - } - $this->processDomElement($child, $sheet, $row, $column, $cellContent); - $column = $this->releaseTableStartColumn(); - if ($this->tableLevel > 1) { - ++$column; - } else { - ++$row; - } + ++$row; + $column = 'A'; + } + } else { + $this->processDomElementLi($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + } + } - break; - case 'thead': - case 'tbody': - $this->processDomElement($child, $sheet, $row, $column, $cellContent); + private function processDomElementLi(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + { + if ($child->nodeName === 'li') { + if ($this->tableLevel > 0) { + // If we're inside a table, replace with a \n + $cellContent .= $cellContent ? "\n" : ''; + $this->processDomElement($child, $sheet, $row, $column, $cellContent); + } else { + if ($cellContent > '') { + $this->flushCell($sheet, $column, $row, $cellContent); + } + ++$row; + $this->processDomElement($child, $sheet, $row, $column, $cellContent); + $this->flushCell($sheet, $column, $row, $cellContent); + $column = 'A'; + } + } else { + $this->processDomElementImg($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + } + } - break; - case 'tr': - $column = $this->getTableStartColumn(); - $cellContent = ''; - $this->processDomElement($child, $sheet, $row, $column, $cellContent); + private function processDomElementImg(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + { + if ($child->nodeName === 'img') { + $this->insertImage($sheet, $column, $row, $attributeArray); + } else { + $this->processDomElementTable($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + } + } - if (isset($attributeArray['height'])) { - $sheet->getRowDimension($row)->setRowHeight($attributeArray['height']); - } + private function processDomElementTable(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + { + if ($child->nodeName === 'table') { + $this->flushCell($sheet, $column, $row, $cellContent); + $column = $this->setTableStartColumn($column); + if ($this->tableLevel > 1) { + --$row; + } + $this->processDomElement($child, $sheet, $row, $column, $cellContent); + $column = $this->releaseTableStartColumn(); + if ($this->tableLevel > 1) { + ++$column; + } else { + ++$row; + } + } else { + $this->processDomElementTr($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + } + } - ++$row; + private function processDomElementTr(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + { + if ($child->nodeName === 'tr') { + $column = $this->getTableStartColumn(); + $cellContent = ''; + $this->processDomElement($child, $sheet, $row, $column, $cellContent); - break; - case 'th': - case 'td': - $this->processDomElement($child, $sheet, $row, $column, $cellContent); + if (isset($attributeArray['height'])) { + $sheet->getRowDimension($row)->setRowHeight($attributeArray['height']); + } - while (isset($this->rowspan[$column . $row])) { - ++$column; - } + ++$row; + } else { + $this->processDomElementThTdOther($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + } + } - // apply inline style - $this->applyInlineStyle($sheet, $row, $column, $attributeArray); - - $this->flushCell($sheet, $column, $row, $cellContent); - - if (isset($attributeArray['rowspan'], $attributeArray['colspan'])) { - //create merging rowspan and colspan - $columnTo = $column; - for ($i = 0; $i < (int) $attributeArray['colspan'] - 1; ++$i) { - ++$columnTo; - } - $range = $column . $row . ':' . $columnTo . ($row + (int) $attributeArray['rowspan'] - 1); - foreach (Coordinate::extractAllCellReferencesInRange($range) as $value) { - $this->rowspan[$value] = true; - } - $sheet->mergeCells($range); - $column = $columnTo; - } elseif (isset($attributeArray['rowspan'])) { - //create merging rowspan - $range = $column . $row . ':' . $column . ($row + (int) $attributeArray['rowspan'] - 1); - foreach (Coordinate::extractAllCellReferencesInRange($range) as $value) { - $this->rowspan[$value] = true; - } - $sheet->mergeCells($range); - } elseif (isset($attributeArray['colspan'])) { - //create merging colspan - $columnTo = $column; - for ($i = 0; $i < (int) $attributeArray['colspan'] - 1; ++$i) { - ++$columnTo; - } - $sheet->mergeCells($column . $row . ':' . $columnTo . $row); - $column = $columnTo; - } elseif (isset($attributeArray['bgcolor'])) { - $sheet->getStyle($column . $row)->applyFromArray( - [ - 'fill' => [ - 'fillType' => Fill::FILL_SOLID, - 'color' => ['rgb' => $attributeArray['bgcolor']], - ], - ] - ); - } + private function processDomElementThTdOther(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + { + if ($child->nodeName !== 'td' && $child->nodeName !== 'th') { + $this->processDomElement($child, $sheet, $row, $column, $cellContent); + } else { + $this->processDomElementThTd($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + } + } - if (isset($attributeArray['width'])) { - $sheet->getColumnDimension($column)->setWidth($attributeArray['width']); - } + private function processDomElementBgcolor(Worksheet $sheet, int $row, string $column, array $attributeArray): void + { + if (isset($attributeArray['bgcolor'])) { + $sheet->getStyle("$column$row")->applyFromArray( + [ + 'fill' => [ + 'fillType' => Fill::FILL_SOLID, + 'color' => ['rgb' => $this->getStyleColor($attributeArray['bgcolor'])], + ], + ] + ); + } + } - if (isset($attributeArray['height'])) { - $sheet->getRowDimension($row)->setRowHeight($attributeArray['height']); - } + private function processDomElementWidth(Worksheet $sheet, string $column, array $attributeArray): void + { + if (isset($attributeArray['width'])) { + $sheet->getColumnDimension($column)->setWidth($attributeArray['width']); + } + } - if (isset($attributeArray['align'])) { - $sheet->getStyle($column . $row)->getAlignment()->setHorizontal($attributeArray['align']); - } + private function processDomElementHeight(Worksheet $sheet, int $row, array $attributeArray): void + { + if (isset($attributeArray['height'])) { + $sheet->getRowDimension($row)->setRowHeight($attributeArray['height']); + } + } - if (isset($attributeArray['valign'])) { - $sheet->getStyle($column . $row)->getAlignment()->setVertical($attributeArray['valign']); - } + private function processDomElementAlign(Worksheet $sheet, int $row, string $column, array $attributeArray): void + { + if (isset($attributeArray['align'])) { + $sheet->getStyle($column . $row)->getAlignment()->setHorizontal($attributeArray['align']); + } + } - if (isset($attributeArray['data-format'])) { - $sheet->getStyle($column . $row)->getNumberFormat()->setFormatCode($attributeArray['data-format']); - } + private function processDomElementVAlign(Worksheet $sheet, int $row, string $column, array $attributeArray): void + { + if (isset($attributeArray['valign'])) { + $sheet->getStyle($column . $row)->getAlignment()->setVertical($attributeArray['valign']); + } + } - ++$column; + private function processDomElementDataFormat(Worksheet $sheet, int $row, string $column, array $attributeArray): void + { + if (isset($attributeArray['data-format'])) { + $sheet->getStyle($column . $row)->getNumberFormat()->setFormatCode($attributeArray['data-format']); + } + } - break; - case 'body': - $row = 1; - $column = 'A'; - $cellContent = ''; - $this->tableLevel = 0; - $this->processDomElement($child, $sheet, $row, $column, $cellContent); + private function processDomElementThTd(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + { + while (isset($this->rowspan[$column . $row])) { + ++$column; + } + $this->processDomElement($child, $sheet, $row, $column, $cellContent); - break; - default: - $this->processDomElement($child, $sheet, $row, $column, $cellContent); + // apply inline style + $this->applyInlineStyle($sheet, $row, $column, $attributeArray); + + $this->flushCell($sheet, $column, $row, $cellContent); + + $this->processDomElementBgcolor($sheet, $row, $column, $attributeArray); + $this->processDomElementWidth($sheet, $column, $attributeArray); + $this->processDomElementHeight($sheet, $row, $attributeArray); + $this->processDomElementAlign($sheet, $row, $column, $attributeArray); + $this->processDomElementVAlign($sheet, $row, $column, $attributeArray); + $this->processDomElementDataFormat($sheet, $row, $column, $attributeArray); + + if (isset($attributeArray['rowspan'], $attributeArray['colspan'])) { + //create merging rowspan and colspan + $columnTo = $column; + for ($i = 0; $i < (int) $attributeArray['colspan'] - 1; ++$i) { + ++$columnTo; + } + $range = $column . $row . ':' . $columnTo . ($row + (int) $attributeArray['rowspan'] - 1); + foreach (Coordinate::extractAllCellReferencesInRange($range) as $value) { + $this->rowspan[$value] = true; + } + $sheet->mergeCells($range); + $column = $columnTo; + } elseif (isset($attributeArray['rowspan'])) { + //create merging rowspan + $range = $column . $row . ':' . $column . ($row + (int) $attributeArray['rowspan'] - 1); + foreach (Coordinate::extractAllCellReferencesInRange($range) as $value) { + $this->rowspan[$value] = true; + } + $sheet->mergeCells($range); + } elseif (isset($attributeArray['colspan'])) { + //create merging colspan + $columnTo = $column; + for ($i = 0; $i < (int) $attributeArray['colspan'] - 1; ++$i) { + ++$columnTo; + } + $sheet->mergeCells($column . $row . ':' . $columnTo . $row); + $column = $columnTo; + } + + ++$column; + } + + protected function processDomElement(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent): void + { + foreach ($element->childNodes as $child) { + if ($child instanceof DOMText) { + $domText = preg_replace('/\s+/u', ' ', trim($child->nodeValue)); + if (is_string($cellContent)) { + // simply append the text if the cell content is a plain text string + $cellContent .= $domText; } + // but if we have a rich text run instead, we need to append it correctly + // TODO + } elseif ($child instanceof DOMElement) { + $this->processDomElementBody($element, $sheet, $row, $column, $cellContent, $child); } } } @@ -588,7 +644,11 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) // Create a new DOM object $dom = new DOMDocument(); // Reload the HTML file into the DOM object - $loaded = $dom->loadHTML(mb_convert_encoding($this->securityScanner->scanFile($pFilename), 'HTML-ENTITIES', 'UTF-8')); + try { + $loaded = $dom->loadHTML(mb_convert_encoding($this->securityScanner->scanFile($pFilename), 'HTML-ENTITIES', 'UTF-8')); + } catch (Throwable $e) { + $loaded = false; + } if ($loaded === false) { throw new Exception('Failed to load ' . $pFilename . ' as a DOM Document'); } @@ -606,7 +666,11 @@ public function loadFromString($content, ?Spreadsheet $spreadsheet = null): Spre // Create a new DOM object $dom = new DOMDocument(); // Reload the HTML file into the DOM object - $loaded = $dom->loadHTML(mb_convert_encoding($this->securityScanner->scan($content), 'HTML-ENTITIES', 'UTF-8')); + try { + $loaded = $dom->loadHTML(mb_convert_encoding($this->securityScanner->scan($content), 'HTML-ENTITIES', 'UTF-8')); + } catch (Throwable $e) { + $loaded = false; + } if ($loaded === false) { throw new Exception('Failed to load content as a DOM Document'); } @@ -837,7 +901,7 @@ public function getStyleColor($value) return substr($value, 1); } - return null; + return \PhpOffice\PhpSpreadsheet\Helper\Html::colourNameLookup((string) $value); } /** @@ -853,7 +917,7 @@ private function insertImage(Worksheet $sheet, $column, $row, array $attributes) $src = urldecode($attributes['src']); $width = isset($attributes['width']) ? (float) $attributes['width'] : null; $height = isset($attributes['height']) ? (float) $attributes['height'] : null; - $name = isset($attributes['alt']) ? (float) $attributes['alt'] : null; + $name = $attributes['alt'] ?? null; $drawing = new Drawing(); $drawing->setPath($src); @@ -884,6 +948,28 @@ private function insertImage(Worksheet $sheet, $column, $row, array $attributes) ); } + private static $borderMappings = [ + 'dash-dot' => Border::BORDER_DASHDOT, + 'dash-dot-dot' => Border::BORDER_DASHDOTDOT, + 'dashed' => Border::BORDER_DASHED, + 'dotted' => Border::BORDER_DOTTED, + 'double' => Border::BORDER_DOUBLE, + 'hair' => Border::BORDER_HAIR, + 'medium' => Border::BORDER_MEDIUM, + 'medium-dashed' => Border::BORDER_MEDIUMDASHED, + 'medium-dash-dot' => Border::BORDER_MEDIUMDASHDOT, + 'medium-dash-dot-dot' => Border::BORDER_MEDIUMDASHDOTDOT, + 'none' => Border::BORDER_NONE, + 'slant-dash-dot' => Border::BORDER_SLANTDASHDOT, + 'solid' => Border::BORDER_THIN, + 'thick' => Border::BORDER_THICK, + ]; + + public static function getBorderMappings(): array + { + return self::$borderMappings; + } + /** * Map html border style to PhpSpreadsheet border style. * @@ -893,38 +979,7 @@ private function insertImage(Worksheet $sheet, $column, $row, array $attributes) */ public function getBorderStyle($style) { - switch ($style) { - case 'solid': - return Border::BORDER_THIN; - case 'dashed': - return Border::BORDER_DASHED; - case 'dotted': - return Border::BORDER_DOTTED; - case 'medium': - return Border::BORDER_MEDIUM; - case 'thick': - return Border::BORDER_THICK; - case 'none': - return Border::BORDER_NONE; - case 'dash-dot': - return Border::BORDER_DASHDOT; - case 'dash-dot-dot': - return Border::BORDER_DASHDOTDOT; - case 'double': - return Border::BORDER_DOUBLE; - case 'hair': - return Border::BORDER_HAIR; - case 'medium-dash-dot': - return Border::BORDER_MEDIUMDASHDOT; - case 'medium-dash-dot-dot': - return Border::BORDER_MEDIUMDASHDOTDOT; - case 'medium-dashed': - return Border::BORDER_MEDIUMDASHED; - case 'slant-dash-dot': - return Border::BORDER_SLANTDASHDOT; - } - - return null; + return (array_key_exists($style, self::$borderMappings)) ? self::$borderMappings[$style] : null; } /** diff --git a/tests/PhpSpreadsheetTests/Reader/Html/HtmlBorderTest.php b/tests/PhpSpreadsheetTests/Reader/Html/HtmlBorderTest.php new file mode 100644 index 0000000000..58a0b5d756 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Html/HtmlBorderTest.php @@ -0,0 +1,110 @@ + + + Thin border + Border bottom + Border top + Border left + Border right + + + '; + $filename = HtmlHelper::createHtml($html); + $spreadsheet = HtmlHelper::loadHtmlIntoSpreadsheet($filename, true); + $firstSheet = $spreadsheet->getSheet(0); + $style = $firstSheet->getCell('A1')->getStyle(); + $borders = $style->getBorders(); + + /** @var Border $border */ + foreach ([$borders->getTop(), $borders->getBottom(), $borders->getLeft(), $borders->getRight()] as $border) { + self::assertEquals('333333', $border->getColor()->getRGB()); + self::assertEquals(Border::BORDER_THIN, $border->getBorderStyle()); + } + + $style = $firstSheet->getCell('B1')->getStyle(); + $border = $style->getBorders()->getBottom(); + self::assertEquals('333333', $border->getColor()->getRGB()); + self::assertEquals(Border::BORDER_DASHED, $border->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $style->getBorders()->getTop()->getBorderStyle()); + + $style = $firstSheet->getCell('C1')->getStyle(); + $border = $style->getBorders()->getTop(); + self::assertEquals('333333', $border->getColor()->getRGB()); + self::assertEquals(Border::BORDER_THIN, $border->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $style->getBorders()->getBottom()->getBorderStyle()); + + $style = $firstSheet->getCell('D1')->getStyle(); + $border = $style->getBorders()->getLeft(); + self::assertEquals('00ff00', $border->getColor()->getRGB()); + self::assertEquals(Border::BORDER_THIN, $border->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $style->getBorders()->getBottom()->getBorderStyle()); + + $style = $firstSheet->getCell('E1')->getStyle(); + $border = $style->getBorders()->getRight(); + self::assertEquals('333333', $border->getColor()->getRGB()); + self::assertEquals(Border::BORDER_THIN, $border->getBorderStyle()); + self::assertEquals(Border::BORDER_NONE, $style->getBorders()->getBottom()->getBorderStyle()); + + $style = $firstSheet->getCell('F1')->getStyle(); + $borders = $style->getBorders(); + foreach ([$borders->getTop(), $borders->getBottom(), $borders->getLeft(), $borders->getRight()] as $border) { + self::assertEquals(Border::BORDER_NONE, $border->getBorderStyle()); + } + } + + /** + * @dataProvider providerBorderStyle + */ + public function testBorderStyle(string $style, string $expectedResult): void + { + $borders = Html::getBorderMappings(); + self::assertEquals($expectedResult, $borders[$style]); + } + + public function testBorderStyleCoverage(): void + { + $expected = Html::getBorderMappings(); + $covered = []; + foreach ($expected as $key => $val) { + $covered[$key] = 0; + } + $tests = $this->providerBorderStyle(); + foreach ($tests as $test) { + $covered[$test[0]] = 1; + } + foreach ($covered as $key => $val) { + self::assertEquals(1, $val, "Borderstyle $key not tested"); + } + } + + public function providerBorderStyle(): array + { + return [ + ['dash-dot', Border::BORDER_DASHDOT], + ['dash-dot-dot', Border::BORDER_DASHDOTDOT], + ['dashed', Border::BORDER_DASHED], + ['dotted', Border::BORDER_DOTTED], + ['double', Border::BORDER_DOUBLE], + ['hair', Border::BORDER_HAIR], + ['medium', Border::BORDER_MEDIUM], + ['medium-dashed', Border::BORDER_MEDIUMDASHED], + ['medium-dash-dot', Border::BORDER_MEDIUMDASHDOT], + ['medium-dash-dot-dot', Border::BORDER_MEDIUMDASHDOTDOT], + ['none', Border::BORDER_NONE], + ['slant-dash-dot', Border::BORDER_SLANTDASHDOT], + ['solid', Border::BORDER_THIN], + ['thick', Border::BORDER_THICK], + ]; + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/Html/HtmlHelper.php b/tests/PhpSpreadsheetTests/Reader/Html/HtmlHelper.php new file mode 100644 index 0000000000..c09902ff07 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Html/HtmlHelper.php @@ -0,0 +1,28 @@ +load($filename); + if ($unlink) { + unlink($filename); + } + + return $spreadsheet; + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/Html/HtmlImageTest.php b/tests/PhpSpreadsheetTests/Reader/Html/HtmlImageTest.php new file mode 100644 index 0000000000..cf4157e3a6 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Html/HtmlImageTest.php @@ -0,0 +1,84 @@ + + + test image + + '; + $filename = HtmlHelper::createHtml($html); + $spreadsheet = HtmlHelper::loadHtmlIntoSpreadsheet($filename, true); + $firstSheet = $spreadsheet->getSheet(0); + + /** @var Drawing $drawing */ + $drawing = $firstSheet->getDrawingCollection()[0]; + self::assertEquals($imagePath, $drawing->getPath()); + self::assertEquals('A1', $drawing->getCoordinates()); + self::assertEquals('test image', $drawing->getName()); + self::assertEquals('100', $drawing->getWidth()); + self::assertEquals('100', $drawing->getHeight()); + } + + public function testCanInsertImageWidth(): void + { + $imagePath = realpath(__DIR__ . '/../../../data/Reader/HTML/image.jpg'); + + $html = ' + + + +
test image
'; + $filename = HtmlHelper::createHtml($html); + $spreadsheet = HtmlHelper::loadHtmlIntoSpreadsheet($filename, true); + $firstSheet = $spreadsheet->getSheet(0); + + /** @var Drawing $drawing */ + $drawing = $firstSheet->getDrawingCollection()[0]; + self::assertEquals('50', $drawing->getWidth()); + self::assertEquals('50', $drawing->getHeight()); + } + + public function testCanInsertImageHeight(): void + { + $imagePath = realpath(__DIR__ . '/../../../data/Reader/HTML/image.jpg'); + + $html = ' + + + +
'; + $filename = HtmlHelper::createHtml($html); + $spreadsheet = HtmlHelper::loadHtmlIntoSpreadsheet($filename, true); + $firstSheet = $spreadsheet->getSheet(0); + + /** @var Drawing $drawing */ + $drawing = $firstSheet->getDrawingCollection()[0]; + self::assertEquals('', $drawing->getName()); + self::assertEquals('75', $drawing->getWidth()); + self::assertEquals('75', $drawing->getHeight()); + } + + public function testImageWithourSrc(): void + { + $html = ' + + + +
'; + $filename = HtmlHelper::createHtml($html); + $spreadsheet = HtmlHelper::loadHtmlIntoSpreadsheet($filename, true); + $firstSheet = $spreadsheet->getSheet(0); + + self::assertCount(0, $firstSheet->getDrawingCollection()); + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/Html/HtmlLoadStringTest.php b/tests/PhpSpreadsheetTests/Reader/Html/HtmlLoadStringTest.php new file mode 100644 index 0000000000..e104150702 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Html/HtmlLoadStringTest.php @@ -0,0 +1,92 @@ + + + Hello World + + + Hello
World + + + Hello
World + + '; + $spreadsheet = (new Html())->loadFromString($html); + $firstSheet = $spreadsheet->getSheet(0); + + $cellStyle = $firstSheet->getStyle('A1'); + self::assertFalse($cellStyle->getAlignment()->getWrapText()); + + $cellStyle = $firstSheet->getStyle('A2'); + self::assertTrue($cellStyle->getAlignment()->getWrapText()); + $cellValue = $firstSheet->getCell('A2')->getValue(); + self::assertStringContainsString("\n", $cellValue); + + $cellStyle = $firstSheet->getStyle('A3'); + self::assertTrue($cellStyle->getAlignment()->getWrapText()); + $cellValue = $firstSheet->getCell('A3')->getValue(); + self::assertStringContainsString("\n", $cellValue); + } + + public function testLoadInvalidString(): void + { + $this->expectException(ReaderException::class); + $html = ''; + $spreadsheet = (new Html())->loadFromString($html); + $firstSheet = $spreadsheet->getSheet(0); + $cellStyle = $firstSheet->getStyle('A1'); + self::assertFalse($cellStyle->getAlignment()->getWrapText()); + } + + public function testCanLoadFromStringIntoExistingSpreadsheet(): void + { + $html = ' + + + + + + + + + +
Hello World
Hello
World
Hello
World
'; + $reader = new Html(); + $spreadsheet = $reader->loadFromString($html); + $firstSheet = $spreadsheet->getSheet(0); + + $cellStyle = $firstSheet->getStyle('A1'); + self::assertFalse($cellStyle->getAlignment()->getWrapText()); + + $cellStyle = $firstSheet->getStyle('A2'); + self::assertTrue($cellStyle->getAlignment()->getWrapText()); + $cellValue = $firstSheet->getCell('A2')->getValue(); + self::assertStringContainsString("\n", $cellValue); + + $cellStyle = $firstSheet->getStyle('A3'); + self::assertTrue($cellStyle->getAlignment()->getWrapText()); + $cellValue = $firstSheet->getCell('A3')->getValue(); + self::assertStringContainsString("\n", $cellValue); + + $reader->setSheetIndex(1); + $html = ' + + + +
Goodbye World
'; + + self::assertEquals(1, $spreadsheet->getSheetCount()); + $spreadsheet = $reader->loadFromString($html, $spreadsheet); + self::assertEquals(2, $spreadsheet->getSheetCount()); + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/Html/HtmlTagsTest.php b/tests/PhpSpreadsheetTests/Reader/Html/HtmlTagsTest.php new file mode 100644 index 0000000000..c0c206f9cb --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Html/HtmlTagsTest.php @@ -0,0 +1,236 @@ + +123 +
hyperlink5


6 +789 +101112 + +
+ + + + + +
123
456
789
  • A
  • B
  • C
1112
+
  • D
  • E
  • F
+
+ + + + + + +
M + + + +
NO
PQ
+
R
STU
+EOF; + $robj = $reader->loadFromString($html1); + $sheet = $robj->getActiveSheet(); + + self::assertEquals('www.google.com', $sheet->getCell('A2')->getHyperlink()->getUrl()); + self::assertEquals('hyperlink', $sheet->getCell('A2')->getValue()); + self::assertEquals(-1, $sheet->getRowDimension(11)->getRowHeight()); + self::assertEquals(20, $sheet->getRowDimension(12)->getRowHeight()); + self::assertEquals(5, $sheet->getCell('B2')->getValue()); + self::assertEquals(Border::BORDER_THIN, $sheet->getCell('B3')->getStyle()->getBorders()->getBottom()->getBorderStyle()); + self::assertEquals(6, $sheet->getCell('C4')->getValue()); + self::assertEquals(Border::BORDER_THIN, $sheet->getCell('A9')->getStyle()->getBorders()->getBottom()->getBorderStyle()); + + self::assertEquals(2, $sheet->getCell('B11')->getValue()); + self::assertTrue($sheet->getCell('B11')->getStyle()->getFont()->getItalic()); + + // list within table + self::assertEquals("A\nB\nC", $sheet->getCell('A14')->getValue()); + self::assertTrue($sheet->getCell('A14')->getStyle()->getAlignment()->getWrapText()); + // list outside of table + self::assertEquals('D', $sheet->getCell('A17')->getValue()); + self::assertEquals('E', $sheet->getCell('A18')->getValue()); + self::assertEquals('F', $sheet->getCell('A19')->getValue()); + + // embedded table + self::assertEquals('M', $sheet->getCell('A21')->getValue()); + self::assertEquals('N', $sheet->getCell('B20')->getValue()); + self::assertEquals('O', $sheet->getCell('C20')->getValue()); + self::assertEquals('P', $sheet->getCell('B21')->getValue()); + self::assertEquals('Q', $sheet->getCell('C21')->getValue()); + self::assertEquals('R', $sheet->getCell('C23')->getValue()); + self::assertEquals('S', $sheet->getCell('A24')->getValue()); + } + + public static function testTagsRowColSpans(): void + { + $reader = new Html(); + $html1 = << + + Month + Savings + Expenses + + + January + $100 + $50 + + + February + $80 + + + Away in March + $30 + + + $40 + + +EOF; + $robj = $reader->loadFromString($html1); + $sheet = $robj->getActiveSheet(); + + self::assertEquals(['C2:C3' => 'C2:C3', 'A4:B5' => 'A4:B5'], $sheet->getMergeCells()); + self::assertEquals('Away in March', $sheet->getCell('A4')->getValue()); + self::assertEquals('00FFFF', $sheet->getCell('A4')->getStyle()->getFill()->getEndColor()->getRGB()); + } + + public static function testDoublyEmbeddedTable(): void + { + $reader = new Html(); + $html1 = << +123 +456 +789 + + + +M + + + + + + + +
N + + + +
1011
1213
+
Y
PQX
+ +R + +STU + +EOF; + $robj = $reader->loadFromString($html1); + $sheet = $robj->getActiveSheet(); + + self::assertEquals('1', $sheet->getCell('A1')->getValue()); + self::assertEquals('2', $sheet->getCell('B1')->getValue()); + self::assertEquals('3', $sheet->getCell('C1')->getValue()); + self::assertEquals('4', $sheet->getCell('A2')->getValue()); + self::assertEquals('5', $sheet->getCell('B2')->getValue()); + self::assertEquals('6', $sheet->getCell('C2')->getValue()); + self::assertEquals('7', $sheet->getCell('A3')->getValue()); + self::assertEquals('8', $sheet->getCell('B3')->getValue()); + self::assertEquals('9', $sheet->getCell('C3')->getValue()); + self::assertEquals('10', $sheet->getCell('C5')->getValue()); + self::assertEquals('11', $sheet->getCell('D5')->getValue()); + self::assertEquals('12', $sheet->getCell('C6')->getValue()); + self::assertEquals('13', $sheet->getCell('D6')->getValue()); + self::assertEquals('N', $sheet->getCell('B6')->getValue()); + self::assertEquals('M', $sheet->getCell('A7')->getValue()); + self::assertEquals('Y', $sheet->getCell('E7')->getValue()); + self::assertEquals('P', $sheet->getCell('B8')->getValue()); + self::assertEquals('Q', $sheet->getCell('C8')->getValue()); + self::assertEquals('X', $sheet->getCell('D8')->getValue()); + self::assertEquals('R', $sheet->getCell('C10')->getValue()); + self::assertEquals('S', $sheet->getCell('A11')->getValue()); + self::assertEquals('T', $sheet->getCell('B11')->getValue()); + self::assertEquals('U', $sheet->getCell('C11')->getValue()); + } + + public static function testTagsOutsideTable(): void + { + $reader = new Html(); + $html1 = <<Here comes a list +
    +
  1. Item 1
  2. +
  3. Item 2
  4. +
  5. Item 3
  6. +
  7. Item 4
  8. +
+And here's another +
    +
  • Item A
  • +
  • Item B
  • +
+
    +Content before list +
  1. Item I
  2. +
  3. Item II
  4. +
  5. This is rich text
  6. +
+ +EOF; + $robj = $reader->loadFromString($html1); + $sheet = $robj->getActiveSheet(); + + self::assertTrue($sheet->getCell('A1')->getStyle()->getFont()->getBold()); + self::assertEquals('Here comes a list', $sheet->getCell('A1')->getValue()); + self::assertEquals('Item 1', $sheet->getCell('A3')->getValue()); + self::assertEquals('Item 2', $sheet->getCell('A4')->getValue()); + self::assertEquals('Item 3', $sheet->getCell('A5')->getValue()); + self::assertEquals('Item 4', $sheet->getCell('A6')->getValue()); + self::assertEquals('And here\'s another', $sheet->getCell('A7')->getValue()); + self::assertEquals('Item A', $sheet->getCell('A9')->getValue()); + self::assertEquals('Item B', $sheet->getCell('A10')->getValue()); + self::assertEquals('Content before list', $sheet->getCell('A11')->getValue()); + self::assertEquals('Item I', $sheet->getCell('A12')->getValue()); + self::assertEquals('Item II', $sheet->getCell('A13')->getValue()); + // TODO Rich Text not yet supported + } + + public static function testHyperlinksWithRowspan(): void + { + $reader = new Html(); + $html1 = << + + Title + Link 1 + + + Link 2 + + + Link 3 + + +EOF; + $robj = $reader->loadFromString($html1); + $sheet = $robj->getActiveSheet(); + self::assertEquals('https://google.com', $sheet->getCell('B1')->getHyperlink()->getUrl()); + self::assertEquals('https://google.com', $sheet->getCell('B2')->getHyperlink()->getUrl()); + self::assertEquals('https://google.com', $sheet->getCell('B3')->getHyperlink()->getUrl()); + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/HtmlTest.php b/tests/PhpSpreadsheetTests/Reader/Html/HtmlTest.php similarity index 53% rename from tests/PhpSpreadsheetTests/Reader/HtmlTest.php rename to tests/PhpSpreadsheetTests/Reader/Html/HtmlTest.php index b0994a3344..e87e636bbc 100644 --- a/tests/PhpSpreadsheetTests/Reader/HtmlTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Html/HtmlTest.php @@ -1,12 +1,11 @@ canRead($filename)); } + public function testBadHtml(): void + { + $this->expectException(ReaderException::class); + $filename = 'tests/data/Reader/HTML/badhtml.html'; + $reader = new Html(); + self::assertTrue($reader->canRead($filename)); + $spreadsheet = $reader->load($filename); + self::assertTrue(false); + } + + public function testNonHtml(): void + { + $this->expectException(ReaderException::class); + $filename = __FILE__; + $reader = new Html(); + self::assertFalse($reader->canRead($filename)); + $spreadsheet = $reader->load($filename); + self::assertTrue(false); + } + + public function testInvalidFilename(): void + { + $reader = new Html(); + self::assertEquals(0, $reader->getSheetIndex()); + self::assertFalse($reader->canRead('')); + } + public function providerCanReadVerySmallFile() { $padding = str_repeat('a', 2048); @@ -38,7 +64,7 @@ public function providerCanReadVerySmallFile() */ public function testCanReadVerySmallFile($expected, $content): void { - $filename = $this->createHtml($content); + $filename = HtmlHelper::createHtml($content); $reader = new Html(); $actual = $reader->canRead($filename); @@ -51,63 +77,21 @@ public function testBackgroundColorInRanding(): void { $html = ' - + +
Blue backgroundBlue backgroundUnknown fore/background
'; - $filename = $this->createHtml($html); - $spreadsheet = $this->loadHtmlIntoSpreadsheet($filename); + $filename = HtmlHelper::createHtml($html); + $spreadsheet = HtmlHelper::loadHtmlIntoSpreadsheet($filename, true); $firstSheet = $spreadsheet->getSheet(0); $style = $firstSheet->getCell('A1')->getStyle(); - self::assertEquals('FFFFFF', $style->getFont()->getColor()->getRGB()); - - unlink($filename); - } - - public function testCanApplyInlineBordersStyles(): void - { - $html = ' - - - - - - - -
Thin borderBorder bottomBorder topBorder leftBorder right
'; - $filename = $this->createHtml($html); - $spreadsheet = $this->loadHtmlIntoSpreadsheet($filename); - $firstSheet = $spreadsheet->getSheet(0); - $style = $firstSheet->getCell('A1')->getStyle(); - $borders = $style->getBorders(); - - /** @var Border $border */ - foreach ([$borders->getTop(), $borders->getBottom(), $borders->getLeft(), $borders->getRight()] as $border) { - self::assertEquals('333333', $border->getColor()->getRGB()); - self::assertEquals(Border::BORDER_THIN, $border->getBorderStyle()); - } - + self::assertEquals('0000FF', $style->getFill()->getStartColor()->getRGB()); + self::assertEquals('0000FF', $style->getFill()->getEndColor()->getRGB()); $style = $firstSheet->getCell('B1')->getStyle(); - $border = $style->getBorders()->getBottom(); - self::assertEquals('333333', $border->getColor()->getRGB()); - self::assertEquals(Border::BORDER_THIN, $border->getBorderStyle()); - - $style = $firstSheet->getCell('C1')->getStyle(); - $border = $style->getBorders()->getTop(); - self::assertEquals('333333', $border->getColor()->getRGB()); - self::assertEquals(Border::BORDER_THIN, $border->getBorderStyle()); - - $style = $firstSheet->getCell('D1')->getStyle(); - $border = $style->getBorders()->getLeft(); - self::assertEquals('333333', $border->getColor()->getRGB()); - self::assertEquals(Border::BORDER_THIN, $border->getBorderStyle()); - - $style = $firstSheet->getCell('E1')->getStyle(); - $border = $style->getBorders()->getRight(); - self::assertEquals('333333', $border->getColor()->getRGB()); - self::assertEquals(Border::BORDER_THIN, $border->getBorderStyle()); - - unlink($filename); + self::assertEquals('000000', $style->getFont()->getColor()->getRGB()); + self::assertEquals('000000', $style->getFill()->getEndColor()->getRGB()); + self::assertEquals('FFFFFF', $style->getFill()->getstartColor()->getRGB()); } public function testCanApplyInlineFontStyles(): void @@ -122,8 +106,8 @@ public function testCanApplyInlineFontStyles(): void Line through '; - $filename = $this->createHtml($html); - $spreadsheet = $this->loadHtmlIntoSpreadsheet($filename); + $filename = HtmlHelper::createHtml($html); + $spreadsheet = HtmlHelper::loadHtmlIntoSpreadsheet($filename, true); $firstSheet = $spreadsheet->getSheet(0); $style = $firstSheet->getCell('A1')->getStyle(); @@ -143,8 +127,6 @@ public function testCanApplyInlineFontStyles(): void $style = $firstSheet->getCell('F1')->getStyle(); self::assertTrue($style->getFont()->getStrikethrough()); - - unlink($filename); } public function testCanApplyInlineWidth(): void @@ -155,8 +137,8 @@ public function testCanApplyInlineWidth(): void 100px '; - $filename = $this->createHtml($html); - $spreadsheet = $this->loadHtmlIntoSpreadsheet($filename); + $filename = HtmlHelper::createHtml($html); + $spreadsheet = HtmlHelper::loadHtmlIntoSpreadsheet($filename, true); $firstSheet = $spreadsheet->getSheet(0); $dimension = $firstSheet->getColumnDimension('A'); @@ -164,8 +146,6 @@ public function testCanApplyInlineWidth(): void $dimension = $firstSheet->getColumnDimension('B'); self::assertEquals(100, $dimension->getWidth()); - - unlink($filename); } public function testCanApplyInlineHeight(): void @@ -178,8 +158,8 @@ public function testCanApplyInlineHeight(): void 2 '; - $filename = $this->createHtml($html); - $spreadsheet = $this->loadHtmlIntoSpreadsheet($filename); + $filename = HtmlHelper::createHtml($html); + $spreadsheet = HtmlHelper::loadHtmlIntoSpreadsheet($filename, true); $firstSheet = $spreadsheet->getSheet(0); $dimension = $firstSheet->getRowDimension(1); @@ -187,8 +167,6 @@ public function testCanApplyInlineHeight(): void $dimension = $firstSheet->getRowDimension(2); self::assertEquals(100, $dimension->getRowHeight()); - - unlink($filename); } public function testCanApplyAlignment(): void @@ -203,8 +181,8 @@ public function testCanApplyAlignment(): void Wraptext '; - $filename = $this->createHtml($html); - $spreadsheet = $this->loadHtmlIntoSpreadsheet($filename); + $filename = HtmlHelper::createHtml($html); + $spreadsheet = HtmlHelper::loadHtmlIntoSpreadsheet($filename, true); $firstSheet = $spreadsheet->getSheet(0); $style = $firstSheet->getCell('A1')->getStyle(); @@ -224,8 +202,6 @@ public function testCanApplyAlignment(): void $style = $firstSheet->getCell('F1')->getStyle(); self::assertTrue($style->getAlignment()->getWrapText()); - - unlink($filename); } public function testCanApplyInlineDataFormat(): void @@ -235,35 +211,12 @@ public function testCanApplyInlineDataFormat(): void 2019-02-02 12:34:00 '; - $filename = $this->createHtml($html); - $spreadsheet = $this->loadHtmlIntoSpreadsheet($filename); + $filename = HtmlHelper::createHtml($html); + $spreadsheet = HtmlHelper::loadHtmlIntoSpreadsheet($filename, true); $firstSheet = $spreadsheet->getSheet(0); $style = $firstSheet->getCell('A1')->getStyle(); self::assertEquals('mmm-yy', $style->getNumberFormat()->getFormatCode()); - - unlink($filename); - } - - public function testCanInsertImage(): void - { - $imagePath = realpath(__DIR__ . '/../../data/Reader/HTML/image.jpg'); - - $html = ' - - - -
'; - $filename = $this->createHtml($html); - $spreadsheet = $this->loadHtmlIntoSpreadsheet($filename); - $firstSheet = $spreadsheet->getSheet(0); - - /** @var Drawing $drawing */ - $drawing = $firstSheet->getDrawingCollection()[0]; - self::assertEquals($imagePath, $drawing->getPath()); - self::assertEquals('A1', $drawing->getCoordinates()); - - unlink($filename); } public function testCanApplyCellWrapping(): void @@ -279,40 +232,8 @@ public function testCanApplyCellWrapping(): void Hello
World '; - $filename = $this->createHtml($html); - $spreadsheet = $this->loadHtmlIntoSpreadsheet($filename); - $firstSheet = $spreadsheet->getSheet(0); - - $cellStyle = $firstSheet->getStyle('A1'); - self::assertFalse($cellStyle->getAlignment()->getWrapText()); - - $cellStyle = $firstSheet->getStyle('A2'); - self::assertTrue($cellStyle->getAlignment()->getWrapText()); - $cellValue = $firstSheet->getCell('A2')->getValue(); - self::assertStringContainsString("\n", $cellValue); - - $cellStyle = $firstSheet->getStyle('A3'); - self::assertTrue($cellStyle->getAlignment()->getWrapText()); - $cellValue = $firstSheet->getCell('A3')->getValue(); - self::assertStringContainsString("\n", $cellValue); - - unlink($filename); - } - - public function testCanLoadFromString(): void - { - $html = ' - - - - - - - - - -
Hello World
Hello
World
Hello
World
'; - $spreadsheet = (new Html())->loadFromString($html); + $filename = HtmlHelper::createHtml($html); + $spreadsheet = HtmlHelper::loadHtmlIntoSpreadsheet($filename, true); $firstSheet = $spreadsheet->getSheet(0); $cellStyle = $firstSheet->getStyle('A1'); @@ -329,71 +250,6 @@ public function testCanLoadFromString(): void self::assertStringContainsString("\n", $cellValue); } - public function testCanLoadFromStringIntoExistingSpreadsheet(): void - { - $html = ' - - - - - - - - - -
Hello World
Hello
World
Hello
World
'; - $reader = new Html(); - $spreadsheet = $reader->loadFromString($html); - $firstSheet = $spreadsheet->getSheet(0); - - $cellStyle = $firstSheet->getStyle('A1'); - self::assertFalse($cellStyle->getAlignment()->getWrapText()); - - $cellStyle = $firstSheet->getStyle('A2'); - self::assertTrue($cellStyle->getAlignment()->getWrapText()); - $cellValue = $firstSheet->getCell('A2')->getValue(); - self::assertStringContainsString("\n", $cellValue); - - $cellStyle = $firstSheet->getStyle('A3'); - self::assertTrue($cellStyle->getAlignment()->getWrapText()); - $cellValue = $firstSheet->getCell('A3')->getValue(); - self::assertStringContainsString("\n", $cellValue); - - $reader->setSheetIndex(1); - $html = ' - - - -
Goodbye World
'; - - self::assertEquals(1, $spreadsheet->getSheetCount()); - $spreadsheet = $reader->loadFromString($html, $spreadsheet); - self::assertEquals(2, $spreadsheet->getSheetCount()); - } - - /** - * @param string $html - * - * @return string - */ - private function createHtml($html) - { - $filename = tempnam(sys_get_temp_dir(), 'html'); - file_put_contents($filename, $html); - - return $filename; - } - - /** - * @param $filename - * - * @return \PhpOffice\PhpSpreadsheet\Spreadsheet - */ - private function loadHtmlIntoSpreadsheet($filename) - { - return (new Html())->load($filename); - } - public function testRowspanInRendering(): void { $filename = 'tests/data/Reader/HTML/rowspan.html'; @@ -417,11 +273,10 @@ public function testTextIndentUseRowspan(): void Text Indent '; - $filename = $this->createHtml($html); - $spreadsheet = $this->loadHtmlIntoSpreadsheet($filename); + $filename = HtmlHelper::createHtml($html); + $spreadsheet = HtmlHelper::loadHtmlIntoSpreadsheet($filename, true); $firstSheet = $spreadsheet->getSheet(0); $style = $firstSheet->getCell('C2')->getStyle(); self::assertEquals(10, $style->getAlignment()->getIndent()); - unlink($filename); } } diff --git a/tests/data/Reader/HTML/badhtml.html b/tests/data/Reader/HTML/badhtml.html new file mode 100644 index 0000000000..6816fb0852 --- /dev/null +++ b/tests/data/Reader/HTML/badhtml.html @@ -0,0 +1 @@ + From 752a0a5a6c00f89f8cea6f3ea3584bd5ebac4086 Mon Sep 17 00:00:00 2001 From: Owen Leibman Date: Thu, 25 Jun 2020 23:11:30 -0700 Subject: [PATCH 106/659] Scrutinizer Recommendations Two unneeded assignments in tests, one unused parameter in source code. --- src/PhpSpreadsheet/Reader/Html.php | 4 ++-- tests/PhpSpreadsheetTests/Reader/Html/HtmlTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 7cb14f49c6..a83ed8073d 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -506,7 +506,7 @@ private function processDomElementThTdOther(DOMNode $element, Worksheet $sheet, if ($child->nodeName !== 'td' && $child->nodeName !== 'th') { $this->processDomElement($child, $sheet, $row, $column, $cellContent); } else { - $this->processDomElementThTd($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + $this->processDomElementThTd($sheet, $row, $column, $cellContent, $child, $attributeArray); } } @@ -559,7 +559,7 @@ private function processDomElementDataFormat(Worksheet $sheet, int $row, string } } - private function processDomElementThTd(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + private function processDomElementThTd(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void { while (isset($this->rowspan[$column . $row])) { ++$column; diff --git a/tests/PhpSpreadsheetTests/Reader/Html/HtmlTest.php b/tests/PhpSpreadsheetTests/Reader/Html/HtmlTest.php index e87e636bbc..91e60d3ea5 100644 --- a/tests/PhpSpreadsheetTests/Reader/Html/HtmlTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Html/HtmlTest.php @@ -23,7 +23,7 @@ public function testBadHtml(): void $filename = 'tests/data/Reader/HTML/badhtml.html'; $reader = new Html(); self::assertTrue($reader->canRead($filename)); - $spreadsheet = $reader->load($filename); + $reader->load($filename); self::assertTrue(false); } @@ -33,7 +33,7 @@ public function testNonHtml(): void $filename = __FILE__; $reader = new Html(); self::assertFalse($reader->canRead($filename)); - $spreadsheet = $reader->load($filename); + $reader->load($filename); self::assertTrue(false); } From 9f1a33cc8a386b97d2c330ec8cef1f6250a1e7e0 Mon Sep 17 00:00:00 2001 From: Owen Leibman Date: Thu, 25 Jun 2020 23:39:28 -0700 Subject: [PATCH 107/659] Scrutinizer Again Cascading series of unused unused parameters. --- src/PhpSpreadsheet/Reader/Html.php | 48 +++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index a83ed8073d..1e34de0e45 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -298,7 +298,7 @@ protected function flushCell(Worksheet $sheet, $column, $row, &$cellContent): vo $cellContent = (string) ''; } - private function processDomElementBody(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child): void + private function processDomElementBody(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child): void { $attributeArray = []; foreach ($child->attributes as $attribute) { @@ -312,24 +312,24 @@ private function processDomElementBody(DOMNode $element, Worksheet $sheet, int & $this->tableLevel = 0; $this->processDomElement($child, $sheet, $row, $column, $cellContent); } else { - $this->processDomElementTitle($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + $this->processDomElementTitle($sheet, $row, $column, $cellContent, $child, $attributeArray); } } - private function processDomElementTitle(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + private function processDomElementTitle(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void { if ($child->nodeName === 'title') { $this->processDomElement($child, $sheet, $row, $column, $cellContent); $sheet->setTitle($cellContent, true, false); $cellContent = ''; } else { - $this->processDomElementSpanEtc($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + $this->processDomElementSpanEtc($sheet, $row, $column, $cellContent, $child, $attributeArray); } } private static $spanEtc = ['span', 'div', 'font', 'i', 'em', 'strong', 'b']; - private function processDomElementSpanEtc(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + private function processDomElementSpanEtc(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void { if (in_array($child->nodeName, self::$spanEtc)) { if (isset($attributeArray['class']) && $attributeArray['class'] === 'comment') { @@ -343,11 +343,11 @@ private function processDomElementSpanEtc(DOMNode $element, Worksheet $sheet, in $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); } } else { - $this->processDomElementHr($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + $this->processDomElementHr($sheet, $row, $column, $cellContent, $child, $attributeArray); } } - private function processDomElementHr(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + private function processDomElementHr(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void { if ($child->nodeName === 'hr') { $this->flushCell($sheet, $column, $row, $cellContent); @@ -358,10 +358,10 @@ private function processDomElementHr(DOMNode $element, Worksheet $sheet, int &$r ++$row; } // fall through to br - $this->processDomElementBr($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + $this->processDomElementBr($sheet, $row, $column, $cellContent, $child, $attributeArray); } - private function processDomElementBr(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + private function processDomElementBr(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void { if ($child->nodeName === 'br' || $child->nodeName === 'hr') { if ($this->tableLevel > 0) { @@ -374,11 +374,11 @@ private function processDomElementBr(DOMNode $element, Worksheet $sheet, int &$r ++$row; } } else { - $this->processDomElementA($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + $this->processDomElementA($sheet, $row, $column, $cellContent, $child, $attributeArray); } } - private function processDomElementA(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + private function processDomElementA(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void { if ($child->nodeName === 'a') { foreach ($attributeArray as $attributeName => $attributeValue) { @@ -400,13 +400,13 @@ private function processDomElementA(DOMNode $element, Worksheet $sheet, int &$ro //$cellContent .= ' '; $this->processDomElement($child, $sheet, $row, $column, $cellContent); } else { - $this->processDomElementH1Etc($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + $this->processDomElementH1Etc($sheet, $row, $column, $cellContent, $child, $attributeArray); } } private static $h1Etc = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul', 'p']; - private function processDomElementH1Etc(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + private function processDomElementH1Etc(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void { if (in_array($child->nodeName, self::$h1Etc)) { if ($this->tableLevel > 0) { @@ -430,11 +430,11 @@ private function processDomElementH1Etc(DOMNode $element, Worksheet $sheet, int $column = 'A'; } } else { - $this->processDomElementLi($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + $this->processDomElementLi($sheet, $row, $column, $cellContent, $child, $attributeArray); } } - private function processDomElementLi(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + private function processDomElementLi(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void { if ($child->nodeName === 'li') { if ($this->tableLevel > 0) { @@ -451,20 +451,20 @@ private function processDomElementLi(DOMNode $element, Worksheet $sheet, int &$r $column = 'A'; } } else { - $this->processDomElementImg($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + $this->processDomElementImg($sheet, $row, $column, $cellContent, $child, $attributeArray); } } - private function processDomElementImg(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + private function processDomElementImg(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void { if ($child->nodeName === 'img') { $this->insertImage($sheet, $column, $row, $attributeArray); } else { - $this->processDomElementTable($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + $this->processDomElementTable($sheet, $row, $column, $cellContent, $child, $attributeArray); } } - private function processDomElementTable(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + private function processDomElementTable(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void { if ($child->nodeName === 'table') { $this->flushCell($sheet, $column, $row, $cellContent); @@ -480,11 +480,11 @@ private function processDomElementTable(DOMNode $element, Worksheet $sheet, int ++$row; } } else { - $this->processDomElementTr($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + $this->processDomElementTr($sheet, $row, $column, $cellContent, $child, $attributeArray); } } - private function processDomElementTr(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + private function processDomElementTr(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void { if ($child->nodeName === 'tr') { $column = $this->getTableStartColumn(); @@ -497,11 +497,11 @@ private function processDomElementTr(DOMNode $element, Worksheet $sheet, int &$r ++$row; } else { - $this->processDomElementThTdOther($element, $sheet, $row, $column, $cellContent, $child, $attributeArray); + $this->processDomElementThTdOther($sheet, $row, $column, $cellContent, $child, $attributeArray); } } - private function processDomElementThTdOther(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void + private function processDomElementThTdOther(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void { if ($child->nodeName !== 'td' && $child->nodeName !== 'th') { $this->processDomElement($child, $sheet, $row, $column, $cellContent); @@ -622,7 +622,7 @@ protected function processDomElement(DOMNode $element, Worksheet $sheet, int &$r // but if we have a rich text run instead, we need to append it correctly // TODO } elseif ($child instanceof DOMElement) { - $this->processDomElementBody($element, $sheet, $row, $column, $cellContent, $child); + $this->processDomElementBody($sheet, $row, $column, $cellContent, $child); } } } From a264cafe4c2541c8a3f0d6cb2147ae6843b5aa3a Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sat, 27 Jun 2020 23:03:25 +0200 Subject: [PATCH 108/659] Helper class for the conversion of cell addresses between A1 and R1C1 formats, and vice-versa (#1558) * Helper class for the conversion of cell addresses between A1 and R1C1 formats, and vice-versa --- src/PhpSpreadsheet/Cell/AddressHelper.php | 88 ++++++++++++++ .../Cell/AddressHelperTest.php | 108 ++++++++++++++++++ .../data/Cell/A1ConversionToR1C1Absolute.php | 15 +++ .../data/Cell/A1ConversionToR1C1Exception.php | 5 + .../data/Cell/A1ConversionToR1C1Relative.php | 19 +++ .../data/Cell/R1C1ConversionToA1Absolute.php | 14 +++ .../data/Cell/R1C1ConversionToA1Exception.php | 9 ++ .../data/Cell/R1C1ConversionToA1Relative.php | 14 +++ 8 files changed, 272 insertions(+) create mode 100644 src/PhpSpreadsheet/Cell/AddressHelper.php create mode 100644 tests/PhpSpreadsheetTests/Cell/AddressHelperTest.php create mode 100644 tests/data/Cell/A1ConversionToR1C1Absolute.php create mode 100644 tests/data/Cell/A1ConversionToR1C1Exception.php create mode 100644 tests/data/Cell/A1ConversionToR1C1Relative.php create mode 100644 tests/data/Cell/R1C1ConversionToA1Absolute.php create mode 100644 tests/data/Cell/R1C1ConversionToA1Exception.php create mode 100644 tests/data/Cell/R1C1ConversionToA1Relative.php diff --git a/src/PhpSpreadsheet/Cell/AddressHelper.php b/src/PhpSpreadsheet/Cell/AddressHelper.php new file mode 100644 index 0000000000..77a521b069 --- /dev/null +++ b/src/PhpSpreadsheet/Cell/AddressHelper.php @@ -0,0 +1,88 @@ +expectException(Exception::class); + + AddressHelper::convertToA1($address); + } + + public function providerR1C1ConversionToA1Exception() + { + return require 'tests/data/Cell/R1C1ConversionToA1Exception.php'; + } + + /** + * @dataProvider providerA1ConversionToR1C1Absolute + */ + public function testA1ConversionToR1C1Absolute(string $expectedValue, string $address): void + { + $actualValue = AddressHelper::convertToR1C1($address); + + self::assertSame($expectedValue, $actualValue); + } + + public function providerA1ConversionToR1C1Absolute() + { + return require 'tests/data/Cell/A1ConversionToR1C1Absolute.php'; + } + + /** + * @dataProvider providerA1ConversionToR1C1Relative + */ + public function testA1ConversionToR1C1Relative(string $expectedValue, string $address, ?int $row = null, ?int $column = null): void + { + $actualValue = AddressHelper::convertToR1C1($address, $row, $column); + + self::assertSame($expectedValue, $actualValue); + } + + public function providerA1ConversionToR1C1Relative() + { + return require 'tests/data/Cell/A1ConversionToR1C1Relative.php'; + } + + /** + * @dataProvider providerA1ConversionToR1C1Exception + */ + public function testA1ConversionToR1C1Exception(string $address): void + { + $this->expectException(Exception::class); + + AddressHelper::convertToR1C1($address); + } + + public function providerA1ConversionToR1C1Exception() + { + return require 'tests/data/Cell/A1ConversionToR1C1Exception.php'; + } +} diff --git a/tests/data/Cell/A1ConversionToR1C1Absolute.php b/tests/data/Cell/A1ConversionToR1C1Absolute.php new file mode 100644 index 0000000000..171672bbff --- /dev/null +++ b/tests/data/Cell/A1ConversionToR1C1Absolute.php @@ -0,0 +1,15 @@ + Date: Sat, 27 Jun 2020 23:10:28 +0200 Subject: [PATCH 109/659] And now phpcs is telling me to fix my grammar --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02179db6fb..68aad0c14d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Added - Add support for IFS() logical function [#1442](https://github.com/PHPOffice/PhpSpreadsheet/pull/1442) +- Add Cell Address Helper to provide conversions between the R1C1 and A1 address formats [#1558](https://github.com/PHPOffice/PhpSpreadsheet/pull/1558) ## [1.13.0] - 2020-05-31 From 321dfc7a3da7f982084f0959d71f6ab4ea01561e Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 28 Jun 2020 16:29:13 +0900 Subject: [PATCH 110/659] Upgrad PHP deps --- composer.json | 4 +- composer.lock | 836 +++++++++++------- src/PhpSpreadsheet/Chart/Renderer/JpGraph.php | 2 + src/PhpSpreadsheet/Reader/Xls.php | 3 + src/PhpSpreadsheet/Shared/Font.php | 4 + src/PhpSpreadsheet/Shared/OLE/PPS.php | 1 + src/PhpSpreadsheet/Writer/Xls/Parser.php | 2 + 7 files changed, 510 insertions(+), 342 deletions(-) diff --git a/composer.json b/composer.json index 6ce3a72830..b480c0826a 100644 --- a/composer.json +++ b/composer.json @@ -53,10 +53,10 @@ "ext-xmlwriter": "*", "ext-zip": "*", "ext-zlib": "*", + "maennchen/zipstream-php": "^2.1", "markbaker/complex": "^1.4", "markbaker/matrix": "^1.2", - "psr/simple-cache": "^1.0", - "maennchen/zipstream-php": "^2.0" + "psr/simple-cache": "^1.0" }, "require-dev": { "dompdf/dompdf": "^0.8.5", diff --git a/composer.lock b/composer.lock index 41ec1b9b75..9f5ae4aaee 100644 --- a/composer.lock +++ b/composer.lock @@ -4,27 +4,27 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ab06908c3ff8187971def16c578f1ced", + "content-hash": "4103c8180a2e28881d3dbb45e835e863", "packages": [ { "name": "maennchen/zipstream-php", - "version": "2.0.0", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/maennchen/ZipStream-PHP.git", - "reference": "9ceee828f9620b2e5c075e551ec7ed8a7035ac95" + "reference": "c4c5803cc1f93df3d2448478ef79394a5981cc58" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/9ceee828f9620b2e5c075e551ec7ed8a7035ac95", - "reference": "9ceee828f9620b2e5c075e551ec7ed8a7035ac95", + "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/c4c5803cc1f93df3d2448478ef79394a5981cc58", + "reference": "c4c5803cc1f93df3d2448478ef79394a5981cc58", "shasum": "" }, "require": { - "ext-mbstring": "*", "myclabs/php-enum": "^1.5", "php": ">= 7.1", - "psr/http-message": "^1.0" + "psr/http-message": "^1.0", + "symfony/polyfill-mbstring": "^1.0" }, "require-dev": { "ext-zip": "*", @@ -65,7 +65,7 @@ "stream", "zip" ], - "time": "2020-02-23T01:48:39+00:00" + "time": "2020-05-30T13:11:16+00:00" }, { "name": "markbaker/complex", @@ -374,6 +374,69 @@ "simple-cache" ], "time": "2017-10-23T01:57:42+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "7110338d81ce1cbc3e273136e4574663627037a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7110338d81ce1cbc3e273136e4574663627037a7", + "reference": "7110338d81ce1cbc3e273136e4574663627037a7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2020-06-06T08:46:27+00:00" } ], "packages-dev": [ @@ -440,16 +503,16 @@ }, { "name": "composer/xdebug-handler", - "version": "1.4.1", + "version": "1.4.2", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "1ab9842d69e64fb3a01be6b656501032d1b78cb7" + "reference": "fa2aaf99e2087f013a14f7432c1cd2dd7d8f1f51" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/1ab9842d69e64fb3a01be6b656501032d1b78cb7", - "reference": "1ab9842d69e64fb3a01be6b656501032d1b78cb7", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/fa2aaf99e2087f013a14f7432c1cd2dd7d8f1f51", + "reference": "fa2aaf99e2087f013a14f7432c1cd2dd7d8f1f51", "shasum": "" }, "require": { @@ -480,32 +543,26 @@ "Xdebug", "performance" ], - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - } - ], - "time": "2020-03-01T12:26:26+00:00" + "time": "2020-06-04T11:16:35+00:00" }, { "name": "doctrine/annotations", - "version": "1.10.2", + "version": "1.10.3", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "b9d758e831c70751155c698c2f7df4665314a1cb" + "reference": "5db60a4969eba0e0c197a19c077780aadbc43c5d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/b9d758e831c70751155c698c2f7df4665314a1cb", - "reference": "b9d758e831c70751155c698c2f7df4665314a1cb", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/5db60a4969eba0e0c197a19c077780aadbc43c5d", + "reference": "5db60a4969eba0e0c197a19c077780aadbc43c5d", "shasum": "" }, "require": { "doctrine/lexer": "1.*", "ext-tokenizer": "*", - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "require-dev": { "doctrine/cache": "1.*", @@ -555,24 +612,24 @@ "docblock", "parser" ], - "time": "2020-04-20T09:18:32+00:00" + "time": "2020-05-25T17:24:27+00:00" }, { "name": "doctrine/instantiator", - "version": "1.3.0", + "version": "1.3.1", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" + "reference": "f350df0268e904597e3bd9c4685c53e0e333feea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f350df0268e904597e3bd9c4685c53e0e333feea", + "reference": "f350df0268e904597e3bd9c4685c53e0e333feea", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "require-dev": { "doctrine/coding-standard": "^6.0", @@ -611,24 +668,24 @@ "constructor", "instantiate" ], - "time": "2019-10-21T16:45:58+00:00" + "time": "2020-05-29T17:27:14+00:00" }, { "name": "doctrine/lexer", - "version": "1.2.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/doctrine/lexer.git", - "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6" + "reference": "e864bbf5904cb8f5bb334f99209b48018522f042" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", - "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/e864bbf5904cb8f5bb334f99209b48018522f042", + "reference": "e864bbf5904cb8f5bb334f99209b48018522f042", "shasum": "" }, "require": { - "php": "^7.2" + "php": "^7.2 || ^8.0" }, "require-dev": { "doctrine/coding-standard": "^6.0", @@ -673,7 +730,7 @@ "parser", "php" ], - "time": "2019-10-30T14:39:59+00:00" + "time": "2020-05-25T17:44:05+00:00" }, { "name": "dompdf/dompdf", @@ -743,16 +800,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v2.16.3", + "version": "v2.16.4", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "83baf823a33a1cbd5416c8626935cf3f843c10b0" + "reference": "1023c3458137ab052f6ff1e09621a721bfdeca13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/83baf823a33a1cbd5416c8626935cf3f843c10b0", - "reference": "83baf823a33a1cbd5416c8626935cf3f843c10b0", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/1023c3458137ab052f6ff1e09621a721bfdeca13", + "reference": "1023c3458137ab052f6ff1e09621a721bfdeca13", "shasum": "" }, "require": { @@ -784,12 +841,12 @@ "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1", "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1", "phpunitgoodpractices/traits": "^1.8", - "symfony/phpunit-bridge": "^4.3 || ^5.0", + "symfony/phpunit-bridge": "^5.1", "symfony/yaml": "^3.0 || ^4.0 || ^5.0" }, "suggest": { "ext-dom": "For handling output formats in XML", - "ext-mbstring": "For handling non-UTF8 characters in cache signature.", + "ext-mbstring": "For handling non-UTF8 characters.", "php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.", "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible." @@ -830,13 +887,7 @@ } ], "description": "A tool to automatically fix PHP code style", - "funding": [ - { - "url": "https://github.com/keradus", - "type": "github" - } - ], - "time": "2020-04-15T18:51:10+00:00" + "time": "2020-06-27T23:57:46+00:00" }, { "name": "jpgraph/jpgraph", @@ -876,20 +927,21 @@ "jpgraph", "pie" ], + "abandoned": true, "time": "2017-02-23T09:44:15+00:00" }, { "name": "mpdf/mpdf", - "version": "v8.0.5", + "version": "v8.0.6", "source": { "type": "git", "url": "https://github.com/mpdf/mpdf.git", - "reference": "bad32aa9cd5958175aef185c02e032ddbadc56ea" + "reference": "d27aa93513b915896fa7cb53901d3122e286f811" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mpdf/mpdf/zipball/bad32aa9cd5958175aef185c02e032ddbadc56ea", - "reference": "bad32aa9cd5958175aef185c02e032ddbadc56ea", + "url": "https://api.github.com/repos/mpdf/mpdf/zipball/d27aa93513b915896fa7cb53901d3122e286f811", + "reference": "d27aa93513b915896fa7cb53901d3122e286f811", "shasum": "" }, "require": { @@ -945,7 +997,7 @@ "php", "utf-8" ], - "time": "2020-02-05T08:43:46+00:00" + "time": "2020-05-25T09:08:39+00:00" }, { "name": "myclabs/deep-copy", @@ -1330,25 +1382,25 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "2.1.0", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b" + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/6568f4687e5b41b054365f9ae03fcb1ed5f2069b", - "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", "shasum": "" }, "require": { - "php": ">=7.1" + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-2.x": "2.x-dev" } }, "autoload": { @@ -1375,7 +1427,7 @@ "reflection", "static analysis" ], - "time": "2020-04-27T09:25:28+00:00" + "time": "2020-06-27T09:03:43+00:00" }, { "name": "phpdocumentor/reflection-docblock", @@ -1432,30 +1484,29 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.1.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "7462d5f123dfc080dfdf26897032a6513644fc95" + "reference": "e878a14a65245fbe78f8080eba03b47c3b705651" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/7462d5f123dfc080dfdf26897032a6513644fc95", - "reference": "7462d5f123dfc080dfdf26897032a6513644fc95", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e878a14a65245fbe78f8080eba03b47c3b705651", + "reference": "e878a14a65245fbe78f8080eba03b47c3b705651", "shasum": "" }, "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "ext-tokenizer": "^7.2", - "mockery/mockery": "~1" + "ext-tokenizer": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-1.x": "1.x-dev" } }, "autoload": { @@ -1474,7 +1525,7 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2020-02-18T18:59:58+00:00" + "time": "2020-06-27T10:12:23+00:00" }, { "name": "phpspec/prophecy", @@ -1793,16 +1844,16 @@ }, { "name": "phpunit/phpunit", - "version": "8.5.4", + "version": "8.5.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "8474e22d7d642f665084ba5ec780626cbd1efd23" + "reference": "34c18baa6a44f1d1fbf0338907139e9dce95b997" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8474e22d7d642f665084ba5ec780626cbd1efd23", - "reference": "8474e22d7d642f665084ba5ec780626cbd1efd23", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/34c18baa6a44f1d1fbf0338907139e9dce95b997", + "reference": "34c18baa6a44f1d1fbf0338907139e9dce95b997", "shasum": "" }, "require": { @@ -1872,17 +1923,7 @@ "testing", "xunit" ], - "funding": [ - { - "url": "https://phpunit.de/donate.html", - "type": "custom" - }, - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-04-23T04:39:42+00:00" + "time": "2020-06-22T07:06:58+00:00" }, { "name": "psr/container", @@ -2028,16 +2069,16 @@ }, { "name": "sabberworm/php-css-parser", - "version": "8.3.0", + "version": "8.3.1", "source": { "type": "git", "url": "https://github.com/sabberworm/PHP-CSS-Parser.git", - "reference": "91bcc3e3fdb7386c9a2e0e0aa09ca75cc43f121f" + "reference": "d217848e1396ef962fb1997cf3e2421acba7f796" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sabberworm/PHP-CSS-Parser/zipball/91bcc3e3fdb7386c9a2e0e0aa09ca75cc43f121f", - "reference": "91bcc3e3fdb7386c9a2e0e0aa09ca75cc43f121f", + "url": "https://api.github.com/repos/sabberworm/PHP-CSS-Parser/zipball/d217848e1396ef962fb1997cf3e2421acba7f796", + "reference": "d217848e1396ef962fb1997cf3e2421acba7f796", "shasum": "" }, "require": { @@ -2069,7 +2110,7 @@ "parser", "stylesheet" ], - "time": "2019-02-22T07:42:52+00:00" + "time": "2020-06-01T09:10:00+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -2688,16 +2729,16 @@ }, { "name": "setasign/fpdi", - "version": "v2.3.2", + "version": "v2.3.3", "source": { "type": "git", "url": "https://github.com/Setasign/FPDI.git", - "reference": "527761458f504882ab844f15754523825647f291" + "reference": "50c388860a73191e010810ed57dbed795578e867" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Setasign/FPDI/zipball/527761458f504882ab844f15754523825647f291", - "reference": "527761458f504882ab844f15754523825647f291", + "url": "https://api.github.com/repos/Setasign/FPDI/zipball/50c388860a73191e010810ed57dbed795578e867", + "reference": "50c388860a73191e010810ed57dbed795578e867", "shasum": "" }, "require": { @@ -2745,13 +2786,7 @@ "fpdi", "pdf" ], - "funding": [ - { - "url": "https://tidelift.com/funding/github/packagist/setasign/fpdi", - "type": "tidelift" - } - ], - "time": "2020-03-23T15:53:59+00:00" + "time": "2020-04-28T12:40:35+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -2806,26 +2841,29 @@ }, { "name": "symfony/console", - "version": "v5.0.7", + "version": "v5.1.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "5fa1caadc8cdaa17bcfb25219f3b53fe294a9935" + "reference": "34ac555a3627e324b660e318daa07572e1140123" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/5fa1caadc8cdaa17bcfb25219f3b53fe294a9935", - "reference": "5fa1caadc8cdaa17bcfb25219f3b53fe294a9935", + "url": "https://api.github.com/repos/symfony/console/zipball/34ac555a3627e324b660e318daa07572e1140123", + "reference": "34ac555a3627e324b660e318daa07572e1140123", "shasum": "" }, "require": { - "php": "^7.2.5", + "php": ">=7.2.5", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php73": "^1.8", - "symfony/service-contracts": "^1.1|^2" + "symfony/polyfill-php80": "^1.15", + "symfony/service-contracts": "^1.1|^2", + "symfony/string": "^5.1" }, "conflict": { "symfony/dependency-injection": "<4.4", + "symfony/dotenv": "<5.1", "symfony/event-dispatcher": "<4.4", "symfony/lock": "<4.4", "symfony/process": "<4.4" @@ -2851,7 +2889,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -2878,39 +2916,73 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, + "time": "2020-06-15T12:59:21+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337", + "reference": "dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { - "url": "https://github.com/fabpot", - "type": "github" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "time": "2020-03-30T11:42:42+00:00" + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "time": "2020-05-27T08:34:37+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v5.0.7", + "version": "v5.1.2", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "24f40d95385774ed5c71dbf014edd047e2f2f3dc" + "reference": "cc0d059e2e997e79ca34125a52f3e33de4424ac7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/24f40d95385774ed5c71dbf014edd047e2f2f3dc", - "reference": "24f40d95385774ed5c71dbf014edd047e2f2f3dc", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/cc0d059e2e997e79ca34125a52f3e33de4424ac7", + "reference": "cc0d059e2e997e79ca34125a52f3e33de4424ac7", "shasum": "" }, "require": { - "php": "^7.2.5", - "symfony/event-dispatcher-contracts": "^2" + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/event-dispatcher-contracts": "^2", + "symfony/polyfill-php80": "^1.15" }, "conflict": { "symfony/dependency-injection": "<4.4" @@ -2935,7 +3007,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -2962,38 +3034,24 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-03-27T16:56:45+00:00" + "time": "2020-05-20T17:43:50+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v2.0.1", + "version": "v2.1.2", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "af23c2584d4577d54661c434446fb8fbed6025dd" + "reference": "405952c4e90941a17e52ef7489a2bd94870bb290" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/af23c2584d4577d54661c434446fb8fbed6025dd", - "reference": "af23c2584d4577d54661c434446fb8fbed6025dd", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/405952c4e90941a17e52ef7489a2bd94870bb290", + "reference": "405952c4e90941a17e52ef7489a2bd94870bb290", "shasum": "" }, "require": { - "php": "^7.2.5", + "php": ">=7.2.5", "psr/event-dispatcher": "^1" }, "suggest": { @@ -3002,7 +3060,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -3034,30 +3092,30 @@ "interoperability", "standards" ], - "time": "2019-11-18T17:27:11+00:00" + "time": "2020-05-20T17:43:50+00:00" }, { "name": "symfony/filesystem", - "version": "v5.0.7", + "version": "v5.1.2", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "ca3b87dd09fff9b771731637f5379965fbfab420" + "reference": "6e4320f06d5f2cce0d96530162491f4465179157" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/ca3b87dd09fff9b771731637f5379965fbfab420", - "reference": "ca3b87dd09fff9b771731637f5379965fbfab420", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/6e4320f06d5f2cce0d96530162491f4465179157", + "reference": "6e4320f06d5f2cce0d96530162491f4465179157", "shasum": "" }, "require": { - "php": "^7.2.5", + "php": ">=7.2.5", "symfony/polyfill-ctype": "~1.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -3084,43 +3142,29 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-03-27T16:56:45+00:00" + "time": "2020-05-30T20:35:19+00:00" }, { "name": "symfony/finder", - "version": "v5.0.7", + "version": "v5.1.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "600a52c29afc0d1caa74acbec8d3095ca7e9910d" + "reference": "4298870062bfc667cb78d2b379be4bf5dec5f187" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/600a52c29afc0d1caa74acbec8d3095ca7e9910d", - "reference": "600a52c29afc0d1caa74acbec8d3095ca7e9910d", + "url": "https://api.github.com/repos/symfony/finder/zipball/4298870062bfc667cb78d2b379be4bf5dec5f187", + "reference": "4298870062bfc667cb78d2b379be4bf5dec5f187", "shasum": "" }, "require": { - "php": "^7.2.5" + "php": ">=7.2.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -3147,43 +3191,31 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-03-27T16:56:45+00:00" + "time": "2020-05-20T17:43:50+00:00" }, { "name": "symfony/options-resolver", - "version": "v5.0.7", + "version": "v5.1.2", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "09dccfffd24b311df7f184aa80ee7b61ad61ed8d" + "reference": "663f5dd5e14057d1954fe721f9709d35837f2447" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/09dccfffd24b311df7f184aa80ee7b61ad61ed8d", - "reference": "09dccfffd24b311df7f184aa80ee7b61ad61ed8d", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/663f5dd5e14057d1954fe721f9709d35837f2447", + "reference": "663f5dd5e14057d1954fe721f9709d35837f2447", "shasum": "" }, "require": { - "php": "^7.2.5" + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-php80": "^1.15" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -3215,34 +3247,20 @@ "configuration", "options" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-03-27T16:56:45+00:00" + "time": "2020-05-23T13:08:13+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.15.0", + "version": "v1.17.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14" + "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/4719fa9c18b0464d399f1a63bf624b42b6fa8d14", - "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", + "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", "shasum": "" }, "require": { @@ -3254,7 +3272,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -3287,51 +3309,41 @@ "polyfill", "portable" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-02-27T09:26:54+00:00" + "time": "2020-06-06T08:46:27+00:00" }, { - "name": "symfony/polyfill-mbstring", - "version": "v1.15.0", + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.17.1", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac" + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "6e4dbcf5e81eba86e36731f94fe56b1726835846" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/81ffd3a9c6d707be22e3012b827de1c9775fc5ac", - "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/6e4dbcf5e81eba86e36731f94fe56b1726835846", + "reference": "6e4dbcf5e81eba86e36731f94fe56b1726835846", "shasum": "" }, "require": { "php": ">=5.3.3" }, "suggest": { - "ext-mbstring": "For best performance" + "ext-intl": "For best performance" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" }, "files": [ "bootstrap.php" @@ -3351,43 +3363,97 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill for the Mbstring extension", + "description": "Symfony polyfill for intl's grapheme_* functions", "homepage": "https://symfony.com", "keywords": [ "compatibility", - "mbstring", + "grapheme", + "intl", "polyfill", "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" + "time": "2020-06-06T08:46:27+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "40309d1700e8f72447bb9e7b54af756eeea35620" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/40309d1700e8f72447bb9e7b54af756eeea35620", + "reference": "40309d1700e8f72447bb9e7b54af756eeea35620", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { - "url": "https://github.com/fabpot", - "type": "github" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "time": "2020-03-09T19:04:49+00:00" + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "time": "2020-06-14T14:40:37+00:00" }, { "name": "symfony/polyfill-php70", - "version": "v1.15.0", + "version": "v1.17.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "2a18e37a489803559284416df58c71ccebe50bf0" + "reference": "471b096aede7025bace8eb356b9ac801aaba7e2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/2a18e37a489803559284416df58c71ccebe50bf0", - "reference": "2a18e37a489803559284416df58c71ccebe50bf0", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/471b096aede7025bace8eb356b9ac801aaba7e2d", + "reference": "471b096aede7025bace8eb356b9ac801aaba7e2d", "shasum": "" }, "require": { @@ -3397,7 +3463,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -3433,20 +3503,20 @@ "portable", "shim" ], - "time": "2020-02-27T09:26:54+00:00" + "time": "2020-06-06T08:46:27+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.15.0", + "version": "v1.17.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "37b0976c78b94856543260ce09b460a7bc852747" + "reference": "f048e612a3905f34931127360bdd2def19a5e582" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/37b0976c78b94856543260ce09b460a7bc852747", - "reference": "37b0976c78b94856543260ce09b460a7bc852747", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/f048e612a3905f34931127360bdd2def19a5e582", + "reference": "f048e612a3905f34931127360bdd2def19a5e582", "shasum": "" }, "require": { @@ -3455,7 +3525,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-master": "1.17-dev" } }, "autoload": { @@ -3488,34 +3558,20 @@ "portable", "shim" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-02-27T09:26:54+00:00" + "time": "2020-05-12T16:47:27+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.15.0", + "version": "v1.17.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7" + "reference": "fa0837fe02d617d31fbb25f990655861bb27bd1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7", - "reference": "0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fa0837fe02d617d31fbb25f990655861bb27bd1a", + "reference": "fa0837fe02d617d31fbb25f990655861bb27bd1a", "shasum": "" }, "require": { @@ -3524,7 +3580,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -3560,43 +3620,96 @@ "portable", "shim" ], - "funding": [ + "time": "2020-06-06T08:46:27+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4a5b6bba3259902e386eb80dd1956181ee90b5b2", + "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2", + "shasum": "" + }, + "require": { + "php": ">=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" }, { - "url": "https://github.com/fabpot", - "type": "github" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "time": "2020-02-27T09:26:54+00:00" + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2020-06-06T08:46:27+00:00" }, { "name": "symfony/process", - "version": "v5.0.7", + "version": "v5.1.2", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "c5ca4a0fc16a0c888067d43fbcfe1f8a53d8e70e" + "reference": "7f6378c1fa2147eeb1b4c385856ce9de0d46ebd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/c5ca4a0fc16a0c888067d43fbcfe1f8a53d8e70e", - "reference": "c5ca4a0fc16a0c888067d43fbcfe1f8a53d8e70e", + "url": "https://api.github.com/repos/symfony/process/zipball/7f6378c1fa2147eeb1b4c385856ce9de0d46ebd1", + "reference": "7f6378c1fa2147eeb1b4c385856ce9de0d46ebd1", "shasum": "" }, "require": { - "php": "^7.2.5" + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.15" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -3623,38 +3736,24 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-03-27T16:56:45+00:00" + "time": "2020-05-30T20:35:19+00:00" }, { "name": "symfony/service-contracts", - "version": "v2.0.1", + "version": "v2.1.2", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "144c5e51266b281231e947b51223ba14acf1a749" + "reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/144c5e51266b281231e947b51223ba14acf1a749", - "reference": "144c5e51266b281231e947b51223ba14acf1a749", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/66a8f0957a3ca54e4f724e49028ab19d75a8918b", + "reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b", "shasum": "" }, "require": { - "php": "^7.2.5", + "php": ">=7.2.5", "psr/container": "^1.0" }, "suggest": { @@ -3663,7 +3762,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -3695,30 +3794,30 @@ "interoperability", "standards" ], - "time": "2019-11-18T17:27:11+00:00" + "time": "2020-05-20T17:43:50+00:00" }, { "name": "symfony/stopwatch", - "version": "v5.0.7", + "version": "v5.1.2", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "a1d86d30d4522423afc998f32404efa34fcf5a73" + "reference": "0f7c58cf81dbb5dd67d423a89d577524a2ec0323" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/a1d86d30d4522423afc998f32404efa34fcf5a73", - "reference": "a1d86d30d4522423afc998f32404efa34fcf5a73", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/0f7c58cf81dbb5dd67d423a89d577524a2ec0323", + "reference": "0f7c58cf81dbb5dd67d423a89d577524a2ec0323", "shasum": "" }, "require": { - "php": "^7.2.5", + "php": ">=7.2.5", "symfony/service-contracts": "^1.0|^2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -3745,21 +3844,78 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" + "time": "2020-05-20T17:43:50+00:00" + }, + { + "name": "symfony/string", + "version": "v5.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "ac70459db781108db7c6d8981dd31ce0e29e3298" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/ac70459db781108db7c6d8981dd31ce0e29e3298", + "reference": "ac70459db781108db7c6d8981dd31ce0e29e3298", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "~1.15" + }, + "require-dev": { + "symfony/error-handler": "^4.4|^5.0", + "symfony/http-client": "^4.4|^5.0", + "symfony/translation-contracts": "^1.1|^2", + "symfony/var-exporter": "^4.4|^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\String\\": "" }, + "files": [ + "Resources/functions.php" + ], + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { - "url": "https://github.com/fabpot", - "type": "github" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "time": "2020-03-27T16:56:45+00:00" + "description": "Symfony String component", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "time": "2020-06-11T12:16:36+00:00" }, { "name": "tecnickcom/tcpdf", @@ -3865,16 +4021,16 @@ }, { "name": "webmozart/assert", - "version": "1.8.0", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6" + "reference": "9dc4f203e36f2b486149058bade43c851dd97451" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6", - "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6", + "url": "https://api.github.com/repos/webmozart/assert/zipball/9dc4f203e36f2b486149058bade43c851dd97451", + "reference": "9dc4f203e36f2b486149058bade43c851dd97451", "shasum": "" }, "require": { @@ -3882,6 +4038,7 @@ "symfony/polyfill-ctype": "^1.8" }, "conflict": { + "phpstan/phpstan": "<0.12.20", "vimeo/psalm": "<3.9.1" }, "require-dev": { @@ -3909,7 +4066,7 @@ "check", "validate" ], - "time": "2020-04-18T12:12:48+00:00" + "time": "2020-06-16T10:16:42+00:00" } ], "aliases": [], @@ -3933,6 +4090,5 @@ "ext-zip": "*", "ext-zlib": "*" }, - "platform-dev": [], - "plugin-api-version": "1.1.0" + "platform-dev": [] } diff --git a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php index bd931c66c5..5546da5863 100644 --- a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php +++ b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php @@ -219,9 +219,11 @@ private function renderLegend(): void break; case 't': $this->graph->legend->SetPos(0.5, 0.01, 'center', 'top'); // top + break; case 'b': $this->graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); // bottom + break; default: $this->graph->legend->SetPos(0.01, 0.01, 'right', 'top'); // top-right diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index 3f383b9ecf..c7c5f77f39 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -4944,6 +4944,7 @@ private function readDataValidation(): void // offset: var; size: $sz1; formula data for first condition (without size field) $formula1 = substr($recordData, $offset, $sz1); $formula1 = pack('v', $sz1) . $formula1; // prepend the length + try { $formula1 = $this->getFormulaFromStructure($formula1); @@ -4966,6 +4967,7 @@ private function readDataValidation(): void // offset: var; size: $sz2; formula data for second condition (without size field) $formula2 = substr($recordData, $offset, $sz2); $formula2 = pack('v', $sz2) . $formula2; // prepend the length + try { $formula2 = $this->getFormulaFromStructure($formula2); } catch (PhpSpreadsheetException $e) { @@ -5763,6 +5765,7 @@ private function getNextToken($formulaData, $baseCell = 'A1') $size = 9; $data = self::extractNumber(substr($formulaData, 1)); $data = str_replace(',', '.', (string) $data); // in case non-English locale + break; case 0x20: // array constant case 0x40: diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index ca94529cb1..ee1f8abac8 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -318,21 +318,25 @@ public static function getTextWidthPixelsApprox($columnText, \PhpOffice\PhpSprea // value 8.26 was found via interpolation by inspecting real Excel files with Calibri 11 font. $columnWidth = (int) (8.26 * StringHelper::countCharacters($columnText)); $columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size + break; case 'Arial': // value 8 was set because of experience in different exports at Arial 10 font. $columnWidth = (int) (8 * StringHelper::countCharacters($columnText)); $columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size + break; case 'Verdana': // value 8 was found via interpolation by inspecting real Excel files with Verdana 10 font. $columnWidth = (int) (8 * StringHelper::countCharacters($columnText)); $columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size + break; default: // just assume Calibri $columnWidth = (int) (8.26 * StringHelper::countCharacters($columnText)); $columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size + break; } diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS.php b/src/PhpSpreadsheet/Shared/OLE/PPS.php index 0407e0d1d5..7aa42a148c 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS.php @@ -192,6 +192,7 @@ public function _getPpsWk() . pack('V', isset($this->startBlock) ? $this->startBlock : 0) // 120 . pack('V', $this->Size) // 124 . pack('V', 0); // 128 + return $ret; } diff --git a/src/PhpSpreadsheet/Writer/Xls/Parser.php b/src/PhpSpreadsheet/Writer/Xls/Parser.php index 5e3316ab43..621853c0ef 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Parser.php +++ b/src/PhpSpreadsheet/Writer/Xls/Parser.php @@ -1250,6 +1250,7 @@ private function fact() throw new WriterException("')' token expected."); } $this->advance(); // eat the ")" + return $result; } // if it's a reference @@ -1350,6 +1351,7 @@ private function func() $result = $this->createTree($function, $result, $num_args); $this->advance(); // eat the ")" + return $result; } From 2896e6ceb969297f8ff3669bb8d07a91a910a08d Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 28 Jun 2020 17:34:32 +0900 Subject: [PATCH 111/659] Consistent regexp escaping --- samples/Pdf/21b_Pdf.php | 2 +- tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/Pdf/21b_Pdf.php b/samples/Pdf/21b_Pdf.php index 142fc344cd..c67ff3d29d 100644 --- a/samples/Pdf/21b_Pdf.php +++ b/samples/Pdf/21b_Pdf.php @@ -8,7 +8,7 @@ function replaceBody(string $html): string { $lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; - $bodystring = '@.*@ms'; + $bodystring = '~.*~ms'; $bodyrepl = <<

Serif

diff --git a/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php b/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php index 388dbd0e6d..94c201a71d 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php @@ -20,7 +20,7 @@ public function yellowBody(string $html): string EOF; - return preg_replace('@@', "$newstyle", $html); + return preg_replace('~~', "$newstyle", $html); } public function testSetAndReset(): void From 5e64479c06b5880182e2b6276f94ba9fd3c75106 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 28 Jun 2020 17:34:50 +0900 Subject: [PATCH 112/659] Document the callback --- src/PhpSpreadsheet/Writer/Html.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 752f286f08..f3b40fa137 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -208,9 +208,15 @@ public function generateHtmlAll() return $html; } - public function setEditHtmlCallback(?callable $cbk): void + /** + * Set a callback to edit the entire HTML. + * + * The callback must accept the HTML as string as first parameter, + * and it must return the edited HTML as string. + */ + public function setEditHtmlCallback(?callable $callback): void { - $this->editHtmlCallback = $cbk; + $this->editHtmlCallback = $callback; } const VALIGN_ARR = [ From 14a0fa4cd0601da933616e06dfc95537f822ec80 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 28 Jun 2020 17:35:10 +0900 Subject: [PATCH 113/659] New members should always be private --- src/PhpSpreadsheet/Writer/Html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index f3b40fa137..eb50c456aa 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -136,7 +136,7 @@ class Html extends BaseWriter * * @var null|callable */ - protected $editHtmlCallback; + private $editHtmlCallback; /** * Create a new HTML. From f1fb8dcf1fe0f3e00ae4ff6d22308394f2d2fdbb Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 28 Jun 2020 21:56:12 +0900 Subject: [PATCH 114/659] Don't ouput row and columns without any cells in HTML writer If row or column dimensions are accessed, then HTML writer would still generate lots of empty cells, to show nothing at all. This now ignore row and column dimensions to only output cell that actually exists (even if those cells are empty). Fixes #1235 Close #1537 --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Writer/Html.php | 41 ++++---- .../Html/ExtendForChartsAndImagesTest.php | 94 +++++++++++++++++++ 3 files changed, 113 insertions(+), 23 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/Writer/Html/ExtendForChartsAndImagesTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 68aad0c14d..1867f097dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Fix for Issue [#1495](https://github.com/PHPOffice/PhpSpreadsheet/issues/1495) (Sheet index being changed when multiple sheets are used in formula) [#1500]((https://github.com/PHPOffice/PhpSpreadsheet/pull/1500)) - Fix for Issue [#1533](https://github.com/PHPOffice/PhpSpreadsheet/issues/1533) (A reference to a cell containing a string starting with "#" leads to errors in the generated xlsx.) [#1534](https://github.com/PHPOffice/PhpSpreadsheet/pull/1534) - Xls Writer - Correct Timestamp Bug [#1493](https://github.com/PHPOffice/PhpSpreadsheet/pull/1493) +- Don't ouput row and columns without any cells in HTML writer [#1235](https://github.com/PHPOffice/PhpSpreadsheet/issues/1235) ### Added - Add support for IFS() logical function [#1442](https://github.com/PHPOffice/PhpSpreadsheet/pull/1442) diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index eb50c456aa..ec8fec7da4 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -449,22 +449,19 @@ public function generateSheetData() foreach ($sheets as $sheet) { // Write table header $html .= $this->generateTableHeader($sheet); - // Get worksheet dimension - $dimension = explode(':', $sheet->calculateWorksheetDimension()); - $dimension[0] = Coordinate::coordinateFromString($dimension[0]); - $dimension[0][0] = Coordinate::columnIndexFromString($dimension[0][0]); - $dimension[1] = Coordinate::coordinateFromString($dimension[1]); - $dimension[1][0] = Coordinate::columnIndexFromString($dimension[1][0]); - // row min,max - $rowMin = $dimension[0][1]; - $rowMax = $dimension[1][1]; + // Get worksheet dimension + [$min, $max] = explode(':', $sheet->calculateWorksheetDataDimension()); + [$minCol, $minRow] = Coordinate::coordinateFromString($min); + $minCol = Coordinate::columnIndexFromString($minCol); + [$maxCol, $maxRow] = Coordinate::coordinateFromString($max); + $maxCol = Coordinate::columnIndexFromString($maxCol); - [$theadStart, $theadEnd, $tbodyStart] = $this->generateSheetStarts($sheet, $rowMin); + [$theadStart, $theadEnd, $tbodyStart] = $this->generateSheetStarts($sheet, $minRow); // Loop through cells - $row = $rowMin - 1; - while ($row++ < $rowMax) { + $row = $minRow - 1; + while ($row++ < $maxRow) { [$cellType, $startTag, $endTag] = $this->generateSheetTags($row, $theadStart, $theadEnd, $tbodyStart); $html .= $startTag; @@ -473,8 +470,8 @@ public function generateSheetData() // Start a new rowData $rowData = []; // Loop through columns - $column = $dimension[0][0]; - while ($column <= $dimension[1][0]) { + $column = $minCol; + while ($column <= $maxCol) { // Cell exists? if ($sheet->cellExistsByColumnAndRow($column, $row)) { $rowData[$column] = Coordinate::stringFromColumnIndex($column) . $row; @@ -557,7 +554,7 @@ public function generateNavigation() * * @codeCoverageIgnore */ - private function extendRowsForCharts(Worksheet $pSheet, $row) + private function extendRowsForCharts(Worksheet $pSheet, int $row) { $rowMax = $row; $colMax = 'A'; @@ -582,7 +579,7 @@ private function extendRowsForCharts(Worksheet $pSheet, $row) return [$rowMax, $colMax, $anyfound]; } - private function extendRowsForChartsAndImages(Worksheet $pSheet, $row) + private function extendRowsForChartsAndImages(Worksheet $pSheet, int $row): string { [$rowMax, $colMax, $anyfound] = $this->extendRowsForCharts($pSheet, $row); @@ -1169,7 +1166,7 @@ private function generateTableTag($pSheet, $id, &$html, $sheetIndex): void * Generate table header. * * @param Worksheet $pSheet The worksheet for the table we are writing - * @param bool $showid whether or not to add id to table tag + * @param bool $showid whether or not to add id to table tag * * @return string */ @@ -1182,8 +1179,6 @@ private function generateTableHeader($pSheet, $showid = true) $id = $showid ? "id='sheet$sheetIndex'" : ''; if ($showid) { $html .= "
\n"; - //} elseif ($this->useInlineCss) { - // $html .= "
\n"; } else { $html .= "
\n"; } @@ -1621,11 +1616,11 @@ public function setUseInlineCss($pValue) /** * Get use embedded CSS? * - * @deprecated no longer used - * * @return bool * * @codeCoverageIgnore + * + * @deprecated no longer used */ public function getUseEmbeddedCSS() { @@ -1635,13 +1630,13 @@ public function getUseEmbeddedCSS() /** * Set use embedded CSS? * - * @deprecated no longer used - * * @param bool $pValue * * @return $this * * @codeCoverageIgnore + * + * @deprecated no longer used */ public function setUseEmbeddedCSS($pValue) { diff --git a/tests/PhpSpreadsheetTests/Writer/Html/ExtendForChartsAndImagesTest.php b/tests/PhpSpreadsheetTests/Writer/Html/ExtendForChartsAndImagesTest.php new file mode 100644 index 0000000000..e3d23230c1 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Html/ExtendForChartsAndImagesTest.php @@ -0,0 +1,94 @@ +assertMaxColumnAndMaxRow($spreadsheet, 1, 1); + } + + public function testSimpleSheet(): void + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('B3', 'foo'); + + $this->assertMaxColumnAndMaxRow($spreadsheet, 2, 3); + } + + public function testSheetWithExtraColumnDimensions(): void + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('B3', 'foo'); + + // Artificially expend the sheet column count without any real cells + $sheet->getColumnDimension('E'); + + $this->assertMaxColumnAndMaxRow($spreadsheet, 2, 3); + } + + public function testSheetWithExtraRowDimensions(): void + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('B3', 'foo'); + + // Artificially expend the sheet row count without any real cells + $sheet->getRowDimension(5); + + $this->assertMaxColumnAndMaxRow($spreadsheet, 2, 3); + } + + public function testSheetWithImageBelowData(): void + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('B3', 'foo'); + + // Add a drawing to the worksheet + $drawing = new Drawing(); + $drawing->setPath('foo.png', false); + $drawing->setCoordinates('A5'); + $drawing->setWorksheet($sheet); + + $this->assertMaxColumnAndMaxRow($spreadsheet, 2, 5); + } + + public function testSheetWithImageRightOfData(): void + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('B3', 'foo'); + + // Add a drawing to the worksheet + $drawing = new Drawing(); + $drawing->setPath('foo.png', false); + $drawing->setCoordinates('E1'); + $drawing->setWorksheet($sheet); + + $this->assertMaxColumnAndMaxRow($spreadsheet, 5, 3); + } + + private function assertMaxColumnAndMaxRow(Spreadsheet $spreadsheet, int $expectedColumnCount, int $expectedRowCount): void + { + $writer = new Html($spreadsheet); + $html = $writer->generateHtmlAll(); + + $rowCount = substr_count($html, ' Date: Sun, 28 Jun 2020 22:03:17 +0900 Subject: [PATCH 115/659] Update CHANGELOG --- CHANGELOG.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1867f097dc..610615d569 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org). ## [Unreleased] +### Added + +- Add support for IFS() logical function [#1442](https://github.com/PHPOffice/PhpSpreadsheet/pull/1442) +- Add Cell Address Helper to provide conversions between the R1C1 and A1 address formats [#1558](https://github.com/PHPOffice/PhpSpreadsheet/pull/1558) +- Add ability to edit Html/Pdf before saving [#1499](https://github.com/PHPOffice/PhpSpreadsheet/pull/1499) + ### Fixed - Resolve evaluation of utf-8 named ranges in calculation engine [#1522](https://github.com/PHPOffice/PhpSpreadsheet/pull/1522) @@ -21,10 +27,6 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Xls Writer - Correct Timestamp Bug [#1493](https://github.com/PHPOffice/PhpSpreadsheet/pull/1493) - Don't ouput row and columns without any cells in HTML writer [#1235](https://github.com/PHPOffice/PhpSpreadsheet/issues/1235) -### Added -- Add support for IFS() logical function [#1442](https://github.com/PHPOffice/PhpSpreadsheet/pull/1442) -- Add Cell Address Helper to provide conversions between the R1C1 and A1 address formats [#1558](https://github.com/PHPOffice/PhpSpreadsheet/pull/1558) - ## [1.13.0] - 2020-05-31 ### Added From 6caa0cb4f5b6f71eae4bfffff6a0772df6122d29 Mon Sep 17 00:00:00 2001 From: Pavel Alazankin Date: Sun, 28 Jun 2020 17:39:38 +0300 Subject: [PATCH 116/659] add ability to set codepage explicitly for BIFF5 (#1484) If BIFF5 excel 95 file doesn't have codepage record, the default codepage CP1252 is used and can't be change. That causes to problems with decoding cyrillic text. --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Reader/Xls.php | 11 ++++++++++- src/PhpSpreadsheet/Shared/CodePage.php | 7 +++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 610615d569..b97431c5df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Add support for IFS() logical function [#1442](https://github.com/PHPOffice/PhpSpreadsheet/pull/1442) - Add Cell Address Helper to provide conversions between the R1C1 and A1 address formats [#1558](https://github.com/PHPOffice/PhpSpreadsheet/pull/1558) - Add ability to edit Html/Pdf before saving [#1499](https://github.com/PHPOffice/PhpSpreadsheet/pull/1499) +- Add ability to set codepage explicitly for BIFF5 [#1018](https://github.com/PHPOffice/PhpSpreadsheet/issues/1018) ### Fixed diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index c7c5f77f39..11a6195c30 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -439,6 +439,15 @@ public function canRead($pFilename) } } + public function setCodepage(string $codepage): void + { + if (!CodePage::validate($codepage)) { + throw new PhpSpreadsheetException('Unknown codepage: ' . $codepage); + } + + $this->codepage = $codepage; + } + /** * Reads names of the worksheets from a file, without parsing the whole file to a PhpSpreadsheet object. * @@ -640,7 +649,7 @@ public function load($pFilename) // initialize $this->pos = 0; - $this->codepage = 'CP1252'; + $this->codepage = $this->codepage ?: CodePage::DEFAULT_CODE_PAGE; $this->formats = []; $this->objFonts = []; $this->palette = []; diff --git a/src/PhpSpreadsheet/Shared/CodePage.php b/src/PhpSpreadsheet/Shared/CodePage.php index 97cbfbbef0..1d5d8933ed 100644 --- a/src/PhpSpreadsheet/Shared/CodePage.php +++ b/src/PhpSpreadsheet/Shared/CodePage.php @@ -6,6 +6,8 @@ class CodePage { + public const DEFAULT_CODE_PAGE = 'CP1252'; + private static $pageArray = [ 0 => 'CP1252', // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program 367 => 'ASCII', // ASCII @@ -65,6 +67,11 @@ class CodePage 65001 => 'UTF-8', // Unicode (UTF-8) ]; + public static function validate(string $codePage): bool + { + return in_array($codePage, self::$pageArray, true); + } + /** * Convert Microsoft Code Page Identifier to Code Page Name which iconv * and mbstring understands. From e74ef3a802640b9a790bae131a7a0b2e64ccba56 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 29 Jun 2020 10:15:42 +0900 Subject: [PATCH 117/659] Generate API doc on tag only Because it doesn't need to be run on every PR and documenting only release is exactly what we want --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 05e964a1b6..7a17dd93ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ jobs: - php ocular.phar code-coverage:upload --format=php-clover tests/coverage-clover.xml - stage: API documentations - if: branch = master + if: tag is present php: 7.4 before_script: - curl -LO https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.0.0-rc/phpDocumentor.phar From 7f23ccb69d1957e0f968acbc08b695656cf5f5ab Mon Sep 17 00:00:00 2001 From: paulkned Date: Mon, 29 Jun 2020 03:17:58 +0200 Subject: [PATCH 118/659] Added support for the WEBSERVICE function (#1409) Co-authored-by: Paul Kievits --- CHANGELOG.md | 1 + composer.json | 3 +- composer.lock | 294 +++++++++++++++++- .../Calculation/Calculation.php | 5 + src/PhpSpreadsheet/Calculation/Category.php | 1 + src/PhpSpreadsheet/Calculation/Web.php | 53 ++++ src/PhpSpreadsheet/Settings.php | 29 ++ .../Functions/Web/WebServiceTest.php | 54 ++++ .../DocumentGeneratorTest.php | 5 + tests/data/Calculation/Web/WEBSERVICE.php | 28 ++ 10 files changed, 471 insertions(+), 2 deletions(-) create mode 100644 src/PhpSpreadsheet/Calculation/Web.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php create mode 100644 tests/data/Calculation/Web/WEBSERVICE.php diff --git a/CHANGELOG.md b/CHANGELOG.md index b97431c5df..f667053f8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Add Cell Address Helper to provide conversions between the R1C1 and A1 address formats [#1558](https://github.com/PHPOffice/PhpSpreadsheet/pull/1558) - Add ability to edit Html/Pdf before saving [#1499](https://github.com/PHPOffice/PhpSpreadsheet/pull/1499) - Add ability to set codepage explicitly for BIFF5 [#1018](https://github.com/PHPOffice/PhpSpreadsheet/issues/1018) +- Added support for the WEBSERVICE function ### Fixed diff --git a/composer.json b/composer.json index b480c0826a..d4810ce6a9 100644 --- a/composer.json +++ b/composer.json @@ -56,7 +56,8 @@ "maennchen/zipstream-php": "^2.1", "markbaker/complex": "^1.4", "markbaker/matrix": "^1.2", - "psr/simple-cache": "^1.0" + "psr/simple-cache": "^1.0", + "guzzlehttp/guzzle": "^7.0" }, "require-dev": { "dompdf/dompdf": "^0.8.5", diff --git a/composer.lock b/composer.lock index 9f5ae4aaee..99de82bf11 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,211 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4103c8180a2e28881d3dbb45e835e863", + "content-hash": "b7ea4dea7ce2e1c2299029fe978d2173", "packages": [ + { + "name": "guzzlehttp/guzzle", + "version": "7.0.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "2d9d3c186a6637a43193e66b097c50e4451eaab2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/2d9d3c186a6637a43193e66b097c50e4451eaab2", + "reference": "2d9d3c186a6637a43193e66b097c50e4451eaab2", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.6.1", + "php": "^7.2.5", + "psr/http-client": "^1.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.0", + "ext-curl": "*", + "php-http/client-integration-tests": "dev-phpunit8", + "phpunit/phpunit": "^8.5.5", + "psr/log": "^1.1" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.0-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "time": "2020-06-27T10:33:25+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2016-12-20T10:07:11+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.6.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "239400de7a173fe9901b9ac7c06497751f00727a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", + "reference": "239400de7a173fe9901b9ac7c06497751f00727a", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0", + "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "ext-zlib": "*", + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" + }, + "suggest": { + "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2019-07-01T23:21:34+00:00" + }, { "name": "maennchen/zipstream-php", "version": "2.1.0", @@ -277,6 +480,55 @@ ], "time": "2020-02-14T08:15:52+00:00" }, + { + "name": "psr/http-client", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "496a823ef742b632934724bf769560c2a5c7c44e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/496a823ef742b632934724bf769560c2a5c7c44e", + "reference": "496a823ef742b632934724bf769560c2a5c7c44e", + "shasum": "" + }, + "require": { + "php": "^7.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "time": "2018-10-30T23:29:13+00:00" + }, { "name": "psr/http-message", "version": "1.0.1", @@ -375,6 +627,46 @@ ], "time": "2017-10-23T01:57:42+00:00" }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "time": "2019-03-08T08:55:37+00:00" + }, { "name": "symfony/polyfill-mbstring", "version": "v1.17.1", diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index ed630354dd..a8f93a88de 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -2184,6 +2184,11 @@ class Calculation 'functionCall' => [LookupRef::class, 'VLOOKUP'], 'argumentCount' => '3,4', ], + 'WEBSERVICE' => [ + 'category' => Category::CATEGORY_WEB, + 'functionCall' => [Web::class, 'WEBSERVICE'], + 'argumentCount' => '1', + ], 'WEEKDAY' => [ 'category' => Category::CATEGORY_DATE_AND_TIME, 'functionCall' => [DateTime::class, 'WEEKDAY'], diff --git a/src/PhpSpreadsheet/Calculation/Category.php b/src/PhpSpreadsheet/Calculation/Category.php index 7574cb4766..96bb72ad4c 100644 --- a/src/PhpSpreadsheet/Calculation/Category.php +++ b/src/PhpSpreadsheet/Calculation/Category.php @@ -16,4 +16,5 @@ abstract class Category const CATEGORY_MATH_AND_TRIG = 'Math and Trig'; const CATEGORY_STATISTICAL = 'Statistical'; const CATEGORY_TEXT_AND_DATA = 'Text and Data'; + const CATEGORY_WEB = 'Web'; } diff --git a/src/PhpSpreadsheet/Calculation/Web.php b/src/PhpSpreadsheet/Calculation/Web.php new file mode 100644 index 0000000000..9f0faf993c --- /dev/null +++ b/src/PhpSpreadsheet/Calculation/Web.php @@ -0,0 +1,53 @@ + 2048) { + return Functions::VALUE(); // Invalid URL length + } + + if (!preg_match('/^http[s]?:\/\//', $url)) { + return Functions::VALUE(); // Invalid protocol + } + + // Get results from the the webservice + $client = Settings::getHttpClient(); + $request = new Request('GET', $url); + + try { + $response = $client->sendRequest($request); + } catch (ClientExceptionInterface $e) { + return Functions::VALUE(); // cURL error + } + + if ($response->getStatusCode() != 200) { + return Functions::VALUE(); // cURL error + } + + $output = (string) $response->getBody(); + if (strlen($output) > 32767) { + return Functions::VALUE(); // Output not a string or too long + } + + return $output; + } +} diff --git a/src/PhpSpreadsheet/Settings.php b/src/PhpSpreadsheet/Settings.php index 4e0c91ef48..15218c7291 100644 --- a/src/PhpSpreadsheet/Settings.php +++ b/src/PhpSpreadsheet/Settings.php @@ -2,9 +2,11 @@ namespace PhpOffice\PhpSpreadsheet; +use GuzzleHttp\Client; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Chart\Renderer\IRenderer; use PhpOffice\PhpSpreadsheet\Collection\Memory; +use Psr\Http\Client\ClientInterface; use Psr\SimpleCache\CacheInterface; class Settings @@ -42,6 +44,13 @@ class Settings */ private static $cache; + /** + * The HTTP client implementation to be used for network request. + * + * @var ClientInterface + */ + private static $client; + /** * Set the locale code to use for formula translations and any special formatting. * @@ -156,4 +165,24 @@ public static function getCache() return self::$cache; } + + /** + * Set the HTTP client implementation to be used for network request. + */ + public static function setHttpClient(ClientInterface $httpClient): void + { + self::$client = $httpClient; + } + + /** + * Get the HTTP client implementation to be used for network request. + */ + public static function getHttpClient(): ClientInterface + { + if (!self::$client) { + self::$client = new Client(); + } + + return self::$client; + } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php new file mode 100644 index 0000000000..acc83cff12 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php @@ -0,0 +1,54 @@ + $handlerStack]); + } + + protected function setUp(): void + { + Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); + } + + /** + * @dataProvider providerWEBSERVICE + */ + public function testWEBSERVICE(string $expectedResult, string $url): void + { + Settings::setHttpClient(self::$client); + $result = Web::WEBSERVICE($url); + self::assertEquals($expectedResult, $result); + } + + public function providerWEBSERVICE(): array + { + return require 'tests/data/Calculation/Web/WEBSERVICE.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php index ac9af83841..8a34f1c0bb 100644 --- a/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php +++ b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php @@ -127,6 +127,11 @@ public function providerGenerateFunctionListByCategory(): array Excel Function | PhpSpreadsheet Function --------------------|------------------------------------------- +## CATEGORY_WEB + +Excel Function | PhpSpreadsheet Function +--------------------|------------------------------------------- + EXPECTED ], diff --git a/tests/data/Calculation/Web/WEBSERVICE.php b/tests/data/Calculation/Web/WEBSERVICE.php new file mode 100644 index 0000000000..6d9934da86 --- /dev/null +++ b/tests/data/Calculation/Web/WEBSERVICE.php @@ -0,0 +1,28 @@ + Date: Mon, 29 Jun 2020 10:23:33 +0900 Subject: [PATCH 119/659] Update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f667053f8a..a945169ec8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Add Cell Address Helper to provide conversions between the R1C1 and A1 address formats [#1558](https://github.com/PHPOffice/PhpSpreadsheet/pull/1558) - Add ability to edit Html/Pdf before saving [#1499](https://github.com/PHPOffice/PhpSpreadsheet/pull/1499) - Add ability to set codepage explicitly for BIFF5 [#1018](https://github.com/PHPOffice/PhpSpreadsheet/issues/1018) -- Added support for the WEBSERVICE function +- Added support for the WEBSERVICE function [#1409](https://github.com/PHPOffice/PhpSpreadsheet/pull/1409) ### Fixed From 73fe58fdc9f3977619bec6b26e867eb2ac059dcd Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 29 Jun 2020 10:51:21 +0900 Subject: [PATCH 120/659] 1.14.0 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a945169ec8..ebdbf775b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com) and this project adheres to [Semantic Versioning](https://semver.org). -## [Unreleased] +## [1.14.0] - 2020-06-29 ### Added From 39f1a611207ce74c87ee51bf2bcb9afb9450e221 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 29 Jun 2020 10:52:36 +0900 Subject: [PATCH 121/659] CHANGELOG placeholder --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebdbf775b8..48ee629343 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) and this project adheres to [Semantic Versioning](https://semver.org). +## [Unreleased] + +### Added + +- nothing + +### Fixed + +- nothing + +### Changed + +- nothing + ## [1.14.0] - 2020-06-29 ### Added From 8712fb0424cc7240405c6c708a571f0f7ac3bfee Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 29 Jun 2020 11:28:05 +0900 Subject: [PATCH 122/659] Drop polyfill that are not needed since PHP 7.2 --- src/PhpSpreadsheet/Chart/Renderer/JpGraph.php | 2 -- src/PhpSpreadsheet/Chart/Renderer/Polyfill.php | 9 --------- 2 files changed, 11 deletions(-) delete mode 100644 src/PhpSpreadsheet/Chart/Renderer/Polyfill.php diff --git a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php index 5546da5863..02fbfed7ea 100644 --- a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php +++ b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php @@ -21,8 +21,6 @@ use Spline; use StockPlot; -require_once __DIR__ . '/Polyfill.php'; - class JpGraph implements IRenderer { private static $width = 640; diff --git a/src/PhpSpreadsheet/Chart/Renderer/Polyfill.php b/src/PhpSpreadsheet/Chart/Renderer/Polyfill.php deleted file mode 100644 index 5e233abdbb..0000000000 --- a/src/PhpSpreadsheet/Chart/Renderer/Polyfill.php +++ /dev/null @@ -1,9 +0,0 @@ - Date: Mon, 29 Jun 2020 20:15:41 +0200 Subject: [PATCH 123/659] Support pageOrder in page setup for Xlsx Reader and Writer --- src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php | 3 +++ src/PhpSpreadsheet/Worksheet/PageSetup.php | 19 +++++++++++++++++++ src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 3 +++ 3 files changed, 25 insertions(+) diff --git a/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php b/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php index bfb7a1f5f5..b556703c97 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php @@ -69,6 +69,9 @@ private function pageSetup(SimpleXMLElement $xmlSheet, Worksheet $worksheet, arr self::boolean((string) $xmlSheet->pageSetup['useFirstPageNumber'])) { $docPageSetup->setFirstPageNumber((int) ($xmlSheet->pageSetup['firstPageNumber'])); } + if (isset($xmlSheet->pageSetup['pageOrder'])) { + $docPageSetup->setPageOrder((string) $xmlSheet->pageSetup['pageOrder']); + } $relAttributes = $xmlSheet->pageSetup->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); if (isset($relAttributes['id'])) { diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index f29dbad599..f52b414aa0 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -156,6 +156,9 @@ class PageSetup const SETPRINTRANGE_OVERWRITE = 'O'; const SETPRINTRANGE_INSERT = 'I'; + const PAGEORDER_OVER_THEN_DOWN = 'overThenDown'; + const PAGEORDER_DOWN_THEN_OVER = 'downThenOver'; + /** * Paper size. * @@ -246,6 +249,8 @@ class PageSetup */ private $firstPageNumber; + private $pageOrder; + /** * Create a new PageSetup. */ @@ -818,6 +823,20 @@ public function resetFirstPageNumber() return $this->setFirstPageNumber(null); } + public function getPageOrder(): string + { + return $this->pageOrder; + } + + public function setPageOrder(?string $pageOrder): self + { + if ($pageOrder === null || $pageOrder === self::PAGEORDER_DOWN_THEN_OVER || $pageOrder === self::PAGEORDER_OVER_THEN_DOWN) { + $this->pageOrder = $pageOrder; + } + + return $this; + } + /** * Implement PHP __clone to create a deep clone, not just a shallow copy. */ diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index be064256db..2a8a3add53 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -875,6 +875,9 @@ private function writePageSetup(XMLWriter $objWriter, PhpspreadsheetWorksheet $p $objWriter->writeAttribute('firstPageNumber', $pSheet->getPageSetup()->getFirstPageNumber()); $objWriter->writeAttribute('useFirstPageNumber', '1'); } + if ($pSheet->getPageSetup()->getPageOrder() !== null) { + $objWriter->writeAttribute('pageOrder', $pSheet->getPageSetup()->getPageOrder()); + } $getUnparsedLoadedData = $pSheet->getParent()->getUnparsedLoadedData(); if (isset($getUnparsedLoadedData['sheets'][$pSheet->getCodeName()]['pageSetupRelId'])) { From 21b34f0afbabb30da2bd19980bb052ccf1295129 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Mon, 29 Jun 2020 20:27:47 +0200 Subject: [PATCH 124/659] pageOrder is nullable --- src/PhpSpreadsheet/Worksheet/PageSetup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index f52b414aa0..290b834927 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -823,7 +823,7 @@ public function resetFirstPageNumber() return $this->setFirstPageNumber(null); } - public function getPageOrder(): string + public function getPageOrder(): ?string { return $this->pageOrder; } From 362b18ca122412eb12d2287aa9f329dba328cd54 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 30 Jun 2020 00:53:10 +0200 Subject: [PATCH 125/659] Read Print Settings Page Order in Xls Reader And eliminate switch for simple boolean portrait/landscape option --- src/PhpSpreadsheet/Reader/Xls.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index 11a6195c30..c60ea7721b 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -3444,6 +3444,9 @@ private function readPageSetup(): void // offset: 10; size: 2; option flags + // bit: 0; mask: 0x0001; 0=landscape, 1=portrait + $isOverThenDown= (0x0001 & self::getUInt2d($recordData, 10)); + // bit: 1; mask: 0x0002; 0=landscape, 1=portrait $isPortrait = (0x0002 & self::getUInt2d($recordData, 10)) >> 1; @@ -3453,16 +3456,8 @@ private function readPageSetup(): void if (!$isNotInit) { $this->phpSheet->getPageSetup()->setPaperSize($paperSize); - switch ($isPortrait) { - case 0: - $this->phpSheet->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE); - - break; - case 1: - $this->phpSheet->getPageSetup()->setOrientation(PageSetup::ORIENTATION_PORTRAIT); - - break; - } + $this->phpSheet->getPageSetup()->setPageOrder(((bool) $isOverThenDown) ? PageSetup::PAGEORDER_OVER_THEN_DOWN : PageSetup::PAGEORDER_DOWN_THEN_OVER); + $this->phpSheet->getPageSetup()->setOrientation(((bool) $isPortrait) ? PageSetup::ORIENTATION_PORTRAIT : PageSetup::ORIENTATION_LANDSCAPE); $this->phpSheet->getPageSetup()->setScale($scale, false); $this->phpSheet->getPageSetup()->setFitToPage((bool) $this->isFitToPages); From 4060cdec7e9e73919e154e8e89d0873def567588 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 30 Jun 2020 01:11:53 +0200 Subject: [PATCH 126/659] Fix comment --- src/PhpSpreadsheet/Reader/Xls.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index c60ea7721b..5e4ee22591 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -3444,7 +3444,7 @@ private function readPageSetup(): void // offset: 10; size: 2; option flags - // bit: 0; mask: 0x0001; 0=landscape, 1=portrait + // bit: 0; mask: 0x0001; 0=down then over, 1=over then down $isOverThenDown= (0x0001 & self::getUInt2d($recordData, 10)); // bit: 1; mask: 0x0002; 0=landscape, 1=portrait From fbb04c1f8203420e9aa7171b8f2a87fe1c55b642 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 30 Jun 2020 07:01:51 +0200 Subject: [PATCH 127/659] Xls Writer changes to save print order --- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 0dce7ba54e..1a4504ed88 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -1729,11 +1729,12 @@ private function writeSetup(): void $numFtr = $this->phpSheet->getPageMargins()->getFooter(); // Footer Margin $iCopies = 0x01; // Number of copies - $fLeftToRight = 0x0; // Print over then down - + // Order of printing pages + $fLeftToRight = $this->phpSheet->getPageSetup()->getPageOrder() == PageSetup::PAGEORDER_OVER_THEN_DOWN + ? 0x0 : 0x1; // Page orientation - $fLandscape = ($this->phpSheet->getPageSetup()->getOrientation() == PageSetup::ORIENTATION_LANDSCAPE) ? - 0x0 : 0x1; + $fLandscape = ($this->phpSheet->getPageSetup()->getOrientation() == PageSetup::ORIENTATION_LANDSCAPE) + ? 0x0 : 0x1; $fNoPls = 0x0; // Setup not read from printer $fNoColor = 0x0; // Print black and white From 1f865c84c0d960c09b08d731edbac20797131cad Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 30 Jun 2020 07:24:12 +0200 Subject: [PATCH 128/659] Keep phpcs happy --- src/PhpSpreadsheet/Reader/Xls.php | 2 +- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index 5e4ee22591..cdac07d0b0 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -3445,7 +3445,7 @@ private function readPageSetup(): void // offset: 10; size: 2; option flags // bit: 0; mask: 0x0001; 0=down then over, 1=over then down - $isOverThenDown= (0x0001 & self::getUInt2d($recordData, 10)); + $isOverThenDown = (0x0001 & self::getUInt2d($recordData, 10)); // bit: 1; mask: 0x0002; 0=landscape, 1=portrait $isPortrait = (0x0002 & self::getUInt2d($recordData, 10)) >> 1; diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 1a4504ed88..eb6b479d22 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -1730,8 +1730,8 @@ private function writeSetup(): void $iCopies = 0x01; // Number of copies // Order of printing pages - $fLeftToRight = $this->phpSheet->getPageSetup()->getPageOrder() == PageSetup::PAGEORDER_OVER_THEN_DOWN - ? 0x0 : 0x1; + $fLeftToRight = $this->phpSheet->getPageSetup()->getPageOrder() === PageSetup::PAGEORDER_DOWN_THEN_OVER + ? 0x1 : 0x0; // Page orientation $fLandscape = ($this->phpSheet->getPageSetup()->getOrientation() == PageSetup::ORIENTATION_LANDSCAPE) ? 0x0 : 0x1; From 3780072ae96fbe8f61c1b2109d217e62616c4f1e Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 30 Jun 2020 19:07:56 +0200 Subject: [PATCH 129/659] Retrieve basic print settings in the Ods Reader --- src/PhpSpreadsheet/Reader/Ods.php | 89 ++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 2 deletions(-) diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index d638d1fb23..d3482716ba 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -19,11 +19,19 @@ use PhpOffice\PhpSpreadsheet\Shared\File; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; +use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; +use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use XMLReader; use ZipArchive; class Ods extends BaseReader { + private $pageLayoutStyles = []; + + private $masterStylesCrossReference = []; + + private $masterPrintStylesCrossReference = []; + /** * Create a new Ods Reader instance. */ @@ -276,7 +284,45 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) (new DocumentProperties($spreadsheet))->load($xml, $namespacesMeta); - // Content + // Styles + + $dom = new DOMDocument('1.01', 'UTF-8'); + $dom->loadXML( + $this->securityScanner->scan($zip->getFromName('styles.xml')), + Settings::getLibXmlLoaderOptions() + ); + $officeNs = $dom->lookupNamespaceUri('office'); + $stylesNs = $dom->lookupNamespaceUri('style'); + + $styles = $dom->getElementsByTagNameNS($officeNs, 'automatic-styles') + ->item(0) + ->getElementsByTagNameNS($stylesNs, 'page-layout'); + + foreach ($styles as $styleSet) { + $styleName = $styleSet->getAttributeNS($stylesNs, 'name'); + $pageLayoutProperties = $styleSet->getElementsByTagNameNS($stylesNs, 'page-layout-properties')[0]; + $styleOrientation = $pageLayoutProperties->getAttributeNS($stylesNs, 'print-orientation'); + $styleScale = $pageLayoutProperties->getAttributeNS($stylesNs, 'scale-to'); + $stylePrintOrder = $pageLayoutProperties->getAttributeNS($stylesNs, 'print-page-order'); + + $this->pageLayoutStyles[$styleName] = (object) [ + 'orientation' => $styleOrientation, + 'scale' => $styleScale, + 'printOrder' => $stylePrintOrder, + ]; + } + + $styleMasterLookup = $dom->getElementsByTagNameNS($officeNs, 'master-styles') + ->item(0) + ->getElementsByTagNameNS($stylesNs, 'master-page'); + + foreach ($styleMasterLookup as $styleMasterSet) { + $styleMasterName = $styleMasterSet->getAttributeNS($stylesNs, 'name'); + $pageLayoutName = $styleMasterSet->getAttributeNS($stylesNs, 'page-layout-name'); + $this->masterPrintStylesCrossReference[$styleMasterName] = $pageLayoutName; + } + + // Main Content $dom = new DOMDocument('1.01', 'UTF-8'); $dom->loadXML( @@ -289,6 +335,20 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) $textNs = $dom->lookupNamespaceUri('text'); $xlinkNs = $dom->lookupNamespaceUri('xlink'); + $styleXReferences = $dom->getElementsByTagNameNS($officeNs, 'automatic-styles') + ->item(0) + ->getElementsByTagNameNS($stylesNs, 'style'); + + foreach ($styleXReferences as $styleXreferenceSet) { + $styleXRefName = $styleXreferenceSet->getAttributeNS($stylesNs, 'name'); + $stylePageLayoutName = $styleXreferenceSet->getAttributeNS($stylesNs, 'master-page-name'); + if (!empty($stylePageLayoutName)) { + $this->masterStylesCrossReference[$styleXRefName] = $stylePageLayoutName; + } + } + + // Content + $spreadsheets = $dom->getElementsByTagNameNS($officeNs, 'body') ->item(0) ->getElementsByTagNameNS($officeNs, 'spreadsheet'); @@ -309,6 +369,8 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) continue; } + $worksheetStyleName = $worksheetDataSet->getAttributeNS($tableNs, 'style-name'); + // Create sheet if ($worksheetID > 0) { $spreadsheet->createSheet(); // First sheet is added by default @@ -319,7 +381,7 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in // formula cells... during the load, all formulae should be correct, and we're simply // bringing the worksheet name in line with the formula, not the reverse - $spreadsheet->getActiveSheet()->setTitle($worksheetName, false, false); + $spreadsheet->getActiveSheet()->setTitle((string) $worksheetName, false, false); } // Go through every child of table element @@ -641,6 +703,7 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) break; } } + $this->getPrintSettings($spreadsheet->getActiveSheet(), $worksheetStyleName); ++$worksheetID; } } @@ -649,6 +712,28 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) return $spreadsheet; } + private function getPrintSettings(Worksheet $worksheet, string $styleName) + { + if (!array_key_exists($styleName, $this->masterStylesCrossReference)) { + return; + } + $masterStyleName = $this->masterStylesCrossReference[$styleName]; + + if (!array_key_exists($masterStyleName, $this->masterPrintStylesCrossReference)) { + return; + } + $printSettingsIndex = $this->masterPrintStylesCrossReference[$masterStyleName]; + + if (!array_key_exists($printSettingsIndex, $this->pageLayoutStyles)) { + return; + } + $printSettings = $this->pageLayoutStyles[$printSettingsIndex]; + + $worksheet->getPageSetup()->setOrientation($printSettings->orientation ?? PageSetup::ORIENTATION_DEFAULT); + $worksheet->getPageSetup()->setScale((int) trim($printSettings->scale, '%')); + $worksheet->getPageSetup()->setPageOrder($printSettings->printOrder === 'ltr' ? PageSetup::PAGEORDER_OVER_THEN_DOWN : PageSetup::PAGEORDER_DOWN_THEN_OVER); + } + /** * Recursively scan element. * From 13a3363410e44c7d30814be3e7c94c2e68ddbff7 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 30 Jun 2020 19:15:08 +0200 Subject: [PATCH 130/659] Return void, just to keep phpcs happy --- src/PhpSpreadsheet/Reader/Ods.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index d3482716ba..040bfffa6d 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -712,7 +712,7 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) return $spreadsheet; } - private function getPrintSettings(Worksheet $worksheet, string $styleName) + private function getPrintSettings(Worksheet $worksheet, string $styleName): void { if (!array_key_exists($styleName, $this->masterStylesCrossReference)) { return; From 4dadf4a5c8d816e2f9ff04d9f803b5b1ad18f680 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 30 Jun 2020 22:23:33 +0200 Subject: [PATCH 131/659] Refactor reading Ods Page Settings into a separate class --- src/PhpSpreadsheet/Reader/Ods.php | 69 +----------- .../Reader/Ods/PageSettings.php | 104 ++++++++++++++++++ 2 files changed, 108 insertions(+), 65 deletions(-) create mode 100644 src/PhpSpreadsheet/Reader/Ods/PageSettings.php diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index 040bfffa6d..ad87192f8a 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -11,6 +11,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Cell\DataType; +use PhpOffice\PhpSpreadsheet\Reader\Ods\PageSettings; use PhpOffice\PhpSpreadsheet\Reader\Ods\Properties as DocumentProperties; use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner; use PhpOffice\PhpSpreadsheet\RichText\RichText; @@ -19,8 +20,6 @@ use PhpOffice\PhpSpreadsheet\Shared\File; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; -use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; -use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use XMLReader; use ZipArchive; @@ -291,36 +290,8 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) $this->securityScanner->scan($zip->getFromName('styles.xml')), Settings::getLibXmlLoaderOptions() ); - $officeNs = $dom->lookupNamespaceUri('office'); - $stylesNs = $dom->lookupNamespaceUri('style'); - - $styles = $dom->getElementsByTagNameNS($officeNs, 'automatic-styles') - ->item(0) - ->getElementsByTagNameNS($stylesNs, 'page-layout'); - - foreach ($styles as $styleSet) { - $styleName = $styleSet->getAttributeNS($stylesNs, 'name'); - $pageLayoutProperties = $styleSet->getElementsByTagNameNS($stylesNs, 'page-layout-properties')[0]; - $styleOrientation = $pageLayoutProperties->getAttributeNS($stylesNs, 'print-orientation'); - $styleScale = $pageLayoutProperties->getAttributeNS($stylesNs, 'scale-to'); - $stylePrintOrder = $pageLayoutProperties->getAttributeNS($stylesNs, 'print-page-order'); - - $this->pageLayoutStyles[$styleName] = (object) [ - 'orientation' => $styleOrientation, - 'scale' => $styleScale, - 'printOrder' => $stylePrintOrder, - ]; - } - - $styleMasterLookup = $dom->getElementsByTagNameNS($officeNs, 'master-styles') - ->item(0) - ->getElementsByTagNameNS($stylesNs, 'master-page'); - foreach ($styleMasterLookup as $styleMasterSet) { - $styleMasterName = $styleMasterSet->getAttributeNS($stylesNs, 'name'); - $pageLayoutName = $styleMasterSet->getAttributeNS($stylesNs, 'page-layout-name'); - $this->masterPrintStylesCrossReference[$styleMasterName] = $pageLayoutName; - } + $pageSettings = new PageSettings($dom); // Main Content @@ -335,17 +306,7 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) $textNs = $dom->lookupNamespaceUri('text'); $xlinkNs = $dom->lookupNamespaceUri('xlink'); - $styleXReferences = $dom->getElementsByTagNameNS($officeNs, 'automatic-styles') - ->item(0) - ->getElementsByTagNameNS($stylesNs, 'style'); - - foreach ($styleXReferences as $styleXreferenceSet) { - $styleXRefName = $styleXreferenceSet->getAttributeNS($stylesNs, 'name'); - $stylePageLayoutName = $styleXreferenceSet->getAttributeNS($stylesNs, 'master-page-name'); - if (!empty($stylePageLayoutName)) { - $this->masterStylesCrossReference[$styleXRefName] = $stylePageLayoutName; - } - } + $pageSettings->readStyleCrossReferences($dom); // Content @@ -703,7 +664,7 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) break; } } - $this->getPrintSettings($spreadsheet->getActiveSheet(), $worksheetStyleName); + $pageSettings->setPrintSettingsForWorksheet($spreadsheet->getActiveSheet(), $worksheetStyleName); ++$worksheetID; } } @@ -712,28 +673,6 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) return $spreadsheet; } - private function getPrintSettings(Worksheet $worksheet, string $styleName): void - { - if (!array_key_exists($styleName, $this->masterStylesCrossReference)) { - return; - } - $masterStyleName = $this->masterStylesCrossReference[$styleName]; - - if (!array_key_exists($masterStyleName, $this->masterPrintStylesCrossReference)) { - return; - } - $printSettingsIndex = $this->masterPrintStylesCrossReference[$masterStyleName]; - - if (!array_key_exists($printSettingsIndex, $this->pageLayoutStyles)) { - return; - } - $printSettings = $this->pageLayoutStyles[$printSettingsIndex]; - - $worksheet->getPageSetup()->setOrientation($printSettings->orientation ?? PageSetup::ORIENTATION_DEFAULT); - $worksheet->getPageSetup()->setScale((int) trim($printSettings->scale, '%')); - $worksheet->getPageSetup()->setPageOrder($printSettings->printOrder === 'ltr' ? PageSetup::PAGEORDER_OVER_THEN_DOWN : PageSetup::PAGEORDER_DOWN_THEN_OVER); - } - /** * Recursively scan element. * diff --git a/src/PhpSpreadsheet/Reader/Ods/PageSettings.php b/src/PhpSpreadsheet/Reader/Ods/PageSettings.php new file mode 100644 index 0000000000..5ff1d58b63 --- /dev/null +++ b/src/PhpSpreadsheet/Reader/Ods/PageSettings.php @@ -0,0 +1,104 @@ +setDomNameSpaces($styleDom); + $this->readPageSettingStyles($styleDom); + $this->readStyleMasterLookup($styleDom); + } + + private function setDomNameSpaces(DOMDocument $styleDom): void + { + $this->officeNs = $styleDom->lookupNamespaceUri('office'); + $this->stylesNs = $styleDom->lookupNamespaceUri('style'); + } + + private function readPageSettingStyles(DOMDocument $styleDom): void + { + $styles = $styleDom->getElementsByTagNameNS($this->officeNs, 'automatic-styles') + ->item(0) + ->getElementsByTagNameNS($this->stylesNs, 'page-layout'); + + foreach ($styles as $styleSet) { + $styleName = $styleSet->getAttributeNS($this->stylesNs, 'name'); + $pageLayoutProperties = $styleSet->getElementsByTagNameNS($this->stylesNs, 'page-layout-properties')[0]; + $styleOrientation = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'print-orientation'); + $styleScale = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'scale-to'); + $stylePrintOrder = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'print-page-order'); + + $this->pageLayoutStyles[$styleName] = (object) [ + 'orientation' => $styleOrientation, + 'scale' => $styleScale, + 'printOrder' => $stylePrintOrder, + ]; + } + } + + private function readStyleMasterLookup(DOMDocument $styleDom): void + { + $styleMasterLookup = $styleDom->getElementsByTagNameNS($this->officeNs, 'master-styles') + ->item(0) + ->getElementsByTagNameNS($this->stylesNs, 'master-page'); + + foreach ($styleMasterLookup as $styleMasterSet) { + $styleMasterName = $styleMasterSet->getAttributeNS($this->stylesNs, 'name'); + $pageLayoutName = $styleMasterSet->getAttributeNS($this->stylesNs, 'page-layout-name'); + $this->masterPrintStylesCrossReference[$styleMasterName] = $pageLayoutName; + } + } + + public function readStyleCrossReferences(DOMDocument $contentDom): void + { + $styleXReferences = $contentDom->getElementsByTagNameNS($this->officeNs, 'automatic-styles') + ->item(0) + ->getElementsByTagNameNS($this->stylesNs, 'style'); + + foreach ($styleXReferences as $styleXreferenceSet) { + $styleXRefName = $styleXreferenceSet->getAttributeNS($this->stylesNs, 'name'); + $stylePageLayoutName = $styleXreferenceSet->getAttributeNS($this->stylesNs, 'master-page-name'); + if (!empty($stylePageLayoutName)) { + $this->masterStylesCrossReference[$styleXRefName] = $stylePageLayoutName; + } + } + } + + public function setPrintSettingsForWorksheet(Worksheet $worksheet, string $styleName): void + { + if (!array_key_exists($styleName, $this->masterStylesCrossReference)) { + return; + } + $masterStyleName = $this->masterStylesCrossReference[$styleName]; + + if (!array_key_exists($masterStyleName, $this->masterPrintStylesCrossReference)) { + return; + } + $printSettingsIndex = $this->masterPrintStylesCrossReference[$masterStyleName]; + + if (!array_key_exists($printSettingsIndex, $this->pageLayoutStyles)) { + return; + } + $printSettings = $this->pageLayoutStyles[$printSettingsIndex]; + + $worksheet->getPageSetup() + ->setOrientation($printSettings->orientation ?? PageSetup::ORIENTATION_DEFAULT) + ->setPageOrder($printSettings->printOrder === 'ltr' ? PageSetup::PAGEORDER_OVER_THEN_DOWN : PageSetup::PAGEORDER_DOWN_THEN_OVER) + ->setScale((int) trim($printSettings->scale, '%')); + } +} From 736d9ffd3b03667a2038a12876b8a0c5df0e54d9 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 30 Jun 2020 22:45:08 +0200 Subject: [PATCH 132/659] Gotta keep phpcs happy, even if it is only a blank line between property declarations --- src/PhpSpreadsheet/Reader/Ods/PageSettings.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PhpSpreadsheet/Reader/Ods/PageSettings.php b/src/PhpSpreadsheet/Reader/Ods/PageSettings.php index 5ff1d58b63..6810ef5ffd 100644 --- a/src/PhpSpreadsheet/Reader/Ods/PageSettings.php +++ b/src/PhpSpreadsheet/Reader/Ods/PageSettings.php @@ -9,6 +9,7 @@ class PageSettings { private $officeNs; + private $stylesNs; private $pageLayoutStyles = []; From 163da065054345959b25550702c532738b046d5e Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Wed, 1 Jul 2020 14:50:13 +0200 Subject: [PATCH 133/659] Horizontal an dVertical centering for the Ods Reader --- src/PhpSpreadsheet/Reader/Ods/PageSettings.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Reader/Ods/PageSettings.php b/src/PhpSpreadsheet/Reader/Ods/PageSettings.php index 6810ef5ffd..4a1fc06581 100644 --- a/src/PhpSpreadsheet/Reader/Ods/PageSettings.php +++ b/src/PhpSpreadsheet/Reader/Ods/PageSettings.php @@ -43,11 +43,14 @@ private function readPageSettingStyles(DOMDocument $styleDom): void $styleOrientation = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'print-orientation'); $styleScale = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'scale-to'); $stylePrintOrder = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'print-page-order'); + $centered = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'table-centering'); $this->pageLayoutStyles[$styleName] = (object) [ 'orientation' => $styleOrientation, 'scale' => $styleScale, 'printOrder' => $stylePrintOrder, + 'horizontalCentered' => $centered === 'horizontal' || $centered === 'both', + 'verticalCentered' => $centered === 'vertical' || $centered === 'both', ]; } } @@ -100,6 +103,8 @@ public function setPrintSettingsForWorksheet(Worksheet $worksheet, string $style $worksheet->getPageSetup() ->setOrientation($printSettings->orientation ?? PageSetup::ORIENTATION_DEFAULT) ->setPageOrder($printSettings->printOrder === 'ltr' ? PageSetup::PAGEORDER_OVER_THEN_DOWN : PageSetup::PAGEORDER_DOWN_THEN_OVER) - ->setScale((int) trim($printSettings->scale, '%')); + ->setScale((int) trim($printSettings->scale, '%')) + ->setHorizontalCentered($printSettings->horizontalCentered) + ->setVerticalCentered($printSettings->verticalCentered); } } From e644cc72d03df950e211c0b711e0a8b9f550c9fe Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Wed, 1 Jul 2020 19:55:25 +0200 Subject: [PATCH 134/659] Additional print information for Gnumeric --- src/PhpSpreadsheet/Reader/Gnumeric.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index 810967308c..4d4988e945 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -17,6 +17,7 @@ use PhpOffice\PhpSpreadsheet\Style\Borders; use PhpOffice\PhpSpreadsheet\Style\Fill; use PhpOffice\PhpSpreadsheet\Style\Font; +use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use SimpleXMLElement; use XMLReader; @@ -431,15 +432,35 @@ private function sheetMargin(string $key, float $marginSize): void } } + private function printInformation(SimpleXMLElement $sheet) + { + if (!$this->readDataOnly && isset($sheet->PrintInformation)) { + $printInformation = $sheet->PrintInformation[0]; + $scale = $printInformation->Scale->attributes()['percentage']; + $pageOrder = (string) $printInformation->order; + $orientation = (string) $printInformation->orientation; + $horizontalCentered = (bool) $printInformation->hcenter; + $verticalCentered = (bool) $printInformation->vcenter; + + $this->spreadsheet->getActiveSheet()->getPageSetup() + ->setPageOrder($pageOrder === 'r_then_d' ? PageSetup::PAGEORDER_OVER_THEN_DOWN : PageSetup::PAGEORDER_DOWN_THEN_OVER) + ->setScale((int) $scale) + ->setOrientation($orientation ?? PageSetup::ORIENTATION_DEFAULT) + ->setHorizontalCentered($horizontalCentered) + ->setVerticalCentered($verticalCentered); + } + } + private function sheetMargins(SimpleXMLElement $sheet): void { if (!$this->readDataOnly && isset($sheet->PrintInformation, $sheet->PrintInformation->Margins)) { foreach ($sheet->PrintInformation->Margins->children($this->gnm, true) as $key => $margin) { $marginAttributes = $margin->attributes(); - $marginSize = 72 / 100; // Default + $marginSize = $marginAttributes['Points'] ?? 72 / 100; // Default switch ($marginAttributes['PrefUnit']) { + case 'inch': case 'mm': - $marginSize = (int) ($marginAttributes['Points']) / 100; + $marginSize = ($marginAttributes['Points']) / 100; break; } @@ -513,6 +534,7 @@ public function loadIntoExisting(string $pFilename, Spreadsheet $spreadsheet): S // name in line with the formula, not the reverse $this->spreadsheet->getActiveSheet()->setTitle($worksheetName, false, false); + $this->printInformation($sheet); $this->sheetMargins($sheet); foreach ($sheet->Cells->Cell as $cell) { From c288c11d0150521e9383cc9cfa217f6891bf733b Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Wed, 1 Jul 2020 20:06:36 +0200 Subject: [PATCH 135/659] Failed to avoid the void trap --- src/PhpSpreadsheet/Reader/Gnumeric.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index 4d4988e945..d96d562e31 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -432,7 +432,7 @@ private function sheetMargin(string $key, float $marginSize): void } } - private function printInformation(SimpleXMLElement $sheet) + private function printInformation(SimpleXMLElement $sheet): void { if (!$this->readDataOnly && isset($sheet->PrintInformation)) { $printInformation = $sheet->PrintInformation[0]; From aecef1372f9582153b42df9b0e4fb8d67f5ef21c Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Fri, 3 Jul 2020 19:26:57 +0200 Subject: [PATCH 136/659] Read Ods Margins --- src/PhpSpreadsheet/Reader/Ods.php | 6 ----- .../Reader/Ods/PageSettings.php | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index ad87192f8a..4f164b6f20 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -25,12 +25,6 @@ class Ods extends BaseReader { - private $pageLayoutStyles = []; - - private $masterStylesCrossReference = []; - - private $masterPrintStylesCrossReference = []; - /** * Create a new Ods Reader instance. */ diff --git a/src/PhpSpreadsheet/Reader/Ods/PageSettings.php b/src/PhpSpreadsheet/Reader/Ods/PageSettings.php index 4a1fc06581..05095752e2 100644 --- a/src/PhpSpreadsheet/Reader/Ods/PageSettings.php +++ b/src/PhpSpreadsheet/Reader/Ods/PageSettings.php @@ -12,6 +12,8 @@ class PageSettings private $stylesNs; + private $stylesFo; + private $pageLayoutStyles = []; private $masterStylesCrossReference = []; @@ -29,6 +31,7 @@ private function setDomNameSpaces(DOMDocument $styleDom): void { $this->officeNs = $styleDom->lookupNamespaceUri('office'); $this->stylesNs = $styleDom->lookupNamespaceUri('style'); + $this->stylesFo = $styleDom->lookupNamespaceUri('fo'); } private function readPageSettingStyles(DOMDocument $styleDom): void @@ -44,6 +47,16 @@ private function readPageSettingStyles(DOMDocument $styleDom): void $styleScale = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'scale-to'); $stylePrintOrder = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'print-page-order'); $centered = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'table-centering'); + $marginLeft = $pageLayoutProperties->getAttributeNS($this->stylesFo, 'margin-left'); + $marginRight = $pageLayoutProperties->getAttributeNS($this->stylesFo, 'margin-right'); + $marginTop = $pageLayoutProperties->getAttributeNS($this->stylesFo, 'margin-top'); + $marginBottom = $pageLayoutProperties->getAttributeNS($this->stylesFo, 'margin-bottom'); + $header = $styleSet->getElementsByTagNameNS($this->stylesNs, 'header-style')[0]; + $headerProperties = $header->getElementsByTagNameNS($this->stylesNs, 'header-footer-properties')[0]; + $marginHeader = $headerProperties->getAttributeNS($this->stylesFo, 'min-height'); + $footer = $styleSet->getElementsByTagNameNS($this->stylesNs, 'footer-style')[0]; + $footerProperties = $footer->getElementsByTagNameNS($this->stylesNs, 'header-footer-properties')[0]; + $marginFooter = $footerProperties->getAttributeNS($this->stylesFo, 'min-height'); $this->pageLayoutStyles[$styleName] = (object) [ 'orientation' => $styleOrientation, @@ -51,6 +64,12 @@ private function readPageSettingStyles(DOMDocument $styleDom): void 'printOrder' => $stylePrintOrder, 'horizontalCentered' => $centered === 'horizontal' || $centered === 'both', 'verticalCentered' => $centered === 'vertical' || $centered === 'both', + 'marginLeft' => round((float) $marginLeft ?? 0.7, 5), + 'marginRight' => round((float) $marginRight ?? 0.7, 5), + 'marginTop' => round((float) $marginTop ?? 0.7, 5), + 'marginBottom' => round((float) $marginBottom ?? 0.7, 5), + 'marginHeader' => round((float) $marginHeader ?? 0.0, 5), + 'marginFooter' => round((float) $marginFooter ?? 0.0, 5), ]; } } @@ -106,5 +125,13 @@ public function setPrintSettingsForWorksheet(Worksheet $worksheet, string $style ->setScale((int) trim($printSettings->scale, '%')) ->setHorizontalCentered($printSettings->horizontalCentered) ->setVerticalCentered($printSettings->verticalCentered); + + $worksheet->getPageMargins() + ->setLeft($printSettings->marginLeft) + ->setRight($printSettings->marginRight) + ->setTop($printSettings->marginTop) + ->setBottom($printSettings->marginBottom) + ->setHeader($printSettings->marginHeader) + ->setFooter($printSettings->marginFooter); } } From 84ba21400c5043b7bc68addbc7a6fc8ba7f6a2d7 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Sat, 4 Jul 2020 00:28:16 +0200 Subject: [PATCH 137/659] Fix datatype conversion for Gnumeric values --- src/PhpSpreadsheet/Reader/Gnumeric.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index d96d562e31..8375b37e7f 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -436,18 +436,18 @@ private function printInformation(SimpleXMLElement $sheet): void { if (!$this->readDataOnly && isset($sheet->PrintInformation)) { $printInformation = $sheet->PrintInformation[0]; - $scale = $printInformation->Scale->attributes()['percentage']; + $scale = (string) $printInformation->Scale->attributes()['percentage']; $pageOrder = (string) $printInformation->order; $orientation = (string) $printInformation->orientation; - $horizontalCentered = (bool) $printInformation->hcenter; - $verticalCentered = (bool) $printInformation->vcenter; + $horizontalCentered = (string) $printInformation->hcenter->attributes()['value']; + $verticalCentered = (string) $printInformation->vcenter->attributes()['value']; $this->spreadsheet->getActiveSheet()->getPageSetup() ->setPageOrder($pageOrder === 'r_then_d' ? PageSetup::PAGEORDER_OVER_THEN_DOWN : PageSetup::PAGEORDER_DOWN_THEN_OVER) ->setScale((int) $scale) ->setOrientation($orientation ?? PageSetup::ORIENTATION_DEFAULT) - ->setHorizontalCentered($horizontalCentered) - ->setVerticalCentered($verticalCentered); + ->setHorizontalCentered((bool) $horizontalCentered) + ->setVerticalCentered((bool) $verticalCentered); } } From 8629337101fef7bf51fb7e062080de510438a94b Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Sun, 5 Jul 2020 16:22:35 +0200 Subject: [PATCH 138/659] Retrieving print/page setup for the Xml Reader --- src/PhpSpreadsheet/Reader/Gnumeric.php | 104 +++++++----- .../Reader/Ods/PageSettings.php | 18 ++- src/PhpSpreadsheet/Reader/Xml.php | 102 ++++++++++++ src/PhpSpreadsheet/Worksheet/PageMargins.php | 30 ++++ src/PhpSpreadsheet/Worksheet/PageSetup.php | 6 +- .../Reader/Gnumeric/PageSetupTest.php | 147 +++++++++++++++++ .../Reader/Ods/PageSetupTest.php | 149 ++++++++++++++++++ .../Reader/Xls/PageSetupTest.php | 149 ++++++++++++++++++ .../Reader/Xlsx/PageSetupTest.php | 149 ++++++++++++++++++ .../Reader/Xml/PageSetupTest.php | 148 +++++++++++++++++ .../Worksheet/PageMarginsTest.php | 89 +++++++++++ 11 files changed, 1044 insertions(+), 47 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/Reader/Gnumeric/PageSetupTest.php create mode 100644 tests/PhpSpreadsheetTests/Reader/Ods/PageSetupTest.php create mode 100644 tests/PhpSpreadsheetTests/Reader/Xls/PageSetupTest.php create mode 100644 tests/PhpSpreadsheetTests/Reader/Xlsx/PageSetupTest.php create mode 100644 tests/PhpSpreadsheetTests/Reader/Xml/PageSetupTest.php create mode 100644 tests/PhpSpreadsheetTests/Worksheet/PageMarginsTest.php diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index 8375b37e7f..32105477d0 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -17,6 +17,7 @@ use PhpOffice\PhpSpreadsheet\Style\Borders; use PhpOffice\PhpSpreadsheet\Style\Fill; use PhpOffice\PhpSpreadsheet\Style\Font; +use PhpOffice\PhpSpreadsheet\Worksheet\PageMargins; use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use SimpleXMLElement; @@ -24,6 +25,8 @@ class Gnumeric extends BaseReader { + private const UOM_CONVERSION_POINTS_TO_CENTIMETERS = 0.03527777778; + /** * Shared Expressions. * @@ -402,36 +405,6 @@ private function docProperties(SimpleXMLElement $xml, SimpleXMLElement $gnmXML, } } - private function sheetMargin(string $key, float $marginSize): void - { - switch ($key) { - case 'top': - $this->spreadsheet->getActiveSheet()->getPageMargins()->setTop($marginSize); - - break; - case 'bottom': - $this->spreadsheet->getActiveSheet()->getPageMargins()->setBottom($marginSize); - - break; - case 'left': - $this->spreadsheet->getActiveSheet()->getPageMargins()->setLeft($marginSize); - - break; - case 'right': - $this->spreadsheet->getActiveSheet()->getPageMargins()->setRight($marginSize); - - break; - case 'header': - $this->spreadsheet->getActiveSheet()->getPageMargins()->setHeader($marginSize); - - break; - case 'footer': - $this->spreadsheet->getActiveSheet()->getPageMargins()->setFooter($marginSize); - - break; - } - } - private function printInformation(SimpleXMLElement $sheet): void { if (!$this->readDataOnly && isset($sheet->PrintInformation)) { @@ -454,21 +427,80 @@ private function printInformation(SimpleXMLElement $sheet): void private function sheetMargins(SimpleXMLElement $sheet): void { if (!$this->readDataOnly && isset($sheet->PrintInformation, $sheet->PrintInformation->Margins)) { + $marginSet = [ + // Default Settings + 'top' => 0.75, + 'header' => 0.3, + 'left' => 0.7, + 'right' => 0.7, + 'bottom' => 0.75, + 'footer' => 0.3, + ]; + foreach ($sheet->PrintInformation->Margins->children($this->gnm, true) as $key => $margin) { $marginAttributes = $margin->attributes(); - $marginSize = $marginAttributes['Points'] ?? 72 / 100; // Default - switch ($marginAttributes['PrefUnit']) { - case 'inch': - case 'mm': - $marginSize = ($marginAttributes['Points']) / 100; + $marginSize = ($marginAttributes['Points']) ?? 72; // Default is 72pt + // Convert value in points to inches + $marginSize = PageMargins::fromPoints((float) $marginSize); + $marginSet[$key] = $marginSize; + } + foreach ($marginSet as $key => $marginSize) { + // Gnumeric is quirky in the way it displays the header/footer values: + // header is actually the sum of top and header; footer is actually the sum of bottom and footer + // then top is actually the header value, and bottom is actually the footer value + switch ($key) { + case 'left': + case 'right': + $this->sheetMargin($key, $marginSize); + break; + case 'top': + $this->sheetMargin($key, $marginSet['header'] ?? 0); + break; + case 'bottom': + $this->sheetMargin($key, $marginSet['footer'] ?? 0); + break; + case 'header': + $this->sheetMargin($key, ($marginSet['top'] ?? 0) - $marginSize); + break; + case 'footer': + $this->sheetMargin($key, ($marginSet['bottom'] ?? 0) - $marginSize); break; } - $this->sheetMargin($key, (float) $marginSize); } } } + private function sheetMargin(string $key, float $marginSize): void + { + switch ($key) { + case 'top': + $this->spreadsheet->getActiveSheet()->getPageMargins()->setTop($marginSize); + + break; + case 'bottom': + $this->spreadsheet->getActiveSheet()->getPageMargins()->setBottom($marginSize); + + break; + case 'left': + $this->spreadsheet->getActiveSheet()->getPageMargins()->setLeft($marginSize); + + break; + case 'right': + $this->spreadsheet->getActiveSheet()->getPageMargins()->setRight($marginSize); + + break; + case 'header': + $this->spreadsheet->getActiveSheet()->getPageMargins()->setHeader($marginSize); + + break; + case 'footer': + $this->spreadsheet->getActiveSheet()->getPageMargins()->setFooter($marginSize); + + break; + } + } + private function processComments(SimpleXMLElement $sheet): void { if ((!$this->readDataOnly) && (isset($sheet->Objects))) { diff --git a/src/PhpSpreadsheet/Reader/Ods/PageSettings.php b/src/PhpSpreadsheet/Reader/Ods/PageSettings.php index 05095752e2..77341aab85 100644 --- a/src/PhpSpreadsheet/Reader/Ods/PageSettings.php +++ b/src/PhpSpreadsheet/Reader/Ods/PageSettings.php @@ -47,6 +47,7 @@ private function readPageSettingStyles(DOMDocument $styleDom): void $styleScale = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'scale-to'); $stylePrintOrder = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'print-page-order'); $centered = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'table-centering'); + $marginLeft = $pageLayoutProperties->getAttributeNS($this->stylesFo, 'margin-left'); $marginRight = $pageLayoutProperties->getAttributeNS($this->stylesFo, 'margin-right'); $marginTop = $pageLayoutProperties->getAttributeNS($this->stylesFo, 'margin-top'); @@ -59,17 +60,18 @@ private function readPageSettingStyles(DOMDocument $styleDom): void $marginFooter = $footerProperties->getAttributeNS($this->stylesFo, 'min-height'); $this->pageLayoutStyles[$styleName] = (object) [ - 'orientation' => $styleOrientation, - 'scale' => $styleScale, + 'orientation' => $styleOrientation ?: PageSetup::ORIENTATION_DEFAULT, + 'scale' => $styleScale ?: 100, 'printOrder' => $stylePrintOrder, 'horizontalCentered' => $centered === 'horizontal' || $centered === 'both', 'verticalCentered' => $centered === 'vertical' || $centered === 'both', - 'marginLeft' => round((float) $marginLeft ?? 0.7, 5), - 'marginRight' => round((float) $marginRight ?? 0.7, 5), - 'marginTop' => round((float) $marginTop ?? 0.7, 5), - 'marginBottom' => round((float) $marginBottom ?? 0.7, 5), - 'marginHeader' => round((float) $marginHeader ?? 0.0, 5), - 'marginFooter' => round((float) $marginFooter ?? 0.0, 5), + // margin size is already stored in inches, so no UOM conversion is required + 'marginLeft' => (float) $marginLeft ?? 0.7, + 'marginRight' => (float) $marginRight ?? 0.7, + 'marginTop' => (float) $marginTop ?? 0.3, + 'marginBottom' => (float) $marginBottom ?? 0.3, + 'marginHeader' => (float) $marginHeader ?? 0.45, + 'marginFooter' => (float) $marginFooter ?? 0.45, ]; } } diff --git a/src/PhpSpreadsheet/Reader/Xml.php b/src/PhpSpreadsheet/Reader/Xml.php index f9ad5475d8..9ea0a82d29 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -15,6 +15,7 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Style\Font; +use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; use SimpleXMLElement; /** @@ -626,6 +627,27 @@ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) ++$rowID; } + + $xml_x = $worksheet->children($namespaces['x']); + if (isset($xml_x->WorksheetOptions)) { + $printSettings = $this->pageSetup($xml_x, $namespaces, $this->getPrintDefaults()); + $printSettings = $this->printSetup($xml_x, $namespaces, $printSettings); + + $spreadsheet->getActiveSheet()->getPageSetup() + ->setPaperSize($printSettings->paperSize) + ->setOrientation($printSettings->orientation) + ->setScale($printSettings->scale) + ->setVerticalCentered($printSettings->verticalCentered) + ->setHorizontalCentered($printSettings->horizontalCentered) + ->setPageOrder($printSettings->printOrder); + $spreadsheet->getActiveSheet()->getPageMargins() + ->setTop($printSettings->topMargin) + ->setHeader($printSettings->headerMargin) + ->setLeft($printSettings->leftMargin) + ->setRight($printSettings->rightMargin) + ->setBottom($printSettings->bottomMargin) + ->setFooter($printSettings->footerMargin); + } } ++$worksheetID; } @@ -855,4 +877,84 @@ private function parseStyleNumberFormat($styleID, SimpleXMLElement $styleAttribu } } } + + private function getPrintDefaults() + { + return (object) [ + 'paperSize' => 9, + 'orientation' => PageSetup::ORIENTATION_DEFAULT, + 'scale' => 100, + 'horizontalCentered' => false, + 'verticalCentered' => false, + 'printOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + 'topMargin' => 0.75, + 'headerMargin' => 0.3, + 'leftMargin' => 0.7, + 'rightMargin' => 0.7, + 'bottomMargin' => 0.75, + 'footerMargin' => 0.3, + ]; + } + + private function pageSetup(SimpleXMLElement $xmlX, array $namespaces, \stdClass $printDefaults): \stdClass + { + if (isset($xmlX->WorksheetOptions->PageSetup)) { + foreach ($xmlX->WorksheetOptions->PageSetup as $pageSetupData) { + foreach ($pageSetupData as $pageSetupKey => $pageSetupValue) { + $pageSetupAttributes = $pageSetupValue->attributes($namespaces['x']); + switch ($pageSetupKey) { + case 'Layout': + $printDefaults->orientation = (string) strtolower($pageSetupAttributes->Orientation) ?: PageSetup::ORIENTATION_PORTRAIT; + $printDefaults->horizontalCentered = (bool)$pageSetupAttributes->CenterHorizontal ?: false; + $printDefaults->verticalCentered = (bool)$pageSetupAttributes->CenterVertical ?: false; + + break; + case 'Header': + $printDefaults->headerMargin = (float)$pageSetupAttributes->Margin ?: 1.0; + + break; + case 'Footer': + $printDefaults->footerMargin = (float)$pageSetupAttributes->Margin ?: 1.0; + + break; + case 'PageMargins': + $printDefaults->leftMargin = (float) $pageSetupAttributes->Left ?: 1.0; + $printDefaults->rightMargin = (float) $pageSetupAttributes->Right ?: 1.0; + $printDefaults->topMargin = (float) $pageSetupAttributes->Top ?: 1.0; + $printDefaults->bottomMargin = (float) $pageSetupAttributes->Bottom ?: 1.0; + + break; + } + } + } + } + + return $printDefaults; + } + + private function printSetup(SimpleXMLElement $xmlX, array $namespaces, \stdClass $printDefaults): \stdClass + { + if (isset($xmlX->WorksheetOptions->Print)) { + foreach ($xmlX->WorksheetOptions->Print as $printData) { + foreach ($printData as $printKey => $printValue) { + switch ($printKey) { + case 'LeftToRight': + $printDefaults->printOrder = PageSetup::PAGEORDER_OVER_THEN_DOWN; + + break; + case 'PaperSizeIndex': + $printDefaults->paperSize = (int) $printValue ?: 9; + + break; + case 'Scale': + $printDefaults->scale = (int) $printValue ?: 100; + + break; + } + } + } + } + + return $printDefaults; + } } diff --git a/src/PhpSpreadsheet/Worksheet/PageMargins.php b/src/PhpSpreadsheet/Worksheet/PageMargins.php index 9ebfb6488b..d59c6afd2a 100644 --- a/src/PhpSpreadsheet/Worksheet/PageMargins.php +++ b/src/PhpSpreadsheet/Worksheet/PageMargins.php @@ -211,4 +211,34 @@ public function __clone() } } } + + public static function fromCentimeters($value): float + { + return $value / 2.54; + } + + public static function toCentimeters($value): float + { + return $value * 2.54; + } + + public static function fromMillimeters($value): float + { + return $value / 25.4; + } + + public static function toMillimeters($value): float + { + return $value * 25.4; + } + + public static function fromPoints($value): float + { + return $value / 72; + } + + public static function toPoints($value): float + { + return $value * 72; + } } diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index 290b834927..d8d5098f01 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -249,7 +249,7 @@ class PageSetup */ private $firstPageNumber; - private $pageOrder; + private $pageOrder = self::PAGEORDER_DOWN_THEN_OVER; /** * Create a new PageSetup. @@ -823,7 +823,7 @@ public function resetFirstPageNumber() return $this->setFirstPageNumber(null); } - public function getPageOrder(): ?string + public function getPageOrder(): string { return $this->pageOrder; } @@ -831,7 +831,7 @@ public function getPageOrder(): ?string public function setPageOrder(?string $pageOrder): self { if ($pageOrder === null || $pageOrder === self::PAGEORDER_DOWN_THEN_OVER || $pageOrder === self::PAGEORDER_OVER_THEN_DOWN) { - $this->pageOrder = $pageOrder; + $this->pageOrder = $pageOrder ?? self::PAGEORDER_DOWN_THEN_OVER; } return $this; diff --git a/tests/PhpSpreadsheetTests/Reader/Gnumeric/PageSetupTest.php b/tests/PhpSpreadsheetTests/Reader/Gnumeric/PageSetupTest.php new file mode 100644 index 0000000000..057dbf69fd --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Gnumeric/PageSetupTest.php @@ -0,0 +1,147 @@ +spreadsheet = $reader->load($filename); + } + + public function testPageSetup() + { + $assertions = $this->pageSetupAssertions(); + + foreach ($this->spreadsheet->getAllSheets() as $worksheet) { + if (!array_key_exists($worksheet->getTitle(), $assertions)) { + continue; + } + + $sheetAssertions = $assertions[$worksheet->getTitle()]; + foreach ($sheetAssertions as $test => $expectedResult) { + $testMethodName = 'get' . ucfirst($test); + $actualResult = $worksheet->getPageSetup()->$testMethodName(); + $this->assertSame( + $expectedResult, + $actualResult, + "Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test}" + ); + } + } + } + + public function testPageMargins() + { + $assertions = $this->pageMarginAssertions(); + + foreach ($this->spreadsheet->getAllSheets() as $worksheet) { + if (!array_key_exists($worksheet->getTitle(), $assertions)) { + continue; + } + + $sheetAssertions = $assertions[$worksheet->getTitle()]; + foreach ($sheetAssertions as $test => $expectedResult) { + $testMethodName = 'get' . ucfirst($test); + $actualResult = $worksheet->getPageMargins()->$testMethodName(); + $this->assertEqualsWithDelta( + $expectedResult, + $actualResult, + self::MARGIN_PRECISION, + "Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test} margin" + ); + } + } + } + + public function pageSetupAssertions() + { + return [ + 'Sheet1' => [ + 'orientation' => PageSetup::ORIENTATION_PORTRAIT, + 'scale' => 75, + 'horizontalCentered' => true, + 'verticalCentered' => false, + 'pageOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + ], + 'Sheet2' => [ + 'orientation' => PageSetup::ORIENTATION_LANDSCAPE, + 'scale' => 100, + 'horizontalCentered' => false, + 'verticalCentered' => true, + 'pageOrder' => PageSetup::PAGEORDER_OVER_THEN_DOWN, + ], + 'Sheet3' => [ + 'orientation' => PageSetup::ORIENTATION_PORTRAIT, + 'scale' => 90, + 'horizontalCentered' => true, + 'verticalCentered' => true, + 'pageOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + ], + 'Sheet4' => [ + // Default Settings + 'orientation' => PageSetup::ORIENTATION_PORTRAIT, + 'scale' => 100, + 'horizontalCentered' => false, + 'verticalCentered' => false, + 'pageOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + ], + ]; + } + + public function pageMarginAssertions() + { + return [ + 'Sheet1' => [ + // Here the values are in inches + 'top' => 0.315, + 'header' => 0.630, + 'left' => 0.512, + 'right' => 0.512, + 'bottom' => 0.315, + 'footer' => 0.433, + ], + 'Sheet2' => [ + // Here the values are in inches + 'top' => 0.315, + 'header' => 0.433, + 'left' => 0.709, + 'right' => 0.709, + 'bottom' => 0.315, + 'footer' => 0.433, + ], + 'Sheet3' => [ + // Here the values are in inches + 'top' => 0.512, + 'header' => 0.433, + 'left' => 0.709, + 'right' => 0.709, + 'bottom' => 0.512, + 'footer' => 0.433, + ], + 'Sheet4' => [ + // Default Settings (in inches) + 'top' => 0.3, + 'header' => 0.45, + 'left' => 0.7, + 'right' => 0.7, + 'bottom' => 0.3, + 'footer' => 0.45, + ], + ]; + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/Ods/PageSetupTest.php b/tests/PhpSpreadsheetTests/Reader/Ods/PageSetupTest.php new file mode 100644 index 0000000000..74eaae8f67 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Ods/PageSetupTest.php @@ -0,0 +1,149 @@ +spreadsheet = $reader->load($filename); + } + + public function testPageSetup() + { + $assertions = $this->pageSetupAssertions(); + + foreach ($this->spreadsheet->getAllSheets() as $worksheet) { + if (!array_key_exists($worksheet->getTitle(), $assertions)) { + continue; + } + + $sheetAssertions = $assertions[$worksheet->getTitle()]; + foreach ($sheetAssertions as $test => $expectedResult) { + $testMethodName = 'get' . ucfirst($test); + $actualResult = $worksheet->getPageSetup()->$testMethodName(); + $this->assertSame( + $expectedResult, + $actualResult, + "Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test}" + ); + } + } + } + + public function testPageMargins() + { + $assertions = $this->pageMarginAssertions(); + + foreach ($this->spreadsheet->getAllSheets() as $worksheet) { + if (!array_key_exists($worksheet->getTitle(), $assertions)) { + continue; + } + + $sheetAssertions = $assertions[$worksheet->getTitle()]; + foreach ($sheetAssertions as $test => $expectedResult) { + $testMethodName = 'get' . ucfirst($test); + $actualResult = $worksheet->getPageMargins()->$testMethodName(); + $this->assertEqualsWithDelta( + $expectedResult, + $actualResult, + self::MARGIN_PRECISION, + "Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test} margin" + ); + } + } + } + + public function pageSetupAssertions() + { + return [ + 'Sheet1' => [ + 'orientation' => PageSetup::ORIENTATION_PORTRAIT, + 'scale' => 75, + 'horizontalCentered' => true, + 'verticalCentered' => false, + 'pageOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + ], + 'Sheet2' => [ + 'orientation' => PageSetup::ORIENTATION_LANDSCAPE, + 'scale' => 100, + 'horizontalCentered' => false, + 'verticalCentered' => true, + 'pageOrder' => PageSetup::PAGEORDER_OVER_THEN_DOWN, + ], + 'Sheet3' => [ + 'orientation' => PageSetup::ORIENTATION_PORTRAIT, + 'scale' => 90, + 'horizontalCentered' => true, + 'verticalCentered' => true, + 'pageOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + ], + 'Sheet4' => [ + // Default Settings + 'orientation' => PageSetup::ORIENTATION_DEFAULT, + 'scale' => 100, + 'horizontalCentered' => false, + 'verticalCentered' => false, + 'pageOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + ], + ]; + } + + public function pageMarginAssertions() + { + return [ + 'Sheet1' => [ + // Here the values are in cm + 'top' => 0.8 / self::MARGIN_UNIT_CONVERSION, + 'header' => 1.6 / self::MARGIN_UNIT_CONVERSION, + 'left' => 1.3 / self::MARGIN_UNIT_CONVERSION, + 'right' => 1.3 / self::MARGIN_UNIT_CONVERSION, + 'bottom' => 0.8 / self::MARGIN_UNIT_CONVERSION, + 'footer' => 1.1 / self::MARGIN_UNIT_CONVERSION, + ], + 'Sheet2' => [ + // Here the values are in cm + 'top' => 0.8 / self::MARGIN_UNIT_CONVERSION, + 'header' => 1.1 / self::MARGIN_UNIT_CONVERSION, + 'left' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'right' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'bottom' => 0.8 / self::MARGIN_UNIT_CONVERSION, + 'footer' => 1.1 / self::MARGIN_UNIT_CONVERSION, + ], + 'Sheet3' => [ + // Here the values are in cm + 'top' => 1.3 / self::MARGIN_UNIT_CONVERSION, + 'header' => 1.1 / self::MARGIN_UNIT_CONVERSION, + 'left' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'right' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'bottom' => 1.3 / self::MARGIN_UNIT_CONVERSION, + 'footer' => 1.1 / self::MARGIN_UNIT_CONVERSION, + ], + 'Sheet4' => [ + // Default Settings (already in inches) + 'top' => 0.3, + 'header' => 0.45, + 'left' => 0.7, + 'right' => 0.7, + 'bottom' => 0.3, + 'footer' => 0.45, + ], + ]; + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/Xls/PageSetupTest.php b/tests/PhpSpreadsheetTests/Reader/Xls/PageSetupTest.php new file mode 100644 index 0000000000..2cfbbb3f6e --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Xls/PageSetupTest.php @@ -0,0 +1,149 @@ +spreadsheet = $reader->load($filename); + } + + public function testPageSetup() + { + $assertions = $this->pageSetupAssertions(); + + foreach ($this->spreadsheet->getAllSheets() as $worksheet) { + if (!array_key_exists($worksheet->getTitle(), $assertions)) { + continue; + } + + $sheetAssertions = $assertions[$worksheet->getTitle()]; + foreach ($sheetAssertions as $test => $expectedResult) { + $testMethodName = 'get' . ucfirst($test); + $actualResult = $worksheet->getPageSetup()->$testMethodName(); + $this->assertSame( + $expectedResult, + $actualResult, + "Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test}" + ); + } + } + } + + public function testPageMargins() + { + $assertions = $this->pageMarginAssertions(); + + foreach ($this->spreadsheet->getAllSheets() as $worksheet) { + if (!array_key_exists($worksheet->getTitle(), $assertions)) { + continue; + } + + $sheetAssertions = $assertions[$worksheet->getTitle()]; + foreach ($sheetAssertions as $test => $expectedResult) { + $testMethodName = 'get' . ucfirst($test); + $actualResult = $worksheet->getPageMargins()->$testMethodName(); + $this->assertEqualsWithDelta( + $expectedResult, + $actualResult, + self::MARGIN_PRECISION, + "Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test} margin" + ); + } + } + } + + public function pageSetupAssertions() + { + return [ + 'Sheet1' => [ + 'orientation' => PageSetup::ORIENTATION_PORTRAIT, + 'scale' => 75, + 'horizontalCentered' => true, + 'verticalCentered' => false, + 'pageOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + ], + 'Sheet2' => [ + 'orientation' => PageSetup::ORIENTATION_LANDSCAPE, + 'scale' => 100, + 'horizontalCentered' => false, + 'verticalCentered' => true, + 'pageOrder' => PageSetup::PAGEORDER_OVER_THEN_DOWN, + ], + 'Sheet3' => [ + 'orientation' => PageSetup::ORIENTATION_PORTRAIT, + 'scale' => 90, + 'horizontalCentered' => true, + 'verticalCentered' => true, + 'pageOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + ], + 'Sheet4' => [ + // Default Settings + 'orientation' => PageSetup::ORIENTATION_DEFAULT, + 'scale' => 100, + 'horizontalCentered' => false, + 'verticalCentered' => false, + 'pageOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + ], + ]; + } + + public function pageMarginAssertions() + { + return [ + 'Sheet1' => [ + // Here the values are in cm, so we convert to inches for comparison with internal uom + 'top' => 2.4 / self::MARGIN_UNIT_CONVERSION, + 'header' => 0.8 / self::MARGIN_UNIT_CONVERSION, + 'left' => 1.3 / self::MARGIN_UNIT_CONVERSION, + 'right' => 1.3 / self::MARGIN_UNIT_CONVERSION, + 'bottom' => 1.9 / self::MARGIN_UNIT_CONVERSION, + 'footer' => 0.8 / self::MARGIN_UNIT_CONVERSION, + ], + 'Sheet2' => [ + // Here the values are in cm, so we convert to inches for comparison with internal uom + 'top' => 1.9 / self::MARGIN_UNIT_CONVERSION, + 'header' => 0.8 / self::MARGIN_UNIT_CONVERSION, + 'left' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'right' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'bottom' => 1.9 / self::MARGIN_UNIT_CONVERSION, + 'footer' => 0.8 / self::MARGIN_UNIT_CONVERSION, + ], + 'Sheet3' => [ + // Here the values are in cm, so we convert to inches for comparison with internal uom + 'top' => 2.4 / self::MARGIN_UNIT_CONVERSION, + 'header' => 1.3 / self::MARGIN_UNIT_CONVERSION, + 'left' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'right' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'bottom' => 2.4 / self::MARGIN_UNIT_CONVERSION, + 'footer' => 1.3 / self::MARGIN_UNIT_CONVERSION, + ], + 'Sheet4' => [ + // Default Settings (already in inches for comparison) + 'top' => 0.75, + 'header' => 0.3, + 'left' => 0.7, + 'right' => 0.7, + 'bottom' => 0.75, + 'footer' => 0.3, + ], + ]; + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/PageSetupTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/PageSetupTest.php new file mode 100644 index 0000000000..a5b287fee2 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/PageSetupTest.php @@ -0,0 +1,149 @@ +spreadsheet = $reader->load($filename); + } + + public function testPageSetup() + { + $assertions = $this->pageSetupAssertions(); + + foreach ($this->spreadsheet->getAllSheets() as $worksheet) { + if (!array_key_exists($worksheet->getTitle(), $assertions)) { + continue; + } + + $sheetAssertions = $assertions[$worksheet->getTitle()]; + foreach ($sheetAssertions as $test => $expectedResult) { + $testMethodName = 'get' . ucfirst($test); + $actualResult = $worksheet->getPageSetup()->$testMethodName(); + $this->assertSame( + $expectedResult, + $actualResult, + "Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test}" + ); + } + } + } + + public function testPageMargins() + { + $assertions = $this->pageMarginAssertions(); + + foreach ($this->spreadsheet->getAllSheets() as $worksheet) { + if (!array_key_exists($worksheet->getTitle(), $assertions)) { + continue; + } + + $sheetAssertions = $assertions[$worksheet->getTitle()]; + foreach ($sheetAssertions as $test => $expectedResult) { + $testMethodName = 'get' . ucfirst($test); + $actualResult = $worksheet->getPageMargins()->$testMethodName(); + $this->assertEqualsWithDelta( + $expectedResult, + $actualResult, + self::MARGIN_PRECISION, + "Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test} margin" + ); + } + } + } + + public function pageSetupAssertions() + { + return [ + 'Sheet1' => [ + 'orientation' => PageSetup::ORIENTATION_PORTRAIT, + 'scale' => 75, + 'horizontalCentered' => true, + 'verticalCentered' => false, + 'pageOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + ], + 'Sheet2' => [ + 'orientation' => PageSetup::ORIENTATION_LANDSCAPE, + 'scale' => 100, + 'horizontalCentered' => false, + 'verticalCentered' => true, + 'pageOrder' => PageSetup::PAGEORDER_OVER_THEN_DOWN, + ], + 'Sheet3' => [ + 'orientation' => PageSetup::ORIENTATION_PORTRAIT, + 'scale' => 90, + 'horizontalCentered' => true, + 'verticalCentered' => true, + 'pageOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + ], + 'Sheet4' => [ + // Default Settings + 'orientation' => PageSetup::ORIENTATION_DEFAULT, + 'scale' => 100, + 'horizontalCentered' => false, + 'verticalCentered' => false, + 'pageOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + ], + ]; + } + + public function pageMarginAssertions() + { + return [ + 'Sheet1' => [ + // Here the values are in cm, so we convert to inches for comparison with internal uom + 'top' => 2.4 / self::MARGIN_UNIT_CONVERSION, + 'header' => 0.8 / self::MARGIN_UNIT_CONVERSION, + 'left' => 1.3 / self::MARGIN_UNIT_CONVERSION, + 'right' => 1.3 / self::MARGIN_UNIT_CONVERSION, + 'bottom' => 1.9 / self::MARGIN_UNIT_CONVERSION, + 'footer' => 0.8 / self::MARGIN_UNIT_CONVERSION, + ], + 'Sheet2' => [ + // Here the values are in cm, so we convert to inches for comparison with internal uom + 'top' => 1.9 / self::MARGIN_UNIT_CONVERSION, + 'header' => 0.8 / self::MARGIN_UNIT_CONVERSION, + 'left' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'right' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'bottom' => 1.9 / self::MARGIN_UNIT_CONVERSION, + 'footer' => 0.8 / self::MARGIN_UNIT_CONVERSION, + ], + 'Sheet3' => [ + // Here the values are in cm, so we convert to inches for comparison with internal uom + 'top' => 2.4 / self::MARGIN_UNIT_CONVERSION, + 'header' => 1.3 / self::MARGIN_UNIT_CONVERSION, + 'left' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'right' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'bottom' => 2.4 / self::MARGIN_UNIT_CONVERSION, + 'footer' => 1.3 / self::MARGIN_UNIT_CONVERSION, + ], + 'Sheet4' => [ + // Default Settings (already in inches for comparison) + 'top' => 0.75, + 'header' => 0.3, + 'left' => 0.7, + 'right' => 0.7, + 'bottom' => 0.75, + 'footer' => 0.3, + ], + ]; + } +} diff --git a/tests/PhpSpreadsheetTests/Reader/Xml/PageSetupTest.php b/tests/PhpSpreadsheetTests/Reader/Xml/PageSetupTest.php new file mode 100644 index 0000000000..8b934be60f --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Xml/PageSetupTest.php @@ -0,0 +1,148 @@ +spreadsheet = $reader->load($filename); + } + + public function testPageSetup() + { + $assertions = $this->pageSetupAssertions(); + + foreach ($this->spreadsheet->getAllSheets() as $worksheet) { + if (!array_key_exists($worksheet->getTitle(), $assertions)) { + continue; + } + + $sheetAssertions = $assertions[$worksheet->getTitle()]; + foreach ($sheetAssertions as $test => $expectedResult) { + $testMethodName = 'get' . ucfirst($test); + $actualResult = $worksheet->getPageSetup()->$testMethodName(); + $this->assertSame( + $expectedResult, + $actualResult, + "Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test}" + ); + } + } + } + + public function testPageMargins() + { + $assertions = $this->pageMarginAssertions(); + + foreach ($this->spreadsheet->getAllSheets() as $worksheet) { + if (!array_key_exists($worksheet->getTitle(), $assertions)) { + continue; + } + + $sheetAssertions = $assertions[$worksheet->getTitle()]; + foreach ($sheetAssertions as $test => $expectedResult) { + $testMethodName = 'get' . ucfirst($test); + $actualResult = $worksheet->getPageMargins()->$testMethodName(); + $this->assertEqualsWithDelta( + $expectedResult, + $actualResult, + self::MARGIN_PRECISION, + "Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test} margin" + ); + } + } + } + + public function pageSetupAssertions() + { + return [ + 'Sheet1' => [ + 'orientation' => PageSetup::ORIENTATION_PORTRAIT, + 'scale' => 75, + 'horizontalCentered' => true, + 'verticalCentered' => false, + 'pageOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + ], + 'Sheet2' => [ + 'orientation' => PageSetup::ORIENTATION_LANDSCAPE, + 'scale' => 100, + 'horizontalCentered' => false, + 'verticalCentered' => true, + 'pageOrder' => PageSetup::PAGEORDER_OVER_THEN_DOWN, + ], + 'Sheet3' => [ + 'orientation' => PageSetup::ORIENTATION_PORTRAIT, + 'scale' => 90, + 'horizontalCentered' => true, + 'verticalCentered' => true, + 'pageOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + ], + 'Sheet4' => [ + // Default Settings + 'orientation' => PageSetup::ORIENTATION_DEFAULT, + 'scale' => 100, + 'horizontalCentered' => false, + 'verticalCentered' => false, + 'pageOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER, + ], + ]; + } + + public function pageMarginAssertions() + { + return [ + 'Sheet1' => [ + // Here the values are in cm, so we convert to inches for comparison with internal uom + 'top' => 2.4 / self::MARGIN_UNIT_CONVERSION, + 'header' => 0.8 / self::MARGIN_UNIT_CONVERSION, + 'left' => 1.3 / self::MARGIN_UNIT_CONVERSION, + 'right' => 1.3 / self::MARGIN_UNIT_CONVERSION, + 'bottom' => 1.9 / self::MARGIN_UNIT_CONVERSION, + 'footer' => 0.8 / self::MARGIN_UNIT_CONVERSION, + ], + 'Sheet2' => [ + // Here the values are in cm, so we convert to inches for comparison with internal uom + 'top' => 1.9 / self::MARGIN_UNIT_CONVERSION, + 'header' => 0.8 / self::MARGIN_UNIT_CONVERSION, + 'left' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'right' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'bottom' => 1.9 / self::MARGIN_UNIT_CONVERSION, + 'footer' => 0.8 / self::MARGIN_UNIT_CONVERSION, + ], + 'Sheet3' => [ + // Here the values are in cm, so we convert to inches for comparison with internal uom + 'top' => 2.4 / self::MARGIN_UNIT_CONVERSION, + 'header' => 1.3 / self::MARGIN_UNIT_CONVERSION, + 'left' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'right' => 1.8 / self::MARGIN_UNIT_CONVERSION, + 'bottom' => 2.4 / self::MARGIN_UNIT_CONVERSION, + 'footer' => 1.3 / self::MARGIN_UNIT_CONVERSION, + ], + 'Sheet4' => [ + // Default Settings (already in inches for comparison) + 'top' => 0.75, + 'header' => 0.3, + 'left' => 0.7, + 'right' => 0.7, + 'bottom' => 0.75, + 'footer' => 0.3, + ], + ]; + } +} diff --git a/tests/PhpSpreadsheetTests/Worksheet/PageMarginsTest.php b/tests/PhpSpreadsheetTests/Worksheet/PageMarginsTest.php new file mode 100644 index 0000000000..b971370782 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Worksheet/PageMarginsTest.php @@ -0,0 +1,89 @@ + Date: Sun, 5 Jul 2020 16:28:46 +0200 Subject: [PATCH 139/659] Forgot to check in the test files for the unit tests --- tests/data/Reader/Gnumeric/PageSetup.gnumeric | Bin 0 -> 2347 bytes tests/data/Reader/Ods/PageSetup.ods | Bin 0 -> 4814 bytes tests/data/Reader/XLS/PageSetup.xls | Bin 0 -> 34816 bytes tests/data/Reader/XLSX/PageSetup.xlsx | Bin 0 -> 15225 bytes tests/data/Reader/Xml/PageSetup.xml | 250 ++++++++++++++++++ 5 files changed, 250 insertions(+) create mode 100644 tests/data/Reader/Gnumeric/PageSetup.gnumeric create mode 100644 tests/data/Reader/Ods/PageSetup.ods create mode 100644 tests/data/Reader/XLS/PageSetup.xls create mode 100644 tests/data/Reader/XLSX/PageSetup.xlsx create mode 100644 tests/data/Reader/Xml/PageSetup.xml diff --git a/tests/data/Reader/Gnumeric/PageSetup.gnumeric b/tests/data/Reader/Gnumeric/PageSetup.gnumeric new file mode 100644 index 0000000000000000000000000000000000000000..53359154866fec0215c55f3144d34ea5444f4014 GIT binary patch literal 2347 zcmV+`3DoucWR z2((1oyvU-Dq?)9^eut!_NODp;O?z#&YJq|r&O;8#nc+N9k;6Z3SAp>nGfrsOF|BId zG;ruqpM;B!`EGhz**E{_zB*ilE9X6B*E3454SLQF*m=Ui^ z*`oH*s#ksCo3ZXKCpq1lhSIX@b*uKTi{Zpu;uWfpkP8%g7*L!zTnUHNLqgg1=u!vO zTkf0PSB9a?ywaO7`fKVfVN0fQf&NPwv}|aSP&M~V<1`8axns+&LbsOUdqOZWiv;FU zR1|7iEDg~LcavkeBKXE}_>$hZOUlS68VVG+++#EdW{4fuQbcx&k0^+6cRGI8*9y9? z7p^_9@)uYGw=0PEW7rZ>fu+b5XvV*b89sGUB&h4r)jGh^wZ4lPgu817hv5nAf7XE0 z-f*&$1qG4v-a|T{6A#0tJ&2f4R90A^I41Q_$BbC$P{avW7H~&+4qf9gfjC)hMtKk646?hGTu$Jgb3wJe2>Sj%%l%@+wb!~K# zYMM3OH;s5RnY3q{@wvuBa_00he9!S1MuM{L1!C965xT|@Lm6>K(?@U}cHOR5>U))X zb8595%W~@N4+@}06K!RF#4)S*cuqp>8%iQ~+%Z9U9nAv5mzbG)K;3^u+^u1l!!?Hs zvwK+Em}R&57kuu>JK`0eFmd<565y->MxoiAqk!XQEyN-H;BUMH_98|e+{iqjNSNLF z*7?9#q(AhpM@TD;H|X2R5n1 zImfe{mgO|94_|z&w*kL(&S7?@9OZb4!Uguf-8HK9CQHPye?q-4U+1t^h~iX`%Y*5Q ze~bbz3e<%{tq?{i7-Mi)NLr9t`XQPHcpxx~>kw5?+@=B!k~-+6f+^U@WElhSDik%#v zI%eB$7q5gD4Kz*&UkB*!l(H3g4p*LXPJH|UGn#hJ81d5%Y~>syAG1^fd&x-R8Q(?% zf(>)!XK`n8x0=C09N~c8JRl!yyFq?MIGK?EvS7zN8(p}Q^L~HoUJWLLqrq@6{ZluG zebbPpfkmD8%vB!h6tiA5D%K_t0RZpDZV~qi3b4O!GgXkitilIMSKWAe)h-&q z6G_&nRFti(E@fVHdyr2zE2%;?_3OBQ`pZT&l~G$$PGl5!d$Db);NF^zBiU-9I!kv- zM1Z%N_}l*?Dt_0euiIbU-g^np9lJWnK{yAmMuj=_EwTl0v<({sT^pAapy0Lb{c62o z8kY>u-@!u%FV{*(Qw}ksLeNzTYBj3+?X92y&qWGpw5$8Atq>+dii;0B}2b=@bY@_TA>9z`1kFOx!20gro2NAf(6P;WI`z_Eb|K1 zhQb0;!sBrK5r;0ByEF{$TrTbc%pX@?(Ga*dgDm^Fj?WNW=cB_y#>!`w02&8e(p4qV z<63IiWwLHblw@AK91liQw|6`pT=jL5+(1$WPSEvTv4nlcgjvgqdPLreik3BHf*~Rj z?fa2DMrVCv2>#qL<qL#y@g|DN`a{$m<(PTw%=RQp*GdI@e}X#8dGtpAw_ z)(9M_OE|FLI5%raUJJ;vVrB+BNuDBU*@HWNdvVbpO(*VP|vsC?2_ z?HxTAjwfz!;+_m9FvXw!llwWeS&!u+9VE&Di;*LRW4w@M92bZQc$3uAsybu& zcB-Fl`ARN}iiYZ{5nWQW%#Fxavl{2UfGk42h4bEUa5i$!`lJ51H-uL=Gj^rNj^0kE zZ!b*aJwxj$z7=Za$r847J*B5a_s3MkC8Zh!pHMAXtAtu(NWE+9tEU|b1`sPL6dgEu zwt-oAK*CSqkCXlbi3bUAlQ8$fOB@^}*oi|ZP=nl7Q}=>s(izKwMUQBp3z&gG0nzpF zJ1|f30d4FAXy`SbLaaxNrIvV%td;p)sH@405q+O>>fGVh($g&_#>_?LeIkGDhe?HK zoZvZ%0x=<<@TE+@&HaowC1vA=mes7<*$YoJrPCQB8t+z}h0-+65%VQlUC1$w`(@FW6VMKxY~OqFhBfz#=T8j>K{0%!%t+==7QB*4 zbE+OAsF9O;O{#81TN`Nm321u*-Pi$bJ!*OL3FuABTTei5THf9PZ9i)H-V@N9mhV3S zy=nQu4(MiTdAGx()jxW+b8NpkvYeyFKc4`%0Pe|{+A_htq!4DZU>>478VO@c*ZPI* zS%pL}p}|LZKQE|{1HH|2(9xfkO4=or{Ek%8etA@KH&*z3D%rBCb^D1_ayQHippx=ums_~x zCRJQ+Bbz0c%px^!WSUF*yK%_?g+BLynw4a-B$FkXEXia^CQCB;Gm%N7f4gRb6HN>y zuYBEmZ8@)xUt4dW)sU^m8!hX}*0COaBIit3u~Yi_#@~#Z>P`KUcyjB- zu++xOW2s;C!E-mz_hG5KeI+fh)GeUrvebj;lhpEqXZgXimd-3x($OD-jyC^h zbo6C?DQ&(y4%%uy`7`NuM4o-ttJ@I;^0^D7_=VJ}ZvS{&{6P9y%>Uv0=+^&hTYeuc zsb@(&OX`{5>`zEN3m-g6o>=n4k|%xxp7?`)Tg-IzZzqu5cY_lokfGxd`%^TF_pP;) R-b$!(!mCfc5rn8d%D<)xx(EY+{Ii`2p3yd8xLoM3tG$_<%WRUy4xcVXoJg` zAOP|22;2aC82U!~Ww4hj0Kl)6+|fQrgu9rxGjiKPJ3dE)`WdRO+Hh8;~sSaJcyu|6&ou7orUF#jm#aj#x8snA==m5(KoY2wF_wOU_{a~~6 z2~BErRQOU%%dbS1Z7Y5E;^d3t9pio=n6!oI>XJnOsr%tN)u*6i4(EnM&Jp}oPAa&O zz0V$PL?izA)gPt1QrD?DYiz??6b2qfdR@tyd6Oln^F75h%v-}sm-Wj>%ZQpVSTEy} z`>2Oxe%ZUU%25vpcX=G8_)gK5wGL45ZiK7hRL6UtQs>0aIkz_HX@V^?KFh`>>AQQ} z2W=oB-oC!R-YiO)NNEUijw8Y9xibt4Y&uBk2^HEUfwL{^4wLjgxsI*v->W38DHkSh z>6GshxF9#0&=m@<4O6WBDn~MlFOpvjp(%RWSQLn*ZBgfHHGfZ4$91rB*5%jaI7+@u zm88q(T`p(E=3IRRz5LCkSCi84%;<<*PB-(6rK=+A{K?ag*p|)Fw){&y4XOOra zYiiLZe5u#Fw*LdwllIdyg<%y;`D_o3=-Rk25R7KHX_L`r!N?Fjk_w|N|$}sn6 zdF;mnR2};Dl@iWINdeRva_`sysyv*4DO2;3M->3_`y?s}7!vE&PW=kNy$S*@%~b+y zQ~8EWD?Y^c_srl4$5yn!r5X4yv#!zeE>H`QGUbi8rDSF8AiGj0LTXQ}lJdQYu@L_f zuN^G!@d9Y7QOOK|FVEpo^X=o^6WtpxA-h8Ni87cgkt%qrysv&i7|_|>@O!;Vi!%N# zj|#v)7myW+Belg$*?GIY4nRdWz1>rw{V4IbK zyY$rj|Gb*zjE!kQhut5K-$u$-Al|c2j=+z(u;D8dy`tx<0zR z`-%qbNjRc(puDslerH(kqY-PUTG3Hk-82kN`GLmm@j!D{^c$)43h557UZ0=j{n_2Z z21g;I=T~s?KxajlVrn7dV%F=fUN!Wp{QJpla*(4_OT~(Uu$&CZlDBj|y7b4s_25QH#%~4Ktno4_op|jMwV`R@p zCJ3Y03r{}uQV5Zuxq62#y33e>*CTJ_*gkqo#EX`b$*GT&^wN?to5ZkyZ?C+7-sjSC zj4|RqgjHw00-CrNBnZt0+_y2Ev8Iums(a~L`Q_a)F?eVVO|cw4-lvG%-5n#A_I$yr z)718gf?+-KGX=wf*R-{S=-cyZdF72czc<+2Y*&V3&EYxjCfE5mPiY^=e%zC8S1n%= z-E~%Ztp|+dQErxf8!5;R)%n$^%yX~8Q?e(6c-Qh0ITPP)Lg~VwCFSxH9;9}Yc@d!_ zRUbK*sxS(McIX_b+Hl5oBFzLZ^Vx-BF!G^fBY(PCnE4KqcA~E@2~iJPebujum}ZAE z&Sa4WpHD{r=0Wtr8gorBGO56d*w~tV1#02eL%~SuZC`cIGz2QtuSP``W_B7@0|L$8 zuLcahT@7ND?|DXy!-?4!27gIf{yu3mX&wK9KhW%Gjr|>7)>V}S{6pn<^|sFk`|zVE z?I#0jYL2*-SS1bhv%2PsranYxScQtCBQKdgSV*7sd4gB|&2*evV*X1|QPmwCBo;Rk zbwJbc*u0qEP}-!mOHTRFm@*>oj=X?hS{HYH)N$L7les}!PqT`}nvW~m8hpq6y&j|- z4|%$r@*;UubR~ro8C;?QD%-Wa@3=BL8YITVp%e;1{sklij(HB+VV_qwu~>wBVLJa^ zl9R3vmD^QHQqFUdLyrgWwQ75@IxFlUXIj?z&|g_0>3ercCw1!&&w!R8Vil$p{Ov)jdoG9 z4xE`ox%)^6l@;^7zdFMRBAs5ms8H*EGH{?F9j)yE$`wrXsH3IWvdV#_B~xYzdYp^_ zmOYEfA3mZTW;2#l_YJkpkm=GZ0Uv8*a?M!>Er`3)atDUUD2rFtbmJ+Z)~brWyF9zG zEK|q;U^hx^DDBqVMp-E$3|vXzeDnmL&vxHc{+Q-=DtBp>p&B%J6>k54D|%Xt()N)B zV)(4?c|M(#nrC@rtT^U$a)w&AkYDOH<7rt9x0|#s@|gy15s9*tGh|*Ix_|-#1uv)o zfQt(Pz<+WWs!W5;ej)&11_A&8FFA~js|)%U>G?%s%ne=Vq^JWqD=)0CbW|#ShY4O3Lj1%#_E zbrze$g6*SyL~wE>(Qs3-7FA}RI+?az2B}b+rxu`&0^+d&YL%(yYtOm zlBWBFQaxQlg6d46!B9#~SY^R~Ex%BV z!A9um)Pu}@e<+rETVw2Sb0b*WN`bSXd-xGNR*O5CI?k!#c+pK)2N_+WQ;Wo0 z3(s)iN=3}y;Q555Iv04m(7-wHE)-?#CORj)*QT!Q;JH7b z@d%fdW!FhF_j0#?W${vE)lgf1*sFO1MEDIAd-JJICtb|gP0i46=`M-3_BD3TzLX*fW@3yYZIeF;b}P^}Tc(!+ zfY4Q%V6q;Z3dZoXXGEr-M{O_Z!);>mIKv!eZDAcE?+Rr2SF@12h|Kw9M@IRT%)pY` zMJ|?Nawj`TX*P)dX>z)?77r$UeD8+Z)5Iv9g;C%Vh|L&dQ7cp-RS47iNh&AkL4TvY zmP^yceT{tp!iUsmfl*~vX&%^#iJA<+_0+k)g#}3nwRJG|1W^Dd6W(Mo8I9nK+%f%Nwda<13&x z>m4ih+QUs5^JZU0tJhS>tgUgu*X%F_dA&WaT^Ew)bi)fVndh*^3)bA|>ukwPWxFg% zH?uPQc8g_$f-X+qb4D~UcI@Jo$4lb7qyr)T66Xie^e(z$E8kXHMsJ)K>*Cs5PFKzs zA}R<@cGg2D_w%iM<$UW!u3`Nml+*Rg!4)i9oD>L9?KQv$t)g@lJ{Co zWmbGQ2?>h}^wwCW1;8iGQ=aPAktpHlO<05^qa7>P5LUjS^%y{%B$KcrJOu* z%(vb6?9w4B0KYmHO2Ik-=5&4mBZ1Q_%b3%c>mM$jCkwnf+hPzi{t7QT;f|tFlZpCx z_4E9=SG>(3Etcfybivg4$qObi^~1OMG<7u(o@9GUZ@#`^RyoT+l5aBWZOT{Glor^y z`e@yMFXd%@?=9GR#@n_t1=NB$E}AX_t2o#kySMG#&~|pV#fm00+V4~bS{`XmpL!% z`F~gZhykj->B|uiJ^(;}dDm5ksfudpX@H&KE)I4G_usX@G(pvo;5xbbaoA#qx3XuA zF#qdq-;g6f=cFXDxfHK1W?o4Tp5$q$nI*5quoK`DB=fRVPsY7?^>C!cJ`CijbFgvP zcRIIQOb;{&wIFS^N<4)72hK8PN^(cfkxgiIH%x9J`0qZZlMe~m=6gGv@PI;FmG;>E zljXt+yL?{Et@~+r>zLGs7_9PQ+1LhN(hWoG?cuLH{?~ZB*m+y z#1mB?&uTgugY@0J|1soY)zrGO%B`y#&~u5p%=Ramey8(gOyK`>E99Q?5Ln^?0L_MV56uByL>gf(fMnI5(6ft zfE}M7U+kLQ^Fs71^;j}^X?p|#qB_?OuR|+N3sBMc>y2WK;w)|lM3i5n=F*1PD2)KZ zvGzhAluFybWzvnu#g?$$Fp=oWK872SL$%`+ z{%GMIJ+ohTUVCPy{stuSipHIhnxqr-;|6Eex{}8#W0E~x3`FC~jP!=Ep|+icXe0(j zNb$nYCi>yE(np`M_rs$gGir}e%u26`1kc)^+k=iRw_I(0aOat)+J3){1idu#?Kc(_ ziD8(39pV>=FHcjBXL@b=KDNgj#-U;vRk_MR#xgDwBh9UQ%m*(C?b$nB-KCq}0yAkb zRUC(UqU!V6Z5HD=>Ygt=J`17qgifap5d&f21(SV&>r?(RU1jv2{{0E?@I`;?C6^As ze=9S;ynot1I*oz$FVz39z5GGIE+79WF@NL!<~x6IOr-z8e*OmjeQf>!$u5c2|9Oc1 j4)J%o{Ru%&eW^(OZ}J&v6A}L!A-cS{E|W8b=9l$9r)hP4 literal 0 HcmV?d00001 diff --git a/tests/data/Reader/XLS/PageSetup.xls b/tests/data/Reader/XLS/PageSetup.xls new file mode 100644 index 0000000000000000000000000000000000000000..559d05326f7887f1c31f07f70c82e30a8f858e62 GIT binary patch literal 34816 zcmeHQ2V4|M)~^``7!)Lk2%<711tkdxCM2mCNMeqNI0Qk^5fo2ZSjAP0h*{Wm&6smS zG2!B(sHmW)t_o()?5eE0>U{5YPeV^nkh|OcZtr$#e%0Z1)&ISE^}4!VRdrAKMdPY9 zyPH)LPUuRs$Y-e@(P7bfa2&v#8xgoJmEtM0_lIL3X~KVz2K0nbkviIBXxMq(lY~!n zgoISXewP5x2)PS!I2lhG5E2q4Ne~4@C5R=WKRyIdGDPuEh7(|TK0G1e0ZoetNIvY1 zi3KH}3AJrZZFf?sk5XG7VnU*XQNmIEB_16BgFx=Vd_OAPd}?b$Z5zRsM-EbXZcvnV zq$T+Y(hErr8axP~%L^n?B$33E(L@4Ug%l(HQz_bzIFQkck#vLsM^X_926kb(ymsjlWw>v~_nU|F?7Sy~Fri8g6Wh|M}1TPIsvx6Z?z znZuTX7Vso6XI&c>As#b=ouDPrgyiy;9V1;Xy$^9B&@`|afdCv{G^LK6 zuWubgPtumSvKTVCW&D|}6x+IdRm2o(ija3w5w)i`Cqx=LYU20T1CNMk6;oRpUmK1o z{qK`q60D~5uSnmif}X8{zDfl>PX&F83i>t`bXD>!Q;~kF3c4zMRq1!D!1<%)IZW|w zqEKJQRM7XUpdVC0->ZU7msgQ5El)!QdA3tHh75g)vGMYT%NrUA=z1}(rN_h^w>oZR zB%tLngBFCc!(Si)6=?f3gQiS5-AM(#jZ!+a<~04S3|@ABL2r(x*V;dAhq?^Cf`t2t z{H%;*>7i3dr>E&=3|+5|F7gwdFjt^+_!=bxgX@nWW3nJ3|USF@W}83yv^S&k}e(G=e8DFJ0)*$Hu|gkQ%2pU(AiGfV@`6-# z`5ojy@`;Xe5a}6pAl~vIgH%W&eVWgbWD%!2+XIMhZE<{kC#jI6Y-KHouB?a|85vTn zUJO|6s1G(xk41w^RA``tmM-K9)e+LNh4NJ{)SEYN6om5i^;HmxO=E;YnoK6}BWdB; zG)18t<%Ie*U4^=p3B}gRzo#kg-RK2E)mfv0Pz*C^Ca+dgiY04PTQa==F(@_Z4I4Jp zf-p9~RxQJfO{>4Uxi_W{h(X_&Xjf2I@;0DY3g|Y=j0Q`AZnDx+NTp>8rP#A)kAl&# zX-p}Q2DnsUjD}59Y+j)&&MF1kft*n3!U3H7u?u7n)V9Y8r9i!7@z{+T>Ybs{ccZc< z*9LOYmZGwf84%U&7CsZ}Koq3I#!rigW7yIuwxDM90VxYs57N9oAl$~Ed-vGNfxwBP z$)HZK2d-Kt*pI4*PSk@mtq(|9uzHXd^#O7BP!D1!2LdO`b%MPV)jGjGNj-F;9t2$b zFN2f?s|Nw+{>vcl9_m5txlXXBs#+)5@2!VU)Puli#+O0Lg4Kgq)d$4gLp?|< zIS@Eet`qERs@4hiY3rdA^&rja15y^O9z;|h5O)vtAg$#<;6%Aj&_hwJ6ZG%up%e8W zmh}NC3sw(eT^|s44>rhRz6mjc#}{#Tvllsw{G+4ANh$4eg&`ytRVNGDf|gPP;toS< z_C!RSA^MYO_=!mpH7JY<;1PYID-g$AuYM!d#$$ZiKrg@^nqxk)G3K&yS7c+Oh7Ik5 zP;9itF(2<=RnEqQ%f>^IO)E8QXfK6gqa%)a{`|ReHjTM#JQdlrQNsrP7@5*^#WB)1 zWy;x@a@n+3WaFZS4Y~_5HbQaCt*150*)-v@@ls^tu7(ZWt)-NvCyu%M@`iFYX2`}< zy`@zCalpePRPnEUA5N`g5L}Eu^|CpOu7klbohO@j(ee_N>$=wsoLj zQCv`K4k+7-2zj2~PC2Mu9Vplj7u22u%C;Foa4dm(s&gf^uLA{Z;etAHK-m@oMLt24 zgSM&z1>4|)I&(nT_CUz6yh`Put?NL+61br4IH2s>CuIEgAZ4IJ;s8%q5)d^eSJ+X$ z=6RM4+xA(j809AN{LTS$`yVs56Cx@ zHYD^Kf@qQoD+!{Y>lIIup$mrNDERC}P#n%;7~t>{#XyI^;4oao@eCd$W}gY=&h+HY z7V`~ZA{7Su1LMTe38Fx8Vq&f^gCkc{X#w6&nYnL3cxfsspV1SKbfp>~$X>ECK-!qNg}&Ong$T z2z&*Opjt+t*`6Q}+I~C;8Vdr_vk(ZU3pY%+{$pu4G(}yIjBW@Q^BaMa!2*Z2j|*JG&>$_5i7m!_LsuAKT~NqIq+}Z{zlM2f_5o5 zJ}E&wMt1-A;Rs_6?GmmKN`kvz3{}o<0kmqZv9>K@S|1$Z)&a%o6K{~8go;yBBvH`3 za2jS_b7+`D0T@dv0h_{xh4yHu_7o;dnDXYsjEcSQ#vhoP93!}9+)KsWWb?CrlG}gX{H6kG3B~;l|ExyF#3#X!RWKa z{D!0>E{hCHO`$4yGKXmsfDWUItXReD79JZ!xhh6Noh0-bBME)RNJ5`s``9T{8&qW{ zCjw7f8}uFyWtP6%w#;_k2n4FXXV^fj+r;Ha*9O05SE^*tUbD_m1P(4Sv&2-k1OrWO8>rR(}3SRl{SG+AecGSUpR%Wm4RS_GeJ{%t#yvJujj>IZw z{pDXf@XxiM)GG5+W~1||eSb24n!TvQz0$yI53~;KYBAX7#e)wk?C$35EA;gW-PSu$ zIAiaL+=^!fA9|FU1-P6&-1?o%`nK6?&JQ`&|AWP@$0Nn%o=Nd8{p`q# zu_6oShsQgAm;LPK)gg&TZ!OrfV4By+ve1)K(^2nyA2+^ImN6^?G$Mu0rM$j2T;25O z1n9{NY6B}PQX)>A=<0&otc4fH7Q5-sdO5Rb#-;SWmy6BqC%JCO33OeTPO2R;;%qE$ zT0XrQc1EYc5nmPbeb2>JPx3jQF}-x=`c3x2VQJ&P zSvU3O{>Y=@m)3PT-_CMF&jW5tO$=vW4?7yMBVf#>QlrbgyWjL2ZI`iW(S*orRx7@< zsPYQF^3E*cn)j$33kyo6dyC!5z6(29y{Rj03+oO9hf z`iMjK(R{^Zn)3H?KXoH^ckF9n;FZJ_bXa@^ua7h|jysKKN>y(rpd!6Y38N-<~P36>&JaUHyFYE)ssX=)a^XWSkGpgc+WlQt^xeP`n=V2-6#LnbKFOBeM#q{y&KUfxX!n?> z#ukgTo;GQ{JJB{G;(pIw6)w&%B>oYTQrhPBbJcFJzPqdT-=3~&`V4rl4j~zTZdvu=q=*8aIe`~#>;iE5@^oyIwIaLKgWGy*Q?1@x?7q_Vt5)d?ZLF(j6-Jh4d@i~0t-(H@ zrfVhhw^?7ilriz};S+ItHrL!gDZ06@f1BlPj;#F3;Co4vYda3KecpRxm{$3CVe62? zfA6$4@BHQF37MC7HoCQaY{J&KYJ*S1+U8F__mAl6_70ViLr+fb6tZjW%xmA9MvgqW z+;V@9b60ozJ09CJeW%%^VH>t=h@277`)+B2!tfo5?VD~oFN*F_lmBYy;fl>k7nVM9 znEj1YVTD<=*}2r+W^1BLI>XYYId<7T9s9g8H?W?QH#?Wt`gT{n0O3)=55XrSQG3fB z6HjKmb9|C~V_lr3ZQ#(?{8ppIy0CeS$CC<@ z&Xx09mKmj1H~YI+b>l`uO0)@+(k zbvr*SPJDF&N-v-Iyxn!5ag zjb*9*%0nqHY)gX2%ney(J;$W!fuOtPr*AiHEbM!~MY|`{C$CJORgmyXYtFU8-}Fu{ zJ905hu+aMOswHno-{ZlDi#fhC295IZo3w4qQ}c##i~C3JU1d{~y({3rEUg3IgiSuM zBrV2afl=h959DaljiUwwF0AZr_+_ytQ z6V7EcJ$$C>SeFBF!>f)7ET+X<^nA9lOn2Ospo$wJ!xdep>l80d@;@!fa9R70EoOP0 z9+bQf$veVpX1n!HcF$=^Kku!0zeM`&fin}lhlds48<@CZTb~1+o<^L#9Wi5XqZ+Hk zgrRZGtfC6+wsw5FaqHnHV?RpM2km_^^4Jsc)zs$RMe_`ONgXpJzAGZZ z>WYX`(-E5=UO5t66l3|=@#*x;+#-FwXpg+p%Vu;--CZzmeQe<0m;H|&`#t_7+9zpN zdDCk2gaMH=ev%}8zk8))+_P`5emXnQA|PgVZlUit+3lvyH<{gH&3A=H237mdg}-_G z&GFtby$hxs&b&-w9#D%#9FSg!`1%M0ItA++^dF8|@>zKQZrp%{U~$bEiX$dsua+rLie*2gGRI8~as^TR~Lr z6zk@KEhkp>*uN!yVEc$h30q%$2skV0ak(sEF?i2|$~i|*j*S}q zV|>iauzod?v)i2|w<1>O4A65+i}4MrEb{YrD|nDMq{8%GrRO%u`)QRsTFlk@F7UZc z_ftRqx^(6Z`y=A^rw+Gp8oBumD6Hbt<+MwK#`bwS=;6a*mRk4MUT)}*F?|2mI1?FYM}(MD4%iN&(;RnonmIyB3Ub+s}Z@wu=6 z#OpJ)9oCkVRoUik2^O3kR#qpDX6$yh;2A2+;@JOHArSGXvIyJ5=~GdmhP$Ir4nex{5H|fw?dM zFd!ixU$4VHI|l6Q2>C{`;}%rK`SA=X8lGrDKN&AFG?ao%!?LkyMfi$21oS>%`Qn!N z;a2F!CwL73@!W`_no?VH*)_z+Yt1RDh}zn~H6558K|T~3?7RBGhDSb`5qne)Il(_+ zkNr8`3EqhS=-<=nd9~@yAwA^(tUNs-*TAp9j$#)W(Z=5?9-PAu`{5{WS6DuKfa)qD zVL6@zY+v9){7N3C9$l;AS_y`R=4_lLat$iB*Wa(AMXhf zf}RkMpeMAga_s)0+aFS%5Oa*45aa#)v7QiL;|Wp5gd3*C(Rf0&D$yKhG@#MIe?S8^ zz!RUy8c*myp!~l)ON}Q)n*eq(|0WOPY&Rz zQh`tGaorg97AcnqiPQm70|e+BAwr#Rro`fr1LB#jiav;LXoba&(yn6{LfQat{?t_RN??Yx>)PQN~{#-&e%?Q)Q zM@y0?CdZ_Rx~D~p6Nw+tGP`w{`l0Vt9v%~&_4hl6%8qBRX!0x2Ws~Z7RTDHC&}cxT z0gVPU8qjD!qXCTuG#b!oK%)VT1~eM@OKL!!|Ie>HUzzV>X|#Ab`2S8HcA)=n4vs&* zvV{IW`u(_=WH3bhs6P7t==Uc=L|+|0Z-)NG_GLl#6F2bc#Deg3Nu+2a5(96$xy zUpJz#kbsyNxcipCL>uVv2{PG7m+B7P>kd8Y4n3*y3F-q)9@gQKc=#rfzeF5G^Z^OE z<7fnO8I&wZn24Wonn4x5n>vi{K+<_=jNlp9KF*FeBR3#|Th&Xh$L; zZsD^E)E2&8rX--Q8S)_DE`hJlkEY~EV952}o4`^ucD>a%V|WyuQX4+0hM)SzKb^p` zUgL0@!$EM>SDo{5M?6gTY;D-MSG7diKhBffd$_p(xu28TcefdYX60RbTbsm|W|>H!J@k^lt)@)`sNOk3E_ z*4fn7SzpE7-qcB#{+*3AVJ-w1Wi|*H@c;ik{ugUtM0HuNhY_`d;|wopCAHkQAG3EA z>{3ax51Mir%W8MA@DpKMyBTCN{o7DP!gM* z5n40-_{NJ+GR#1#zy>JC1}Kx>?ju>B8dqOfRh$t`G=Gn6TvN#Ut`TlVR%I>yaDhti z{)`wWCh(O5XZ+?ma$i^rbH@4XXRrc|-I%tD-E*-)6|AHP_5M42o5-?4ZWjm$e#-fv*^ce+OiB=0N0_M*4B7L&UpL;Eo`QpbJU@ejDEy7H z^{R{{7eGUl0a6kU$XR_yQ)?#%`k$ZwqB;(xtzI55tnkObZw8OE^R8xkska`A~tmm z&X?k+)i0~LVsujhIwPcfR32Q_$dSDtKbGb*msGfi@a6-T%;97T+7~AyvxN%JFV;kt zx7e!6=3Ew4MwyP>#P0eg)?Mc!X`QbhJ?Z4qzbFy2qTDc#i4TxvU;1d(v7QZQxc70u z_LhD*9rO<;C|Ut-U;j>$_`~!ZIUs!opg};8fSP${&ERI|Xk}z)XZ3Sa%U4~p-CzfJ zF^u~tgtk$mm`XMT&co?fgEo{`FTB-U5Z+W&{1O)$LUea9+(SSpk3%fgQ;;ouA;WgZcz2mx8mSU} zt;GKxgzy5O+Ry3^*v-vln@Fz70aKe*n(6CO;DcyUOh{Dc}jGGj2eyqHlNAj-uA=%~=hyEb<@!*5D08fZ9!)8qhg7~^CaLqv6ViPe7tQ~ZSw zdJ#{qO|Cn>hd?+E_W-wWtf5#lCqK!`3AU=6eU;^y6P}Sj=X=Jv4}lUcpblxSeK{GwP++>ggP#i zu@>XVUG7VmZ|Y1u3tQ$_4Z;xOEPZIax=!)yQte2dnxsTJJXoOM%)hr!L8m6 zVZhJBEmy%EH`vhidQyI8!`zR>C-su$4b)OrAk!5^tvh!X`9j^BOfPUD>aTE;TFOU# z25TXdaw{5l8P4};xZ89z`oivhvdd$QM{ZxekJ89&?25I;IPO&0U3XpdQz*BfRDzDS z$3FE&YCjA~DQiZvLL4tOM$zhdD=xLR5y@}C zqZCz0TO*IQ<&oG`A+1cLt+fC8($3Mo@#{1PN!n?$gTyoso3-2qXrW)+!_ ztxP(H4YqJScF2x8vC> zLZpm@FPJ5v;;WKHz1zCr-t=qk%9C3hQq+nv>}@PKXVR8U9wt+r(5~M>S5^tGt`zpw zDJ(ZsEps*=8F6@g)Ul&*h2^FieK;RcT4;aNj|$gzgSR_=EkI3ZcOM9GZ+E(@4#Z{ zDK#_ozKt8h%jlTy#nKB{kzi1y^B9dBt?GyQNXbPObk*6pk^&p;UYqGE0qyyH8q+yS zSaZ?@Lh4R5Gm^7k&RLi3uhqfB;ACAXA)ADo!CY~z?Vt3QR8&h(7mBX&>pP9Q-$e2# z2J8kDIkUY7RSvt+&?NK2ym9#$!ey9nIIT>g?G>D&#Pq>)EozhLqqX5jTBzET*TE0t zL8e*gTNF_X-^VOYdSCa{-edkai)b)tKjoe6L|DTh5IRHnlOaL#WXG2Pog6M;aDoZ6 zkbkV!%CIb{VemI_5-cKsl1s!ZwqjX@wqcW$9T8Z}^hE^*|8xT4+76Y_~Gr=x>Kh12u5^5DA`*}A z1Bsipwq|-GaG+$t9P}R27bCQ^(6wxlS#g<}!np5aczbrAHHZDVGFiZGzbEFOo)8LO z1!f|d-(Y7Tn%9YY0czDzy%Tb))KLj2vBxL;azSOIX#86|Wg>I+CT;{Kd<&t&pjde- zU{ar$!o;$R=rK5w^+$U=vAuaHZrv~HPp#%gC^;3l(=+v!ADZ}GpQ=0qCZJoX=(s%! z?x_4`mBPgrG#6#MGj)*UUu9p=#-}3%H`WI^;D9YcI*Rg6LlYgv%o8&L*Aw?01Na)Hv~h$b zmEhLdYWzNABTf*ist!XR$w(=@R$oz?j`1!!DSXP6u%mzCw3@Qv+N>ARTd5|j^(P3m zF1Ob9QAl_UzRC|cvQOT-$P@8KCJkPb#ra zDw{?LYg9h|&Oipd!EDX}JDl{&x)IX*vEsE>wlj)E+pECr>^etT8k_99r_Pp< zEuzJ_0Ez=GLqXN)_~_6`OrMKv+PbcdE6Lh~!G%j!dWcHGl-V(yXKF^_NyFIse7$v@ ziW{xzyx?@Dr;nuYl_#XKHBN)m?lV!j=w!!|GZaiF1XkQQiJga+c`A3c7rm17fenX63QP)i-1!=@H6-9=~Tb~wy%9!FfQn=ypGEq1x5kPu+9T4C0Q z^4y(BBie~8naE!yotB*p%5No<5tsIlh@6Kc7mg~f-#OskIxvbYtuj>Kj^5O;GvdWs zfjbvOn!6FAex4<#JK2#@Hh=ZODesfYc3%v!veAY>0Fz8SsjH4XHu275nWz}u7*+7Y z9OP&ln~4O$gdI3`n}``W_OSv|-ytd_K>_71ny5z@lyloBbAgTCuxxq)<-96&)&*tO z>?uA`@Kjti2-#;$QDX%aG<6OPeX&m@=}~V%c&A1iq68ygZL3hPq)0Dhz4pLB_>`a0t-|uz;HYX@K{DykzliLlZmOz; z;3o7>?1&25}qcR6f}62A<*yWPQEJme$e2- z>-x6TAYF!JQ$@&ksJB~uMt!6#pCr^|KkQAHrZnK4v}^HuEl^nfxw5oy1Rc{H&dp{0 zSzNYLNb^@nh89GpgoKkLWR1z@>YvIhl@RNdc1-o@?XFc(|7_u|%SP((KrdVY=!O4> z6`bWS3;%AH#t87vs(S|2bf3>>Hy{io%$9mBTUuA4I%PYC_|X83u{I-rPrs98G@9*e zzS{nhLrCZSaVrl`$GZ|5E72g6Hc7xS&zD@;ey3SllneXkBVLgtmHa`;&p4^s2#LGI zj}KIOPG^+TQi+f-kunO!DmV)bBT`zg7k21u2$k#=UqfaY84jx{#JPp+54qw|R9W?4 zn*fN<(Bbt^Y4emb>8uth!HLa9QBRY}thNx#M_0hqU!OHukFn@Af-sq(DW@T#YPz87 z(qYqoY4dN%s**4KJzVIOzF6e!#jus$wK|Eg*q0fErx{&% z*}A7um7U7vpyoT*E`-`rx*x^z6MyC4$LSMBOMs&zB>|d+~?}H~YRX z?*gVG1d^i-H(ervfkPa;MkZ}}QxVyF1ij`U5n;|(_KyV|$7@9#duuFJyf*HOU<96- zdjdQ6*h@jS7OS|bhB4$ENN-NQhX)~@8q}Y?0Y(<~V4(K_`>1;58LdZEuB z*%LKo)8fl$%RE%DlAxB0q)XWaFw zf5bIz`}+wt!(ghb(w*xGQ@T_1iQndx=B)W}J#vYp18N}VS#Yrqt7%xWyxSZHCYE$s z`fSM>)rwPqU2QZ$T*jo8vV$!$BP;pm#CjW<4~A&T(-0+F21b>9e8M{Y)5lBUj0_dFD$lyg-{y257Uzi+pwOo^jYC=;PO z>>&9pQFD`Holsbc?fFJrcnI;E?s=HrtHMOZAOzp28$o@K%s490LfSz{PW!niRt6>B z@bz1mc-p<=o#a)XbNR?`E|m#dtpOptpNSYT^_;dNNY3xcpt<5q28;OtD=s{@6^f&9 zEyYJj^{qR(Wwa0mm>1#(Q_Yd*kN!ANbMTJcr>x)nwNlBnjsRt}{+@Nykc45-&mJt& zA3a>ryQi0ErM{qV8~IEy;2(90?BL_!DuVfo&pdgk+-K~c%FN{Dv8YBzeOH6@N%p{V zE{O+Tt)v&fcfM<&KHPAeK`ugH7~9(Tv{Hugx!s+i#ouzZ#IF=2;A#lZd44Al)s|}G z)LLnb^||5U?n19(w@$i~ElV&fEh*_Cc3+7VYNlD~~*LjliEz&e=DJ@roaPg=1PoJ(cz2BcZpG~%Zd@ueHt|u-@ zzeC{%UwXv+N7AVzA1h8uR!@0}ga~9)Sle4T+6U>SEN@3-n?aa?dGK2i>zpJ4Nvha37K-k*WK$>?Jg>WdRV-gPZH9{vKRr%kxu<5G3hvxKYB581}sX|>Qo zaMny3l~O5I4f)MD!WGkvd$lBW`1I61Q)W5-yg9TrbUfDTm|m(34I1tAE&>UhzRpqHh0J+wqWNg_zlE+eBD0wIBCb-$>wlOmRLU5`A7v`r$w2#FMZzRh(w~XZUK@Q zp3w_DB7DNQ3N=jM8etoH9^Vo-L2g>6CQy91GabdNZi`51C%|y_uL?I^>SaL>CwpVq%m&DGQ86~p-ya&h<7MeM)PG<^)lT6)HJTdYL?0|8HUF6 z`Ygew%FNEe{~bDIDDwCGTWpbKDP7L3bd~oRQHZjuY+zdio8ePbbCA1?ajl(_2azzE zX36i-k3DtmX}s-f2MqLA_>MXtuskiX2(KEiz5*1j{CN$7VP3&wEc<^zd(sifDAlq) zPDq^^}zjnZ^S#IF|int;~oy?N%h zF8jDLr&)JZC%u`Q=lhbkQ+oWBrlVFV=UV-jSC@j8DQ%v9L*yqvb~EMMs<&8(5{`!< zKer0Gc|o*IL_jkZEh)B8G+Tm>65phmh;c`S`}^I3K3is z41SB7uw#t&sV=20qT%_|qK{3UC^hoHV)2H)EL|~o3&9$LX z_XY54ZKMj&5TrQ(oO!;yW9}xg2wuii%#9j}aZ0k@}}ATqigoO_1@ zIbTDAfd)D%)Hgi9asMlmUs@Gf?AEQ@y1|h7TwB;AS3(pCcesLU?njf%9=6bmkqLPk z0!;aZ)b5-EdftyE;8*SP%NztVLrzc@+h&EIsrRRy%HW5mH2v65g7uY_^(K%LF z(KjQa%(zRntxbD{gLgC1WsNY)YPQMshSk<8F4eKn!obT;$L;DCHnGlm@wCstrF@>Fm2uBdr?5D(WCk9o&KH7>H-0$F9i&&TeS+|Q zxoQHJ_q3e^0daB0R^fo-RlQ@QHjE{isdt`c5p<#yPf;VzWA-BDbsUu>+p?4W0!7RnZkIHZ)bb zeR6eZyER~6tGp6T7bbEsgmZb!dY|s25@_*XcaBF|6PsI6Z95ILh9C{b&rb~4Bw2o6 zuaOG#EYl{C(G5Q@(jdLHEPH;!ya;Yli)GXgw1^!rek7~7h>j=l!BpKOi|pk8%rpT) zT-ks3n&<$hwiFM=!J=n2a2xq@K*3j`Kve+xV znxeFLZLI9ZAhgREP}&cA&~v-V?&_m$w=DT*13-c+OjCbE@C4u&DMvE-y!CG{#X5&l zKS+7a*_}O=39I9YBV{=b+XBA@8_<2UdThCNxH6x!!q$7FMdFLtWSjTVz{_(uUQocN zqB}lZj?E6TCNH8ItInT_RdUMp&J~wixi@1FCW)Ms{v3q9Zu@*=7`t#9S55J9`b&q~ z`cf&gXSFrE7uKb^JZn)HtEK{j8cPGWIjZw)C(_&N5&9ny^bjU(oFLc`wcU^cC!e0m zJmk$fzOxnKb;%E8H{w6;wcW>*j2bP%Yc$eOX!AyrIwMStBiACkLr74O}IYj+KKv4}EkLFasT`d+mtR{?CAwg9QZ_mC=NK*2w z?bqc`S=WXeYt(u5%zpr_WT-YE`#*kbqr^~vw}Y!8KP=eyh*!jBfIUo=)=CWYk*p5x z+<_!gV9ks`mu#Z`!C0_0qYD?Bq@WYReWyVoFL?pqA2?*#-d`cBGbB`sNU!VC3O= z51DVF5N<`r=B`&QHqIElK4t^Kl5h}bdj0-gt=lTBX!z6_dWZK&q}aaU_J?)WN2&UU zF;gBdfh{BEMf!Trcu1^U2&BE$GitA^hI^Qq#%*Ih)oBdIAY4lbd1i}2TX_;Xoyw`? z5Lx!8^{W%hxygC$nYEzJ>2hW7~P1+)^l$X7BSRb`NFH*ik}EPYKL z+@rm&eZ4-!JM*p>6I@++oP#V4!Gd6$s1OCF}nvodOZLVD-blotLz8e5(}R4Q`JP zkP(7KPmi`Oj8ZCPq_Ak1e+KCKT#egRw)8c@3~$oY6jU%5j{o$7FT74jqJ&d-;j7QW z`PoYOi;(u>^>AT@`fv_@C5iitl&OA91VL0cO%l${fF61nz#i0ka z(lu}TFm^Fwuw~vaoELEEUO~q7TCGh0F6#`~sVGP$-Z~JsD2^ioz^!<6ZYKCt6qKUM z-kl`WwsOZx9TrM`g4{AQAS?cXOYg%7GKmaFE3*XBS#W~kaHqOI8P-SWJNS;z05YK( zaimi~hv`vila$ay0}*9a8SAK-yjDJA^;y=N|80R_m-S0 z;!O|prwwt;kxC7ZY;n(8(0jknNu4>}dbWfYZJZu%dCNos?=a4ozvXXMKW=I4Wcird z)q%FB+IdNKpalv>xICrc83a2ZFgW{ycvY-kvfQXIB@AjjUwd<(o*aX>a}GI7a>b;Ul3v z&i(O{*ZFMih~DZ)wXvg+-j%A8ckNxZhpinv?bl#Px5r*Pg6>mQWy^xMt*VdN(*cN-* zJ#R72Tf|t}=@zh{O=Ar6s#A|ex=z7r&i!wwuynjJhEwz%so-*QQlSGe8fb9UL5if0 zn7!V83)NAu#WDQb3zDJkjDxq~IOAm{mNq~1q3amr>Q87lz0?D^`II!D4x_vXcy04K zMp)VdqVY4_EQCe zWN`*uxe|O|RF8%OfhrKc`sj9t3mb7Tvh3vc$2Kz79N4)3kqUlg=>M()zh5e#2vYLj z(h(w@V}Aru)f*=Mse*#r`+bcxq3E9~INI~boW?+p3Z*@C0e?04iC?Me)VuXiPXK5I z%Ly<*D_EPh;W(m^ld}vR_^7G+%L)i04d1LEYJ7@N8H^b^%!@t%>}+9c=EU&gnu*@X!uC+DU8+w2 z@I;O?N(;THDTOTvDL4k>ABpZ(07ZKND)*sW&%&Y7z@sBL+Q?!}SOce1lHLPur390Q zrS~Z&W5oNOiHApcv#E<~v`U<>0I@0>RlBJVrj@gch`A!auBD&OcK*8|PNYQoFdVt- zkwXh{)yKybY&Z#$9nC~Ozg|ua8=P0=lJkv;?oU%aVttrww9n#_IBXcLLE1iv1ViHqYZWREO{c66%Y5IWI??24*_O;Z7U6LKoIE{H#UK!5WBlk>s zonY=_-ekd>M}1i6S9vqX$j41J{IrP3^BJJXaSNt*1jCV$>T7_MidCos(WDq&(tm2x@ zlV!y~&kKji>a3&k%nyJvALmd1oEFaShHwayz-j4s-Eycw?KWB*i$jJGdllM*zOM4D z!&ryuP>09V@Qq|k<oPIWIn3Qd7BtLB3!0Dtf6b5M|b`0dLLH~0o~>)@C4M)x9eHNAj5C~m!wADN&_D+ z(UimzZ*t%GbP=^Wh7;6Jp9H{ky&Xz=$N=@u`vkE_dfrYZ)Z@Nf&tJ6fn!sY2sK_-< ziz92MqblC=Q`|IKGL7|ApBS1GH_PmKOV*hB`xUI2#~3!58S*#68em_%#8>R|+kK0{suw!at7 zLKDk|zp4ijdc?w z7R$3xP4ci*0%5Hu%wjpo-49Wt_%#yNWaDHAV_d&+`;WVn zLrE&O7VyDRfi*B>U^AJCow0(WoxKx-v7Mvo&!+>nJpZ?c3^?n7ak|pIjF>?ukk7({ zUTOIma>7g93A$XEoQiF5gRSLdveGC=S0}P>j#N%-_;z^H&*R=XP&=Nyt{ap}B*X@6 z`k@qzO!EseEG7Dc@ESMA@iL&1?!rUSO&*kLsK_K>v$vE9EWt5mUMWVrAFCAcWnXxQPT&b6>)Fvkp^2c0)^L$GrzqnlvI#oU-2$1fx) zxe6~tbPP0&A&{%*FE7`F?lqH@E%8xSPV{cL2EAV?Cs?uDOBZz#`>^r&g=3i8VB-2I znUft}6IJd5IH8TSen;U2+@BV~6XNgKtw4i30Gcb{Uk%dG-u}P#2sFfh9O=rkc1w)# z?MS;mr_OepteT1tHDSa@I?mFG)``# zp^$2-_BwM(mF8pG4=h=9m?OJ6wbeW!1nI8b1%ICFfGql# z_g7vDzU<=vExG{gnS0UG|5EtxeaOE>K|oZ1{{DaNN`8s+vJLe&QU?70cN72Cl=>3o zWwYOJ6fd9`{D;=oUy@ZN)Fl|QGT_UyhM4~QScjO zALAFw%l?9w055AIzX2?OJq&-Vkh~OqnZfuidIb#R{;thG<}+RbzDx-G2E3vCzX1MD z54;3?8D9Seyr=rV0R9fPUjn}LzJCKgQU3yb5vu+%bbSf>GSvDFnn?RU0sR$ty#)Qw zcS=Y9KLPy}HM|6U>E-^u(>{h@pnvmuUrPVojr=VO0+PcB0`hN8@6tJBXmo7W%$z%`YG{pZ#H0WTw4WdHyG literal 0 HcmV?d00001 diff --git a/tests/data/Reader/Xml/PageSetup.xml b/tests/data/Reader/Xml/PageSetup.xml new file mode 100644 index 0000000000..8f996a939d --- /dev/null +++ b/tests/data/Reader/Xml/PageSetup.xml @@ -0,0 +1,250 @@ + + + + + Mark Baker + Mark Baker + 2020-07-04T11:51:41Z + 2020-06-29T17:37:00Z + 2020-07-04T11:52:32Z + 16.00 + + + + + + 13170 + 21600 + 2145 + 2145 + False + False + + + + + + + + 1 + 2 + 3 + + + 4 + 5 + 6 + + + 7 + 8 + 9 + + + 30 + 6 + +
+ + + +
+