From 1bcdf15533a5b286e67b81b7e79402eb859044bd Mon Sep 17 00:00:00 2001 From: basbl Date: Fri, 13 Dec 2019 15:59:30 +0100 Subject: [PATCH 01/31] 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 02/31] 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 03/31] 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 04/31] 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 05/31] 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 06/31] 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 07/31] 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 08/31] 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 09/31] 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 10/31] 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 11/31] 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 12/31] 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 13/31] 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 14/31] 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 15/31] 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 16/31] 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 17/31] 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 18/31] 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 19/31] 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 20/31] 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 21/31] 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 22/31] 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 23/31] 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 24/31] 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 25/31] 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 26/31] 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 27/31] 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 .= ''; - $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"; + } 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 28/31] 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 29/31] 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 = ' @@ -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 30/31] 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 31/31] 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