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 b3be69b0..6ce3a728 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 0575eefe..41ec1b9b 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 448b532f..97b14bef 100644 --- a/src/PhpSpreadsheet/Writer/IWriter.php +++ b/src/PhpSpreadsheet/Writer/IWriter.php @@ -59,7 +59,7 @@ interface IWriter /** * 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 43659fa0..2a1dba02 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -12,7 +12,9 @@ use PhpOffice\PhpSpreadsheet\Writer\Ods\Mimetype; 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 @@ class Ods extends BaseWriter /** * Save PhpSpreadsheet to file. * - * @param string $pFilename + * @param resource|string $pFilename * * @throws WriterException */ @@ -88,31 +95,41 @@ class Ods extends BaseWriter // 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 @@ class Ods extends BaseWriter /** * 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 1fa59e51..2297002b 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -24,6 +24,9 @@ use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Theme; 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 @@ class Xlsx extends BaseWriter /** * Save PhpSpreadsheet to file. * - * @param string $pFilename + * @param resource|string $pFilename * * @throws WriterException */ @@ -176,13 +184,24 @@ class Xlsx extends BaseWriter // 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 @@ class Xlsx extends BaseWriter // 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 @@ class Xlsx extends BaseWriter // 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 @@ class Xlsx extends BaseWriter // 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 @@ class Xlsx extends BaseWriter $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 @@ class Xlsx extends BaseWriter // 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 @@ class Xlsx extends BaseWriter $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 @@ class Xlsx extends BaseWriter $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 @@ class Xlsx extends BaseWriter 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 1166bd25..1cf64634 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Writer; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; class Csv extends BaseWriter { @@ -77,7 +78,7 @@ class Csv extends BaseWriter /** * Save PhpSpreadsheet to file. * - * @param string $pFilename + * @param resource|string $pFilename * * @throws Exception */ @@ -92,9 +93,14 @@ class Csv extends BaseWriter 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 @@ class Csv extends BaseWriter } // Close file + rewind($fileHandle); + fclose($fileHandle); Calculation::setArrayReturnType($saveArrayReturnType); diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 37d68e91..91beedb7 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -146,7 +146,7 @@ class Html extends BaseWriter /** * Save Spreadsheet to file. * - * @param string $pFilename + * @param resource|string $pFilename * * @throws WriterException */ @@ -164,7 +164,12 @@ class Html extends BaseWriter $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 6932eb1a..95693dde 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -115,7 +115,7 @@ class Xls extends BaseWriter /** * 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 | 32 ++++++++++++++++++----------- src/PhpSpreadsheet/Writer/Xlsx.php | 33 ++++++++++++++++++------------ 2 files changed, 40 insertions(+), 25 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Ods.php b/src/PhpSpreadsheet/Writer/Ods.php index 2a1dba02..08bd2629 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -93,18 +93,18 @@ class Ods extends BaseWriter // 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') { - // 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 { + // 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; + } + } + $this->fileHandle = fopen($pFilename, 'wb+'); } @@ -128,11 +128,19 @@ class Ods extends BaseWriter 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 @@ class Ods extends BaseWriter 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 2297002b..9c947d0a 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -185,22 +185,21 @@ class Xlsx extends BaseWriter $this->spreadSheet->garbageCollect(); $originalFilename = $pFilename; - 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 { + // 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; + } + } + $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 @@ class Xlsx extends BaseWriter 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 0f5c002c..4bf9b931 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 51c60d49..00000000 --- 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 011b3770..cc469768 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 26d5fcea..00000000 --- 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 a64cda80..00000000 --- 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 4bf9b931..6b2b502c 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 2e51c7a4..31ae804e 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 08bd2629..9de19eb4 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 @@ class Ods extends BaseWriter } } - $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 9c947d0a..3b4bdfd9 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 @@ class Xlsx extends BaseWriter } } - $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 c52cea23..472483eb 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php @@ -22,7 +22,6 @@ namespace PhpOffice\PhpSpreadsheet\Shared\OLE\PPS; // 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 @@ use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; */ 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 @@ class Root extends PPS * 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 @@ class Root extends PPS (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 @@ class Root extends PPS // 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 f13150d7..dc7a0431 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 @@ abstract class BaseWriter implements IWriter { 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 1cf64634..e5c08c13 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -131,11 +131,6 @@ class Csv extends BaseWriter $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 91beedb7..ed6db1b7 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -164,32 +164,23 @@ class Html extends BaseWriter $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 9de19eb4..bb981d35 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 @@ class Ods extends BaseWriter // 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 @@ class Ods extends BaseWriter 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 d9184560..52f95749 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -255,17 +255,14 @@ abstract class Pdf extends Html 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 @@ abstract class Pdf extends Html */ 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 fd2664a8..5fdc4ea8 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php @@ -65,7 +65,7 @@ class Mpdf extends Pdf } // 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 95693dde..fb42bf9e 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -221,7 +221,9 @@ class Xls extends BaseWriter $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 3b4bdfd9..aea6a26c 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 @@ class Xlsx extends BaseWriter // 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 @@ class Xlsx extends BaseWriter 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 00000000..20e588bb --- /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 52f95749..f0c1798f 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -267,10 +267,8 @@ abstract class Pdf extends Html /** * 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 3c3044d7..783bf253 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php @@ -73,6 +73,6 @@ class Dompdf extends Pdf // 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 5fdc4ea8..2922db15 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php @@ -95,7 +95,7 @@ class Mpdf extends Pdf // 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 8a97b8fe..6ba77c75 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php @@ -93,6 +93,6 @@ class Tcpdf extends Pdf // 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 6b2b502c..57bad0aa 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 69f72033..e1469b1f 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -2315,8 +2315,6 @@ class Calculation /** * __clone implementation. Cloning should not be allowed in a Singleton! - * - * @throws Exception */ final public function __clone() { @@ -2765,8 +2763,6 @@ class Calculation * * @param Cell $pCell Cell to calculate * - * @throws Exception - * * @return mixed */ public function calculate(Cell $pCell = null) @@ -2784,8 +2780,6 @@ class Calculation * @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 @@ class Calculation * @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 @@ class Calculation * @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 c3942b2b..1a79ff71 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -2346,8 +2346,6 @@ class Engineering * * @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 9b3c66e9..38c725c2 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 @@ class FormulaParser * * @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 1d28f247..cf638d05 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 e618436e..30be3353 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -92,8 +92,6 @@ class Cell * @param mixed $pValue * @param string $pDataType * @param Worksheet $pSheet - * - * @throws Exception */ public function __construct($pValue, $pDataType, Worksheet $pSheet) { @@ -175,8 +173,6 @@ class Cell * * @param mixed $pValue Value * - * @throws Exception - * * @return $this */ public function setValue($pValue) @@ -194,8 +190,6 @@ class Cell * @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 @@ class Cell * * @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 @@ class Cell /** * Does this cell contain Data validation rules? * - * @throws Exception - * * @return bool */ public function hasDataValidation() @@ -378,8 +368,6 @@ class Cell /** * Get Data validation rules. * - * @throws Exception - * * @return DataValidation */ public function getDataValidation() @@ -396,8 +384,6 @@ class Cell * * @param DataValidation $pDataValidation * - * @throws Exception - * * @return Cell */ public function setDataValidation(DataValidation $pDataValidation = null) @@ -426,8 +412,6 @@ class Cell /** * Does this cell contain a Hyperlink? * - * @throws Exception - * * @return bool */ public function hasHyperlink() @@ -442,8 +426,6 @@ class Cell /** * Get Hyperlink. * - * @throws Exception - * * @return Hyperlink */ public function getHyperlink() @@ -460,8 +442,6 @@ class Cell * * @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 cc0543f6..70fed25a 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 @@ abstract class Coordinate * @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 @@ abstract class Coordinate * * @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 @@ abstract class Coordinate * * @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 cd05cf8b..3a676c4f 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 0552677f..346d0253 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 ec40cb84..e15f5da5 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -115,8 +115,6 @@ class DataSeriesValues * DataSeriesValues::DATASERIES_TYPE_NUMBER * Normally used for chart data values * - * @throws Exception - * * @return $this */ public function setDataType($dataType) @@ -247,8 +245,6 @@ class DataSeriesValues * * @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 84c3d300..127403d9 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -105,8 +105,6 @@ class Cells * * @param Cell $cell Cell to update * - * @throws PhpSpreadsheetException - * * @return Cell */ public function update(Cell $cell) @@ -382,8 +380,6 @@ class Cells /** * 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 @@ class Cells * @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 @@ class Cells * * @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 de6f313f..8baba6e5 100644 --- a/src/PhpSpreadsheet/DocumentGenerator.php +++ b/src/PhpSpreadsheet/DocumentGenerator.php @@ -5,7 +5,6 @@ namespace PhpOffice\PhpSpreadsheet; 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 @@ class DocumentGenerator return $result; } - /** - * @throws ReflectionException - * - * @return array - */ private static function getCategories(): array { return (new ReflectionClass(Category::class))->getConstants(); @@ -82,8 +74,6 @@ class DocumentGenerator /** * @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 4e8f0a5c..4d1e7b4d 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 @@ class HashTable * 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 4266ea54..38c0f221 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 @@ abstract class IOFactory * * @param string $readerType Example: Xlsx * - * @throws Reader\Exception - * * @return Reader\IReader */ public static function createReader($readerType) @@ -82,8 +78,6 @@ abstract class IOFactory * * @param string $pFilename The name of the spreadsheet file * - * @throws Reader\Exception - * * @return Spreadsheet */ public static function load($pFilename) @@ -98,8 +92,6 @@ abstract class IOFactory * * @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 @@ abstract class IOFactory * * @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 e539b7c5..576f17d7 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 f7af1557..35466e73 100644 --- a/src/PhpSpreadsheet/Reader/BaseReader.php +++ b/src/PhpSpreadsheet/Reader/BaseReader.php @@ -144,8 +144,6 @@ abstract class BaseReader implements IReader * 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 47134098..ed3b70f1 100644 --- a/src/PhpSpreadsheet/Reader/Csv.php +++ b/src/PhpSpreadsheet/Reader/Csv.php @@ -272,8 +272,6 @@ class Csv extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetInfo($pFilename) @@ -317,8 +315,6 @@ class Csv extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return Spreadsheet */ public function load($pFilename) @@ -336,8 +332,6 @@ class Csv extends BaseReader * @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 44ab701d..83ff293c 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -46,8 +46,6 @@ class Gnumeric extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return bool */ public function canRead($pFilename) @@ -169,8 +167,6 @@ class Gnumeric extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return Spreadsheet */ public function load($pFilename) @@ -188,8 +184,6 @@ class Gnumeric extends BaseReader * @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 a255cfd9..86263a20 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -205,8 +205,6 @@ class Html extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return Spreadsheet */ public function load($pFilename) @@ -581,8 +579,6 @@ class Html extends BaseReader * @param string $pFilename * @param Spreadsheet $spreadsheet * - * @throws Exception - * * @return Spreadsheet */ public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) @@ -630,8 +626,6 @@ class Html extends BaseReader * @param DOMDocument $document * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Exception - * * @return Spreadsheet */ private function loadDocument(DOMDocument $document, Spreadsheet $spreadsheet): Spreadsheet @@ -862,8 +856,6 @@ class Html extends BaseReader * @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 70a7a200..3f5a7e49 100644 --- a/src/PhpSpreadsheet/Reader/IReader.php +++ b/src/PhpSpreadsheet/Reader/IReader.php @@ -129,8 +129,6 @@ interface IReader * * @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 5fff07aa..41fd34a8 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -34,8 +34,6 @@ class Ods extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return bool */ public function canRead($pFilename) @@ -85,8 +83,6 @@ class Ods extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return string[] */ public function listWorksheetNames($pFilename) @@ -139,8 +135,6 @@ class Ods extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetInfo($pFilename) @@ -233,8 +227,6 @@ class Ods extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return Spreadsheet */ public function load($pFilename) @@ -252,8 +244,6 @@ class Ods extends BaseReader * @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 732f0bf6..33e21f9d 100644 --- a/src/PhpSpreadsheet/Reader/Security/XmlScanner.php +++ b/src/PhpSpreadsheet/Reader/Security/XmlScanner.php @@ -114,8 +114,6 @@ class XmlScanner * * @param mixed $xml * - * @throws Reader\Exception - * * @return string */ public function scan($xml) @@ -143,8 +141,6 @@ class XmlScanner * * @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 9912e937..278abd58 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -107,8 +107,6 @@ class Slk extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetInfo($pFilename) @@ -177,8 +175,6 @@ class Slk extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return Spreadsheet */ public function load($pFilename) @@ -196,8 +192,6 @@ class Slk extends BaseReader * @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 313d7216..ec5879a9 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -444,8 +444,6 @@ class Xls extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetNames($pFilename) @@ -504,8 +502,6 @@ class Xls extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetInfo($pFilename) @@ -618,8 +614,6 @@ class Xls extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return Spreadsheet */ public function load($pFilename) @@ -5516,8 +5510,6 @@ class Xls extends BaseReader * @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 @@ class Xls extends BaseReader * * @param string $subData * - * @throws Exception - * * @return string */ private function readBIFF5CellRangeAddressFixed($subData) @@ -7227,8 +7217,6 @@ class Xls extends BaseReader * * @param string $subData * - * @throws Exception - * * @return string */ private function readBIFF8CellRangeAddressFixed($subData) @@ -7465,8 +7453,6 @@ class Xls extends BaseReader * * @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 566e9fbb..40814c64 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -69,8 +69,6 @@ class Xlsx extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return bool */ public function canRead($pFilename) @@ -95,8 +93,6 @@ class Xlsx extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetNames($pFilename) @@ -140,8 +136,6 @@ class Xlsx extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetInfo($pFilename) @@ -318,8 +312,6 @@ class Xlsx extends BaseReader * * @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 b4fffa4f..03099e3e 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -50,8 +50,6 @@ class Xml extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return bool */ public function canRead($pFilename) @@ -103,8 +101,6 @@ class Xml extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return false|\SimpleXMLElement */ public function trySimpleXMLLoadString($pFilename) @@ -127,8 +123,6 @@ class Xml extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetNames($pFilename) @@ -158,8 +152,6 @@ class Xml extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return array */ public function listWorksheetInfo($pFilename) @@ -229,8 +221,6 @@ class Xml extends BaseReader * * @param string $pFilename * - * @throws Exception - * * @return Spreadsheet */ public function load($pFilename) @@ -300,8 +290,6 @@ class Xml extends BaseReader * @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 143e80d8..6d655730 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -363,8 +363,6 @@ class ReferenceHelper * @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 @@ class ReferenceHelper * @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 @@ class ReferenceHelper * @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 @@ class ReferenceHelper * @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 @@ class ReferenceHelper * @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 @@ class ReferenceHelper /** * __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 6e90fa35..4fa5f2bd 100644 --- a/src/PhpSpreadsheet/RichText/RichText.php +++ b/src/PhpSpreadsheet/RichText/RichText.php @@ -4,7 +4,6 @@ namespace PhpOffice\PhpSpreadsheet\RichText; 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 @@ class RichText implements IComparable * * @param string $pText Text * - * @throws Exception - * * @return TextElement */ public function createText($pText) @@ -78,8 +73,6 @@ class RichText implements IComparable * * @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 d9d74cb0..56f778e5 100644 --- a/src/PhpSpreadsheet/Settings.php +++ b/src/PhpSpreadsheet/Settings.php @@ -59,8 +59,6 @@ class Settings * * @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 4b578242..b395293c 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 5d2deb32..8be255c5 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -95,8 +95,6 @@ class Date * * @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 @@ class Date * * @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 @@ class Date * 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 @@ class Date * 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 239c8375..6b1fe6f5 100644 --- a/src/PhpSpreadsheet/Shared/File.php +++ b/src/PhpSpreadsheet/Shared/File.php @@ -128,8 +128,6 @@ class File * 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 bee13e29..89d91be7 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -276,8 +276,6 @@ class 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 bb2b4b04..4aecff73 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php +++ b/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php @@ -242,9 +242,6 @@ class LUDecomposition * * @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 efa7522f..81ebaa34 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 @@ class OLE * * @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 3af39700..3526c7e6 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 e5a99b9b..a87987df 100644 --- a/src/PhpSpreadsheet/Shared/TimeZone.php +++ b/src/PhpSpreadsheet/Shared/TimeZone.php @@ -61,8 +61,6 @@ class TimeZone * @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 d33a9871..6023c616 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -571,8 +571,6 @@ class Spreadsheet /** * Get active sheet. * - * @throws Exception - * * @return Worksheet */ public function getActiveSheet() @@ -585,8 +583,6 @@ class Spreadsheet * * @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 @@ class Spreadsheet * @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 @@ class Spreadsheet * Remove sheet by index. * * @param int $pIndex Active sheet index - * - * @throws Exception */ public function removeSheetByIndex($pIndex) { @@ -683,8 +675,6 @@ class Spreadsheet * * @param int $pIndex Sheet index * - * @throws Exception - * * @return Worksheet */ public function getSheet($pIndex) @@ -734,8 +724,6 @@ class Spreadsheet * * @param Worksheet $pSheet * - * @throws Exception - * * @return int index */ public function getIndex(Worksheet $pSheet) @@ -755,8 +743,6 @@ class Spreadsheet * @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 @@ class Spreadsheet * * @param int $pIndex Active sheet index * - * @throws Exception - * * @return Worksheet */ public function setActiveSheetIndex($pIndex) @@ -825,8 +809,6 @@ class Spreadsheet * * @param string $pValue Sheet title * - * @throws Exception - * * @return Worksheet */ public function setActiveSheetIndexByName($pValue) @@ -862,8 +844,6 @@ class Spreadsheet * @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 @@ class Spreadsheet /** * Get default style. * - * @throws Exception - * * @return Style */ public function getDefaultStyle() @@ -1095,8 +1073,6 @@ class Spreadsheet * 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 @@ class Spreadsheet * Remove cellStyleXf by index. * * @param int $pIndex Index to cellXf - * - * @throws Exception */ public function removeCellStyleXfByIndex($pIndex) { @@ -1405,8 +1379,6 @@ class Spreadsheet * 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 @@ class Spreadsheet * 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 @@ class Spreadsheet * 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 5eb7c2b0..e54fa2a1 100644 --- a/src/PhpSpreadsheet/Style/Alignment.php +++ b/src/PhpSpreadsheet/Style/Alignment.php @@ -138,8 +138,6 @@ class Alignment extends Supervisor * * @param array $pStyles Array containing style information * - * @throws PhpSpreadsheetException - * * @return $this */ public function applyFromArray(array $pStyles) @@ -267,8 +265,6 @@ class Alignment extends Supervisor * * @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 5fa0cae7..2e076a92 100644 --- a/src/PhpSpreadsheet/Style/Border.php +++ b/src/PhpSpreadsheet/Style/Border.php @@ -69,8 +69,6 @@ class Border extends Supervisor * 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 @@ class Border extends Supervisor * * @param array $pStyles Array containing style information * - * @throws PhpSpreadsheetException - * * @return $this */ public function applyFromArray(array $pStyles) @@ -200,8 +196,6 @@ class Border extends Supervisor * * @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 8f005a99..e75d7eeb 100644 --- a/src/PhpSpreadsheet/Style/Borders.php +++ b/src/PhpSpreadsheet/Style/Borders.php @@ -195,8 +195,6 @@ class Borders extends Supervisor * * @param array $pStyles Array containing style information * - * @throws PhpSpreadsheetException - * * @return $this */ public function applyFromArray(array $pStyles) @@ -286,8 +284,6 @@ class Borders extends Supervisor /** * Get AllBorders (pseudo-border). Only applies to supervisor. * - * @throws PhpSpreadsheetException - * * @return Border */ public function getAllBorders() @@ -302,8 +298,6 @@ class Borders extends Supervisor /** * Get Outline (pseudo-border). Only applies to supervisor. * - * @throws PhpSpreadsheetException - * * @return Border */ public function getOutline() @@ -318,8 +312,6 @@ class Borders extends Supervisor /** * Get Inside (pseudo-border). Only applies to supervisor. * - * @throws PhpSpreadsheetException - * * @return Border */ public function getInside() @@ -334,8 +326,6 @@ class Borders extends Supervisor /** * Get Vertical (pseudo-border). Only applies to supervisor. * - * @throws PhpSpreadsheetException - * * @return Border */ public function getVertical() @@ -350,8 +340,6 @@ class Borders extends Supervisor /** * 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 ab22cbe3..d8ba08b2 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 @@ class Color extends Supervisor * * @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 1d6bace1..789a9801 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 @@ class Fill extends Supervisor * * @param array $pStyles Array containing style information * - * @throws PhpSpreadsheetException - * * @return $this */ public function applyFromArray(array $pStyles) @@ -250,8 +246,6 @@ class Fill extends Supervisor * * @param Color $pValue * - * @throws PhpSpreadsheetException - * * @return $this */ public function setStartColor(Color $pValue) @@ -284,8 +278,6 @@ class Fill extends Supervisor * * @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 0341cad0..5ab58dca 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 @@ class Font extends Supervisor * * @param array $pStyles Array containing style information * - * @throws PhpSpreadsheetException - * * @return $this */ public function applyFromArray(array $pStyles) @@ -510,8 +506,6 @@ class Font extends Supervisor * * @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 df4ca76f..079e1d20 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 @@ class NumberFormat extends Supervisor * * @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 8112bc62..f695837d 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 @@ class Protection extends Supervisor * * @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 dcbc4da5..e6cd40e3 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -83,8 +83,6 @@ class AutoFilter * * @param string $pRange Cell range (i.e. A1:E10) * - * @throws PhpSpreadsheetException - * * @return $this */ public function setRange($pRange) @@ -132,8 +130,6 @@ class AutoFilter * * @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 @@ class AutoFilter * * @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 @@ class AutoFilter * * @param string $pColumn Column name (e.g. A) * - * @throws PhpSpreadsheetException - * * @return AutoFilter\Column */ public function getColumn($pColumn) @@ -190,8 +182,6 @@ class AutoFilter * * @param int $pColumnOffset Column offset within range (starting from 0) * - * @throws PhpSpreadsheetException - * * @return AutoFilter\Column */ public function getColumnByOffset($pColumnOffset) @@ -208,8 +198,6 @@ class AutoFilter * @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 @@ class AutoFilter * * @param string $pColumn Column name (e.g. A) * - * @throws PhpSpreadsheetException - * * @return $this */ public function clearColumn($pColumn) @@ -615,8 +601,6 @@ class AutoFilter /** * 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 3ed7270a..a36740a3 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php @@ -115,8 +115,6 @@ class Column * * @param string $pColumn Column (e.g. A) * - * @throws PhpSpreadsheetException - * * @return $this */ public function setColumnIndex($pColumn) @@ -171,8 +169,6 @@ class Column * * @param string $pFilterType * - * @throws PhpSpreadsheetException - * * @return $this */ public function setFilterType($pFilterType) @@ -201,8 +197,6 @@ class Column * * @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 09a2bacd..28286cee 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php @@ -260,8 +260,6 @@ class Rule * * @param string $pRuleType see self::AUTOFILTER_RULETYPE_* * - * @throws PhpSpreadsheetException - * * @return $this */ public function setRuleType($pRuleType) @@ -290,8 +288,6 @@ class Rule * * @param string|string[] $pValue * - * @throws PhpSpreadsheetException - * * @return $this */ public function setValue($pValue) @@ -334,8 +330,6 @@ class Rule * * @param string $pOperator see self::AUTOFILTER_COLUMN_RULE_* * - * @throws PhpSpreadsheetException - * * @return $this */ public function setOperator($pOperator) @@ -367,8 +361,6 @@ class Rule * * @param string $pGrouping * - * @throws PhpSpreadsheetException - * * @return $this */ public function setGrouping($pGrouping) @@ -391,8 +383,6 @@ class Rule * @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 7d24e449..bcea3435 100644 --- a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php @@ -203,8 +203,6 @@ class BaseDrawing implements IComparable * @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 d97e33f7..472609a3 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 @@ abstract class CellIterator implements \Iterator /** * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary. - * - * @throws PhpSpreadsheetException */ abstract protected function adjustForExistingOnlyRange(); @@ -49,8 +45,6 @@ abstract class CellIterator implements \Iterator * 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 d75da898..184f4888 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php @@ -57,8 +57,6 @@ class ColumnCellIterator extends CellIterator * * @param int $startRow The row number at which to start iterating * - * @throws PhpSpreadsheetException - * * @return $this */ public function resetStart($startRow = 1) @@ -75,8 +73,6 @@ class ColumnCellIterator extends CellIterator * * @param int $endRow The row number at which to stop iterating * - * @throws PhpSpreadsheetException - * * @return $this */ public function resetEnd($endRow = null) @@ -92,8 +88,6 @@ class ColumnCellIterator extends CellIterator * * @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 @@ class ColumnCellIterator extends CellIterator /** * 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 c8913cc1..0aff4859 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php @@ -64,8 +64,6 @@ class ColumnIterator implements \Iterator * * @param string $startColumn The column address at which to start iterating * - * @throws Exception - * * @return $this */ public function resetStart($startColumn = 'A') @@ -104,8 +102,6 @@ class ColumnIterator implements \Iterator * * @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 ce40cf57..a27daf09 100644 --- a/src/PhpSpreadsheet/Worksheet/Dimension.php +++ b/src/PhpSpreadsheet/Worksheet/Dimension.php @@ -85,8 +85,6 @@ abstract class Dimension * * @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 da492b4c..1f1dae93 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing.php @@ -76,8 +76,6 @@ class Drawing extends BaseDrawing * @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 38a09736..19eabcf4 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -323,8 +323,6 @@ class PageSetup * @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 @@ class PageSetup * 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 @@ class PageSetup * 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 @@ class PageSetup * list. * Print areas are numbered from 1 * - * @throws PhpSpreadsheetException - * * @return $this */ public function addPrintArea($value, $index = -1) @@ -760,8 +752,6 @@ class PageSetup * 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 @@ class PageSetup * 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 9746d640..09a5b0a1 100644 --- a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php @@ -57,8 +57,6 @@ class RowCellIterator extends CellIterator * * @param string $startColumn The column address at which to start iterating * - * @throws PhpSpreadsheetException - * * @return $this */ public function resetStart($startColumn = 'A') @@ -75,8 +73,6 @@ class RowCellIterator extends CellIterator * * @param string $endColumn The column address at which to stop iterating * - * @throws PhpSpreadsheetException - * * @return $this */ public function resetEnd($endColumn = null) @@ -93,8 +89,6 @@ class RowCellIterator extends CellIterator * * @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 @@ class RowCellIterator extends CellIterator /** * Set the iterator to its previous value. - * - * @throws PhpSpreadsheetException */ public function prev() { @@ -182,8 +174,6 @@ class RowCellIterator extends CellIterator /** * 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 3b9d0e26..62cede7b 100644 --- a/src/PhpSpreadsheet/Worksheet/RowIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowIterator.php @@ -62,8 +62,6 @@ class RowIterator implements \Iterator * * @param int $startRow The row number at which to start iterating * - * @throws PhpSpreadsheetException - * * @return $this */ public function resetStart($startRow = 1) @@ -100,8 +98,6 @@ class RowIterator implements \Iterator * * @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 fa85bd27..e19ff808 100644 --- a/src/PhpSpreadsheet/Worksheet/SheetView.php +++ b/src/PhpSpreadsheet/Worksheet/SheetView.php @@ -77,8 +77,6 @@ class SheetView * * @param int $pValue * - * @throws PhpSpreadsheetException - * * @return $this */ public function setZoomScale($pValue) @@ -110,8 +108,6 @@ class SheetView * * @param int $pValue * - * @throws PhpSpreadsheetException - * * @return $this */ public function setZoomScaleNormal($pValue) @@ -163,8 +159,6 @@ class SheetView * * @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 9a3f9647..e8a61b78 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -424,8 +424,6 @@ class Worksheet implements IComparable * * @param string $pValue The string to check * - * @throws Exception - * * @return string The valid string */ private static function checkSheetCodeName($pValue) @@ -454,8 +452,6 @@ class Worksheet implements IComparable * * @param string $pValue The string to check * - * @throws Exception - * * @return string The valid string */ private static function checkSheetTitle($pValue) @@ -1185,8 +1181,6 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * * @param string $pCoordinate Coordinate of the cell eg: 'A1' * - * @throws Exception - * * @return bool */ public function cellExists($pCoordinate) @@ -1431,8 +1423,6 @@ class Worksheet implements IComparable * * @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 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * * @param string $pRange Cell range (e.g. A1:E1) * - * @throws Exception - * * @return $this */ public function mergeCells($pRange) @@ -1724,8 +1706,6 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * * @param string $pRange Cell range (e.g. A1:E1) * - * @throws Exception - * * @return $this */ public function unmergeCells($pRange) @@ -1770,8 +1748,6 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * * @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 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * * @param string $pCellCoordinate Cell coordinate to get comment for, eg: 'A1' * - * @throws Exception - * * @return Comment */ public function getComment($pCellCoordinate) @@ -2461,8 +2413,6 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * @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 @@ class Worksheet implements IComparable * @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 e5c08c13..142f15b8 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -79,8 +79,6 @@ class Csv extends BaseWriter * 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 ed6db1b7..ec754001 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -23,7 +23,6 @@ use PhpOffice\PhpSpreadsheet\Style\Style; 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 @@ class Html extends BaseWriter * Save Spreadsheet to file. * * @param resource|string $pFilename - * - * @throws WriterException */ public function save($pFilename) { @@ -343,8 +340,6 @@ class Html extends BaseWriter * * @param bool $pIncludeStyles Include styles? * - * @throws WriterException - * * @return string */ public function generateHTMLHeader($pIncludeStyles = false) @@ -398,8 +393,6 @@ class Html extends BaseWriter /** * Generate sheet data. * - * @throws WriterException - * * @return string */ public function generateSheetData() @@ -514,8 +507,6 @@ class Html extends BaseWriter /** * Generate sheet tabs. * - * @throws WriterException - * * @return string */ public function generateNavigation() @@ -743,8 +734,6 @@ class Html extends BaseWriter * * @param bool $generateSurroundingHTML Generate surrounding HTML tags? (<style> and </style>) * - * @throws WriterException - * * @return string */ public function generateStyles($generateSurroundingHTML = true) @@ -782,8 +771,6 @@ class Html extends BaseWriter * * @param bool $generateSurroundingHTML Generate surrounding HTML style? (html { }) * - * @throws WriterException - * * @return array */ public function buildCSS($generateSurroundingHTML = true) @@ -1158,8 +1145,6 @@ class Html extends BaseWriter * @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 97b14bef..27329537 100644 --- a/src/PhpSpreadsheet/Writer/IWriter.php +++ b/src/PhpSpreadsheet/Writer/IWriter.php @@ -60,8 +60,6 @@ interface IWriter * 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 @@ interface IWriter * @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 bb981d35..e3a0ca98 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -76,8 +76,6 @@ class Ods extends BaseWriter * Save PhpSpreadsheet to file. * * @param resource|string $pFilename - * - * @throws WriterException */ public function save($pFilename) { @@ -113,8 +111,6 @@ class Ods extends BaseWriter /** * Create zip object. * - * @throws WriterException - * * @return ZipStream */ private function createZip() @@ -135,8 +131,6 @@ class Ods extends BaseWriter /** * 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 dea5100f..cbf303bd 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 @@ class Content extends WriterPart * * @param XMLWriter $objWriter * @param Row $row - * - * @throws Exception */ private function writeCells(XMLWriter $objWriter, Row $row) { @@ -373,8 +369,6 @@ class Content extends WriterPart * * @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 ffe5eff7..eb2ebf9e 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 1ec9d1eb..c9085cf8 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 18f7ee6d..11d13341 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 eaf5cad9..cd71566f 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 f0c1798f..bb9f4aef 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -222,8 +222,6 @@ abstract class Pdf extends Html * * @param string $pValue Temporary storage directory * - * @throws WriterException when directory does not exist - * * @return self */ public function setTempDir($pValue) @@ -242,8 +240,6 @@ abstract class Pdf extends Html * * @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 783bf253..4506468b 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php @@ -21,8 +21,6 @@ class Dompdf extends Pdf * 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 2922db15..6f3cc57f 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 @@ class Mpdf extends Pdf * 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 6ba77c75..5c31af8f 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php @@ -25,8 +25,6 @@ class Tcpdf extends Pdf * 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 fb42bf9e..06611789 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -116,8 +116,6 @@ class Xls extends BaseWriter * 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 aea6a26c..4d4d79d6 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -170,8 +170,6 @@ class Xlsx extends BaseWriter * Save PhpSpreadsheet to file. * * @param resource|string $pFilename - * - * @throws WriterException */ public function save($pFilename) { @@ -411,8 +409,6 @@ class Xlsx extends BaseWriter /** * 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 c9c3e055..aeb7a76b 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 @@ class Chart extends WriterPart * * @param XMLWriter $objWriter XML Writer * @param Title $title - * - * @throws WriterException */ private function writeTitle(XMLWriter $objWriter, Title $title = null) { @@ -154,8 +150,6 @@ class Chart extends WriterPart * * @param XMLWriter $objWriter XML Writer * @param Legend $legend - * - * @throws WriterException */ private function writeLegend(XMLWriter $objWriter, Legend $legend = null) { @@ -212,8 +206,6 @@ class Chart extends WriterPart * @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 @@ class Chart extends WriterPart * @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 @@ class Chart extends WriterPart * @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 @@ class Chart extends WriterPart * * @param PlotArea $plotArea * - * @throws WriterException - * * @return array|string */ private static function getChartType($plotArea) @@ -1064,8 +1050,6 @@ class Chart extends WriterPart * @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 a95298af..ee34e318 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 @@ class Comments extends WriterPart * @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 @@ class Comments extends WriterPart * * @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 6b22d713..421f1e73 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 @@ class ContentTypes extends WriterPart * * @param string $pFile Filename * - * @throws WriterException - * * @return string Mime Type */ private function getImageMimeType($pFile) @@ -209,8 +205,6 @@ class ContentTypes extends WriterPart * @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 @@ class ContentTypes extends WriterPart * @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 2a18d5c7..289d08c7 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 @@ class DocProps extends WriterPart * * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * * @return string XML Output */ public function writeDocPropsCore(Spreadsheet $spreadsheet) @@ -180,8 +176,6 @@ class DocProps extends WriterPart * * @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 08256a1d..4c5a413e 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 @@ class Drawing extends WriterPart * @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 @@ class Drawing extends WriterPart * * @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 76c196b4..6dc41502 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 @@ class Rels extends WriterPart * * @param Spreadsheet $spreadsheet * - * @throws WriterException - * * @return string XML Output */ public function writeWorkbookRelationships(Spreadsheet $spreadsheet) @@ -172,8 +168,6 @@ class Rels extends WriterPart * @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 @@ class Rels extends WriterPart * @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 @@ class Rels extends WriterPart * * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * - * @throws WriterException - * * @return string XML Output */ public function writeHeaderFooterDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet) @@ -415,8 +405,6 @@ class Rels extends WriterPart * @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 @@ class Rels extends WriterPart * @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 8a0cfe34..531111ab 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 01ad38de..fb508c6b 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 19604e44..8e18e6f8 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php @@ -8,7 +8,6 @@ use PhpOffice\PhpSpreadsheet\RichText\Run; 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 @@ class StringTable extends WriterPart * * @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 16e800e0..54ec664f 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 @@ class Style extends WriterPart * @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 f5f8dc07..c6090395 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 fd936748..a56c5b72 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 @@ class Workbook extends WriterPart * * @param XMLWriter $objWriter XML Writer * @param Spreadsheet $spreadsheet - * - * @throws WriterException */ private function writeSheets(XMLWriter $objWriter, Spreadsheet $spreadsheet) { @@ -215,8 +211,6 @@ class Workbook extends WriterPart * @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 @@ class Workbook extends WriterPart * * @param XMLWriter $objWriter XML Writer * @param Spreadsheet $spreadsheet - * - * @throws WriterException */ private function writeDefinedNames(XMLWriter $objWriter, Spreadsheet $spreadsheet) { @@ -275,8 +267,6 @@ class Workbook extends WriterPart * * @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 1d5a995a..0c042fe1 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; 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 @@ class Worksheet extends WriterPart * * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet - * - * @throws WriterException */ private function writeSheetViews(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { @@ -459,8 +454,6 @@ class Worksheet extends WriterPart * * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet - * - * @throws WriterException */ private function writeConditionalFormatting(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { @@ -956,8 +949,6 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 14cd993a..f74d29ef 100644 --- a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php @@ -310,8 +310,6 @@ class CalculationTest extends TestCase * 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 b0aed466..214fe593 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 @@ class DocumentGeneratorTest extends TestCase * * @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 df683a1e..893b3784 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 0375f558..0186deae 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 57bad0aa..4101e2eb 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 808fb759..c1a06459 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 4101e2eb..e3ba3de8 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 ed3b70f1..4d104595 100644 --- a/src/PhpSpreadsheet/Reader/Csv.php +++ b/src/PhpSpreadsheet/Reader/Csv.php @@ -236,33 +236,31 @@ class Csv extends BaseReader /** * 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 3b6a037c..c0dc7c03 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 26e9784d..a446e56e 100644 --- a/samples/Basic/13_CalculationCyclicFormulae.php +++ b/samples/Basic/13_CalculationCyclicFormulae.php @@ -16,7 +16,7 @@ $spreadsheet->getActiveSheet()->setCellValue('A1', '=B1') ->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 4d104595..2e485109 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 @@ class Csv extends BaseReader 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 @@ class Csv extends BaseReader 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 @@ class Csv extends BaseReader 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 @@ class Csv extends BaseReader 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 @@ class Csv extends BaseReader // 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 @@ class Csv extends BaseReader // Close file fclose($fileHandle); - if ($this->contiguous) { - $this->contiguousRow = $currentRow; - } - ini_set('auto_detect_line_endings', $lineEnding); // Return @@ -477,9 +458,6 @@ class Csv extends BaseReader public function setContiguous($contiguous) { $this->contiguous = (bool) $contiguous; - if (!$contiguous) { - $this->contiguousRow = -1; - } return $this; } @@ -530,7 +508,7 @@ class Csv extends BaseReader // 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 142f15b8..cabfe450 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -93,6 +93,8 @@ class Csv extends BaseWriter // Open file if (is_resource($pFilename)) { $fileHandle = $pFilename; + } elseif (!$pFilename) { + $fileHandle = false; } else { $fileHandle = fopen($pFilename, 'wb+'); } @@ -176,10 +178,7 @@ class Csv extends BaseWriter */ 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 00000000..95f7e787 --- /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 00000000..4fe2006d --- /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 be08f6a6..bb593ce8 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 @@ class CsvTest extends TestCase $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 00000000..f55781da --- /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 00000000..84ecfd91 --- /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 f74d29ef..b4242364 100644 --- a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php @@ -40,7 +40,7 @@ class CalculationTest extends TestCase public function providerBinaryComparisonOperation() { - return require 'data/CalculationBinaryComparisonOperation.php'; + return require 'tests/data/CalculationBinaryComparisonOperation.php'; } /** @@ -351,6 +351,6 @@ class CalculationTest extends TestCase 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 27eb3d61..e9a62af3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php @@ -26,7 +26,7 @@ class FinancialTest extends TestCase public function providerAMORDEGRC() { - return require 'data/Calculation/Financial/AMORDEGRC.php'; + return require 'tests/data/Calculation/Financial/AMORDEGRC.php'; } /** @@ -42,7 +42,7 @@ class FinancialTest extends TestCase public function providerAMORLINC() { - return require 'data/Calculation/Financial/AMORLINC.php'; + return require 'tests/data/Calculation/Financial/AMORLINC.php'; } /** @@ -58,7 +58,7 @@ class FinancialTest extends TestCase public function providerCOUPDAYBS() { - return require 'data/Calculation/Financial/COUPDAYBS.php'; + return require 'tests/data/Calculation/Financial/COUPDAYBS.php'; } /** @@ -74,7 +74,7 @@ class FinancialTest extends TestCase public function providerCOUPDAYS() { - return require 'data/Calculation/Financial/COUPDAYS.php'; + return require 'tests/data/Calculation/Financial/COUPDAYS.php'; } /** @@ -90,7 +90,7 @@ class FinancialTest extends TestCase public function providerCOUPDAYSNC() { - return require 'data/Calculation/Financial/COUPDAYSNC.php'; + return require 'tests/data/Calculation/Financial/COUPDAYSNC.php'; } /** @@ -106,7 +106,7 @@ class FinancialTest extends TestCase public function providerCOUPNCD() { - return require 'data/Calculation/Financial/COUPNCD.php'; + return require 'tests/data/Calculation/Financial/COUPNCD.php'; } /** @@ -122,7 +122,7 @@ class FinancialTest extends TestCase public function providerCOUPNUM() { - return require 'data/Calculation/Financial/COUPNUM.php'; + return require 'tests/data/Calculation/Financial/COUPNUM.php'; } /** @@ -138,7 +138,7 @@ class FinancialTest extends TestCase public function providerCOUPPCD() { - return require 'data/Calculation/Financial/COUPPCD.php'; + return require 'tests/data/Calculation/Financial/COUPPCD.php'; } /** @@ -154,7 +154,7 @@ class FinancialTest extends TestCase public function providerCUMIPMT() { - return require 'data/Calculation/Financial/CUMIPMT.php'; + return require 'tests/data/Calculation/Financial/CUMIPMT.php'; } /** @@ -170,7 +170,7 @@ class FinancialTest extends TestCase public function providerCUMPRINC() { - return require 'data/Calculation/Financial/CUMPRINC.php'; + return require 'tests/data/Calculation/Financial/CUMPRINC.php'; } /** @@ -186,7 +186,7 @@ class FinancialTest extends TestCase public function providerDB() { - return require 'data/Calculation/Financial/DB.php'; + return require 'tests/data/Calculation/Financial/DB.php'; } /** @@ -202,7 +202,7 @@ class FinancialTest extends TestCase public function providerDDB() { - return require 'data/Calculation/Financial/DDB.php'; + return require 'tests/data/Calculation/Financial/DDB.php'; } /** @@ -218,7 +218,7 @@ class FinancialTest extends TestCase public function providerDISC() { - return require 'data/Calculation/Financial/DISC.php'; + return require 'tests/data/Calculation/Financial/DISC.php'; } /** @@ -234,7 +234,7 @@ class FinancialTest extends TestCase public function providerDOLLARDE() { - return require 'data/Calculation/Financial/DOLLARDE.php'; + return require 'tests/data/Calculation/Financial/DOLLARDE.php'; } /** @@ -250,7 +250,7 @@ class FinancialTest extends TestCase public function providerDOLLARFR() { - return require 'data/Calculation/Financial/DOLLARFR.php'; + return require 'tests/data/Calculation/Financial/DOLLARFR.php'; } /** @@ -266,7 +266,7 @@ class FinancialTest extends TestCase public function providerEFFECT() { - return require 'data/Calculation/Financial/EFFECT.php'; + return require 'tests/data/Calculation/Financial/EFFECT.php'; } /** @@ -282,7 +282,7 @@ class FinancialTest extends TestCase public function providerFV() { - return require 'data/Calculation/Financial/FV.php'; + return require 'tests/data/Calculation/Financial/FV.php'; } /** @@ -298,7 +298,7 @@ class FinancialTest extends TestCase public function providerFVSCHEDULE() { - return require 'data/Calculation/Financial/FVSCHEDULE.php'; + return require 'tests/data/Calculation/Financial/FVSCHEDULE.php'; } /** @@ -314,7 +314,7 @@ class FinancialTest extends TestCase public function providerINTRATE() { - return require 'data/Calculation/Financial/INTRATE.php'; + return require 'tests/data/Calculation/Financial/INTRATE.php'; } /** @@ -330,7 +330,7 @@ class FinancialTest extends TestCase public function providerIPMT() { - return require 'data/Calculation/Financial/IPMT.php'; + return require 'tests/data/Calculation/Financial/IPMT.php'; } /** @@ -346,7 +346,7 @@ class FinancialTest extends TestCase public function providerIRR() { - return require 'data/Calculation/Financial/IRR.php'; + return require 'tests/data/Calculation/Financial/IRR.php'; } /** @@ -362,7 +362,7 @@ class FinancialTest extends TestCase public function providerISPMT() { - return require 'data/Calculation/Financial/ISPMT.php'; + return require 'tests/data/Calculation/Financial/ISPMT.php'; } /** @@ -378,7 +378,7 @@ class FinancialTest extends TestCase public function providerMIRR() { - return require 'data/Calculation/Financial/MIRR.php'; + return require 'tests/data/Calculation/Financial/MIRR.php'; } /** @@ -394,7 +394,7 @@ class FinancialTest extends TestCase public function providerNOMINAL() { - return require 'data/Calculation/Financial/NOMINAL.php'; + return require 'tests/data/Calculation/Financial/NOMINAL.php'; } /** @@ -410,7 +410,7 @@ class FinancialTest extends TestCase public function providerNPER() { - return require 'data/Calculation/Financial/NPER.php'; + return require 'tests/data/Calculation/Financial/NPER.php'; } /** @@ -426,7 +426,7 @@ class FinancialTest extends TestCase public function providerNPV() { - return require 'data/Calculation/Financial/NPV.php'; + return require 'tests/data/Calculation/Financial/NPV.php'; } /** @@ -444,7 +444,7 @@ class FinancialTest extends TestCase public function providerPRICE() { - return require 'data/Calculation/Financial/PRICE.php'; + return require 'tests/data/Calculation/Financial/PRICE.php'; } /** @@ -460,7 +460,7 @@ class FinancialTest extends TestCase public function providerPRICEDISC() { - return require 'data/Calculation/Financial/PRICEDISC.php'; + return require 'tests/data/Calculation/Financial/PRICEDISC.php'; } /** @@ -476,7 +476,7 @@ class FinancialTest extends TestCase public function providerPV() { - return require 'data/Calculation/Financial/PV.php'; + return require 'tests/data/Calculation/Financial/PV.php'; } /** @@ -494,7 +494,7 @@ class FinancialTest extends TestCase public function providerRATE() { - return require 'data/Calculation/Financial/RATE.php'; + return require 'tests/data/Calculation/Financial/RATE.php'; } /** @@ -511,7 +511,7 @@ class FinancialTest extends TestCase public function providerXIRR() { - return require 'data/Calculation/Financial/XIRR.php'; + return require 'tests/data/Calculation/Financial/XIRR.php'; } /** @@ -527,7 +527,7 @@ class FinancialTest extends TestCase public function providerPDURATION() { - return require 'data/Calculation/Financial/PDURATION.php'; + return require 'tests/data/Calculation/Financial/PDURATION.php'; } /** @@ -543,7 +543,7 @@ class FinancialTest extends TestCase public function providerRRI() { - return require 'data/Calculation/Financial/RRI.php'; + return require 'tests/data/Calculation/Financial/RRI.php'; } /** @@ -559,7 +559,7 @@ class FinancialTest extends TestCase public function providerSLN() { - return require 'data/Calculation/Financial/SLN.php'; + return require 'tests/data/Calculation/Financial/SLN.php'; } /** @@ -575,6 +575,6 @@ class FinancialTest extends TestCase 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 c51e520a..abf7589a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FormulaAsStringTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FormulaAsStringTest.php @@ -41,6 +41,6 @@ class FormulaAsStringTest extends TestCase 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 adbc5221..35fbe05b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php @@ -32,6 +32,6 @@ class DateDifTest extends TestCase 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 ef3d60ee..c354f851 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php @@ -32,7 +32,7 @@ class DateTest extends TestCase 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 3c5d7a56..20541801 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php @@ -31,7 +31,7 @@ class DateValueTest extends TestCase 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 1b2bf430..77c29939 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php @@ -36,6 +36,6 @@ class DayTest extends TestCase 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 aa1da823..40e86f31 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php @@ -32,6 +32,6 @@ class Days360Test extends TestCase 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 0d805245..3c043950 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php @@ -31,6 +31,6 @@ class DaysTest extends TestCase 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 fbd4dee4..f931543e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php @@ -31,7 +31,7 @@ class EDateTest extends TestCase 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 deb67992..7c8352fe 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php @@ -31,7 +31,7 @@ class EoMonthTest extends TestCase 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 dc693101..5110f93c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php @@ -30,6 +30,6 @@ class HourTest extends TestCase 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 61a8427a..608a1bf8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php @@ -30,6 +30,6 @@ class IsoWeekNumTest extends TestCase 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 986ce480..36e248be 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php @@ -30,6 +30,6 @@ class MinuteTest extends TestCase 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 d0060af1..8f938c83 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php @@ -30,6 +30,6 @@ class MonthTest extends TestCase 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 f4340d9c..4fa86be8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php @@ -29,6 +29,6 @@ class NetworkDaysTest extends TestCase 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 aa1dba7e..e1032b94 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php @@ -30,6 +30,6 @@ class SecondTest extends TestCase 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 3be26786..1cd0c89b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php @@ -29,7 +29,7 @@ class TimeTest extends TestCase 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 263e665e..ed025cff 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php @@ -30,7 +30,7 @@ class TimeValueTest extends TestCase 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 72c8ac23..fe81c1a4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php @@ -29,6 +29,6 @@ class WeekDayTest extends TestCase 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 a7c3260d..96c2077b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php @@ -29,6 +29,6 @@ class WeekNumTest extends TestCase 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 2edc8609..bc6fd6cc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php @@ -29,6 +29,6 @@ class WorkDayTest extends TestCase 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 2d87c532..37364030 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php @@ -29,6 +29,6 @@ class YearFracTest extends TestCase 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 3545140f..26e416ec 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php @@ -30,6 +30,6 @@ class YearTest extends TestCase 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 e6fa2924..d7b23909 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php @@ -28,6 +28,6 @@ class BesselITest extends TestCase 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 1458ece9..5e4d2f3b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php @@ -28,6 +28,6 @@ class BesselJTest extends TestCase 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 f2ab0529..6a048f37 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php @@ -28,6 +28,6 @@ class BesselKTest extends TestCase 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 66af44c9..98c238e2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php @@ -28,6 +28,6 @@ class BesselYTest extends TestCase 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 61fe3423..341493ea 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php @@ -26,6 +26,6 @@ class Bin2DecTest extends TestCase 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 77e9722d..63945fd1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php @@ -26,6 +26,6 @@ class Bin2HexTest extends TestCase 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 a8f7095e..2aeeb1bc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php @@ -26,6 +26,6 @@ class Bin2OctTest extends TestCase 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 e60aa79b..483bf099 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php @@ -27,6 +27,6 @@ class BitAndTest extends TestCase 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 47703c51..bf280f16 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php @@ -27,6 +27,6 @@ class BitLShiftTest extends TestCase 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 19a5a6b1..6e455431 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php @@ -27,6 +27,6 @@ class BitOrTest extends TestCase 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 597fa333..26bece53 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php @@ -27,6 +27,6 @@ class BitRShiftTest extends TestCase 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 fc3df893..51401f63 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php @@ -27,6 +27,6 @@ class BitXorTest extends TestCase 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 dbdd8257..5bb7fbcd 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php @@ -26,6 +26,6 @@ class ComplexTest extends TestCase 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 593bfc65..3d6a0777 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php @@ -50,6 +50,6 @@ class ConvertUoMTest extends TestCase 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 f5c8f089..740fe3c9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php @@ -26,6 +26,6 @@ class Dec2BinTest extends TestCase 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 2bdeff25..c7aae441 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php @@ -26,6 +26,6 @@ class Dec2HexTest extends TestCase 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 93fa46c7..68456d1a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php @@ -26,6 +26,6 @@ class Dec2OctTest extends TestCase 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 241530ac..fc2df95b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php @@ -26,6 +26,6 @@ class DeltaTest extends TestCase 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 7dbb4158..5409db5f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php @@ -29,6 +29,6 @@ class ErfCTest extends TestCase 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 f42ebde1..857e41c1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php @@ -29,6 +29,6 @@ class ErfPreciseTest extends TestCase 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 fbc004fa..d148501b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php @@ -29,6 +29,6 @@ class ErfTest extends TestCase 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 b96dbcec..24ba1a0f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php @@ -26,6 +26,6 @@ class GeStepTest extends TestCase 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 4e779fba..83fcb1e7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php @@ -26,6 +26,6 @@ class Hex2BinTest extends TestCase 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 acefad65..5765494e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php @@ -26,6 +26,6 @@ class Hex2DecTest extends TestCase 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 2db814d6..25ba6300 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php @@ -26,6 +26,6 @@ class Hex2OctTest extends TestCase 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 fb68d580..c812fdfa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php @@ -29,6 +29,6 @@ class ImAbsTest extends TestCase 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 ffc051ef..60883e14 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php @@ -29,6 +29,6 @@ class ImArgumentTest extends TestCase 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 d431429a..81323a53 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php @@ -44,6 +44,6 @@ class ImConjugateTest extends TestCase 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 1e7a0ac0..c1c610fb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php @@ -44,6 +44,6 @@ class ImCosTest extends TestCase 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 ada76b62..7dacb7cd 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php @@ -44,6 +44,6 @@ class ImCoshTest extends TestCase 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 91089820..512d96f9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php @@ -44,6 +44,6 @@ class ImCotTest extends TestCase 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 151216db..5fb3f49d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php @@ -44,6 +44,6 @@ class ImCscTest extends TestCase 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 5ce9d6bc..9b1934bb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php @@ -44,6 +44,6 @@ class ImCschTest extends TestCase 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 ee75c996..7809ab06 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php @@ -43,6 +43,6 @@ class ImDivTest extends TestCase 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 8d38fe57..3af044d7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php @@ -44,6 +44,6 @@ class ImExpTest extends TestCase 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 54bf5db0..bb09860a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php @@ -44,6 +44,6 @@ class ImLnTest extends TestCase 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 69930da5..4831387d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php @@ -44,6 +44,6 @@ class ImLog10Test extends TestCase 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 aee9f442..b6f25123 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php @@ -44,6 +44,6 @@ class ImLog2Test extends TestCase 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 63211439..c198ffb9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php @@ -43,6 +43,6 @@ class ImPowerTest extends TestCase 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 d13d1a6c..2fd383c4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php @@ -43,6 +43,6 @@ class ImProductTest extends TestCase 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 013e6d93..bd4baf9f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php @@ -29,6 +29,6 @@ class ImRealTest extends TestCase 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 4f2957fa..4de6fcff 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php @@ -44,6 +44,6 @@ class ImSecTest extends TestCase 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 6b842566..11aa8e28 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php @@ -44,6 +44,6 @@ class ImSechTest extends TestCase 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 ca3ceb22..f3c6afe9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php @@ -44,6 +44,6 @@ class ImSinTest extends TestCase 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 b30d8280..7478c15c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php @@ -44,6 +44,6 @@ class ImSinhTest extends TestCase 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 0bff1eef..f9a15195 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php @@ -44,6 +44,6 @@ class ImSqrtTest extends TestCase 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 0daa1827..2ddc3f57 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php @@ -43,6 +43,6 @@ class ImSubTest extends TestCase 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 c4fbc3e7..23f716ca 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php @@ -43,6 +43,6 @@ class ImSumTest extends TestCase 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 c3e5eb1c..d9f39ad5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php @@ -44,6 +44,6 @@ class ImTanTest extends TestCase 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 6f9e67cf..4d2e6781 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php @@ -29,6 +29,6 @@ class ImaginaryTest extends TestCase 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 97558b65..217494fa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php @@ -26,6 +26,6 @@ class Oct2BinTest extends TestCase 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 ed51ab48..c959236c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php @@ -26,6 +26,6 @@ class Oct2DecTest extends TestCase 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 35764d2b..1d14bd78 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php @@ -26,6 +26,6 @@ class Oct2HexTest extends TestCase 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 84f45962..33921bb3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php @@ -26,6 +26,6 @@ class AccrintMTest extends TestCase 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 55ee6747..21aadd0a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php @@ -26,6 +26,6 @@ class AccrintTest extends TestCase 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 74c426ea..c1334988 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php @@ -26,6 +26,6 @@ class AndTest extends TestCase 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 20d71025..1e9ef8bc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php @@ -28,6 +28,6 @@ class IfErrorTest extends TestCase 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 02181b64..e151cd75 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php @@ -28,6 +28,6 @@ class IfNaTest extends TestCase 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 6f0b4087..f289995a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php @@ -26,6 +26,6 @@ class IfTest extends TestCase 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 5dd40fdc..abc0e5bc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php @@ -26,6 +26,6 @@ class NotTest extends TestCase 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 a91fc5b0..46046b7c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php @@ -26,6 +26,6 @@ class OrTest extends TestCase 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 d85ca4f3..2781334d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php @@ -26,6 +26,6 @@ class SwitchTest extends TestCase 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 dc264f52..8f7a921b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php @@ -26,6 +26,6 @@ class XorTest extends TestCase 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 9e720566..00e2c61c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php @@ -26,6 +26,6 @@ class ChooseTest extends TestCase 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 f34a3f64..61c0f8b4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php @@ -26,6 +26,6 @@ class ColumnsTest extends TestCase 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 2baaa4f8..d317089d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php @@ -26,6 +26,6 @@ class HLookupTest extends TestCase 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 972e7511..241d86f7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php @@ -26,6 +26,6 @@ class IndexTest extends TestCase 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 f643783d..6e1fb73a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php @@ -26,6 +26,6 @@ class LookupTest extends TestCase 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 3c956b66..2bf322fc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php @@ -26,6 +26,6 @@ class MatchTest extends TestCase 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 0a97382f..41b0bd2b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php @@ -26,6 +26,6 @@ class RowsTest extends TestCase 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 cf4b3059..bffecb8e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php @@ -26,6 +26,6 @@ class VLookupTest extends TestCase 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 e77c4ffb..2a3cd654 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php @@ -27,6 +27,6 @@ class AcotTest extends TestCase 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 695df010..9661b676 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php @@ -27,6 +27,6 @@ class AcothTest extends TestCase 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 10135e11..0371e0a7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php @@ -27,6 +27,6 @@ class ArabicTest extends TestCase 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 dc965305..c6281fc2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php @@ -28,6 +28,6 @@ class Atan2Test extends TestCase 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 1368df19..fdca1f49 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php @@ -26,6 +26,6 @@ class BaseTest extends TestCase 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 f60fae72..c987cc2e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php @@ -26,6 +26,6 @@ class CeilingTest extends TestCase 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 d3a4ee44..8c982b6b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php @@ -26,6 +26,6 @@ class CombinTest extends TestCase 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 6263c9fd..f864d226 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php @@ -27,6 +27,6 @@ class CotTest extends TestCase 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 2dfa57a5..9243c095 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php @@ -27,6 +27,6 @@ class CothTest extends TestCase 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 1b0cdbf7..24abad4e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php @@ -27,6 +27,6 @@ class CscTest extends TestCase 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 82e286da..393c0883 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php @@ -27,6 +27,6 @@ class CschTest extends TestCase 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 3bd84ddd..b81b119f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php @@ -27,6 +27,6 @@ class EvenTest extends TestCase 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 2dfe8fad..c3118942 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php @@ -27,6 +27,6 @@ class FactDoubleTest extends TestCase 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 0f3294e3..b765d412 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php @@ -27,6 +27,6 @@ class FactTest extends TestCase 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 63b694f3..c5b797f1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php @@ -26,6 +26,6 @@ class FloorMathTest extends TestCase 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 e84e596a..399f05d2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php @@ -26,6 +26,6 @@ class FloorPreciseTest extends TestCase 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 60ff5bb7..fac02f16 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php @@ -26,6 +26,6 @@ class FloorTest extends TestCase 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 d6f588d1..825a9d05 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php @@ -26,6 +26,6 @@ class GcdTest extends TestCase 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 3a287aa3..3a9b1e5b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php @@ -27,6 +27,6 @@ class IntTest extends TestCase 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 a5cc2312..58ea6a6b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php @@ -26,6 +26,6 @@ class LcmTest extends TestCase 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 2e54654e..82c63f99 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php @@ -26,6 +26,6 @@ class LogTest extends TestCase 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 2a4f1af0..3d784a87 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php @@ -26,6 +26,6 @@ class MInverseTest extends TestCase 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 337abbea..16a52e75 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php @@ -26,6 +26,6 @@ class MMultTest extends TestCase 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 ca14bc1c..73568747 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php @@ -26,6 +26,6 @@ class MRoundTest extends TestCase 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 84911aaf..672d5dec 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php @@ -26,6 +26,6 @@ class MdeTermTest extends TestCase 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 8d166618..ae863792 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php @@ -26,6 +26,6 @@ class ModTest extends TestCase 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 1f751351..dd2faf2c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php @@ -26,6 +26,6 @@ class MultinomialTest extends TestCase 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 8ba4beaf..7a9d367c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php @@ -27,6 +27,6 @@ class OddTest extends TestCase 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 9df08b5f..05edecf9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php @@ -26,6 +26,6 @@ class PowerTest extends TestCase 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 fecc806a..3e185bd7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php @@ -26,6 +26,6 @@ class ProductTest extends TestCase 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 e81414fe..96e0b84a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php @@ -26,6 +26,6 @@ class QuotientTest extends TestCase 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 edc72289..a1363714 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php @@ -26,6 +26,6 @@ class RomanTest extends TestCase 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 4d95dac7..17b6780b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php @@ -26,6 +26,6 @@ class RoundDownTest extends TestCase 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 143aa653..6d1c57ba 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php @@ -26,6 +26,6 @@ class RoundUpTest extends TestCase 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 944c3e37..8dad0b9d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php @@ -27,6 +27,6 @@ class SecTest extends TestCase 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 42fecb0b..f98b673e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php @@ -27,6 +27,6 @@ class SechTest extends TestCase 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 7923fbc1..4f8d4db1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php @@ -26,6 +26,6 @@ class SeriesSumTest extends TestCase 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 c0ff7b5e..d7b6bacb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php @@ -27,6 +27,6 @@ class SignTest extends TestCase 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 19a182c5..38528548 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php @@ -27,6 +27,6 @@ class SqrtPiTest extends TestCase 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 2711c657..38434278 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php @@ -54,7 +54,7 @@ class SubTotalTest extends TestCase 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 @@ class SubTotalTest extends TestCase 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 @@ class SubTotalTest extends TestCase 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 359fef44..639e8bdd 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php @@ -26,6 +26,6 @@ class SumIfTest extends TestCase 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 9127705a..dab255c2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php @@ -26,6 +26,6 @@ class SumIfsTest extends TestCase 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 c409ee18..6b94dafa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php @@ -26,6 +26,6 @@ class SumProductTest extends TestCase 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 bfd2d874..bcb00acc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php @@ -26,6 +26,6 @@ class SumSqTest extends TestCase 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 937043ee..1bfe5923 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php @@ -26,6 +26,6 @@ class SumX2MY2Test extends TestCase 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 c58f28a2..c53630de 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php @@ -26,6 +26,6 @@ class SumX2PY2Test extends TestCase 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 a4a6e8a1..bb4dc527 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php @@ -26,6 +26,6 @@ class SumXMY2Test extends TestCase 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 b5bb6e43..244889dc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php @@ -26,6 +26,6 @@ class TruncTest extends TestCase 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 94f214a3..a61730ad 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php @@ -26,6 +26,6 @@ class AveDevTest extends TestCase 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 526875f3..6c5f4093 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php @@ -26,6 +26,6 @@ class AverageATest extends TestCase 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 0d7863bf..f1b4081a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php @@ -26,6 +26,6 @@ class AverageIfTest extends TestCase 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 30503a3a..3d03524e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php @@ -26,6 +26,6 @@ class AverageTest extends TestCase 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 6b1aed82..1cd9280d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php @@ -26,6 +26,6 @@ class BetaDistTest extends TestCase 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 b0fc38d7..10c47c76 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php @@ -26,6 +26,6 @@ class BetaInvTest extends TestCase 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 c16ff6c2..e4891546 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php @@ -26,6 +26,6 @@ class BinomDistTest extends TestCase 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 3d027c23..d00d5fb0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php @@ -26,6 +26,6 @@ class ChiDistTest extends TestCase 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 d176ee78..e2b93e95 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php @@ -26,6 +26,6 @@ class ChiInvTest extends TestCase 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 5d4472d4..9a131ed0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php @@ -26,6 +26,6 @@ class ConfidenceTest extends TestCase 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 c489d4c8..f2bba8d7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php @@ -26,6 +26,6 @@ class CorrelTest extends TestCase 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 4edb1874..15f9c4bf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php @@ -26,6 +26,6 @@ class CountATest extends TestCase 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 5bd008e8..8e61bb47 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php @@ -26,6 +26,6 @@ class CountBlankTest extends TestCase 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 ec3a25b3..7f1dd221 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php @@ -26,6 +26,6 @@ class CountIfTest extends TestCase 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 0170c277..301c3f4c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php @@ -26,6 +26,6 @@ class CountIfsTest extends TestCase 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 798bcbd9..1bfac28e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php @@ -26,7 +26,7 @@ class CountTest extends TestCase public function providerBasicCOUNT() { - return require 'data/Calculation/Statistical/BasicCOUNT.php'; + return require 'tests/data/Calculation/Statistical/BasicCOUNT.php'; } /** @@ -42,7 +42,7 @@ class CountTest extends TestCase public function providerExcelCOUNT() { - return require 'data/Calculation/Statistical/ExcelCOUNT.php'; + return require 'tests/data/Calculation/Statistical/ExcelCOUNT.php'; } /** @@ -60,7 +60,7 @@ class CountTest extends TestCase public function providerOpenOfficeCOUNT() { - return require 'data/Calculation/Statistical/OpenOfficeCOUNT.php'; + return require 'tests/data/Calculation/Statistical/OpenOfficeCOUNT.php'; } /** @@ -78,6 +78,6 @@ class CountTest extends TestCase 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 7658d445..c34e36d2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php @@ -26,6 +26,6 @@ class CovarTest extends TestCase 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 a9184edd..cf3e8849 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php @@ -26,6 +26,6 @@ class ExponDistTest extends TestCase 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 0488d504..f8eb7554 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php @@ -27,6 +27,6 @@ class FisherInvTest extends TestCase 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 25ca6b48..5f9733ab 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php @@ -27,6 +27,6 @@ class FisherTest extends TestCase 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 e0227ad7..4de64500 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php @@ -26,6 +26,6 @@ class ForecastTest extends TestCase 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 325f662d..41806e56 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php @@ -26,6 +26,6 @@ class GammaDistTest extends TestCase 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 76f5e30c..ad72277a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php @@ -26,6 +26,6 @@ class GammaInvTest extends TestCase 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 11363b1f..2fde78aa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php @@ -27,6 +27,6 @@ class GammaLnTest extends TestCase 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 cbb7b33d..6f8f6053 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php @@ -26,6 +26,6 @@ class GeoMeanTest extends TestCase 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 5777204d..38ad95db 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php @@ -26,6 +26,6 @@ class HarMeanTest extends TestCase 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 9362e692..e3f9383c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php @@ -26,6 +26,6 @@ class InterceptTest extends TestCase 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 06fc2263..c8d3d02c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php @@ -26,6 +26,6 @@ class MaxIfsTest extends TestCase 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 29497689..571fca23 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php @@ -26,6 +26,6 @@ class MedianTest extends TestCase 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 4721043f..b8c1e291 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php @@ -26,6 +26,6 @@ class MinIfsTest extends TestCase 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 4e0c9da9..7e7ae7a7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php @@ -26,6 +26,6 @@ class PermutTest extends TestCase 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 229c221f..a0959eac 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php @@ -26,6 +26,6 @@ class RsqTest extends TestCase 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 4bdaef02..fe28f5eb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php @@ -26,6 +26,6 @@ class SlopeTest extends TestCase 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 271c2175..5ab6b662 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php @@ -26,6 +26,6 @@ class SteyxTest extends TestCase 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 66bbdc20..86483180 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php @@ -39,6 +39,6 @@ class CharTest extends TestCase 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 0f0e391a..63042fa5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php @@ -39,6 +39,6 @@ class CleanTest extends TestCase 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 99f7dcf5..b39b66bf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php @@ -39,6 +39,6 @@ class CodeTest extends TestCase 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 7b93f56e..6d32298e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php @@ -38,6 +38,6 @@ class ConcatenateTest extends TestCase 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 827860bc..3f0ae34f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php @@ -38,6 +38,6 @@ class DollarTest extends TestCase 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 ddf685c4..ad44c03f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php @@ -46,6 +46,6 @@ class ExactTest extends TestCase */ 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 495339ab..c20d7df3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php @@ -38,6 +38,6 @@ class FindTest extends TestCase 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 af9b02ca..010278fc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php @@ -38,6 +38,6 @@ class FixedTest extends TestCase 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 b42a4ac3..d1eba19e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php @@ -38,6 +38,6 @@ class LeftTest extends TestCase 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 ad5bffb6..8e711fa9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php @@ -39,6 +39,6 @@ class LenTest extends TestCase 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 5651e7ae..e329dda3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php @@ -39,6 +39,6 @@ class LowerTest extends TestCase 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 cda1dc01..5bcc43fc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php @@ -38,6 +38,6 @@ class MidTest extends TestCase 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 3ffd147d..45e3c6be 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php @@ -39,6 +39,6 @@ class NumberValueTest extends TestCase 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 0aaf968f..13efbd9a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php @@ -39,6 +39,6 @@ class ProperTest extends TestCase 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 e7592a1f..f319b16e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php @@ -38,6 +38,6 @@ class ReplaceTest extends TestCase 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 3ec883f4..216050c3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php @@ -38,6 +38,6 @@ class RightTest extends TestCase 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 c8b3040b..ab3fcb11 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php @@ -38,6 +38,6 @@ class SearchTest extends TestCase 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 a88ee81d..89a89ba3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php @@ -38,6 +38,6 @@ class SubstituteTest extends TestCase 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 4cdf3fb4..56b00838 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php @@ -39,6 +39,6 @@ class TTest extends TestCase 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 c4c929db..ec04ce13 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php @@ -39,6 +39,6 @@ class TextJoinTest extends TestCase 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 306530a5..f7638e4c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php @@ -43,6 +43,6 @@ class TextTest extends TestCase 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 aa896427..d5907803 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php @@ -39,6 +39,6 @@ class TrimTest extends TestCase 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 cdfdb49f..a69d8279 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php @@ -39,6 +39,6 @@ class UpperTest extends TestCase 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 f60a12a9..b2e31ba3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php @@ -43,6 +43,6 @@ class ValueTest extends TestCase 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 b0c8eb87..94788c2d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php @@ -119,7 +119,7 @@ class FunctionsTest extends TestCase public function providerIsBlank() { - return require 'data/Calculation/Functions/IS_BLANK.php'; + return require 'tests/data/Calculation/Functions/IS_BLANK.php'; } /** @@ -135,7 +135,7 @@ class FunctionsTest extends TestCase public function providerIsErr() { - return require 'data/Calculation/Functions/IS_ERR.php'; + return require 'tests/data/Calculation/Functions/IS_ERR.php'; } /** @@ -151,7 +151,7 @@ class FunctionsTest extends TestCase public function providerIsError() { - return require 'data/Calculation/Functions/IS_ERROR.php'; + return require 'tests/data/Calculation/Functions/IS_ERROR.php'; } /** @@ -167,7 +167,7 @@ class FunctionsTest extends TestCase public function providerErrorType() { - return require 'data/Calculation/Functions/ERROR_TYPE.php'; + return require 'tests/data/Calculation/Functions/ERROR_TYPE.php'; } /** @@ -183,7 +183,7 @@ class FunctionsTest extends TestCase public function providerIsLogical() { - return require 'data/Calculation/Functions/IS_LOGICAL.php'; + return require 'tests/data/Calculation/Functions/IS_LOGICAL.php'; } /** @@ -199,7 +199,7 @@ class FunctionsTest extends TestCase public function providerIsNa() { - return require 'data/Calculation/Functions/IS_NA.php'; + return require 'tests/data/Calculation/Functions/IS_NA.php'; } /** @@ -215,7 +215,7 @@ class FunctionsTest extends TestCase public function providerIsNumber() { - return require 'data/Calculation/Functions/IS_NUMBER.php'; + return require 'tests/data/Calculation/Functions/IS_NUMBER.php'; } /** @@ -231,7 +231,7 @@ class FunctionsTest extends TestCase public function providerIsText() { - return require 'data/Calculation/Functions/IS_TEXT.php'; + return require 'tests/data/Calculation/Functions/IS_TEXT.php'; } /** @@ -247,7 +247,7 @@ class FunctionsTest extends TestCase public function providerIsNonText() { - return require 'data/Calculation/Functions/IS_NONTEXT.php'; + return require 'tests/data/Calculation/Functions/IS_NONTEXT.php'; } /** @@ -263,7 +263,7 @@ class FunctionsTest extends TestCase public function providerIsEven() { - return require 'data/Calculation/Functions/IS_EVEN.php'; + return require 'tests/data/Calculation/Functions/IS_EVEN.php'; } /** @@ -279,7 +279,7 @@ class FunctionsTest extends TestCase public function providerIsOdd() { - return require 'data/Calculation/Functions/IS_ODD.php'; + return require 'tests/data/Calculation/Functions/IS_ODD.php'; } /** @@ -295,7 +295,7 @@ class FunctionsTest extends TestCase public function providerTYPE() { - return require 'data/Calculation/Functions/TYPE.php'; + return require 'tests/data/Calculation/Functions/TYPE.php'; } /** @@ -311,7 +311,7 @@ class FunctionsTest extends TestCase public function providerN() { - return require 'data/Calculation/Functions/N.php'; + return require 'tests/data/Calculation/Functions/N.php'; } /** @@ -364,7 +364,7 @@ class FunctionsTest extends TestCase public function providerIsFormula() { - return require 'data/Calculation/Functions/ISFORMULA.php'; + return require 'tests/data/Calculation/Functions/ISFORMULA.php'; } /** @@ -380,6 +380,6 @@ class FunctionsTest extends TestCase 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 5694d859..dff80fad 100644 --- a/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php @@ -71,6 +71,6 @@ class LookupRefTest extends TestCase 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 38fc4280..15e1d384 100644 --- a/tests/PhpSpreadsheetTests/Cell/CellTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CellTest.php @@ -26,7 +26,7 @@ class CellTest extends TestCase public function providerSetValueExplicit() { - return require 'data/Cell/SetValueExplicit.php'; + return require 'tests/data/Cell/SetValueExplicit.php'; } /** @@ -47,6 +47,6 @@ class CellTest extends TestCase 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 8d041c26..7a12ceb7 100644 --- a/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php @@ -25,7 +25,7 @@ class CoordinateTest extends TestCase public function providerColumnString() { - return require 'data/ColumnString.php'; + return require 'tests/data/ColumnString.php'; } public function testColumnIndexFromStringTooLong() @@ -75,7 +75,7 @@ class CoordinateTest extends TestCase public function providerColumnIndex() { - return require 'data/ColumnIndex.php'; + return require 'tests/data/ColumnIndex.php'; } /** @@ -91,7 +91,7 @@ class CoordinateTest extends TestCase public function providerCoordinates() { - return require 'data/CellCoordinates.php'; + return require 'tests/data/CellCoordinates.php'; } public function testCoordinateFromStringWithRangeAddress() @@ -152,7 +152,7 @@ class CoordinateTest extends TestCase public function providerAbsoluteCoordinates() { - return require 'data/CellAbsoluteCoordinate.php'; + return require 'tests/data/CellAbsoluteCoordinate.php'; } public function testAbsoluteCoordinateFromStringWithRangeAddress() @@ -183,7 +183,7 @@ class CoordinateTest extends TestCase public function providerAbsoluteReferences() { - return require 'data/CellAbsoluteReference.php'; + return require 'tests/data/CellAbsoluteReference.php'; } public function testAbsoluteReferenceFromStringWithRangeAddress() @@ -220,7 +220,7 @@ class CoordinateTest extends TestCase public function providerSplitRange() { - return require 'data/CellSplitRange.php'; + return require 'tests/data/CellSplitRange.php'; } /** @@ -236,7 +236,7 @@ class CoordinateTest extends TestCase public function providerBuildRange() { - return require 'data/CellBuildRange.php'; + return require 'tests/data/CellBuildRange.php'; } public function testBuildRangeInvalid() @@ -260,7 +260,7 @@ class CoordinateTest extends TestCase public function providerRangeBoundaries() { - return require 'data/CellRangeBoundaries.php'; + return require 'tests/data/CellRangeBoundaries.php'; } /** @@ -276,7 +276,7 @@ class CoordinateTest extends TestCase public function providerRangeDimension() { - return require 'data/CellRangeDimension.php'; + return require 'tests/data/CellRangeDimension.php'; } /** @@ -292,7 +292,7 @@ class CoordinateTest extends TestCase public function providerGetRangeBoundaries() { - return require 'data/CellGetRangeBoundaries.php'; + return require 'tests/data/CellGetRangeBoundaries.php'; } /** @@ -308,7 +308,7 @@ class CoordinateTest extends TestCase public function providerExtractAllCellReferencesInRange() { - return require 'data/CellExtractAllCellReferencesInRange.php'; + return require 'tests/data/CellExtractAllCellReferencesInRange.php'; } /** @@ -342,7 +342,7 @@ class CoordinateTest extends TestCase public function providerMergeRangesInCollection() { - return require 'data/CellMergeRangesInCollection.php'; + return require 'tests/data/CellMergeRangesInCollection.php'; } /** @@ -358,6 +358,6 @@ class CoordinateTest extends TestCase 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 d116fb99..d22e03cb 100644 --- a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php @@ -73,7 +73,7 @@ class DefaultValueBinderTest extends TestCase 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 53cc718d..cca3777a 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 e97941f7..6bd9c422 100644 --- a/tests/PhpSpreadsheetTests/Helper/SampleTest.php +++ b/tests/PhpSpreadsheetTests/Helper/SampleTest.php @@ -48,7 +48,7 @@ class SampleTest extends TestCase 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 90a9af0e..5084354f 100644 --- a/tests/PhpSpreadsheetTests/IOFactoryTest.php +++ b/tests/PhpSpreadsheetTests/IOFactoryTest.php @@ -120,13 +120,13 @@ class IOFactoryTest extends TestCase 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 ca69d23b..1743c433 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 4fe2006d..4920c001 100644 --- a/tests/PhpSpreadsheetTests/Reader/CsvContiguousTest.php +++ b/tests/PhpSpreadsheetTests/Reader/CsvContiguousTest.php @@ -8,7 +8,7 @@ use PHPUnit\Framework\TestCase; 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 bb593ce8..3b6c61b8 100644 --- a/tests/PhpSpreadsheetTests/Reader/CsvTest.php +++ b/tests/PhpSpreadsheetTests/Reader/CsvTest.php @@ -33,55 +33,55 @@ class CsvTest extends TestCase { 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 @@ class CsvTest extends TestCase 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 @@ class CsvTest extends TestCase 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 @@ class CsvTest extends TestCase { $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 @@ EOF; { $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 a91fe73d..14cccb6b 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 @@ class HtmlTest extends TestCase 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 bec85f7b..82813b74 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 @@ class OdsTest extends TestCase 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 @@ class OdsTest extends TestCase 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 @@ class OdsTest extends TestCase '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 6bb1f021..4bf46429 100644 --- a/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php @@ -35,7 +35,7 @@ class XmlScannerTest extends TestCase 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 @@ class XmlScannerTest extends TestCase 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 @@ class XmlScannerTest extends TestCase 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 @@ class XmlScannerTest extends TestCase 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 f629fed1..dd6344b4 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 54908bc2..b77796c6 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php @@ -22,7 +22,7 @@ class Xlsx2Test extends TestCase 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 @@ class Xlsx2Test extends TestCase 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 7c5b08d9..efa7af72 100644 --- a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php @@ -24,7 +24,7 @@ class XlsxTest extends TestCase '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 @@ class XlsxTest extends TestCase 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 @@ class XlsxTest extends TestCase 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 @@ class XlsxTest extends TestCase 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 @@ class XlsxTest extends TestCase 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 @@ class XlsxTest extends TestCase 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 @@ class XlsxTest extends TestCase 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 @@ class XlsxTest extends TestCase */ 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 @@ class XlsxTest extends TestCase */ 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 @@ class XlsxTest extends TestCase */ 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 @@ class XlsxTest extends TestCase */ 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 f085f437..116ec03e 100644 --- a/tests/PhpSpreadsheetTests/Reader/XmlTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XmlTest.php @@ -24,7 +24,7 @@ class XmlTest extends TestCase 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 @@ class XmlTest extends TestCase 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 @@ class XmlTest extends TestCase 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 b0e5fbfe..e3638687 100644 --- a/tests/PhpSpreadsheetTests/Shared/CodePageTest.php +++ b/tests/PhpSpreadsheetTests/Shared/CodePageTest.php @@ -21,7 +21,7 @@ class CodePageTest extends TestCase 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 8d844cba..14930677 100644 --- a/tests/PhpSpreadsheetTests/Shared/DateTest.php +++ b/tests/PhpSpreadsheetTests/Shared/DateTest.php @@ -42,7 +42,7 @@ class DateTest extends TestCase public function providerDateTimeExcelToTimestamp1900() { - return require 'data/Shared/Date/ExcelToTimestamp1900.php'; + return require 'tests/data/Shared/Date/ExcelToTimestamp1900.php'; } /** @@ -60,7 +60,7 @@ class DateTest extends TestCase public function providerDateTimeTimestampToExcel1900() { - return require 'data/Shared/Date/TimestampToExcel1900.php'; + return require 'tests/data/Shared/Date/TimestampToExcel1900.php'; } /** @@ -78,7 +78,7 @@ class DateTest extends TestCase public function providerDateTimeDateTimeToExcel() { - return require 'data/Shared/Date/DateTimeToExcel.php'; + return require 'tests/data/Shared/Date/DateTimeToExcel.php'; } /** @@ -96,7 +96,7 @@ class DateTest extends TestCase public function providerDateTimeFormattedPHPToExcel1900() { - return require 'data/Shared/Date/FormattedPHPToExcel1900.php'; + return require 'tests/data/Shared/Date/FormattedPHPToExcel1900.php'; } /** @@ -114,7 +114,7 @@ class DateTest extends TestCase public function providerDateTimeExcelToTimestamp1904() { - return require 'data/Shared/Date/ExcelToTimestamp1904.php'; + return require 'tests/data/Shared/Date/ExcelToTimestamp1904.php'; } /** @@ -132,7 +132,7 @@ class DateTest extends TestCase public function providerDateTimeTimestampToExcel1904() { - return require 'data/Shared/Date/TimestampToExcel1904.php'; + return require 'tests/data/Shared/Date/TimestampToExcel1904.php'; } /** @@ -148,7 +148,7 @@ class DateTest extends TestCase public function providerIsDateTimeFormatCode() { - return require 'data/Shared/Date/FormatCodes.php'; + return require 'tests/data/Shared/Date/FormatCodes.php'; } /** @@ -166,6 +166,6 @@ class DateTest extends TestCase 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 fc1aa645..03ff2c4e 100644 --- a/tests/PhpSpreadsheetTests/Shared/FontTest.php +++ b/tests/PhpSpreadsheetTests/Shared/FontTest.php @@ -49,7 +49,7 @@ class FontTest extends TestCase public function providerFontSizeToPixels() { - return require 'data/Shared/FontSizeToPixels.php'; + return require 'tests/data/Shared/FontSizeToPixels.php'; } /** @@ -65,7 +65,7 @@ class FontTest extends TestCase public function providerInchSizeToPixels() { - return require 'data/Shared/InchSizeToPixels.php'; + return require 'tests/data/Shared/InchSizeToPixels.php'; } /** @@ -81,6 +81,6 @@ class FontTest extends TestCase 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 a004c4ae..6135232c 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 65b61345..e92e0886 100644 --- a/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php +++ b/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php @@ -20,6 +20,6 @@ class PasswordHasherTest extends TestCase 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 a99c8990..5bd2f208 100644 --- a/tests/PhpSpreadsheetTests/Style/ColorTest.php +++ b/tests/PhpSpreadsheetTests/Style/ColorTest.php @@ -20,7 +20,7 @@ class ColorTest extends TestCase public function providerColorGetRed() { - return require 'data/Style/ColorGetRed.php'; + return require 'tests/data/Style/ColorGetRed.php'; } /** @@ -36,7 +36,7 @@ class ColorTest extends TestCase public function providerColorGetGreen() { - return require 'data/Style/ColorGetGreen.php'; + return require 'tests/data/Style/ColorGetGreen.php'; } /** @@ -52,7 +52,7 @@ class ColorTest extends TestCase public function providerColorGetBlue() { - return require 'data/Style/ColorGetBlue.php'; + return require 'tests/data/Style/ColorGetBlue.php'; } /** @@ -68,6 +68,6 @@ class ColorTest extends TestCase 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 e0ab660e..9dc20fd7 100644 --- a/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php +++ b/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php @@ -27,7 +27,7 @@ class NumberFormatTest extends TestCase public function providerNumberFormat() { - return require 'data/Style/NumberFormat.php'; + return require 'tests/data/Style/NumberFormat.php'; } /** @@ -43,6 +43,6 @@ class NumberFormatTest extends TestCase 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 3caaba7c..5641d330 100644 --- a/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php @@ -16,7 +16,7 @@ use PHPUnit\Framework\TestCase; 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 8e0d654f..a826dfaa 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 f89fe408..c37c304a 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 90b66acd..63d9e6fb 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 10ac8118..d44ec624 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 0c38a004..98b5ca19 100644 --- a/samples/Basic/01_Simple_download_ods.php +++ b/samples/Basic/01_Simple_download_ods.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Helper\Sample; 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 5f3e71d7..ddd99d29 100644 --- a/samples/Basic/01_Simple_download_pdf.php +++ b/samples/Basic/01_Simple_download_pdf.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Helper\Sample; 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 46d12022..a7df25c4 100644 --- a/samples/Basic/01_Simple_download_xls.php +++ b/samples/Basic/01_Simple_download_xls.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Helper\Sample; 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 93efe73d..c67a17d0 100644 --- a/samples/Basic/01_Simple_download_xlsx.php +++ b/samples/Basic/01_Simple_download_xlsx.php @@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Helper\Sample; 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 fb8bd986..6e0f3b4e 100644 --- a/samples/Header.php +++ b/samples/Header.php @@ -6,7 +6,7 @@ use PhpOffice\PhpSpreadsheet\Helper\Sample; 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 c37c304a..77cd5228 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,5 +4,3 @@ setlocale(LC_ALL, 'en_US.utf8'); // 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 dc7a0431..afda5c43 100644 --- a/src/PhpSpreadsheet/Writer/BaseWriter.php +++ b/src/PhpSpreadsheet/Writer/BaseWriter.php @@ -108,9 +108,9 @@ abstract class BaseWriter implements IWriter 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 @@ abstract class BaseWriter implements IWriter } /** - * 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 cabfe450..4344a5bd 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -4,7 +4,6 @@ namespace PhpOffice\PhpSpreadsheet\Writer; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Spreadsheet; -use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; class Csv extends BaseWriter { @@ -91,17 +90,7 @@ class Csv extends BaseWriter 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 @@ class Csv extends BaseWriter $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 @@ class Csv extends BaseWriter // 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 e3ba3de8..deeb00a6 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 4478d2dd..860c16a6 100644 --- a/samples/Chart/33_Chart_create_area.php +++ b/samples/Chart/33_Chart_create_area.php @@ -83,7 +83,7 @@ $chart = new Chart( $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 7ba4d8de..0aa211a9 100644 --- a/samples/Chart/33_Chart_create_bar_stacked.php +++ b/samples/Chart/33_Chart_create_bar_stacked.php @@ -86,7 +86,7 @@ $chart = new Chart( $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 9ffe9d3f..694082a4 100644 --- a/samples/Chart/33_Chart_create_column.php +++ b/samples/Chart/33_Chart_create_column.php @@ -86,7 +86,7 @@ $chart = new Chart( $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 bba9210a..f5a529b9 100644 --- a/samples/Chart/33_Chart_create_column_2.php +++ b/samples/Chart/33_Chart_create_column_2.php @@ -95,7 +95,7 @@ $chart = new Chart( $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 83dc34a9..dfeacae3 100644 --- a/samples/Chart/33_Chart_create_composite.php +++ b/samples/Chart/33_Chart_create_composite.php @@ -139,7 +139,7 @@ $chart = new Chart( $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 bdaf0111..feae2f27 100644 --- a/samples/Chart/33_Chart_create_line.php +++ b/samples/Chart/33_Chart_create_line.php @@ -84,7 +84,7 @@ $chart = new Chart( $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 10a11e13..d0de5db4 100644 --- a/samples/Chart/33_Chart_create_multiple_charts.php +++ b/samples/Chart/33_Chart_create_multiple_charts.php @@ -158,7 +158,7 @@ $chart2 = new Chart( $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 d4ec0752..54d5916b 100644 --- a/samples/Chart/33_Chart_create_pie.php +++ b/samples/Chart/33_Chart_create_pie.php @@ -84,7 +84,7 @@ $chart1 = new Chart( $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 727a0cde..0e9ce4b7 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 @@ $chart2 = new Chart( 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 e57914ab..1c5c435f 100644 --- a/samples/Chart/33_Chart_create_radar.php +++ b/samples/Chart/33_Chart_create_radar.php @@ -96,7 +96,7 @@ $chart = new Chart( $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 12fc2bdc..02fa866d 100644 --- a/samples/Chart/33_Chart_create_scatter.php +++ b/samples/Chart/33_Chart_create_scatter.php @@ -80,7 +80,7 @@ $chart = new Chart( $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 7a9f7274..4e8ffe8e 100644 --- a/samples/Chart/33_Chart_create_stock.php +++ b/samples/Chart/33_Chart_create_stock.php @@ -92,7 +92,7 @@ $chart = new Chart( $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 59c9ed5d..bc42c854 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 c20efabe..79f4e8d1 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 d0de5db4..c25328a8 100644 --- a/samples/Chart/33_Chart_create_multiple_charts.php +++ b/samples/Chart/33_Chart_create_multiple_charts.php @@ -83,7 +83,7 @@ $chart1 = new Chart( $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 54d5916b..0df41143 100644 --- a/samples/Chart/33_Chart_create_pie.php +++ b/samples/Chart/33_Chart_create_pie.php @@ -154,7 +154,7 @@ $chart2 = new Chart( 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 0e9ce4b7..137e6e75 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 @@ $chart1 = new Chart( $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 84c8c956..44d7b543 100644 --- a/samples/templates/chartSpreadsheet.php +++ b/samples/templates/chartSpreadsheet.php @@ -83,7 +83,7 @@ $chart = new Chart( $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 bc42c854..7064160e 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 deeb00a6..3eeeed15 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 127403d9..b9017e0e 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -426,7 +426,7 @@ class Cells * * @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 | 368 ++++++++++-------- .../Calculation/FinancialTest.php | 60 ++- .../Writer/Xlsx/LocaleFloatsTest.php | 3 +- tests/data/Calculation/Financial/COUPNUM.php | 35 ++ tests/data/Calculation/Financial/PRICE.php | 211 +++++++--- 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, 739 insertions(+), 218 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 4f85edeb..9e1e4cf5 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -59,17 +59,13 @@ class DateTime /** * 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 412b7a62..1a49ac1c 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -6,7 +6,7 @@ use PhpOffice\PhpSpreadsheet\Shared\Date; class Financial { - const FINANCIAL_MAX_ITERATIONS = 32; + const FINANCIAL_MAX_ITERATIONS = 128; const FINANCIAL_PRECISION = 1.0e-08; @@ -50,10 +50,6 @@ class Financial 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial $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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial 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 @@ class Financial * 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 @@ class Financial // 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 @@ class Financial } $previousDepreciation += $depreciation; } - if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) { - $depreciation = round($depreciation, 2); - } return $depreciation; } @@ -962,13 +922,11 @@ class Financial // 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 @@ class Financial 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 @@ class Financial * @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 @@ class Financial $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); + // 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; } - 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 = $y1; - $y1 = $y; - ++$i; + $rate1 = $rate - $nextdiff; + $close = abs($rate1 - $rate) < self::FINANCIAL_PRECISION; + ++$iter; + $rate = $rate1; } - return $rate; + return $close ? $rate : Functions::NAN(); + } + + 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 $numerator / $denominator; } /** @@ -2183,6 +2174,84 @@ class Financial return Functions::VALUE(); } + 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::NA(); + } + $values = Functions::flattenArray($values); + $dates = Functions::flattenArray($dates); + if (count($values) != count($dates)) { + return Functions::NAN(); + } + + $datesCount = count($dates); + for ($i = 0; $i < $datesCount; ++$i) { + $dates[$i] = DateTime::getDateValue($dates[$i]); + if (!is_numeric($dates[$i])) { + return Functions::VALUE(); + } + } + + return self::xirrPart2($values); + } + + private static function xirrPart3($values, $dates, $x1, $x2) + { + $f = self::xnpvOrdered($x1, $values, $dates, false); + if ($f < 0.0) { + $rtb = $x1; + $dx = $x2 - $x1; + } else { + $rtb = $x2; + $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::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)) { + $rslt = $x_mid; + + break; + } + } + + return $rslt; + } + /** * XIRR. * @@ -2202,73 +2271,37 @@ class Financial */ public static function XIRR($values, $dates, $guess = 0.1) { - if ((!is_array($values)) && (!is_array($dates))) { - return Functions::VALUE(); - } - $values = Functions::flattenArray($values); - $dates = Functions::flattenArray($dates); - $guess = Functions::flattenSingleValue($guess); - if (count($values) != count($dates)) { - return Functions::NAN(); - } - - $datesCount = count($dates); - for ($i = 0; $i < $datesCount; ++$i) { - $dates[$i] = DateTime::getDateValue($dates[$i]); - if (!is_numeric($dates[$i])) { - return Functions::VALUE(); - } - } - if (min($dates) != $dates[0]) { - return Functions::NAN(); + $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; - $f1 = self::XNPV($x1, $values, $dates); - if (!is_numeric($f1)) { - return $f1; - } - $f2 = self::XNPV($x2, $values, $dates); - if (!is_numeric($f2)) { - return $f2; - } + $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::XNPV($x1 += 1.6 * ($x1 - $x2), $values, $dates); + $f1 = self::xnpvOrdered($x1 += 1.6 * ($x1 - $x2), $values, $dates, false); } else { - $f2 = self::XNPV($x2 += 1.6 * ($x2 - $x1), $values, $dates); + $f2 = self::xnpvOrdered($x2 += 1.6 * ($x2 - $x1), $values, $dates, false); } } - if (($f1 * $f2) > 0.0) { + if (!$found) { return Functions::NAN(); } - $f = self::XNPV($x1, $values, $dates); - if ($f < 0.0) { - $rtb = $x1; - $dx = $x2 - $x1; - } else { - $rtb = $x2; - $dx = $x1 - $x2; - } - - for ($i = 0; $i < self::FINANCIAL_MAX_ITERATIONS; ++$i) { - $dx *= 0.5; - $x_mid = $rtb + $dx; - $f_mid = self::XNPV($x_mid, $values, $dates); - if ($f_mid <= 0.0) { - $rtb = $x_mid; - } - if ((abs($f_mid) < self::FINANCIAL_PRECISION) || (abs($dx) < self::FINANCIAL_PRECISION)) { - return $x_mid; - } - } - - return Functions::VALUE(); + return self::xirrPart3($values, $dates, $x1, $x2); } /** @@ -2293,32 +2326,61 @@ class Financial */ 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 e9a62af3..f1d51e18 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php @@ -436,10 +436,8 @@ class FinancialTest extends TestCase */ 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 @@ class FinancialTest extends TestCase 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 @@ class FinancialTest extends TestCase */ 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 @@ class FinancialTest extends TestCase 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 @@ class FinancialTest extends TestCase 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 1b088f0b..f3f0eda2 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php @@ -14,7 +14,7 @@ class LocaleFloatsTest extends TestCase { $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 @@ class LocaleFloatsTest extends TestCase $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 683fc317..719ad733 100644 --- a/tests/data/Calculation/Financial/COUPNUM.php +++ b/tests/data/Calculation/Financial/COUPNUM.php @@ -73,4 +73,39 @@ return [ 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 f64f29e0..7fe29340 100644 --- a/tests/data/Calculation/Financial/PRICE.php +++ b/tests/data/Calculation/Financial/PRICE.php @@ -1,14 +1,144 @@ 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 3eeeed15..fc9946b0 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 f1d51e18..5c3928eb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php @@ -461,7 +461,7 @@ class FinancialTest extends TestCase public function providerPRICE3() { - return require 'data/Calculation/Financial/PRICE3.php'; + return require 'tests/data/Calculation/Financial/PRICE3.php'; } /** @@ -559,7 +559,7 @@ class FinancialTest extends TestCase 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 | 66 ++-- .../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, 667 insertions(+), 157 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 fc9946b0..bbc39092 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 e1469b1f..447ae588 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 @@ class Calculation $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; - } - } - - $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]; + } 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*\)/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 b1c7fb02..2b7fd8c9 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -2468,11 +2468,27 @@ class Statistical 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 @@ class Statistical $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 77fd4ee0..2556ec90 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 0c042fe1..febee54d 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -449,6 +449,55 @@ class Worksheet extends WriterPart $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 @@ class Worksheet extends WriterPart $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()); - } + self::writeAttributeIf($objWriter, $conditional->getStopIfTrue(), 'stopIfTrue', '1'); - if ($conditional->getStopIfTrue()) { - $objWriter->writeAttribute('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 @@ class Worksheet extends WriterPart $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 @@ class Worksheet extends WriterPart $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 @@ class Worksheet extends WriterPart // 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 00000000..8f7c07e8 --- /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 00000000..d3eb6f32 --- /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 00000000..ea20fbf3 --- /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 00000000..c8db3bf0 --- /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 00000000..7d27b33e --- /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 | 1262 ++++++++++------- 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, 1845 insertions(+), 638 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 c0dc7c03..8f92e1f2 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 00000000..20578fbe --- /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 a897486d..5985a0a0 100644 --- a/samples/Basic/25_In_memory_image.php +++ b/samples/Basic/25_In_memory_image.php @@ -35,6 +35,7 @@ $drawing->setRenderingFunction(MemoryDrawing::RENDERING_JPEG); $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 079e1d20..1f4a6c0c 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -537,7 +537,15 @@ class NumberFormat extends Supervisor $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 @@ class NumberFormat extends Supervisor 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 @@ class NumberFormat extends Supervisor 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 @@ class NumberFormat extends Supervisor // 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 @@ class NumberFormat extends Supervisor // 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 ec754001..bb509806 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -148,6 +148,23 @@ class Html extends BaseWriter * @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 @@ class Html extends BaseWriter // 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 @@ class Html extends BaseWriter */ 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 @@ class Html extends BaseWriter */ 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 @@ class Html extends BaseWriter return $this; } + private static function generateMeta($val, $desc) + { + return $val ? (' ' . PHP_EOL) : ''; + } + /** * Generate HTML header. * @@ -346,42 +341,22 @@ class Html extends BaseWriter { // 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; - } + $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'); - if ($pIncludeStyles) { - $html .= $this->generateStyles(true); - } + $html .= $pIncludeStyles ? $this->generateStyles(true) : $this->generatePageDeclarations(true); $html .= ' ' . PHP_EOL; $html .= '' . PHP_EOL; @@ -390,6 +365,53 @@ class Html extends BaseWriter return $html; } + private function generateSheetPrep() + { + // Ensure that Spans have been calculated? + $this->calculateSpans(); + + // Fetch sheets + if ($this->sheetIndex === null) { + $sheets = $this->spreadsheet->getAllSheets(); + } else { + $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. * @@ -397,18 +419,7 @@ class Html extends BaseWriter */ public function generateSheetData() { - // Ensure that Spans have been calculated? - if ($this->sheetIndex !== null || !$this->spansAreCalculated) { - $this->calculateSpans(); - } - - // Fetch sheets - $sheets = []; - if ($this->sheetIndex === null) { - $sheets = $this->spreadsheet->getAllSheets(); - } else { - $sheets[] = $this->spreadsheet->getSheet($this->sheetIndex); - } + $sheets = $this->generateSheetPrep(); // Construct HTML $html = ''; @@ -418,7 +429,6 @@ class Html extends BaseWriter 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 @@ class Html extends BaseWriter $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 @@ class Html extends BaseWriter $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 @@ class Html extends BaseWriter 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 @@ class Html extends BaseWriter } } + 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 @@ class Html extends BaseWriter // 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 @@ class Html extends BaseWriter // 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 @@ class Html extends BaseWriter /** * 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 @@ class Html extends BaseWriter $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 @@ class Html extends BaseWriter 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 @@ class Html extends BaseWriter // Start styles if ($generateSurroundingHTML) { $html .= ' \n"; + if (!in_array($baseCell, $adjustedBaseCells)) { + // subtract rowspan by 1 + --$this->isBaseCell[$sheetIndex][$baseCell[0]][$baseCell[1]]['rowspan']; + $adjustedBaseCells[] = $baseCell; + } + } + } + } } /** @@ -1668,4 +1788,70 @@ class Html extends BaseWriter 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 bb9f4aef..87220458 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 @@ abstract class Pdf extends Html */ 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 @@ abstract class Pdf extends Html 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 4506468b..3ecaff68 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php @@ -61,11 +61,7 @@ class Dompdf extends Pdf $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 6f3cc57f..44241575 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php @@ -81,12 +81,10 @@ class Mpdf extends Pdf $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 5c31af8f..3dc172a2 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 @@ class Tcpdf extends Pdf // 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 9dc20fd7..ba44b6af 100644 --- a/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php +++ b/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php @@ -45,4 +45,18 @@ class NumberFormatTest extends TestCase { 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 00000000..03fe741f --- /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 00000000..2bbe3541 --- /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 1b497277..637c6514 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 00000000..f7716e33 --- /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 00000000..f536d2bd --- /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 00000000..e38e4b8e --- /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 00000000..63cdefb7 --- /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 d9ab0940..5038d6da 100644 --- a/tests/data/Style/NumberFormat.php +++ b/tests/data/Style/NumberFormat.php @@ -103,6 +103,11 @@ return [ 12345.678900000001, '#,##0.000\ [$€-1]', ], + [ + '12,345.679 $', + 12345.678900000001, + '#,##0.000\ [$]', + ], [ '5.68', 5.6788999999999996, @@ -177,6 +182,21 @@ return [ 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 @@ return [ -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 bbc39092..27d72197 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 23216924..28c85900 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 464b8c18..556ef61c 100644 --- a/samples/Autofilter/10_Autofilter_selection_1.php +++ b/samples/Autofilter/10_Autofilter_selection_1.php @@ -59,18 +59,18 @@ foreach ($years as $year) { $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 1c55a0cf..4bae0aba 100644 --- a/samples/Autofilter/10_Autofilter_selection_2.php +++ b/samples/Autofilter/10_Autofilter_selection_2.php @@ -59,18 +59,18 @@ foreach ($years as $year) { $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 55211552..4810348c 100644 --- a/samples/Autofilter/10_Autofilter_selection_display.php +++ b/samples/Autofilter/10_Autofilter_selection_display.php @@ -59,18 +59,18 @@ foreach ($years as $year) { $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 d7ba861b..aadb5b92 100644 --- a/samples/Basic/22_Heavily_formatted.php +++ b/samples/Basic/22_Heavily_formatted.php @@ -26,22 +26,22 @@ $spreadsheet->setActiveSheetIndex(0); $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 b5398883..8e75a488 100644 --- a/samples/Basic/23_Sharedstyles.php +++ b/samples/Basic/23_Sharedstyles.php @@ -30,26 +30,26 @@ $sharedStyle2 = new Style(); $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 5985a0a0..af02c64a 100644 --- a/samples/Basic/25_In_memory_image.php +++ b/samples/Basic/25_In_memory_image.php @@ -21,7 +21,11 @@ $spreadsheet->getProperties()->setCreator('Maarten Balliauw') // 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 b70c18b6..409acb66 100644 --- a/samples/Basic/30_Template.php +++ b/samples/Basic/30_Template.php @@ -11,9 +11,9 @@ $spreadsheet = $reader->load(__DIR__ . '/../templates/30template.xls'); $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 860c16a6..57db90fc 100644 --- a/samples/Chart/33_Chart_create_area.php +++ b/samples/Chart/33_Chart_create_area.php @@ -15,12 +15,12 @@ $spreadsheet = new Spreadsheet(); $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 0aa211a9..0c87224e 100644 --- a/samples/Chart/33_Chart_create_bar_stacked.php +++ b/samples/Chart/33_Chart_create_bar_stacked.php @@ -15,12 +15,12 @@ $spreadsheet = new Spreadsheet(); $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 694082a4..5af0908c 100644 --- a/samples/Chart/33_Chart_create_column.php +++ b/samples/Chart/33_Chart_create_column.php @@ -15,12 +15,12 @@ $spreadsheet = new Spreadsheet(); $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 f5a529b9..a62b4906 100644 --- a/samples/Chart/33_Chart_create_column_2.php +++ b/samples/Chart/33_Chart_create_column_2.php @@ -15,20 +15,20 @@ $spreadsheet = new Spreadsheet(); $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 dfeacae3..ce42d2fc 100644 --- a/samples/Chart/33_Chart_create_composite.php +++ b/samples/Chart/33_Chart_create_composite.php @@ -15,20 +15,20 @@ $spreadsheet = new Spreadsheet(); $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 c25328a8..608ffc53 100644 --- a/samples/Chart/33_Chart_create_multiple_charts.php +++ b/samples/Chart/33_Chart_create_multiple_charts.php @@ -15,12 +15,12 @@ $spreadsheet = new Spreadsheet(); $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 0df41143..5480a18a 100644 --- a/samples/Chart/33_Chart_create_pie.php +++ b/samples/Chart/33_Chart_create_pie.php @@ -16,12 +16,12 @@ $spreadsheet = new Spreadsheet(); $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 137e6e75..ca5397a1 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 @@ $spreadsheet = new Spreadsheet(); $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 1c5c435f..eba4dc39 100644 --- a/samples/Chart/33_Chart_create_radar.php +++ b/samples/Chart/33_Chart_create_radar.php @@ -16,20 +16,20 @@ $spreadsheet = new Spreadsheet(); $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 02fa866d..c67e4e95 100644 --- a/samples/Chart/33_Chart_create_scatter.php +++ b/samples/Chart/33_Chart_create_scatter.php @@ -15,12 +15,12 @@ $spreadsheet = new Spreadsheet(); $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 4e8ffe8e..58686784 100644 --- a/samples/Chart/33_Chart_create_stock.php +++ b/samples/Chart/33_Chart_create_stock.php @@ -16,13 +16,13 @@ $spreadsheet = new Spreadsheet(); $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 638d2e0a..a4287927 100644 --- a/samples/Chart/34_Chart_update.php +++ b/samples/Chart/34_Chart_update.php @@ -20,11 +20,11 @@ $helper->log('Update cell data values that are displayed in the chart'); $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 1f39ec4d..61f624b2 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 efe68582..02d3d939 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 44d7b543..2ad61d32 100644 --- a/samples/templates/chartSpreadsheet.php +++ b/samples/templates/chartSpreadsheet.php @@ -12,12 +12,12 @@ $spreadsheet = new Spreadsheet(); $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 c668f447..6d9568be 100644 --- a/samples/templates/sampleSpreadsheet.php +++ b/samples/templates/sampleSpreadsheet.php @@ -184,59 +184,59 @@ $spreadsheet->getActiveSheet()->getStyle('A1:E1')->getFill()->getStartColor()->s $helper->log('Set style for header row using alternative method'); $spreadsheet->getActiveSheet()->getStyle('A3:E3')->applyFromArray( [ - 'font' => [ - 'bold' => true, + 'font' => [ + 'bold' => true, + ], + 'alignment' => [ + 'horizontal' => Alignment::HORIZONTAL_RIGHT, + ], + 'borders' => [ + 'top' => [ + 'borderStyle' => Border::BORDER_THIN, ], - 'alignment' => [ - 'horizontal' => Alignment::HORIZONTAL_RIGHT, + ], + 'fill' => [ + 'fillType' => Fill::FILL_GRADIENT_LINEAR, + 'rotation' => 90, + 'startColor' => [ + 'argb' => 'FFA0A0A0', ], - 'borders' => [ - 'top' => [ - 'borderStyle' => Border::BORDER_THIN, - ], + 'endColor' => [ + 'argb' => 'FFFFFFFF', ], - 'fill' => [ - 'fillType' => Fill::FILL_GRADIENT_LINEAR, - 'rotation' => 90, - 'startColor' => [ - 'argb' => 'FFA0A0A0', - ], - 'endColor' => [ - 'argb' => 'FFFFFFFF', - ], - ], - ] + ], + ] ); $spreadsheet->getActiveSheet()->getStyle('A3')->applyFromArray( [ - 'alignment' => [ - 'horizontal' => Alignment::HORIZONTAL_LEFT, + 'alignment' => [ + 'horizontal' => Alignment::HORIZONTAL_LEFT, + ], + 'borders' => [ + 'left' => [ + 'borderStyle' => Border::BORDER_THIN, ], - '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 447ae588..0be9ab6f 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -11,6 +11,7 @@ use PhpOffice\PhpSpreadsheet\NamedRange; 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 @@ class Calculation * * @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 @@ class Calculation * 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 @@ class Calculation * * @param bool $pValue */ - public function setCalculationCacheEnabled($pValue) + public function setCalculationCacheEnabled($pValue): void { $this->calculationCacheEnabled = $pValue; $this->clearCalculationCache(); @@ -2409,7 +2410,7 @@ class Calculation /** * Enable calculation cache. */ - public function enableCalculationCache() + public function enableCalculationCache(): void { $this->setCalculationCacheEnabled(true); } @@ -2417,7 +2418,7 @@ class Calculation /** * Disable calculation cache. */ - public function disableCalculationCache() + public function disableCalculationCache(): void { $this->setCalculationCacheEnabled(false); } @@ -2425,7 +2426,7 @@ class Calculation /** * Clear calculation cache. */ - public function clearCalculationCache() + public function clearCalculationCache(): void { $this->calculationCache = []; } @@ -2435,7 +2436,7 @@ class Calculation * * @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 @@ class Calculation * @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 @@ class Calculation /** * 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 @@ class Calculation * * @return mixed */ - public function calculate(Cell $pCell = null) + public function calculate(?Cell $pCell = null) { try { return $this->calculateCellValue($pCell); @@ -2796,7 +2796,7 @@ class Calculation * * @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 @@ class Calculation * * @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 @@ class Calculation * @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 @@ class Calculation * * @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 @@ class Calculation * @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 @@ class Calculation * @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 @@ class Calculation /** * @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 @@ class Calculation ++$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 @@ class Calculation // 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 @@ class Calculation } $expectingThenMap[$pendingStoreKey] = false; $expectingElseMap[$pendingStoreKey] = false; - $parenthesisDepthMap[$pendingStoreKey] -= 1; + --$parenthesisDepthMap[$pendingStoreKey]; array_pop($pendingStoreKeysStack); unset($pendingStoreKey); } @@ -3615,7 +3614,7 @@ class Calculation ++$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 @@ class Calculation $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 @@ class Calculation /** * @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 @@ class Calculation * @param mixed $operand1 * @param mixed $operand2 * @param string $operation - * @param Stack $stack * @param bool $recursingArrays * * @return mixed @@ -4583,7 +4580,7 @@ class Calculation break; // Power case '^': - $result = pow($operand1, $operand2); + $result = $operand1 ** $operand2; break; } @@ -4620,7 +4617,7 @@ class Calculation * * @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 @@ class Calculation * * @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 @@ class Calculation /** * 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 9e1e4cf5..a57be297 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 @@ class DateTime 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 @@ class DateTime * * @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 @@ class DateTime 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 5a54d83a..b688e056 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php +++ b/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php @@ -26,7 +26,7 @@ class CyclicReferenceStack * * @param mixed $value */ - public function push($value) + public function push($value): void { $this->stack[$value] = $value; } @@ -56,7 +56,7 @@ class CyclicReferenceStack /** * 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 6793dade..d69ea56d 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 @@ class Logger * * @param bool $pValue */ - public function setWriteDebugLog($pValue) + public function setWriteDebugLog($pValue): void { $this->writeDebugLog = $pValue; } @@ -72,7 +70,7 @@ class Logger * * @param bool $pValue */ - public function setEchoDebugLog($pValue) + public function setEchoDebugLog($pValue): void { $this->echoDebugLog = $pValue; } @@ -90,11 +88,11 @@ class Logger /** * 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 @@ class Logger /** * 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 1a79ff71..aad35eec 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -799,7 +799,7 @@ class Engineering } 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 @@ class Engineering $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 @@ class Engineering } 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 @@ class Engineering $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 fccf0af7..87c7d222 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 1a49ac1c..624f035a 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -851,7 +851,7 @@ class Financial 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 @@ class Financial 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 @@ class Financial $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 @@ class Financial $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 @@ class Financial return Functions::NAN(); } - return pow((1 + $nominal_rate / $npery), $npery) - 1; + return (1 + $nominal_rate / $npery) ** $npery - 1; } /** @@ -1131,7 +1131,7 @@ class Financial // 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 @@ class Financial $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 @@ class Financial 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 @@ class Financial } // Calculate - return $npery * (pow($effect_rate + 1, 1 / $npery) - 1); + return $npery * (($effect_rate + 1) ** (1 / $npery) - 1); } /** @@ -1502,7 +1502,7 @@ class Financial 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 @@ class Financial // 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 @@ class Financial $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 @@ class Financial // 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 @@ class Financial 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 @@ class Financial return Functions::NAN(); } - return pow($fv / $pv, 1 / $nper) - 1; + return ($fv / $pv) ** (1 / $nper) - 1; } /** @@ -2377,7 +2377,7 @@ class Financial 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 38c725c2..f6c88b26 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaParser.php +++ b/src/PhpSpreadsheet/Calculation/FormulaParser.php @@ -125,7 +125,7 @@ class FormulaParser /** * 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 66618d4a..4d225de2 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaToken.php +++ b/src/PhpSpreadsheet/Calculation/FormulaToken.php @@ -103,7 +103,7 @@ class FormulaToken * * @param string $value */ - public function setValue($value) + public function setValue($value): void { $this->value = $value; } @@ -123,7 +123,7 @@ class FormulaToken * * @param string $value */ - public function setTokenType($value) + public function setTokenType($value): void { $this->tokenType = $value; } @@ -143,7 +143,7 @@ class FormulaToken * * @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 1862b008..af872dd7 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -660,7 +660,7 @@ class Functions * * @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 48434300..2d196aef 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -238,7 +238,7 @@ class LookupRef * * @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 @@ class LookupRef * * @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 @@ class LookupRef * 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 @@ class LookupRef * 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 @@ class LookupRef * * @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 f94c8fcc..3db3fb8d 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 @@ class MathTrig try { $arabic = self::calculateArabic(str_split($roman)); - } catch (\Exception $e) { + } catch (Exception $e) { return Functions::VALUE(); // Invalid character detected } @@ -82,7 +83,6 @@ class MathTrig /** * Recursively calculate the arabic value of a roman numeral. * - * @param array $roman * @param int $sum * @param int $subtract * @@ -102,7 +102,7 @@ class MathTrig $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 @@ class MathTrig $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 @@ class MathTrig } // Return - $result = pow($x, $y); + $result = $x ** $y; return (!is_nan($result) && !is_infinite($result)) ? $result : Functions::NAN(); } @@ -1139,10 +1139,10 @@ class MathTrig 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 @@ class MathTrig 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 @@ class MathTrig * * 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 @@ class MathTrig 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 @@ class MathTrig * @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 @@ class MathTrig $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 2b7fd8c9..675f88ef 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -397,10 +397,10 @@ class Statistical 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 @@ class Statistical 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 @@ class Statistical $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 @@ class Statistical } 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 @@ class Statistical 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 @@ class Statistical 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 @@ class Statistical } 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 @@ class Statistical // 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 @@ class Statistical * @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 @@ class Statistical } return [ - $bestFitLinear->getSlope(), - $bestFitLinear->getIntersect(), - ]; + $bestFitLinear->getSlope(), + $bestFitLinear->getIntersect(), + ]; } /** @@ -2078,9 +2077,9 @@ class Statistical } return [ - $bestFitExponential->getSlope(), - $bestFitExponential->getIntersect(), - ]; + $bestFitExponential->getSlope(), + $bestFitExponential->getIntersect(), + ]; } /** @@ -2579,7 +2578,7 @@ class Statistical } } - 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 @@ class Statistical 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 @@ class Statistical * @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 @@ class Statistical $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 @@ class Statistical * @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 @@ class Statistical } 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 @@ class Statistical * @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 @@ class Statistical // 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 @@ class Statistical $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 @@ class Statistical // 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 @@ class Statistical $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 @@ class Statistical * @category Statistical Functions * * @param mixed $args Data values - * @param float $discard Percentage to discard * * @return float|string */ @@ -3746,10 +3741,10 @@ class Statistical } 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 bbb03926..8f4b7d87 100644 --- a/src/PhpSpreadsheet/Calculation/TextData.php +++ b/src/PhpSpreadsheet/Calculation/TextData.php @@ -167,7 +167,7 @@ class TextData 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 @@ class TextData $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 341a0179..941e1ad7 100644 --- a/src/PhpSpreadsheet/Calculation/Token/Stack.php +++ b/src/PhpSpreadsheet/Calculation/Token/Stack.php @@ -49,7 +49,7 @@ class Stack $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 @@ class Stack /** * 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 30be3353..0bca2fc0 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -76,12 +76,12 @@ class Cell 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 @@ class Cell * * @param mixed $pValue * @param string $pDataType - * @param Worksheet $pSheet */ public function __construct($pValue, $pDataType, Worksheet $pSheet) { @@ -386,7 +385,7 @@ class Cell * * @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 @@ class Cell * * @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 @@ class Cell /** * Re-bind parent. * - * @param Worksheet $parent - * * @return Cell */ public function rebindParent(Worksheet $parent) @@ -600,10 +597,8 @@ class Cell /** * 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 70fed25a..8c679913 100644 --- a/src/PhpSpreadsheet/Cell/Coordinate.php +++ b/src/PhpSpreadsheet/Cell/Coordinate.php @@ -503,7 +503,7 @@ abstract class Coordinate * @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 66242e34..7995c3b3 100644 --- a/src/PhpSpreadsheet/Chart/Axis.php +++ b/src/PhpSpreadsheet/Chart/Axis.php @@ -178,7 +178,7 @@ class Axis extends Properties * @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 @@ class Axis extends Properties * * @param string $orientation */ - public function setAxisOrientation($orientation) + public function setAxisOrientation($orientation): void { $this->axisOptions['orientation'] = (string) $orientation; } @@ -222,7 +222,7 @@ class Axis extends Properties * @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 @@ class Axis extends Properties * @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 @@ class Axis extends Properties * @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 @@ class Axis extends Properties * @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 @@ class Axis extends Properties /** * Set Shadow Properties from Mapped Values. * - * @param array $properties_map * @param mixed &$reference * * @return $this @@ -479,7 +478,7 @@ class Axis extends Properties * @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 @@ class Axis extends Properties * * @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 7064160e..20eb2aee 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 @@ class Chart * * @return $this */ - public function setWorksheet(Worksheet $pValue = null) + public function setWorksheet(?Worksheet $pValue = null) { $this->worksheet = $pValue; @@ -219,8 +210,6 @@ class Chart /** * Set Title. * - * @param Title $title - * * @return $this */ public function setTitle(Title $title) @@ -243,8 +232,6 @@ class Chart /** * Set Legend. * - * @param Legend $legend - * * @return $this */ public function setLegend(Legend $legend) @@ -267,8 +254,6 @@ class Chart /** * Set X-Axis Label. * - * @param Title $label - * * @return $this */ public function setXAxisLabel(Title $label) @@ -291,8 +276,6 @@ class Chart /** * Set Y-Axis Label. * - * @param Title $label - * * @return $this */ public function setYAxisLabel(Title $label) @@ -645,7 +628,7 @@ class Chart 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 79f4e8d1..3a44b335 100644 --- a/src/PhpSpreadsheet/Chart/DataSeries.php +++ b/src/PhpSpreadsheet/Chart/DataSeries.php @@ -373,7 +373,7 @@ class DataSeries 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 e15f5da5..c1bd973a 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -352,7 +352,7 @@ class DataSeriesValues 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 b07fcae5..2e424bc2 100644 --- a/src/PhpSpreadsheet/Chart/GridLines.php +++ b/src/PhpSpreadsheet/Chart/GridLines.php @@ -107,7 +107,7 @@ class GridLines extends Properties * @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 @@ class GridLines extends Properties * @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 @@ class GridLines extends Properties * @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 @@ class GridLines extends Properties * @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 @@ class GridLines extends Properties /** * Set Shadow Properties Values. * - * @param array $properties_map * @param mixed &$reference * * @return $this @@ -435,7 +434,7 @@ class GridLines extends Properties * * @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 3e989c6d..51c8995b 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 d0776265..fc0ed140 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 9da4aa32..954777cf 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 @@ class PlotArea 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 c6fcfbfc..3032f6ba 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 9dcab049..bd931c66 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 @@ class JpGraph implements IRenderer $this->chart = $chart; } - private static function init() + private static function init(): void { static $loaded = false; if ($loaded) { @@ -179,7 +193,7 @@ class JpGraph implements IRenderer return $caption; } - private function renderTitle() + private function renderTitle(): void { $title = $this->getCaption($this->chart->getTitle()); if ($title !== null) { @@ -187,7 +201,7 @@ class JpGraph implements IRenderer } } - private function renderLegend() + private function renderLegend(): void { $legend = $this->chart->getLegend(); if ($legend !== null) { @@ -220,9 +234,9 @@ class JpGraph implements IRenderer } } - 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 @@ class JpGraph implements IRenderer } } - 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 @@ class JpGraph implements IRenderer ++$testCurrentIndex; } - $seriesPlot = new \LinePlot($dataValues); + $seriesPlot = new LinePlot($dataValues); if ($combination) { $seriesPlot->SetBarCenter(); } @@ -330,12 +344,12 @@ class JpGraph implements IRenderer 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 @@ class JpGraph implements IRenderer 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 @@ class JpGraph implements IRenderer } 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 @@ class JpGraph implements IRenderer $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 @@ class JpGraph implements IRenderer $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 @@ class JpGraph implements IRenderer } } - private function renderPlotRadar($groupID) + private function renderPlotRadar($groupID): void { $radarStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); @@ -488,7 +502,7 @@ class JpGraph implements IRenderer $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 @@ class JpGraph implements IRenderer } } - private function renderPlotContour($groupID) + private function renderPlotContour($groupID): void { $contourStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); @@ -517,12 +531,12 @@ class JpGraph implements IRenderer $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 @@ class JpGraph implements IRenderer $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 @@ class JpGraph implements IRenderer } } - private function renderLineChart($groupCount, $dimensions = '2d') + private function renderLineChart($groupCount, $dimensions = '2d'): void { $this->renderCartesianPlotArea(); @@ -580,7 +594,7 @@ class JpGraph implements IRenderer } } - private function renderBarChart($groupCount, $dimensions = '2d') + private function renderBarChart($groupCount, $dimensions = '2d'): void { $this->renderCartesianPlotArea(); @@ -589,7 +603,7 @@ class JpGraph implements IRenderer } } - private function renderScatterChart($groupCount) + private function renderScatterChart($groupCount): void { $this->renderCartesianPlotArea('linlin'); @@ -598,7 +612,7 @@ class JpGraph implements IRenderer } } - private function renderBubbleChart($groupCount) + private function renderBubbleChart($groupCount): void { $this->renderCartesianPlotArea('linlin'); @@ -607,7 +621,7 @@ class JpGraph implements IRenderer } } - 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 @@ class JpGraph implements IRenderer } 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 @@ class JpGraph implements IRenderer } } - private function renderRadarChart($groupCount) + private function renderRadarChart($groupCount): void { $this->renderRadarPlotArea(); @@ -688,7 +702,7 @@ class JpGraph implements IRenderer } } - private function renderStockChart($groupCount) + private function renderStockChart($groupCount): void { $this->renderCartesianPlotArea('intint'); @@ -697,7 +711,7 @@ class JpGraph implements IRenderer } } - 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 7fa38394..5e233abd 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 650bcdc1..af9fa088 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 b9017e0e..48f34f41 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 @@ class Cells * * @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 @@ class Cells * * @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 @@ class Cells * * @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 @@ class Cells * 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 @@ class Cells /** * 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 @@ class Cells /** * 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 8041ddaf..31f76640 100644 --- a/src/PhpSpreadsheet/Comment.php +++ b/src/PhpSpreadsheet/Comment.php @@ -118,8 +118,6 @@ class Comment implements IComparable /** * 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 58fd2ef6..cbaae2db 100644 --- a/src/PhpSpreadsheet/Document/Properties.php +++ b/src/PhpSpreadsheet/Document/Properties.php @@ -458,10 +458,10 @@ class Properties 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 8baba6e5..5e06af97 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 @@ class DocumentGenerator 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 @@ class DocumentGenerator /** * @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 4d1e7b4d..90ea806b 100644 --- a/src/PhpSpreadsheet/HashTable.php +++ b/src/PhpSpreadsheet/HashTable.php @@ -36,7 +36,7 @@ class HashTable * * @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 @@ class HashTable * * @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 @@ class HashTable * * @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 @@ class HashTable /** * 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 eaf73028..252e14a5 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 @@ class 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 @@ class Html } } - protected function buildTextRun() + protected function buildTextRun(): void { $text = $this->stringData; if (trim($text) === '') { @@ -691,7 +691,7 @@ class Html $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 @@ class Html 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 @@ class Html } } - 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 @@ class Html } /** - * @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 @@ class Html } } - protected function parseElementNode(DOMElement $element) + protected function parseElementNode(DOMElement $element): void { $callbackTag = strtolower($element->nodeName); $this->stack[] = $callbackTag; @@ -828,7 +826,7 @@ class Html $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 e199c807..a91b195e 100644 --- a/src/PhpSpreadsheet/Helper/Sample.php +++ b/src/PhpSpreadsheet/Helper/Sample.php @@ -11,6 +11,7 @@ use RecursiveIteratorIterator; use RecursiveRegexIterator; use ReflectionClass; use RegexIterator; +use RuntimeException; /** * Helper class to be used in sample code. @@ -106,11 +107,10 @@ class Sample /** * 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 @@ class Sample $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 @@ class Sample 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 @@ class Sample /** * 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 @@ class Sample /** * 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 @@ class Sample * @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 38c0f221..ab04e969 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 @@ abstract class IOFactory * @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 @@ abstract class IOFactory * @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 576f17d7..94fe8190 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 @@ class NamedRange * * @return $this */ - public function setWorksheet(Worksheet $value = null) + public function setWorksheet(?Worksheet $value = null) { if ($value !== null) { $this->worksheet = $value; @@ -196,11 +195,9 @@ class NamedRange /** * 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 35466e73..77a6421b 100644 --- a/src/PhpSpreadsheet/Reader/BaseReader.php +++ b/src/PhpSpreadsheet/Reader/BaseReader.php @@ -145,12 +145,12 @@ abstract class BaseReader implements IReader * * @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 2e485109..db2b50b9 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 @@ class Csv extends BaseReader /** * Move filepointer past any BOM marker. */ - protected function skipBOM() + protected function skipBOM(): void { rewind($this->fileHandle); @@ -101,7 +102,7 @@ class Csv extends BaseReader /** * 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 @@ class Csv extends BaseReader /** * 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 @@ class Csv extends BaseReader $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 @@ class Csv extends BaseReader return $this->loadIntoExisting($pFilename, $spreadsheet); } - private function openFileOrMemory($pFilename) + private function openFileOrMemory($pFilename): void { // Open file $fhandle = $this->canRead($pFilename); @@ -303,7 +304,7 @@ class Csv extends BaseReader 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 @@ class Csv extends BaseReader * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * * @param string $pFilename - * @param Spreadsheet $spreadsheet * * @return Spreadsheet */ @@ -508,7 +508,7 @@ class Csv extends BaseReader // 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 83ff293c..f9768029 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -58,7 +58,7 @@ class Gnumeric extends BaseReader } // Read signature data (first 3 bytes) - $fh = fopen($pFilename, 'r'); + $fh = fopen($pFilename, 'rb'); $data = fread($fh, 2); fclose($fh); @@ -182,7 +182,6 @@ class Gnumeric extends BaseReader * Loads from file into Spreadsheet instance. * * @param string $pFilename - * @param Spreadsheet $spreadsheet * * @return Spreadsheet */ @@ -473,7 +472,7 @@ class Gnumeric extends BaseReader $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 86263a20..5e12a2fb 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -270,7 +270,7 @@ class Html extends BaseReader 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 @@ class Html extends BaseReader } /** - * @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 @@ class Html extends BaseReader * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * * @param string $pFilename - * @param Spreadsheet $spreadsheet * * @return Spreadsheet */ @@ -603,9 +600,6 @@ class Html extends BaseReader * Spreadsheet from content. * * @param string $content - * @param null|Spreadsheet $spreadsheet - * - * @return Spreadsheet */ public function loadFromString($content, ?Spreadsheet $spreadsheet = null): Spreadsheet { @@ -622,11 +616,6 @@ class Html extends BaseReader /** * 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 @@ class Html extends BaseReader * @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 @@ class Html extends BaseReader } /** - * @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 @@ class Html extends BaseReader } /** - * @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 3f5a7e49..a8bd3606 100644 --- a/src/PhpSpreadsheet/Reader/IReader.php +++ b/src/PhpSpreadsheet/Reader/IReader.php @@ -118,8 +118,6 @@ interface IReader /** * 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 41fd34a8..d638d1fb 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -4,6 +4,10 @@ namespace PhpOffice\PhpSpreadsheet\Reader; 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 @@ class Ods extends BaseReader * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * * @param string $pFilename - * @param Spreadsheet $spreadsheet * * @return Spreadsheet */ @@ -251,7 +254,7 @@ class Ods extends BaseReader 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 @@ class Ods extends BaseReader // 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 @@ class Ods extends BaseReader ->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 @@ class Ods extends BaseReader // 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 @@ class Ods extends BaseReader // 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 @@ class Ods extends BaseReader /** * 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 c5c7caf8..c0b309a9 100644 --- a/src/PhpSpreadsheet/Reader/Ods/Properties.php +++ b/src/PhpSpreadsheet/Reader/Ods/Properties.php @@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Ods; use PhpOffice\PhpSpreadsheet\Document\Properties as DocumentProperties; use PhpOffice\PhpSpreadsheet\Spreadsheet; +use SimpleXMLElement; class Properties { @@ -14,7 +15,7 @@ class Properties $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 @@ class Properties } } - 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 @@ class Properties 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 @@ class Properties } } - 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 33e21f9d..55bba632 100644 --- a/src/PhpSpreadsheet/Reader/Security/XmlScanner.php +++ b/src/PhpSpreadsheet/Reader/Security/XmlScanner.php @@ -61,7 +61,7 @@ class XmlScanner return false; } - private function disableEntityLoaderCheck() + private function disableEntityLoaderCheck(): void { if (Settings::getLibXmlDisableEntityLoader()) { $libxmlDisableEntityLoaderValue = libxml_disable_entity_loader(true); @@ -72,7 +72,7 @@ class XmlScanner } } - public static function shutdown() + public static function shutdown(): void { if (self::$libxmlDisableEntityLoaderValue !== null) { libxml_disable_entity_loader(self::$libxmlDisableEntityLoaderValue); @@ -85,7 +85,7 @@ class XmlScanner 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 278abd58..f40eba74 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -190,7 +190,6 @@ class Slk extends BaseReader * 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 ec5879a9..b206f8ac 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -1248,10 +1248,10 @@ class Xls extends BaseReader [$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 @@ class Xls extends BaseReader * * @param string $pFilename */ - private function loadOLE($pFilename) + private function loadOLE($pFilename): void { // OLE reader $ole = new OLERead(); @@ -1365,7 +1365,7 @@ class Xls extends BaseReader /** * Read summary information. */ - private function readSummaryInformation() + private function readSummaryInformation(): void { if (!isset($this->summaryInformation)) { return; @@ -1512,7 +1512,7 @@ class Xls extends BaseReader /** * Read additional document summary information. */ - private function readDocumentSummaryInformation() + private function readDocumentSummaryInformation(): void { if (!isset($this->documentSummaryInformation)) { return; @@ -1650,7 +1650,7 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader * 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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader } } - 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 @@ class Xls extends BaseReader 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 @@ class Xls extends BaseReader 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 @@ class Xls extends BaseReader 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 @@ class Xls extends BaseReader 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 @@ class Xls extends BaseReader 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 @@ class Xls extends BaseReader 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 @@ class Xls extends BaseReader 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 @@ class Xls extends BaseReader 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader /** * Read MSODRAWINGGROUP record. */ - private function readMsoDrawingGroup() + private function readMsoDrawingGroup(): void { $length = self::getUInt2d($this->data, $this->pos + 2); @@ -2957,7 +2957,7 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader * 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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * Read MSODRAWING record. */ - private function readMsoDrawing() + private function readMsoDrawing(): void { $length = self::getUInt2d($this->data, $this->pos + 2); @@ -4300,7 +4300,7 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader * -- "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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader /** * 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 @@ class Xls extends BaseReader * 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 @@ class Xls extends BaseReader * 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 @@ class Xls extends BaseReader // 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 @@ class Xls extends BaseReader $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 @@ class Xls extends BaseReader $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 @@ class Xls extends BaseReader 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 @@ class Xls extends BaseReader $string = self::readUnicodeString(substr($subData, 1), $characterCount); // add 1 for the string length - $string['size'] += 1; + ++$string['size']; return $string; } @@ -7781,13 +7781,13 @@ class Xls extends BaseReader $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 @@ class Xls extends BaseReader $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 858d6bbb..306fc8f1 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Escher.php +++ b/src/PhpSpreadsheet/Reader/Xls/Escher.php @@ -178,7 +178,7 @@ class Escher /** * 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 @@ class Escher /** * 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 @@ class Escher /** * 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 @@ class Escher /** * 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 @@ class Escher /** * Read BSE record. */ - private function readBSE() + private function readBSE(): void { // offset: 0; size: 2; recVer and recInstance @@ -313,7 +313,7 @@ class Escher /** * 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 @@ class Escher // 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 @@ class Escher /** * 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 @@ class Escher // 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 @@ class Escher /** * 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 @@ class Escher /** * Read TertiaryOPT record. */ - private function readTertiaryOPT() + private function readTertiaryOPT(): void { // offset: 0; size: 2; recVer and recInstance @@ -431,7 +431,7 @@ class Escher /** * 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 @@ class Escher /** * 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 @@ class Escher /** * 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 @@ class Escher /** * Read SpgrContainer record (Shape Group Container). */ - private function readSpgrContainer() + private function readSpgrContainer(): void { // context is either context DgContainer or SpgrContainer @@ -501,7 +501,7 @@ class Escher /** * 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 @@ class Escher /** * 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 @@ class Escher /** * Read Sp record (Shape). */ - private function readSp() + private function readSp(): void { // offset: 0; size: 2; recVer and recInstance @@ -550,7 +550,7 @@ class Escher /** * Read ClientTextbox record. */ - private function readClientTextbox() + private function readClientTextbox(): void { // offset: 0; size: 2; recVer and recInstance @@ -567,7 +567,7 @@ class Escher /** * 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 @@ class Escher /** * 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 @@ class Escher * @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 6a10e591..c0417ba6 100644 --- a/src/PhpSpreadsheet/Reader/Xls/MD5.php +++ b/src/PhpSpreadsheet/Reader/Xls/MD5.php @@ -24,7 +24,7 @@ class MD5 /** * Reset the MD5 stream context. */ - public function reset() + public function reset(): void { $this->a = 0x67452301; $this->b = 0xEFCDAB89; @@ -56,7 +56,7 @@ class MD5 * * @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 @@ class MD5 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 40814c64..77035a39 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -35,6 +35,8 @@ use PhpOffice\PhpSpreadsheet\Style\Style; use PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use SimpleXMLElement; +use stdClass; +use Throwable; use XMLReader; use ZipArchive; @@ -256,7 +258,7 @@ class Xlsx extends BaseReader 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 @@ class Xlsx extends BaseReader } /** - * @param ZipArchive $archive * @param string $fileName * * @return string @@ -658,7 +659,7 @@ class Xlsx extends BaseReader $coordinates = Coordinate::coordinateFromString($r); if (!$this->getReadFilter()->readCell($coordinates[0], (int) $coordinates[1], $docSheet->getTitle())) { - $rowIndex += 1; + ++$rowIndex; continue; } @@ -744,9 +745,9 @@ class Xlsx extends BaseReader (int) ($c['s']) : 0); } } - $rowIndex += 1; + ++$rowIndex; } - $cIndex += 1; + ++$cIndex; } } @@ -891,7 +892,7 @@ class Xlsx extends BaseReader 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 @@ class Xlsx extends BaseReader $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 @@ class Xlsx extends BaseReader } /** - * @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 @@ class Xlsx extends BaseReader } /** - * @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 @@ class Xlsx extends BaseReader } /** - * @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 @@ class Xlsx extends BaseReader /** * @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 @@ class Xlsx extends BaseReader $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 @@ class Xlsx extends BaseReader } } - 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 @@ class Xlsx extends BaseReader 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 69d5f69e..f52bfd41 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php @@ -5,6 +5,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx; 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 @@ class AutoFilter } } - private function readAutoFilter($autoFilterRange, $xmlSheet) + private function readAutoFilter($autoFilterRange, $xmlSheet): void { $autoFilter = $this->worksheet->getAutoFilter(); $autoFilter->setRange($autoFilterRange); @@ -62,7 +63,7 @@ class AutoFilter } } - 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 @@ class AutoFilter } } - 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 @@ class AutoFilter } } - 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 @@ class AutoFilter } } - 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 2b920d70..c9a230c2 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php @@ -17,7 +17,6 @@ use SimpleXMLElement; class Chart { /** - * @param SimpleXMLElement $component * @param string $name * @param string $format * @@ -51,7 +50,6 @@ class Chart } /** - * @param SimpleXMLElement $chartElements * @param string $chartName * * @return \PhpOffice\PhpSpreadsheet\Chart\Chart @@ -529,10 +527,9 @@ class Chart } /** - * @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 e901d990..339c0584 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php @@ -5,6 +5,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx; 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 @@ class ColumnAndRowAttributes extends BaseParserClass * @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 @@ class ColumnAndRowAttributes extends BaseParserClass * @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 @@ class ColumnAndRowAttributes extends BaseParserClass * @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 @@ class ColumnAndRowAttributes extends BaseParserClass return false; } - private function readColumnAttributes(\SimpleXMLElement $worksheetCols, $readDataOnly) + private function readColumnAttributes(SimpleXMLElement $worksheetCols, $readDataOnly) { $columnAttributes = []; @@ -145,7 +146,7 @@ class ColumnAndRowAttributes extends BaseParserClass return $columnAttributes; } - private function readColumnRangeAttributes(\SimpleXMLElement $column, $readDataOnly) + private function readColumnRangeAttributes(SimpleXMLElement $column, $readDataOnly) { $columnAttributes = []; @@ -177,7 +178,7 @@ class ColumnAndRowAttributes extends BaseParserClass 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 722b7795..668bfd18 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php @@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx; 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 @@ class ConditionalStyles 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 4bb44129..41a8c9fb 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php @@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx; 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 400b2725..9e6aeaf7 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php @@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; +use SimpleXMLElement; class Hyperlinks { @@ -16,7 +17,7 @@ class Hyperlinks $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 @@ class Hyperlinks } } - 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 6f286769..bfb7a1f5 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php @@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx; 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 @@ class PageSetup extends BaseParserClass 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 @@ class PageSetup extends BaseParserClass } } - 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 @@ class PageSetup extends BaseParserClass 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 @@ class PageSetup extends BaseParserClass } } - 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 @@ class PageSetup extends BaseParserClass } } - 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 @@ class PageSetup extends BaseParserClass } } - 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 bf8e57d8..b6f3c61f 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Properties.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Properties.php @@ -5,6 +5,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx; 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 @@ class Properties ); } - public function readCoreProperties($propertyData) + public function readCoreProperties($propertyData): void { $xmlCore = $this->extractPropertyData($propertyData); @@ -48,7 +49,7 @@ class Properties } } - public function readExtendedProperties($propertyData) + public function readExtendedProperties($propertyData): void { $xmlCore = $this->extractPropertyData($propertyData); @@ -62,13 +63,13 @@ class Properties } } - 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 eb61a5d3..b3bee899 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 @@ class SheetViewOptions extends BaseParserClass /** * @param bool $readDataOnly */ - public function load($readDataOnly = false) + public function load($readDataOnly = false): void { if ($this->worksheetXml === null) { return; @@ -41,21 +42,21 @@ class SheetViewOptions extends BaseParserClass } } - 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 @@ class SheetViewOptions extends BaseParserClass } } - private function pageSetup(\SimpleXMLElement $sheetPr) + private function pageSetup(SimpleXMLElement $sheetPr): void { if (isset($sheetPr->pageSetUpPr)) { if (isset($sheetPr->pageSetUpPr['fitToPage']) && @@ -86,7 +87,7 @@ class SheetViewOptions extends BaseParserClass } } - private function sheetFormat(\SimpleXMLElement $sheetFormatPr) + private function sheetFormat(SimpleXMLElement $sheetFormatPr): void { if (isset($sheetFormatPr['customHeight']) && self::boolean((string) $sheetFormatPr['customHeight']) && @@ -106,7 +107,7 @@ class SheetViewOptions extends BaseParserClass } } - 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 88c01ead..f6c47929 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php @@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx; 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 @@ class SheetViews extends BaseParserClass } } - private function zoomScale() + private function zoomScale(): void { if (isset($this->sheetViewXml['zoomScale'])) { $zoomScale = (int) ($this->sheetViewXml['zoomScale']); @@ -59,14 +60,14 @@ class SheetViews extends BaseParserClass } } - 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 @@ class SheetViews extends BaseParserClass } } - private function headers() + private function headers(): void { if (isset($this->sheetViewXml['showRowColHeaders'])) { $this->worksheet->setShowRowColHeaders( @@ -84,7 +85,7 @@ class SheetViews extends BaseParserClass } } - private function direction() + private function direction(): void { if (isset($this->sheetViewXml['rightToLeft'])) { $this->worksheet->setRightToLeft( @@ -93,7 +94,7 @@ class SheetViews extends BaseParserClass } } - private function showZeros() + private function showZeros(): void { if (isset($this->sheetViewXml['showZeros'])) { $this->worksheet->getSheetView()->setShowZeros( @@ -102,7 +103,7 @@ class SheetViews extends BaseParserClass } } - private function pane() + private function pane(): void { $xSplit = 0; $ySplit = 0; @@ -126,7 +127,7 @@ class SheetViews extends BaseParserClass ); } - 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 40106258..43de8787 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Styles.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Styles.php @@ -11,6 +11,7 @@ use PhpOffice\PhpSpreadsheet\Style\Font; 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 @@ class Styles extends BaseParserClass } } - 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 @@ class Styles extends BaseParserClass } } - 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 @@ class Styles extends BaseParserClass } } - 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 @@ class Styles extends BaseParserClass 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 @@ class Styles extends BaseParserClass } } - 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 @@ class Styles extends BaseParserClass $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 @@ class Styles extends BaseParserClass } } - 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 @@ class Styles extends BaseParserClass } } - 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 03099e3e..15fb34ad 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -101,7 +101,7 @@ class Xml extends BaseReader * * @param string $pFilename * - * @return false|\SimpleXMLElement + * @return false|SimpleXMLElement */ public function trySimpleXMLLoadString($pFilename) { @@ -288,7 +288,6 @@ class Xml extends BaseReader * Loads from file into Spreadsheet instance. * * @param string $pFilename - * @param Spreadsheet $spreadsheet * * @return Spreadsheet */ @@ -653,11 +652,7 @@ class Xml extends BaseReader 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 @@ class Xml extends BaseReader /** * @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 @@ class Xml extends BaseReader /** * @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 @@ class Xml extends BaseReader /** * @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 @@ class Xml extends BaseReader /** * @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 @@ class Xml extends BaseReader /** * @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 6d655730..0b0f6dd3 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -152,7 +152,7 @@ class ReferenceHelper * @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 @@ class ReferenceHelper * @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 @@ class ReferenceHelper * @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 @@ class ReferenceHelper * @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 @@ class ReferenceHelper * @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 @@ class ReferenceHelper * @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 @@ class ReferenceHelper * @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 @@ class ReferenceHelper * @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 @@ class ReferenceHelper * @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 @@ class ReferenceHelper * @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 4fa5f2bd..104177bd 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 aa4a8e46..592d0e36 100644 --- a/src/PhpSpreadsheet/RichText/Run.php +++ b/src/PhpSpreadsheet/RichText/Run.php @@ -42,7 +42,7 @@ class Run extends TextElement implements ITextElement * * @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 56f778e5..4e0c91ef 100644 --- a/src/PhpSpreadsheet/Settings.php +++ b/src/PhpSpreadsheet/Settings.php @@ -60,7 +60,7 @@ class Settings * @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 @@ class Settings * * @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 @@ class Settings * * @param bool $state */ - public static function setLibXmlDisableEntityLoader($state) + public static function setLibXmlDisableEntityLoader($state): void { self::$libXmlDisableEntityLoader = (bool) $state; } @@ -137,10 +137,8 @@ class Settings /** * 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 8be255c5..fd49c1ec 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Shared; 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 @@ class Date return new DateTimeZone($timeZone); } - throw new \Exception('Invalid timezone'); + throw new Exception('Invalid timezone'); } /** @@ -311,8 +312,6 @@ class Date /** * Is a given cell a date/time? * - * @param Cell $pCell - * * @return bool */ public static function isDateTime(Cell $pCell) @@ -328,8 +327,6 @@ class Date /** * 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 e9d387da..b0d75d78 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DgContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer.php @@ -25,7 +25,7 @@ class DgContainer return $this->dgId; } - public function setDgId($value) + public function setDgId($value): void { $this->dgId = $value; } @@ -35,7 +35,7 @@ class DgContainer 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 7e2c3460..1da87726 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 @@ class SpgrContainer * * @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 bbf51df1..8a81ff57 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 @@ class SpContainer * * @param bool $value */ - public function setSpgr($value) + public function setSpgr($value): void { $this->spgr = $value; } @@ -135,7 +135,7 @@ class SpContainer * * @param int $value */ - public function setSpType($value) + public function setSpType($value): void { $this->spType = $value; } @@ -155,7 +155,7 @@ class SpContainer * * @param int $value */ - public function setSpFlag($value) + public function setSpFlag($value): void { $this->spFlag = $value; } @@ -175,7 +175,7 @@ class SpContainer * * @param int $value */ - public function setSpId($value) + public function setSpId($value): void { $this->spId = $value; } @@ -196,7 +196,7 @@ class SpContainer * @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 @@ class SpContainer * * @param string $value eg: 'A1' */ - public function setStartCoordinates($value) + public function setStartCoordinates($value): void { $this->startCoordinates = $value; } @@ -252,7 +252,7 @@ class SpContainer * * @param int $startOffsetX */ - public function setStartOffsetX($startOffsetX) + public function setStartOffsetX($startOffsetX): void { $this->startOffsetX = $startOffsetX; } @@ -272,7 +272,7 @@ class SpContainer * * @param int $startOffsetY */ - public function setStartOffsetY($startOffsetY) + public function setStartOffsetY($startOffsetY): void { $this->startOffsetY = $startOffsetY; } @@ -292,7 +292,7 @@ class SpContainer * * @param string $value eg: 'A1' */ - public function setEndCoordinates($value) + public function setEndCoordinates($value): void { $this->endCoordinates = $value; } @@ -312,7 +312,7 @@ class SpContainer * * @param int $endOffsetX */ - public function setEndOffsetX($endOffsetX) + public function setEndOffsetX($endOffsetX): void { $this->endOffsetX = $endOffsetX; } @@ -332,7 +332,7 @@ class SpContainer * * @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 96da3213..1bd15b9e 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer.php @@ -61,7 +61,7 @@ class DggContainer * * @param int $value */ - public function setSpIdMax($value) + public function setSpIdMax($value): void { $this->spIdMax = $value; } @@ -81,7 +81,7 @@ class DggContainer * * @param int $value */ - public function setCDgSaved($value) + public function setCDgSaved($value): void { $this->cDgSaved = $value; } @@ -101,7 +101,7 @@ class DggContainer * * @param int $value */ - public function setCSpSaved($value) + public function setCSpSaved($value): void { $this->cSpSaved = $value; } @@ -121,7 +121,7 @@ class DggContainer * * @param DggContainer\BstoreContainer $bstoreContainer */ - public function setBstoreContainer($bstoreContainer) + public function setBstoreContainer($bstoreContainer): void { $this->bstoreContainer = $bstoreContainer; } @@ -132,7 +132,7 @@ class DggContainer * @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 @@ class DggContainer * * @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 9d1e68ec..b07786ff 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 f83bdc7e..e8851465 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 @@ class BSE * * @param BSE\Blip $blip */ - public function setBlip($blip) + public function setBlip($blip): void { $this->blip = $blip; $blip->setParent($this); @@ -82,7 +82,7 @@ class BSE * * @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 88bc117a..500d7eaf 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 @@ class Blip * * @param string $data */ - public function setData($data) + public function setData($data): void { $this->data = $data; } @@ -43,7 +43,7 @@ class Blip * * @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 6b1fe6f5..7525df8a 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 @@ class File * * @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 89d91be7..ca94529c 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -198,7 +198,7 @@ class Font * * @param string $pValue */ - public static function setTrueTypeFontPath($pValue) + public static function setTrueTypeFontPath($pValue): void { self::$trueTypeFontPath = $pValue; } @@ -223,7 +223,7 @@ class Font * * @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 @@ class Font * 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 ba59e0e5..f6fbccb8 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 @@ class EigenvalueDecomposition // 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 @@ class EigenvalueDecomposition * 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 @@ class EigenvalueDecomposition $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 @@ class EigenvalueDecomposition $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 @@ class EigenvalueDecomposition * 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 @@ class EigenvalueDecomposition * @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 @@ class EigenvalueDecomposition * 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 a67b6c2d..a5cb6de0 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php +++ b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php @@ -159,11 +159,6 @@ class Matrix * * 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 @@ class Matrix * * A + B * - * @param mixed $B Matrix/Array - * * @return Matrix Sum */ public function plus(...$args) @@ -522,8 +515,6 @@ class Matrix * * A = A + B * - * @param mixed $B Matrix/Array - * * @return $this */ public function plusEquals(...$args) @@ -581,8 +572,6 @@ class Matrix * * A - B * - * @param mixed $B Matrix/Array - * * @return Matrix Sum */ public function minus(...$args) @@ -626,8 +615,6 @@ class Matrix * * A = A - B * - * @param mixed $B Matrix/Array - * * @return $this */ public function minusEquals(...$args) @@ -686,8 +673,6 @@ class Matrix * Element-by-element multiplication * Cij = Aij * Bij * - * @param mixed $B Matrix/Array - * * @return Matrix Matrix Cij */ public function arrayTimes(...$args) @@ -732,8 +717,6 @@ class Matrix * Element-by-element multiplication * Aij = Aij * Bij * - * @param mixed $B Matrix/Array - * * @return $this */ public function arrayTimesEquals(...$args) @@ -792,8 +775,6 @@ class Matrix * Element-by-element right division * A / B * - * @param Matrix $B Matrix B - * * @return Matrix Division result */ public function arrayRightDivide(...$args) @@ -857,8 +838,6 @@ class Matrix * 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 @@ class Matrix * Element-by-element Left division * A / B * - * @param Matrix $B Matrix B - * * @return Matrix Division result */ public function arrayLeftDivide(...$args) @@ -949,8 +926,6 @@ class Matrix * 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 @@ class Matrix * * Matrix multiplication * - * @param mixed $n Matrix/Array/Scalar - * * @return Matrix Product */ public function times(...$args) @@ -1089,8 +1062,6 @@ class Matrix * * A = A ^ B * - * @param mixed $B Matrix/Array - * * @return $this */ public function power(...$args) @@ -1130,7 +1101,7 @@ class Matrix $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 @@ class Matrix * * 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 3ca95619..b997fb7c 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php +++ b/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php @@ -117,7 +117,7 @@ class SingularValueDecomposition } } - 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 @@ class SingularValueDecomposition $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 @@ class SingularValueDecomposition // 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 @@ class SingularValueDecomposition // 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 @@ class SingularValueDecomposition $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 @@ class SingularValueDecomposition */ 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 81ebaa34..27c72acd 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 @@ class OLE 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 @@ class OLE $path .= '&blockId=' . $blockIdOrPps; } - return fopen($path, 'r'); + return fopen($path, 'rb'); } /** @@ -502,7 +502,7 @@ class OLE } // 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 e6ba7242..ecaa97ed 100644 --- a/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php +++ b/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php @@ -101,7 +101,7 @@ class ChainedBlockStream /** * 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 @@ class ChainedBlockStream { 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 68f50a5c..b7425af4 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/File.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/File.php @@ -59,7 +59,7 @@ class File extends PPS * * @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 472483eb..0d70df6d 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php @@ -73,14 +73,12 @@ class Root extends PPS $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 @@ class Root extends PPS $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 @@ class Root extends PPS $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 @@ class Root extends PPS * * @param int $i2 The argument * - * @see save() - * * @return float + * + * @see save() */ private static function adjust2($i2) { @@ -164,7 +162,7 @@ class Root extends PPS * @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 @@ class Root extends PPS * @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 @@ class Root extends PPS // 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 @@ class Root extends PPS } 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 @@ class Root extends PPS * * @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 @@ class Root extends PPS * @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 3526c7e6..b6d5422c 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 @@ class OLERead /** * 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 d949203b..9ae32413 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 @@ class StringHelper /** * Build SYLK characters array. */ - private static function buildSYLKCharacters() + private static function buildSYLKCharacters(): void { self::$SYLKCharacters = [ "\x1B 0" => chr(0), @@ -272,7 +272,7 @@ class StringHelper return self::$isIconvEnabled; } - private static function buildCharacterSets() + private static function buildCharacterSets(): void { if (empty(self::$controlCharacters)) { self::buildControlCharacters(); @@ -603,7 +603,7 @@ class StringHelper * * @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 @@ class StringHelper * * @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 @@ class StringHelper * * @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 d8e63d5e..c9499722 100644 --- a/src/PhpSpreadsheet/Shared/Trend/BestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/BestFit.php @@ -341,7 +341,7 @@ class BestFit 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 @@ class BestFit $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 @@ class BestFit * @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 5b57f4b7..82866dee 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 @@ class ExponentialBestFit extends BestFit * @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 217f0964..26a562c5 100644 --- a/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php @@ -58,7 +58,7 @@ class LinearBestFit extends BestFit * @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 96ca2ed8..c469067d 100644 --- a/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php @@ -58,7 +58,7 @@ class LogarithmicBestFit extends BestFit * @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 a1510491..d959eddb 100644 --- a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php @@ -44,7 +44,7 @@ class PolynomialBestFit extends BestFit $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 @@ class PolynomialBestFit extends BestFit * @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 @@ class PolynomialBestFit extends BestFit $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 @@ class PolynomialBestFit extends BestFit $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 4eefec82..c53eab63 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 @@ class PowerBestFit extends BestFit */ 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 @@ class PowerBestFit extends BestFit * @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 b8ce5e2d..c9eaf378 100644 --- a/src/PhpSpreadsheet/Shared/Xls.php +++ b/src/PhpSpreadsheet/Shared/Xls.php @@ -25,7 +25,7 @@ class Xls $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 @@ class Xls } // 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 @@ class Xls $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 @@ class Xls } // 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 @@ class Xls * 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 @@ class Xls * 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 6023c616..322d5f7c 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -210,7 +210,7 @@ class Spreadsheet * * @param bool $hasMacros true|false */ - public function setHasMacros($hasMacros) + public function setHasMacros($hasMacros): void { $this->hasMacros = (bool) $hasMacros; } @@ -220,7 +220,7 @@ class Spreadsheet * * @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 @@ class Spreadsheet * * @param null|string $certificate */ - public function setMacrosCertificate($certificate) + public function setMacrosCertificate($certificate): void { $this->macrosCertificate = $certificate; } @@ -269,7 +269,7 @@ class Spreadsheet /** * Remove all macros, certificate from spreadsheet. */ - public function discardMacros() + public function discardMacros(): void { $this->hasMacros = false; $this->macrosCode = null; @@ -282,7 +282,7 @@ class Spreadsheet * @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 @@ class Spreadsheet * @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 @@ class Spreadsheet * 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 @@ class Spreadsheet * 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 @@ class Spreadsheet /** * 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 @@ class Spreadsheet /** * 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 @@ class Spreadsheet /** * 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 @@ class Spreadsheet * * @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 @@ class Spreadsheet /** * Get index for sheet. * - * @param Worksheet $pSheet - * * @return int index */ public function getIndex(Worksheet $pSheet) @@ -885,8 +876,6 @@ class Spreadsheet /** * Add named range. * - * @param NamedRange $namedRange - * * @return bool */ public function addNamedRange(NamedRange $namedRange) @@ -910,7 +899,7 @@ class Spreadsheet * * @return null|NamedRange */ - public function getNamedRange($namedRange, Worksheet $pSheet = null) + public function getNamedRange($namedRange, ?Worksheet $pSheet = null) { $returnValue = null; @@ -937,7 +926,7 @@ class Spreadsheet * * @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 @@ class Spreadsheet /** * 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 @@ class Spreadsheet * * @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 @@ class Spreadsheet /** * 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 @@ class Spreadsheet * * @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 @@ class Spreadsheet * 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 @@ class Spreadsheet * * @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 @@ class Spreadsheet * * @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 @@ class Spreadsheet * * @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 @@ class Spreadsheet * * @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 @@ class Spreadsheet * * @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 @@ class Spreadsheet * * @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 @@ class Spreadsheet * * @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 @@ class Spreadsheet * * @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 2e076a92..78ad8b26 100644 --- a/src/PhpSpreadsheet/Style/Border.php +++ b/src/PhpSpreadsheet/Style/Border.php @@ -194,8 +194,6 @@ class Border extends Supervisor /** * 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 2b096a34..35ec479b 100644 --- a/src/PhpSpreadsheet/Style/Conditional.php +++ b/src/PhpSpreadsheet/Style/Conditional.php @@ -234,7 +234,7 @@ class Conditional implements IComparable * * @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 789a9801..c6baeed0 100644 --- a/src/PhpSpreadsheet/Style/Fill.php +++ b/src/PhpSpreadsheet/Style/Fill.php @@ -244,8 +244,6 @@ class Fill extends Supervisor /** * Set Start Color. * - * @param Color $pValue - * * @return $this */ public function setStartColor(Color $pValue) @@ -276,8 +274,6 @@ class Fill extends Supervisor /** * 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 5ab58dca..eee7df04 100644 --- a/src/PhpSpreadsheet/Style/Font.php +++ b/src/PhpSpreadsheet/Style/Font.php @@ -504,8 +504,6 @@ class Font extends Supervisor /** * 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 1f4a6c0c..259acabf 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -228,7 +228,7 @@ class NumberFormat extends Supervisor /** * 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 @@ class NumberFormat extends Supervisor * @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 @@ class NumberFormat extends Supervisor 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 @@ class NumberFormat extends Supervisor $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 @@ class NumberFormat extends Supervisor } } - 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 @@ class NumberFormat extends Supervisor $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 a37d99b5..533a7c38 100644 --- a/src/PhpSpreadsheet/Style/Style.php +++ b/src/PhpSpreadsheet/Style/Style.php @@ -483,8 +483,6 @@ class Style extends Supervisor /** * Set font. * - * @param Font $font - * * @return $this */ public function setFont(Font $font) @@ -634,7 +632,7 @@ class Style extends Supervisor * * @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 e6cd40e3..c085b596 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 @@ class AutoFilter * * @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 a36740a3..09584a7a 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 @@ class Column * * @return $this */ - public function setParent(AutoFilter $pParent = null) + public function setParent(?AutoFilter $pParent = null) { $this->parent = $pParent; @@ -308,8 +308,6 @@ class Column /** * 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 28286cee..c0a15a7c 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 @@ class Rule * * @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 bcea3435..1b145a81 100644 --- a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php @@ -205,7 +205,7 @@ class BaseDrawing implements IComparable * * @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 @@ class BaseDrawing implements IComparable * * @return $this */ - public function setShadow(Drawing\Shadow $pValue = null) + public function setShadow(?Drawing\Shadow $pValue = null) { $this->shadow = $pValue; @@ -517,10 +517,7 @@ class BaseDrawing implements IComparable } } - /** - * @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 472609a3..45f76cab 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 class CellIterator implements \Iterator * * @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 098967f7..410e8073 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 @@ class Column */ public function __destruct() { - unset($this->parent); + $this->parent = null; } /** diff --git a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php index 184f4888..ec16fbe5 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 @@ class ColumnCellIterator extends CellIterator /** * Rewind the iterator to the starting row. */ - public function rewind() + public function rewind(): void { $this->currentRow = $this->startRow; } @@ -133,7 +133,7 @@ class ColumnCellIterator extends CellIterator /** * Set the iterator to its next value. */ - public function next() + public function next(): void { do { ++$this->currentRow; @@ -145,7 +145,7 @@ class ColumnCellIterator extends CellIterator /** * Set the iterator to its previous value. */ - public function prev() + public function prev(): void { do { --$this->currentRow; @@ -167,7 +167,7 @@ class ColumnCellIterator extends CellIterator /** * 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 0aff4859..d0bb20cc 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 @@ class ColumnIterator implements \Iterator */ public function __destruct() { - unset($this->worksheet); + $this->worksheet = null; } /** @@ -118,7 +119,7 @@ class ColumnIterator implements \Iterator /** * Rewind the iterator to the starting column. */ - public function rewind() + public function rewind(): void { $this->currentColumnIndex = $this->startColumnIndex; } @@ -146,7 +147,7 @@ class ColumnIterator implements \Iterator /** * Set the iterator to its next value. */ - public function next() + public function next(): void { ++$this->currentColumnIndex; } @@ -154,7 +155,7 @@ class ColumnIterator implements \Iterator /** * 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 c7594dae..01ffed94 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php @@ -222,7 +222,7 @@ class Shadow implements IComparable * * @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 be19abbd..cc37e7f5 100644 --- a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php +++ b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php @@ -400,7 +400,6 @@ class HeaderFooter /** * 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 d8797a34..6cfed37a 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 @@ class Iterator implements \Iterator */ 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 @@ class Iterator implements \Iterator /** * 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 f0935585..22e09099 100644 --- a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php @@ -53,7 +53,7 @@ class MemoryDrawing extends BaseDrawing $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 2a379d2c..4f48a346 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 @@ class Row */ public function __destruct() { - unset($this->worksheet); + $this->worksheet = null; } /** diff --git a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php index 09a5b0a1..f5576dc7 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 @@ class RowCellIterator extends CellIterator /** * Rewind the iterator to the starting column. */ - public function rewind() + public function rewind(): void { $this->currentColumnIndex = $this->startColumnIndex; } @@ -135,7 +135,7 @@ class RowCellIterator extends CellIterator /** * Set the iterator to its next value. */ - public function next() + public function next(): void { do { ++$this->currentColumnIndex; @@ -145,7 +145,7 @@ class RowCellIterator extends CellIterator /** * Set the iterator to its previous value. */ - public function prev() + public function prev(): void { do { --$this->currentColumnIndex; @@ -175,7 +175,7 @@ class RowCellIterator extends CellIterator /** * 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 62cede7b..42542533 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 @@ class RowIterator implements \Iterator */ public function __destruct() { - unset($this->subject); + $this->subject = null; } /** @@ -113,7 +114,7 @@ class RowIterator implements \Iterator /** * Rewind the iterator to the starting row. */ - public function rewind() + public function rewind(): void { $this->position = $this->startRow; } @@ -141,7 +142,7 @@ class RowIterator implements \Iterator /** * Set the iterator to its next value. */ - public function next() + public function next(): void { ++$this->position; } @@ -149,7 +150,7 @@ class RowIterator implements \Iterator /** * 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 e19ff808..2f7d3812 100644 --- a/src/PhpSpreadsheet/Worksheet/SheetView.php +++ b/src/PhpSpreadsheet/Worksheet/SheetView.php @@ -126,7 +126,7 @@ class SheetView * * @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 e8a61b78..1ed77e05 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 @@ class Worksheet implements IComparable // 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 @@ class Worksheet implements IComparable * 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 @@ class Worksheet implements IComparable /** * 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 @@ class Worksheet implements IComparable /** * Re-bind parent. * - * @param Spreadsheet $parent - * * @return $this */ public function rebindParent(Spreadsheet $parent) @@ -931,8 +928,6 @@ class Worksheet implements IComparable /** * Set page setup. * - * @param PageSetup $pValue - * * @return $this */ public function setPageSetup(PageSetup $pValue) @@ -955,8 +950,6 @@ class Worksheet implements IComparable /** * Set page margins. * - * @param PageMargins $pValue - * * @return $this */ public function setPageMargins(PageMargins $pValue) @@ -979,8 +972,6 @@ class Worksheet implements IComparable /** * Set page header/footer. * - * @param HeaderFooter $pValue - * * @return $this */ public function setHeaderFooter(HeaderFooter $pValue) @@ -1003,8 +994,6 @@ class Worksheet implements IComparable /** * Set sheet view. * - * @param SheetView $pValue - * * @return $this */ public function setSheetView(SheetView $pValue) @@ -1027,8 +1016,6 @@ class Worksheet implements IComparable /** * Set Protection. * - * @param Protection $pValue - * * @return $this */ public function setProtection(Protection $pValue) @@ -1771,8 +1758,6 @@ class Worksheet implements IComparable * 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 @@ class Worksheet implements IComparable * 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 @@ class Worksheet implements IComparable * 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 @@ class Worksheet implements IComparable 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 4344a5bd..414bdf90 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -79,7 +79,7 @@ class Csv extends BaseWriter * * @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 @@ class Csv extends BaseWriter * @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 bb509806..65b04c7d 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 @@ class Html extends BaseWriter * * @param resource|string $pFilename */ - public function save($pFilename) + public function save($pFilename): void { // Open file $this->openFileHandle($pFilename); @@ -204,7 +202,7 @@ class Html extends BaseWriter Alignment::VERTICAL_TOP => 'top', Alignment::VERTICAL_CENTER => 'middle', Alignment::VERTICAL_JUSTIFY => 'middle', - ]; + ]; /** * Map VAlign. @@ -224,7 +222,7 @@ class Html extends BaseWriter Alignment::HORIZONTAL_CENTER => 'center', Alignment::HORIZONTAL_CENTER_CONTINUOUS => 'center', Alignment::HORIZONTAL_JUSTIFY => 'justify', - ]; + ]; /** * Map HAlign. @@ -251,7 +249,7 @@ class Html extends BaseWriter Border::BORDER_MEDIUMDASHDOTDOT => '2px dotted', Border::BORDER_SLANTDASHDOT => '2px dashed', Border::BORDER_THICK => '3px solid', - ]; + ]; /** * Map border style. @@ -805,7 +803,7 @@ class Html extends BaseWriter 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 @@ class Html extends BaseWriter } } - 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 @@ class Html extends BaseWriter /** * Create CSS style. * - * @param Style $pStyle - * * @return array */ private function createCSSStyle(Style $pStyle) @@ -1018,8 +1014,6 @@ class Html extends BaseWriter /** * Create CSS style (\PhpOffice\PhpSpreadsheet\Style\Font). * - * @param Font $pStyle - * * @return array */ private function createCSSStyleFont(Font $pStyle) @@ -1138,7 +1132,7 @@ class Html extends BaseWriter 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 @@ class Html extends BaseWriter 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 @@ class Html extends BaseWriter } } - 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 @@ class Html extends BaseWriter 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 @@ class Html extends BaseWriter /** * 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 @@ class Html extends BaseWriter /** * 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 @@ class Html extends BaseWriter $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 @@ class Html extends BaseWriter * * @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 27329537..5129d655 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 e3a0ca98..36f3e9ca 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 @@ class Ods extends BaseWriter * * @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 2f543be5..880a8554 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php +++ b/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php @@ -13,7 +13,7 @@ use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; */ 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 cbf303bd..cb6c6628 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Content.php +++ b/src/PhpSpreadsheet/Writer/Ods/Content.php @@ -106,13 +106,10 @@ class Content extends WriterPart /** * 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 @@ class Content extends WriterPart /** * 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 @@ class Content extends WriterPart /** * 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 @@ class Content extends WriterPart /** * 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 @@ class Content extends WriterPart /** * 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 @@ class Content extends WriterPart /** * 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 eb2ebf9e..365221f7 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 d0fed2b3..4aac3685 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 11d13341..d458e8c2 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 cd71566f..7ba7eba7 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 a29a14ad..dfab0654 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 3e2f9684..1982c450 100644 --- a/src/PhpSpreadsheet/Writer/Ods/WriterPart.php +++ b/src/PhpSpreadsheet/Writer/Ods/WriterPart.php @@ -25,8 +25,6 @@ abstract class WriterPart /** * 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 3ecaff68..9ae2ccee 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php @@ -22,7 +22,7 @@ class Dompdf extends Pdf * * @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 44241575..75e0010d 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php @@ -24,7 +24,7 @@ class Mpdf extends Pdf * * @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 3dc172a2..7530b1ef 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php @@ -38,7 +38,7 @@ class Tcpdf extends Pdf * * @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 06611789..cf87d5be 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -117,7 +117,7 @@ class Xls extends BaseWriter * * @param resource|string $pFilename */ - public function save($pFilename) + public function save($pFilename): void { // garbage collect $this->spreadsheet->garbageCollect(); @@ -230,7 +230,7 @@ class Xls extends BaseWriter /** * Build the Worksheet Escher objects. */ - private function buildWorksheetEschers() + private function buildWorksheetEschers(): void { // 1-based index to BstoreContainer $blipIndex = 0; @@ -392,7 +392,7 @@ class Xls extends BaseWriter /** * Build the Escher object corresponding to the MSODRAWINGGROUP record. */ - private function buildWorkbookEscher() + private function buildWorkbookEscher(): void { $escher = null; @@ -716,7 +716,7 @@ class Xls extends BaseWriter } 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 @@ class Xls extends BaseWriter } 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 3b2eb9af..84e27d0d 100644 --- a/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php +++ b/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php @@ -109,7 +109,7 @@ class BIFFwriter * * @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 @@ class BIFFwriter * @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 @@ class BIFFwriter /** * 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 df37dcb5..9cb31ead 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 @@ class 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 59820628..5e3316ab 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Parser.php +++ b/src/PhpSpreadsheet/Writer/Xls/Parser.php @@ -516,7 +516,7 @@ class Parser } 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 @@ class Parser 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 @@ class Parser * @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 @@ class Parser $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 @@ class Parser $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 @@ class Parser 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 @@ class Parser 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 @@ class Parser 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 @@ class Parser 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 @@ class Parser private function term() { $result = $this->fact(); - while (($this->currentToken == '*') or + while (($this->currentToken == '*') || ($this->currentToken == '/')) { if ($this->currentToken == '*') { $this->advance(); @@ -1270,7 +1270,7 @@ class Parser $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 @@ class Parser } $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 @@ class Parser $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 41c8e64e..d5f61bf2 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xls/Workbook.php @@ -222,7 +222,6 @@ class Workbook extends BIFFwriter /** * 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 @@ class Workbook extends BIFFwriter /** * 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 @@ class Workbook extends BIFFwriter /** * 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 @@ class Workbook extends BIFFwriter /** * 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 @@ class Workbook extends BIFFwriter /** * 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 @@ class Workbook extends BIFFwriter /** * 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 @@ class Workbook extends BIFFwriter /** * Write all XF records. */ - private function writeAllXfs() + private function writeAllXfs(): void { foreach ($this->xfWriters as $xfWriter) { $this->append($xfWriter->writeXf()); @@ -519,7 +516,7 @@ class Workbook extends BIFFwriter /** * Write all STYLE records. */ - private function writeAllStyles() + private function writeAllStyles(): void { $this->writeStyle(); } @@ -554,7 +551,7 @@ class Workbook extends BIFFwriter $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 @@ class Workbook extends BIFFwriter /** * 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 @@ class Workbook extends BIFFwriter /** * 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 @@ class Workbook extends BIFFwriter * @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 @@ class Workbook extends BIFFwriter /** * 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 @@ class Workbook extends BIFFwriter * @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 @@ class Workbook extends BIFFwriter /** * 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 @@ class Workbook extends BIFFwriter /** * Stores the PALETTE biff record. */ - private function writePalette() + private function writePalette(): void { $aref = $this->palette; @@ -1143,7 +1140,7 @@ class Workbook extends BIFFwriter * * @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 5a6fa61a..f6b3e297 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -277,7 +277,7 @@ class Worksheet extends BIFFwriter * * @see \PhpOffice\PhpSpreadsheet\Writer\Xls\Workbook::storeWorkbook() */ - public function close() + public function close(): void { $phpSheet = $this->phpSheet; @@ -603,7 +603,7 @@ class Worksheet extends BIFFwriter // Return data stored in memory if (isset($this->_data)) { $tmp = $this->_data; - unset($this->_data); + $this->_data = null; return $tmp; } @@ -616,7 +616,7 @@ class Worksheet extends BIFFwriter * * @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 @@ class Worksheet extends BIFFwriter * @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 @@ class Worksheet extends BIFFwriter * @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 @@ class Worksheet extends BIFFwriter * @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 @@ class Worksheet extends BIFFwriter * @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 @@ class Worksheet extends BIFFwriter * * @param string $stringValue */ - private function writeStringRecord($stringValue) + private function writeStringRecord($stringValue): void { $record = 0x0207; // Record identifier $data = StringHelper::UTF8toBIFF8UnicodeLong($stringValue); @@ -1176,7 +1176,7 @@ class Worksheet extends BIFFwriter * @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 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter /** * Write BIFF record Window2. */ - private function writeWindow2() + private function writeWindow2(): void { $record = 0x023E; // Record identifier $length = 0x0012; @@ -1291,7 +1291,7 @@ class Worksheet extends BIFFwriter /** * Write BIFF record DEFAULTROWHEIGHT. */ - private function writeDefaultRowHeight() + private function writeDefaultRowHeight(): void { $defaultRowHeight = $this->phpSheet->getDefaultRowDimension()->getRowHeight(); @@ -1313,7 +1313,7 @@ class Worksheet extends BIFFwriter /** * Write BIFF record DEFCOLWIDTH if COLINFO records are in use. */ - private function writeDefcol() + private function writeDefcol(): void { $defaultColWidth = 8; @@ -1339,7 +1339,7 @@ class Worksheet extends BIFFwriter * 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 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter $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 @@ class Worksheet extends BIFFwriter /** * Write SHEETLAYOUT record. */ - private function writeSheetLayout() + private function writeSheetLayout(): void { if (!$this->phpSheet->isTabColorSet()) { return; @@ -1527,7 +1527,7 @@ class Worksheet extends BIFFwriter /** * Write SHEETPROTECTION. */ - private function writeSheetProtection() + private function writeSheetProtection(): void { // record identifier $record = 0x0867; @@ -1574,7 +1574,7 @@ class Worksheet extends BIFFwriter * 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 @@ class Worksheet extends BIFFwriter * 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 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter /** * Store the header caption BIFF record. */ - private function writeHeader() + private function writeHeader(): void { $record = 0x0014; // Record identifier @@ -1791,7 +1791,7 @@ class Worksheet extends BIFFwriter /** * Store the footer caption BIFF record. */ - private function writeFooter() + private function writeFooter(): void { $record = 0x0015; // Record identifier @@ -1815,7 +1815,7 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter * 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 @@ class Worksheet extends BIFFwriter * 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 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter * * @see writeWsbool() */ - private function writeGuts() + private function writeGuts(): void { $record = 0x0080; // Record identifier $length = 0x0008; // Bytes to follow @@ -2033,7 +2033,7 @@ class Worksheet extends BIFFwriter * 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 @@ class Worksheet extends BIFFwriter /** * Write the HORIZONTALPAGEBREAKS and VERTICALPAGEBREAKS BIFF records. */ - private function writeBreaks() + private function writeBreaks(): void { // initialize $vbreaks = []; @@ -2151,7 +2151,7 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter * @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 @@ class Worksheet extends BIFFwriter * @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 @@ class Worksheet extends BIFFwriter * @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 @@ class Worksheet extends BIFFwriter * 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 @@ class Worksheet extends BIFFwriter * * @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 @@ class Worksheet extends BIFFwriter /** * Write MSODRAWING record. */ - private function writeMsoDrawing() + private function writeMsoDrawing(): void { // write the Escher stream if necessary if (isset($this->escher)) { @@ -2696,7 +2696,7 @@ class Worksheet extends BIFFwriter /** * Store the DATAVALIDATIONS and DATAVALIDATION records. */ - private function writeDataValidity() + private function writeDataValidity(): void { // Datavalidation collection $dataValidationCollection = $this->phpSheet->getDataValidationCollection(); @@ -2938,7 +2938,7 @@ class Worksheet extends BIFFwriter /** * Write PLV Record. */ - private function writePageLayoutView() + private function writePageLayoutView(): void { $record = 0x088B; // Record identifier $length = 0x0010; // Bytes to follow @@ -2968,10 +2968,8 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter 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 @@ class Worksheet extends BIFFwriter /** * 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 238fb34c..3e8169b3 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Xf.php +++ b/src/PhpSpreadsheet/Writer/Xls/Xf.php @@ -248,7 +248,7 @@ class Xf * * @param bool $value */ - public function setIsStyleXf($value) + public function setIsStyleXf($value): void { $this->isStyleXf = $value; } @@ -258,7 +258,7 @@ class Xf * * @param int $colorIndex Color index */ - public function setBottomColor($colorIndex) + public function setBottomColor($colorIndex): void { $this->bottomBorderColor = $colorIndex; } @@ -268,7 +268,7 @@ class Xf * * @param int $colorIndex Color index */ - public function setTopColor($colorIndex) + public function setTopColor($colorIndex): void { $this->topBorderColor = $colorIndex; } @@ -278,7 +278,7 @@ class Xf * * @param int $colorIndex Color index */ - public function setLeftColor($colorIndex) + public function setLeftColor($colorIndex): void { $this->leftBorderColor = $colorIndex; } @@ -288,7 +288,7 @@ class Xf * * @param int $colorIndex Color index */ - public function setRightColor($colorIndex) + public function setRightColor($colorIndex): void { $this->rightBorderColor = $colorIndex; } @@ -298,7 +298,7 @@ class Xf * * @param int $colorIndex Color index */ - public function setDiagColor($colorIndex) + public function setDiagColor($colorIndex): void { $this->_diag_color = $colorIndex; } @@ -308,7 +308,7 @@ class Xf * * @param int $colorIndex Color index */ - public function setFgColor($colorIndex) + public function setFgColor($colorIndex): void { $this->foregroundColor = $colorIndex; } @@ -318,7 +318,7 @@ class Xf * * @param int $colorIndex Color index */ - public function setBgColor($colorIndex) + public function setBgColor($colorIndex): void { $this->backgroundColor = $colorIndex; } @@ -329,7 +329,7 @@ class Xf * * @param int $numberFormatIndex Index to format record */ - public function setNumberFormatIndex($numberFormatIndex) + public function setNumberFormatIndex($numberFormatIndex): void { $this->numberFormatIndex = $numberFormatIndex; } @@ -339,7 +339,7 @@ class Xf * * @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 4d4d79d6..bfcde049 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 @@ class Xlsx extends BaseWriter * * @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 aeb7a76b..583b262c 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 @@ class Chart extends WriterPart * @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 @@ class Chart extends WriterPart * @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 @@ class Chart extends WriterPart * 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 @@ class Chart extends WriterPart * @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 @@ class Chart extends WriterPart * @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 @@ class Chart extends WriterPart * @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 @@ class Chart extends WriterPart * @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 @@ class Chart extends WriterPart * @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 @@ class Chart extends WriterPart * @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 @@ class Chart extends WriterPart * @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 @@ class Chart extends WriterPart * @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 @@ class Chart extends WriterPart * * @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 @@ class Chart extends WriterPart * * @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 ee34e318..73c4308b 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 @@ class Comments extends WriterPart * @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 @@ class Comments extends WriterPart /** * 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 @@ class Comments extends WriterPart * @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 421f1e73..2cff1a8f 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 @@ class ContentTypes extends WriterPart * @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 @@ class ContentTypes extends WriterPart * @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 289d08c7..bcbc2379 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 @@ class DocProps extends WriterPart /** * Write docProps/core.xml to XML format. * - * @param Spreadsheet $spreadsheet - * * @return string XML Output */ public function writeDocPropsCore(Spreadsheet $spreadsheet) @@ -174,8 +170,6 @@ class DocProps extends WriterPart /** * 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 4c5a413e..1713b982 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 @@ class Drawing extends WriterPart * 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 @@ class Drawing extends WriterPart * 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 @@ class Drawing extends WriterPart /** * 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 @@ class Drawing extends WriterPart * @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 @@ class Drawing extends WriterPart /** * 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 @@ class Drawing extends WriterPart } /** - * @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 6dc41502..c2876065 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 @@ class Rels extends WriterPart /** * Write workbook relationships to XML format. * - * @param Spreadsheet $spreadsheet - * * @return string XML Output */ public function writeWorkbookRelationships(Spreadsheet $spreadsheet) @@ -164,7 +160,6 @@ class Rels extends WriterPart * 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 @@ class Rels extends WriterPart 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 @@ class Rels extends WriterPart /** * 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 @@ class Rels extends WriterPart /** * 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 @@ class Rels extends WriterPart * @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 531111ab..8005207c 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 fb508c6b..55bcd360 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 8e18e6f8..872d0343 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php @@ -112,7 +112,7 @@ class StringTable extends WriterPart * @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 @@ class StringTable extends WriterPart * @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 54ec664f..74300a9c 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 @@ class Style extends WriterPart * @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 @@ class Style extends WriterPart * @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 @@ class Style extends WriterPart * @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 @@ class Style extends WriterPart * @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 @@ class Style extends WriterPart * @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 @@ class Style extends WriterPart * @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 @@ class Style extends WriterPart * @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 @@ class Style extends WriterPart * @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 @@ class Style extends WriterPart * @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 @@ class Style extends WriterPart /** * 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 @@ class Style extends WriterPart /** * 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 @@ class Style extends WriterPart /** * Get an array of all fills. * - * @param Spreadsheet $spreadsheet - * * @return Fill[] All fills in PhpSpreadsheet */ public function allFills(Spreadsheet $spreadsheet) @@ -614,8 +606,6 @@ class Style extends WriterPart /** * Get an array of all fonts. * - * @param Spreadsheet $spreadsheet - * * @return Font[] All fonts in PhpSpreadsheet */ public function allFonts(Spreadsheet $spreadsheet) @@ -637,8 +627,6 @@ class Style extends WriterPart /** * Get an array of all borders. * - * @param Spreadsheet $spreadsheet - * * @return Borders[] All borders in PhpSpreadsheet */ public function allBorders(Spreadsheet $spreadsheet) @@ -660,8 +648,6 @@ class Style extends WriterPart /** * 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 c6090395..5119117a 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 a56c5b72..88befd02 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 @@ class Workbook extends WriterPart * * @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 @@ class Workbook extends WriterPart * * @param XMLWriter $objWriter XML Writer */ - private function writeWorkbookPr(XMLWriter $objWriter) + private function writeWorkbookPr(XMLWriter $objWriter): void { $objWriter->startElement('workbookPr'); @@ -104,9 +103,8 @@ class Workbook extends WriterPart * 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 @@ class Workbook extends WriterPart * 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 @@ class Workbook extends WriterPart * @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 @@ class Workbook extends WriterPart * 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 @@ class Workbook extends WriterPart * @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 @@ class Workbook extends WriterPart * 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 @@ class Workbook extends WriterPart * 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 @@ class Workbook extends WriterPart * 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 @@ class Workbook extends WriterPart * 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 @@ class Workbook extends WriterPart * 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 @@ class Workbook extends WriterPart * 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 febee54d..25b09d19 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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart } /** - * @param XMLWriter $objWriter - * @param string $mappedType * @param RichText|string $cellValue */ private function writeCellInlineStr(XMLWriter $objWriter, string $mappedType, $cellValue): void @@ -1066,8 +1063,6 @@ class Worksheet extends WriterPart } /** - * @param XMLWriter $objWriter - * @param string $mappedType * @param RichText|string $cellValue * @param string[] $pFlippedStringTable */ @@ -1082,7 +1077,6 @@ class Worksheet extends WriterPart } /** - * @param XMLWriter $objWriter * @param float|int $cellValue */ private function writeCellNumeric(XMLWriter $objWriter, $cellValue): void @@ -1156,7 +1150,7 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart * @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 @@ class Worksheet extends WriterPart } } - 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 7119512c..a9137dfc 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php @@ -25,8 +25,6 @@ abstract class WriterPart /** * 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 a923fa19..80431c4d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php @@ -27,7 +27,7 @@ class CalculationTest extends TestCase * @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 @@ class CalculationTest extends TestCase * @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 @@ class CalculationTest extends TestCase 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 @@ class CalculationTest extends TestCase * * @param string $locale */ - public function testCanLoadAllSupportedLocales($locale) + public function testCanLoadAllSupportedLocales($locale): void { $calculation = Calculation::getInstance(); self::assertTrue($calculation->setLocale($locale)); @@ -104,7 +104,7 @@ class CalculationTest extends TestCase ]; } - public function testDoesHandleXlfnFunctions() + public function testDoesHandleXlfnFunctions(): void { $calculation = Calculation::getInstance(); @@ -119,7 +119,7 @@ class CalculationTest extends TestCase self::assertEquals('Function', $function['type']); } - public function testFormulaWithOptionalArgumentsAndRequiredCellReferenceShouldPassNullForMissingArguments() + public function testFormulaWithOptionalArgumentsAndRequiredCellReferenceShouldPassNullForMissingArguments(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -141,7 +141,7 @@ class CalculationTest extends TestCase 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 @@ class CalculationTest extends TestCase 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 @@ class CalculationTest extends TestCase 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 @@ class CalculationTest extends TestCase self::assertEquals('9', $cell3->getCalculatedValue()); } - public function testBranchPruningFormulaParsingSimpleCase() + public function testBranchPruningFormulaParsingSimpleCase(): void { $calculation = Calculation::getInstance(); $calculation->flushInstance(); // resets the ids @@ -204,11 +204,11 @@ class CalculationTest extends TestCase $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 @@ class CalculationTest extends TestCase $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 @@ class CalculationTest extends TestCase $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 @@ class CalculationTest extends TestCase self::assertTrue(true); } - public function testBranchPruningFormulaParsingInequalitiesConditionsCase() + public function testBranchPruningFormulaParsingInequalitiesConditionsCase(): void { $calculation = Calculation::getInstance(); $calculation->flushInstance(); // resets the ids @@ -298,7 +298,7 @@ class CalculationTest extends TestCase $properlyTaggedPlus = $properlyTaggedPlus || ($isPlus && $hasOnlyIf); } - $this->assertTrue($properlyTaggedPlus); + self::assertTrue($properlyTaggedPlus); } /** @@ -320,7 +320,7 @@ class CalculationTest extends TestCase $cellCoordinates, $shouldBeSetInCacheCells = [], $shouldNotBeSetInCacheCells = [] - ) { + ): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -330,24 +330,24 @@ class CalculationTest extends TestCase $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 54333afa..12d73356 100644 --- a/tests/PhpSpreadsheetTests/Calculation/DefinedNameConfusedForCellTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/DefinedNameConfusedForCellTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; 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 5c3928eb..e80ef35b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php @@ -18,7 +18,7 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * @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 @@ class FinancialTest extends TestCase * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 @@ class FinancialTest extends TestCase * * @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 abf7589a..2cbdc960 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 35fbe05b..db8e29a1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php @@ -24,10 +24,10 @@ class DateDifTest extends TestCase * @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 c354f851..48f7cfd7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php @@ -24,10 +24,10 @@ class DateTest extends TestCase * @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 @@ class DateTest extends TestCase 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 20541801..51e4f7c0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php @@ -23,10 +23,10 @@ class DateValueTest extends TestCase * @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 @@ class DateValueTest extends TestCase 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 77c29939..8f4639eb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php @@ -23,15 +23,15 @@ class DayTest extends TestCase * @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 40e86f31..47449e0d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php @@ -24,10 +24,10 @@ class Days360Test extends TestCase * @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 3c043950..fe31dfcc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php @@ -23,10 +23,10 @@ class DaysTest extends TestCase * @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 f931543e..a887ba5b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php @@ -23,10 +23,10 @@ class EDateTest extends TestCase * @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 @@ class EDateTest extends TestCase 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 7c8352fe..f9c54039 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php @@ -23,10 +23,10 @@ class EoMonthTest extends TestCase * @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 @@ class EoMonthTest extends TestCase 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 5110f93c..2d0cd5d1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php @@ -22,10 +22,10 @@ class HourTest extends TestCase * @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 608a1bf8..1ef0080a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php @@ -22,10 +22,10 @@ class IsoWeekNumTest extends TestCase * @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 36e248be..8472c6de 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php @@ -22,10 +22,10 @@ class MinuteTest extends TestCase * @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 8f938c83..62513702 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php @@ -22,10 +22,10 @@ class MonthTest extends TestCase * @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 4fa86be8..e366c44e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php @@ -21,10 +21,10 @@ class NetworkDaysTest extends TestCase * * @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 e1032b94..bc2b0752 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php @@ -22,10 +22,10 @@ class SecondTest extends TestCase * @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 1cd0c89b..344061d4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php @@ -21,10 +21,10 @@ class TimeTest extends TestCase * * @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 @@ class TimeTest extends TestCase 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 ed025cff..04b8c058 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php @@ -22,10 +22,10 @@ class TimeValueTest extends TestCase * @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 @@ class TimeValueTest extends TestCase 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 fe81c1a4..c5b89e01 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php @@ -21,10 +21,10 @@ class WeekDayTest extends TestCase * * @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 96c2077b..9d8e1eb2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php @@ -21,10 +21,10 @@ class WeekNumTest extends TestCase * * @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 bc6fd6cc..4784e463 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php @@ -21,10 +21,10 @@ class WorkDayTest extends TestCase * * @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 37364030..05f11310 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php @@ -21,10 +21,10 @@ class YearFracTest extends TestCase * * @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 26e416ec..bbdaf92a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php @@ -22,10 +22,10 @@ class YearTest extends TestCase * @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 d7b23909..8fff98af 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselITest.php @@ -20,10 +20,10 @@ class BesselITest extends TestCase * * @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 5e4d2f3b..d10f028f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselJTest.php @@ -20,10 +20,10 @@ class BesselJTest extends TestCase * * @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 6a048f37..27123a26 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselKTest.php @@ -20,10 +20,10 @@ class BesselKTest extends TestCase * * @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 98c238e2..ab55f0ac 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BesselYTest.php @@ -20,10 +20,10 @@ class BesselYTest extends TestCase * * @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 341493ea..faba3de8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php @@ -18,10 +18,10 @@ class Bin2DecTest extends TestCase * * @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 63945fd1..2a16d5ac 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php @@ -18,10 +18,10 @@ class Bin2HexTest extends TestCase * * @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 2aeeb1bc..78db6a6e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php @@ -18,10 +18,10 @@ class Bin2OctTest extends TestCase * * @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 483bf099..e73efccc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php @@ -19,10 +19,10 @@ class BitAndTest extends TestCase * @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 bf280f16..61aa89b4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php @@ -19,10 +19,10 @@ class BitLShiftTest extends TestCase * @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 6e455431..857c7466 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php @@ -19,10 +19,10 @@ class BitOrTest extends TestCase * @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 26bece53..26b13d07 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php @@ -19,10 +19,10 @@ class BitRShiftTest extends TestCase * @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 51401f63..4415f6da 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php @@ -19,10 +19,10 @@ class BitXorTest extends TestCase * @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 5bb7fbcd..4b857e2d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php @@ -18,10 +18,10 @@ class ComplexTest extends TestCase * * @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 3d6a0777..7a18067f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php @@ -13,28 +13,28 @@ class ConvertUoMTest extends TestCase 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 @@ class ConvertUoMTest extends TestCase * * @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 740fe3c9..3626ac6b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php @@ -18,10 +18,10 @@ class Dec2BinTest extends TestCase * * @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 c7aae441..d191f620 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php @@ -18,10 +18,10 @@ class Dec2HexTest extends TestCase * * @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 68456d1a..61eb3dbb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php @@ -18,10 +18,10 @@ class Dec2OctTest extends TestCase * * @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 fc2df95b..a93d2ea6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php @@ -18,10 +18,10 @@ class DeltaTest extends TestCase * * @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 5409db5f..09bf448e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php @@ -20,11 +20,11 @@ class ErfCTest extends TestCase * * @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 857e41c1..eb26ae98 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php @@ -20,11 +20,11 @@ class ErfPreciseTest extends TestCase * * @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 d148501b..8201edbc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php @@ -20,11 +20,11 @@ class ErfTest extends TestCase * * @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 24ba1a0f..370c1a82 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php @@ -18,10 +18,10 @@ class GeStepTest extends TestCase * * @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 83fcb1e7..44d8908d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php @@ -18,10 +18,10 @@ class Hex2BinTest extends TestCase * * @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 5765494e..b388b2b7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php @@ -18,10 +18,10 @@ class Hex2DecTest extends TestCase * * @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 25ba6300..bc0a5cb7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php @@ -18,10 +18,10 @@ class Hex2OctTest extends TestCase * * @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 c812fdfa..1f1ee9dd 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php @@ -21,10 +21,10 @@ class ImAbsTest extends TestCase * @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 60883e14..6f1a6485 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php @@ -21,10 +21,10 @@ class ImArgumentTest extends TestCase * @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 81323a53..bc3a3918 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php @@ -33,10 +33,10 @@ class ImConjugateTest extends TestCase * @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 c1c610fb..693f0bab 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php @@ -33,10 +33,10 @@ class ImCosTest extends TestCase * @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 7dacb7cd..ae035fef 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php @@ -33,10 +33,10 @@ class ImCoshTest extends TestCase * @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 512d96f9..8b888b3f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php @@ -33,10 +33,10 @@ class ImCotTest extends TestCase * @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 5fb3f49d..5a08c0b6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php @@ -33,10 +33,10 @@ class ImCscTest extends TestCase * @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 9b1934bb..a95a4eaf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php @@ -33,10 +33,10 @@ class ImCschTest extends TestCase * @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 7809ab06..2bc91619 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php @@ -32,10 +32,10 @@ class ImDivTest extends TestCase * * @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 3af044d7..7debbc9c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php @@ -33,10 +33,10 @@ class ImExpTest extends TestCase * @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 bb09860a..3e270975 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php @@ -33,10 +33,10 @@ class ImLnTest extends TestCase * @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 4831387d..2a4db7fb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php @@ -33,10 +33,10 @@ class ImLog10Test extends TestCase * @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 b6f25123..53b302dd 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php @@ -33,10 +33,10 @@ class ImLog2Test extends TestCase * @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 c198ffb9..41e52878 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php @@ -32,10 +32,10 @@ class ImPowerTest extends TestCase * * @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 2fd383c4..43495739 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php @@ -32,10 +32,10 @@ class ImProductTest extends TestCase * * @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 bd4baf9f..08d2feb1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php @@ -21,10 +21,10 @@ class ImRealTest extends TestCase * @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 4de6fcff..e785d3ac 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php @@ -33,10 +33,10 @@ class ImSecTest extends TestCase * @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 11aa8e28..22cb6fae 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php @@ -33,10 +33,10 @@ class ImSechTest extends TestCase * @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 f3c6afe9..dd797a35 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php @@ -33,10 +33,10 @@ class ImSinTest extends TestCase * @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 7478c15c..4174d1c0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php @@ -33,10 +33,10 @@ class ImSinhTest extends TestCase * @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 f9a15195..091b11c5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php @@ -33,10 +33,10 @@ class ImSqrtTest extends TestCase * @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 2ddc3f57..79286120 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php @@ -32,10 +32,10 @@ class ImSubTest extends TestCase * * @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 23f716ca..8abc3638 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php @@ -32,10 +32,10 @@ class ImSumTest extends TestCase * * @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 d9f39ad5..57b23815 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php @@ -33,10 +33,10 @@ class ImTanTest extends TestCase * @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 4d2e6781..6ad72287 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php @@ -21,10 +21,10 @@ class ImaginaryTest extends TestCase * @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 217494fa..e56c8652 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php @@ -18,10 +18,10 @@ class Oct2BinTest extends TestCase * * @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 c959236c..87e213ef 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php @@ -18,10 +18,10 @@ class Oct2DecTest extends TestCase * * @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 1d14bd78..e2d75a78 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php @@ -18,10 +18,10 @@ class Oct2HexTest extends TestCase * * @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 bc1437a3..1022052e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php @@ -13,16 +13,16 @@ class ParseComplexTest extends TestCase 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 33921bb3..597db5c2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintMTest.php @@ -18,7 +18,7 @@ class AccrintMTest extends TestCase * * @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 21aadd0a..edb79230 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php @@ -18,10 +18,10 @@ class AccrintTest extends TestCase * * @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 c1334988..d315e82a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php @@ -18,10 +18,10 @@ class AndTest extends TestCase * * @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 c546554e..1fa78af0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/FalseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/FalseTest.php @@ -13,9 +13,9 @@ class FalseTest extends TestCase 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 1e9ef8bc..c1602eda 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php @@ -20,10 +20,10 @@ class IfErrorTest extends TestCase * @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 e151cd75..2976761a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php @@ -20,10 +20,10 @@ class IfNaTest extends TestCase * @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 f289995a..571a80e3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php @@ -18,10 +18,10 @@ class IfTest extends TestCase * * @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 abc0e5bc..4b7c70be 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php @@ -18,10 +18,10 @@ class NotTest extends TestCase * * @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 46046b7c..021cc97b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php @@ -18,10 +18,10 @@ class OrTest extends TestCase * * @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 2781334d..eacad823 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php @@ -18,10 +18,10 @@ class SwitchTest extends TestCase * * @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 77166db0..21e65b76 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php @@ -13,9 +13,9 @@ class TrueTest extends TestCase 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 8f7a921b..8ca05f84 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php @@ -18,10 +18,10 @@ class XorTest extends TestCase * * @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 00e2c61c..01ba6f75 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php @@ -18,10 +18,10 @@ class ChooseTest extends TestCase * * @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 61c0f8b4..a7908241 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php @@ -18,10 +18,10 @@ class ColumnsTest extends TestCase * * @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 d317089d..767b6de8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php @@ -18,10 +18,10 @@ class HLookupTest extends TestCase * * @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 241d86f7..8ff66931 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php @@ -18,10 +18,10 @@ class IndexTest extends TestCase * * @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 6e1fb73a..d1b36e4a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php @@ -18,10 +18,10 @@ class LookupTest extends TestCase * * @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 2bf322fc..e020d3ba 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php @@ -18,10 +18,10 @@ class MatchTest extends TestCase * * @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 41b0bd2b..62a06626 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php @@ -18,10 +18,10 @@ class RowsTest extends TestCase * * @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 bffecb8e..badf8f68 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php @@ -18,10 +18,10 @@ class VLookupTest extends TestCase * * @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 2a3cd654..d81c3b9d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php @@ -19,10 +19,10 @@ class AcotTest extends TestCase * @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 9661b676..0a3864cc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php @@ -19,10 +19,10 @@ class AcothTest extends TestCase * @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 0371e0a7..7b3a5e15 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php @@ -19,10 +19,10 @@ class ArabicTest extends TestCase * @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 c6281fc2..4edec4cb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php @@ -20,10 +20,10 @@ class Atan2Test extends TestCase * @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 fdca1f49..72b52559 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php @@ -18,10 +18,10 @@ class BaseTest extends TestCase * * @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 c987cc2e..b60d7c30 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php @@ -18,10 +18,10 @@ class CeilingTest extends TestCase * * @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 8c982b6b..d9156339 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php @@ -18,10 +18,10 @@ class CombinTest extends TestCase * * @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 f864d226..3fee6901 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php @@ -19,10 +19,10 @@ class CotTest extends TestCase * @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 9243c095..e3db23d5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php @@ -19,10 +19,10 @@ class CothTest extends TestCase * @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 24abad4e..675ebf57 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php @@ -19,10 +19,10 @@ class CscTest extends TestCase * @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 393c0883..c630be2f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php @@ -19,10 +19,10 @@ class CschTest extends TestCase * @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 b81b119f..96c0b046 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php @@ -19,10 +19,10 @@ class EvenTest extends TestCase * @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 c3118942..f0b6b146 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php @@ -19,10 +19,10 @@ class FactDoubleTest extends TestCase * @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 b765d412..f6092896 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php @@ -19,10 +19,10 @@ class FactTest extends TestCase * @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 c5b797f1..d7d51b59 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php @@ -18,10 +18,10 @@ class FloorMathTest extends TestCase * * @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 399f05d2..ae5a3199 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php @@ -18,10 +18,10 @@ class FloorPreciseTest extends TestCase * * @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 fac02f16..e66d97ae 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php @@ -18,10 +18,10 @@ class FloorTest extends TestCase * * @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 825a9d05..ce1aec3f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php @@ -18,10 +18,10 @@ class GcdTest extends TestCase * * @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 3a9b1e5b..f400a7fe 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php @@ -19,10 +19,10 @@ class IntTest extends TestCase * @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 58ea6a6b..57b4a67f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php @@ -18,10 +18,10 @@ class LcmTest extends TestCase * * @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 82c63f99..184d83e6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php @@ -18,10 +18,10 @@ class LogTest extends TestCase * * @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 3d784a87..a500c3f6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php @@ -18,10 +18,10 @@ class MInverseTest extends TestCase * * @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 16a52e75..66fa80db 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MMultTest.php @@ -18,10 +18,10 @@ class MMultTest extends TestCase * * @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 73568747..32c9c355 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php @@ -18,10 +18,10 @@ class MRoundTest extends TestCase * * @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 672d5dec..995ea2f3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php @@ -18,10 +18,10 @@ class MdeTermTest extends TestCase * * @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 ae863792..930708f5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php @@ -18,10 +18,10 @@ class ModTest extends TestCase * * @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 dd2faf2c..93735ba9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MultinomialTest.php @@ -18,10 +18,10 @@ class MultinomialTest extends TestCase * * @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 7a9d367c..6c5758c6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php @@ -19,10 +19,10 @@ class OddTest extends TestCase * @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 05edecf9..6749b14a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php @@ -18,10 +18,10 @@ class PowerTest extends TestCase * * @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 3e185bd7..251b783b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php @@ -18,10 +18,10 @@ class ProductTest extends TestCase * * @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 96e0b84a..4232729a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php @@ -18,10 +18,10 @@ class QuotientTest extends TestCase * * @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 a1363714..c74daa32 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php @@ -18,10 +18,10 @@ class RomanTest extends TestCase * * @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 17b6780b..2fc211f3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php @@ -18,10 +18,10 @@ class RoundDownTest extends TestCase * * @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 6d1c57ba..825fe419 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php @@ -18,10 +18,10 @@ class RoundUpTest extends TestCase * * @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 8dad0b9d..ad4b196c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php @@ -19,10 +19,10 @@ class SecTest extends TestCase * @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 f98b673e..b9488bda 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php @@ -19,10 +19,10 @@ class SechTest extends TestCase * @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 4f8d4db1..689336a3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php @@ -18,10 +18,10 @@ class SeriesSumTest extends TestCase * * @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 d7b6bacb..68f5acb9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php @@ -19,10 +19,10 @@ class SignTest extends TestCase * @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 38528548..bb4bba4b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php @@ -19,10 +19,10 @@ class SqrtPiTest extends TestCase * @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 38434278..14865673 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php @@ -22,7 +22,7 @@ class SubTotalTest extends TestCase * * @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 @@ class SubTotalTest extends TestCase 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 @@ class SubTotalTest extends TestCase * * @param mixed $expectedResult */ - public function testHiddenSUBTOTAL($expectedResult, ...$args) + public function testHiddenSUBTOTAL($expectedResult, ...$args): void { $visibilityGenerator = $this->rowVisibility(); @@ -79,12 +79,12 @@ class SubTotalTest extends TestCase ->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 @@ class SubTotalTest extends TestCase 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 @@ class SubTotalTest extends TestCase * * @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 @@ class SubTotalTest extends TestCase ->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 @@ class SubTotalTest extends TestCase 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 639e8bdd..f7ff928f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php @@ -18,10 +18,10 @@ class SumIfTest extends TestCase * * @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 dab255c2..b7be17c9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php @@ -18,10 +18,10 @@ class SumIfsTest extends TestCase * * @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 6b94dafa..b34036e5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProductTest.php @@ -18,10 +18,10 @@ class SumProductTest extends TestCase * * @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 bcb00acc..f1165e7b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php @@ -18,10 +18,10 @@ class SumSqTest extends TestCase * * @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 1bfe5923..3bf2785b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php @@ -18,10 +18,10 @@ class SumX2MY2Test extends TestCase * * @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 c53630de..a370d79b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php @@ -18,10 +18,10 @@ class SumX2PY2Test extends TestCase * * @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 bb4dc527..1f64523b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php @@ -18,10 +18,10 @@ class SumXMY2Test extends TestCase * * @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 244889dc..5fc248cc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php @@ -18,10 +18,10 @@ class TruncTest extends TestCase * * @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 a61730ad..571c06c3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php @@ -18,10 +18,10 @@ class AveDevTest extends TestCase * * @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 6c5f4093..1af96dfc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php @@ -18,10 +18,10 @@ class AverageATest extends TestCase * * @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 f1b4081a..69dcfb87 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfTest.php @@ -18,10 +18,10 @@ class AverageIfTest extends TestCase * * @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 3d03524e..c67452ab 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php @@ -18,10 +18,10 @@ class AverageTest extends TestCase * * @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 1cd9280d..a85781e5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php @@ -18,10 +18,10 @@ class BetaDistTest extends TestCase * * @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 10c47c76..24ddd3fc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php @@ -18,10 +18,10 @@ class BetaInvTest extends TestCase * * @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 e4891546..8b3e6856 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php @@ -18,10 +18,10 @@ class BinomDistTest extends TestCase * * @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 d00d5fb0..9dc7326c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistTest.php @@ -18,10 +18,10 @@ class ChiDistTest extends TestCase * * @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 e2b93e95..72680914 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvTest.php @@ -18,10 +18,10 @@ class ChiInvTest extends TestCase * * @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 9a131ed0..d4bc586f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php @@ -18,10 +18,10 @@ class ConfidenceTest extends TestCase * * @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 f2bba8d7..52f773bc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php @@ -18,10 +18,10 @@ class CorrelTest extends TestCase * * @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 15f9c4bf..2df0ebd1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountATest.php @@ -18,10 +18,10 @@ class CountATest extends TestCase * * @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 8e61bb47..b0c6698b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php @@ -18,10 +18,10 @@ class CountBlankTest extends TestCase * * @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 7f1dd221..fed32e5c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php @@ -18,10 +18,10 @@ class CountIfTest extends TestCase * * @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 301c3f4c..1eeb4f67 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php @@ -18,10 +18,10 @@ class CountIfsTest extends TestCase * * @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 1bfac28e..26e621ec 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php @@ -18,10 +18,10 @@ class CountTest extends TestCase * * @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 @@ class CountTest extends TestCase * * @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 @@ class CountTest extends TestCase * * @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 @@ class CountTest extends TestCase * * @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 c34e36d2..5b73d1d9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php @@ -18,10 +18,10 @@ class CovarTest extends TestCase * * @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 cf3e8849..0296ab7b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php @@ -18,10 +18,10 @@ class ExponDistTest extends TestCase * * @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 f8eb7554..efd212c8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php @@ -19,10 +19,10 @@ class FisherInvTest extends TestCase * @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 5f9733ab..788ffc6a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php @@ -19,10 +19,10 @@ class FisherTest extends TestCase * @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 4de64500..6ecbb9c8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php @@ -18,10 +18,10 @@ class ForecastTest extends TestCase * * @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 41806e56..6765d340 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php @@ -18,10 +18,10 @@ class GammaDistTest extends TestCase * * @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 ad72277a..3e9e41cb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php @@ -18,10 +18,10 @@ class GammaInvTest extends TestCase * * @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 2fde78aa..d0ae623f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php @@ -19,10 +19,10 @@ class GammaLnTest extends TestCase * @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 6f8f6053..99f125d1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php @@ -18,10 +18,10 @@ class GeoMeanTest extends TestCase * * @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 38ad95db..5ddf58a8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HarMeanTest.php @@ -18,10 +18,10 @@ class HarMeanTest extends TestCase * * @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 e3f9383c..51245861 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php @@ -18,10 +18,10 @@ class InterceptTest extends TestCase * * @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 c8d3d02c..a031203a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php @@ -18,10 +18,10 @@ class MaxIfsTest extends TestCase * * @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 571fca23..c29d65e5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php @@ -18,10 +18,10 @@ class MedianTest extends TestCase * * @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 b8c1e291..f1740110 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php @@ -18,10 +18,10 @@ class MinIfsTest extends TestCase * * @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 d3eb6f32..9f811287 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 7e7ae7a7..98e39978 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php @@ -18,10 +18,10 @@ class PermutTest extends TestCase * * @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 a0959eac..423cc3ae 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php @@ -18,10 +18,10 @@ class RsqTest extends TestCase * * @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 fe28f5eb..467bff1e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php @@ -18,10 +18,10 @@ class SlopeTest extends TestCase * * @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 5ab6b662..ab109345 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php @@ -18,10 +18,10 @@ class SteyxTest extends TestCase * * @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 86483180..70ea7526 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php @@ -31,10 +31,10 @@ class CharTest extends TestCase * @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 63042fa5..6aedb599 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php @@ -31,10 +31,10 @@ class CleanTest extends TestCase * @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 b39b66bf..ec9f26d6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php @@ -31,10 +31,10 @@ class CodeTest extends TestCase * @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 6d32298e..18a2d684 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php @@ -30,10 +30,10 @@ class ConcatenateTest extends TestCase * * @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 3f0ae34f..4a0f6013 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php @@ -30,10 +30,10 @@ class DollarTest extends TestCase * * @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 ad44c03f..09d45a32 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php @@ -31,14 +31,14 @@ class ExactTest extends TestCase * @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 c20d7df3..38203a33 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php @@ -30,10 +30,10 @@ class FindTest extends TestCase * * @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 010278fc..53e6a513 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php @@ -30,10 +30,10 @@ class FixedTest extends TestCase * * @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 d1eba19e..9a033ae7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php @@ -30,10 +30,10 @@ class LeftTest extends TestCase * * @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 8e711fa9..af784163 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php @@ -31,10 +31,10 @@ class LenTest extends TestCase * @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 e329dda3..6ad522d8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php @@ -31,10 +31,10 @@ class LowerTest extends TestCase * @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 5bcc43fc..df02575f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php @@ -30,10 +30,10 @@ class MidTest extends TestCase * * @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 45e3c6be..006e4ce1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php @@ -29,12 +29,11 @@ class NumberValueTest extends TestCase * @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 13efbd9a..d799b395 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php @@ -31,10 +31,10 @@ class ProperTest extends TestCase * @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 f319b16e..ff3d58bb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php @@ -30,10 +30,10 @@ class ReplaceTest extends TestCase * * @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 216050c3..a89ea6ed 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php @@ -30,10 +30,10 @@ class RightTest extends TestCase * * @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 ab3fcb11..919ec0fb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php @@ -30,10 +30,10 @@ class SearchTest extends TestCase * * @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 89a89ba3..d1884fd8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php @@ -30,10 +30,10 @@ class SubstituteTest extends TestCase * * @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 56b00838..1ce989b4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php @@ -31,10 +31,10 @@ class TTest extends TestCase * @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 ec04ce13..7eec585c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php @@ -29,12 +29,11 @@ class TextJoinTest extends TestCase * @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 f7638e4c..eab517cc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php @@ -30,7 +30,7 @@ class TextTest extends TestCase * * @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 @@ class TextTest extends TestCase 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 d5907803..24ede75f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php @@ -31,10 +31,10 @@ class TrimTest extends TestCase * @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 a69d8279..1600f37c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php @@ -31,10 +31,10 @@ class UpperTest extends TestCase * @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 b2e31ba3..a5083b22 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php @@ -31,14 +31,14 @@ class ValueTest extends TestCase * @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 94788c2d..4412215a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php @@ -22,85 +22,85 @@ class FunctionsTest extends TestCase 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 @@ class FunctionsTest extends TestCase * * @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 @@ class FunctionsTest extends TestCase * * @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 @@ class FunctionsTest extends TestCase * * @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 @@ class FunctionsTest extends TestCase * * @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 @@ class FunctionsTest extends TestCase * * @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 @@ class FunctionsTest extends TestCase * * @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 @@ class FunctionsTest extends TestCase * * @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 @@ class FunctionsTest extends TestCase * * @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 @@ class FunctionsTest extends TestCase * * @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 @@ class FunctionsTest extends TestCase * * @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 @@ class FunctionsTest extends TestCase * * @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 @@ class FunctionsTest extends TestCase * * @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 @@ class FunctionsTest extends TestCase * * @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 @@ class FunctionsTest extends TestCase * @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 @@ class FunctionsTest extends TestCase ->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 @@ class FunctionsTest extends TestCase * * @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 dff80fad..04dc0a32 100644 --- a/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php @@ -26,7 +26,7 @@ class LookupRefTest extends TestCase * @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 @@ class LookupRefTest extends TestCase ->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 fe770731..936092d4 100644 --- a/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php +++ b/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php @@ -40,7 +40,7 @@ class AdvancedValueBinderTest extends TestCase * @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 @@ class AdvancedValueBinderTest extends TestCase $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 15e1d384..8c95e864 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 @@ class CellTest extends TestCase /** * @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 7a12ceb7..37579e80 100644 --- a/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php @@ -5,6 +5,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Cell; 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 @@ class CoordinateTest extends TestCase return require 'tests/data/ColumnString.php'; } - public function testColumnIndexFromStringTooLong() + public function testColumnIndexFromStringTooLong(): void { $cellAddress = 'ABCD'; @@ -40,10 +41,10 @@ class CoordinateTest extends TestCase 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 @@ class CoordinateTest extends TestCase return; } - $this->fail('An expected exception has not been raised.'); + self::fail('An expected exception has not been raised.'); } /** @@ -64,7 +65,7 @@ class CoordinateTest extends TestCase * @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 @@ class CoordinateTest extends TestCase * * @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 @@ class CoordinateTest extends TestCase return require 'tests/data/CellCoordinates.php'; } - public function testCoordinateFromStringWithRangeAddress() + public function testCoordinateFromStringWithRangeAddress(): void { $cellAddress = 'A1:AI2012'; @@ -106,10 +107,10 @@ class CoordinateTest extends TestCase 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 @@ class CoordinateTest extends TestCase 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 @@ class CoordinateTest extends TestCase return; } - $this->fail('An expected exception has not been raised.'); + self::fail('An expected exception has not been raised.'); } /** @@ -144,7 +145,7 @@ class CoordinateTest extends TestCase * * @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 @@ class CoordinateTest extends TestCase return require 'tests/data/CellAbsoluteCoordinate.php'; } - public function testAbsoluteCoordinateFromStringWithRangeAddress() + public function testAbsoluteCoordinateFromStringWithRangeAddress(): void { $cellAddress = 'A1:AI2012'; @@ -167,7 +168,7 @@ class CoordinateTest extends TestCase return; } - $this->fail('An expected exception has not been raised.'); + self::fail('An expected exception has not been raised.'); } /** @@ -175,7 +176,7 @@ class CoordinateTest extends TestCase * * @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 @@ class CoordinateTest extends TestCase return require 'tests/data/CellAbsoluteReference.php'; } - public function testAbsoluteReferenceFromStringWithRangeAddress() + public function testAbsoluteReferenceFromStringWithRangeAddress(): void { $cellAddress = 'A1:AI2012'; @@ -198,7 +199,7 @@ class CoordinateTest extends TestCase return; } - $this->fail('An expected exception has not been raised.'); + self::fail('An expected exception has not been raised.'); } /** @@ -206,7 +207,7 @@ class CoordinateTest extends TestCase * * @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 @@ class CoordinateTest extends TestCase * * @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 @@ class CoordinateTest extends TestCase 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 @@ class CoordinateTest extends TestCase * * @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 @@ class CoordinateTest extends TestCase * * @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 @@ class CoordinateTest extends TestCase * * @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 @@ class CoordinateTest extends TestCase * * @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 @@ class CoordinateTest extends TestCase * * @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 @@ class CoordinateTest extends TestCase * * @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 @@ class CoordinateTest extends TestCase * * @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 8acba297..95454c16 100644 --- a/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php @@ -8,7 +8,7 @@ use PHPUnit\Framework\TestCase; class DataTypeTest extends TestCase { - public function testGetErrorCodes() + public function testGetErrorCodes(): void { $result = DataType::getErrorCodes(); self::assertIsArray($result); @@ -16,7 +16,7 @@ class DataTypeTest extends TestCase 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 c41c0335..62be68dd 100644 --- a/tests/PhpSpreadsheetTests/Cell/DataValidationTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DataValidationTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; 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 9d4db699..bae315af 100644 --- a/tests/PhpSpreadsheetTests/Cell/DataValidatorTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DataValidatorTest.php @@ -8,7 +8,7 @@ use PHPUnit\Framework\TestCase; class DataValidatorTest extends TestCase { - public function testNoValidation() + public function testNoValidation(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -17,7 +17,7 @@ class DataValidatorTest extends TestCase 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 @@ class DataValidatorTest extends TestCase 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 d22e03cb..90dabce3 100644 --- a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php @@ -21,9 +21,9 @@ class DefaultValueBinderTest extends TestCase ->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 @@ class DefaultValueBinderTest extends TestCase * * @param mixed $value */ - public function testBindValue($value) + public function testBindValue($value): void { $cellStub = $this->createCellStub(); $binder = new DefaultValueBinder(); @@ -65,7 +65,7 @@ class DefaultValueBinderTest extends TestCase * * @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 @@ class DefaultValueBinderTest extends TestCase 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 @@ class DefaultValueBinderTest extends TestCase 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 b1337a0b..9c09aa75 100644 --- a/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php +++ b/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; class HyperlinkTest extends TestCase { - public function testGetUrl() + public function testGetUrl(): void { $urlValue = 'https://www.example.com'; @@ -17,7 +17,7 @@ class HyperlinkTest extends TestCase 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 @@ class HyperlinkTest extends TestCase self::assertEquals($newUrlValue, $result); } - public function testGetTooltip() + public function testGetTooltip(): void { $tooltipValue = 'PhpSpreadsheet Web Site'; @@ -40,7 +40,7 @@ class HyperlinkTest extends TestCase self::assertEquals($tooltipValue, $result); } - public function testSetTooltip() + public function testSetTooltip(): void { $initialTooltipValue = 'PhpSpreadsheet Web Site'; $newTooltipValue = 'PhpSpreadsheet Repository on Github'; @@ -53,7 +53,7 @@ class HyperlinkTest extends TestCase self::assertEquals($newTooltipValue, $result); } - public function testIsInternal() + public function testIsInternal(): void { $initialUrlValue = 'https://www.example.com'; $newUrlValue = 'sheet://Worksheet1!A1'; @@ -67,7 +67,7 @@ class HyperlinkTest extends TestCase 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 6641cc6b..c34ca697 100644 --- a/tests/PhpSpreadsheetTests/Chart/DataSeriesValuesTest.php +++ b/tests/PhpSpreadsheetTests/Chart/DataSeriesValuesTest.php @@ -8,7 +8,7 @@ use PHPUnit\Framework\TestCase; class DataSeriesValuesTest extends TestCase { - public function testSetDataType() + public function testSetDataType(): void { $dataTypeValues = [ 'Number', @@ -23,7 +23,7 @@ class DataSeriesValuesTest extends TestCase } } - public function testSetInvalidDataTypeThrowsException() + public function testSetInvalidDataTypeThrowsException(): void { $testInstance = new DataSeriesValues(); @@ -34,10 +34,10 @@ class DataSeriesValuesTest extends TestCase 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 @@ class DataSeriesValuesTest extends TestCase 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 @@ class DataSeriesValuesTest extends TestCase self::assertEquals(12700, $testInstance->getLineWidth(), 'should enforce minimum width'); } - public function testFillColorCorrectInput() + public function testFillColorCorrectInput(): void { $testInstance = new DataSeriesValues(); @@ -68,7 +68,7 @@ class DataSeriesValuesTest extends TestCase 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 @@ class DataSeriesValuesTest extends TestCase $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 9ae80460..8e927985 100644 --- a/tests/PhpSpreadsheetTests/Chart/LayoutTest.php +++ b/tests/PhpSpreadsheetTests/Chart/LayoutTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; class LayoutTest extends TestCase { - public function testSetLayoutTarget() + public function testSetLayoutTarget(): void { $LayoutTargetValue = 'String'; @@ -17,7 +17,7 @@ class LayoutTest extends TestCase 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 e21baaf5..30715365 100644 --- a/tests/PhpSpreadsheetTests/Chart/LegendTest.php +++ b/tests/PhpSpreadsheetTests/Chart/LegendTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; class LegendTest extends TestCase { - public function testSetPosition() + public function testSetPosition(): void { $positionValues = [ Legend::POSITION_RIGHT, @@ -25,7 +25,7 @@ class LegendTest extends TestCase } } - public function testSetInvalidPositionReturnsFalse() + public function testSetInvalidPositionReturnsFalse(): void { $testInstance = new Legend(); @@ -36,7 +36,7 @@ class LegendTest extends TestCase self::assertEquals(Legend::POSITION_RIGHT, $result); } - public function testGetPosition() + public function testGetPosition(): void { $PositionValue = Legend::POSITION_BOTTOM; @@ -47,7 +47,7 @@ class LegendTest extends TestCase self::assertEquals($PositionValue, $result); } - public function testSetPositionXL() + public function testSetPositionXL(): void { $positionValues = [ Legend::XL_LEGEND_POSITION_BOTTOM, @@ -66,7 +66,7 @@ class LegendTest extends TestCase } } - public function testSetInvalidXLPositionReturnsFalse() + public function testSetInvalidXLPositionReturnsFalse(): void { $testInstance = new Legend(); @@ -77,7 +77,7 @@ class LegendTest extends TestCase 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 @@ class LegendTest extends TestCase self::assertEquals($PositionValue, $result); } - public function testSetOverlay() + public function testSetOverlay(): void { $overlayValues = [ true, @@ -103,7 +103,7 @@ class LegendTest extends TestCase } } - public function testSetInvalidOverlayReturnsFalse() + public function testSetInvalidOverlayReturnsFalse(): void { $testInstance = new Legend(); @@ -114,7 +114,7 @@ class LegendTest extends TestCase 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 e1dcfc8f..539d0232 100644 --- a/tests/PhpSpreadsheetTests/Collection/CellsTest.php +++ b/tests/PhpSpreadsheetTests/Collection/CellsTest.php @@ -11,7 +11,7 @@ use PHPUnit\Framework\TestCase; class CellsTest extends TestCase { - public function testCollectionCell() + public function testCollectionCell(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -63,7 +63,7 @@ class CellsTest extends TestCase 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 @@ class CellsTest extends TestCase 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 @@ class CellsTest extends TestCase 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 @@ class CellsTest extends TestCase $collection->get('A2'); } - public function testThrowsWhenCellCannotBeStoredInCache() + public function testThrowsWhenCellCannotBeStoredInCache(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -115,20 +115,20 @@ class CellsTest extends TestCase $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 d039dab0..4d1025d2 100644 --- a/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php +++ b/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php @@ -27,7 +27,7 @@ class ComplexAssert 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 214fe593..ac9af838 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 @@ class DocumentGeneratorTest extends TestCase /** * @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 da9f76e0..f242c698 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 9274e9c4..56682b34 100644 --- a/tests/PhpSpreadsheetTests/Functional/ActiveSheetTest.php +++ b/tests/PhpSpreadsheetTests/Functional/ActiveSheetTest.php @@ -20,7 +20,7 @@ class ActiveSheetTest extends AbstractFunctional * * @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 6d4fc2ca..5cd0aec7 100644 --- a/tests/PhpSpreadsheetTests/Functional/ColumnWidthTest.php +++ b/tests/PhpSpreadsheetTests/Functional/ColumnWidthTest.php @@ -18,7 +18,7 @@ class ColumnWidthTest extends AbstractFunctional * * @param $format */ - public function testReadColumnWidth($format) + public function testReadColumnWidth($format): void { // create new sheet with column width $spreadsheet = new Spreadsheet(); @@ -31,7 +31,7 @@ class ColumnWidthTest extends AbstractFunctional $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 a394c967..6f1c5340 100644 --- a/tests/PhpSpreadsheetTests/Functional/CommentsTest.php +++ b/tests/PhpSpreadsheetTests/Functional/CommentsTest.php @@ -23,7 +23,7 @@ class CommentsTest extends AbstractFunctional * * @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 3aa3f949..3183450f 100644 --- a/tests/PhpSpreadsheetTests/Functional/ConditionalStopIfTrueTest.php +++ b/tests/PhpSpreadsheetTests/Functional/ConditionalStopIfTrueTest.php @@ -21,7 +21,7 @@ class ConditionalStopIfTrueTest extends AbstractFunctional * * @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 99333150..7a8e2cda 100644 --- a/tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php +++ b/tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php @@ -8,7 +8,7 @@ use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing; 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 3a5f9616..1f1cb7eb 100644 --- a/tests/PhpSpreadsheetTests/Functional/EnclosureTest.php +++ b/tests/PhpSpreadsheetTests/Functional/EnclosureTest.php @@ -22,7 +22,7 @@ class EnclosureTest extends AbstractFunctional * * @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 38709716..4e725d03 100644 --- a/tests/PhpSpreadsheetTests/Functional/FreezePaneTest.php +++ b/tests/PhpSpreadsheetTests/Functional/FreezePaneTest.php @@ -19,7 +19,7 @@ class FreezePaneTest extends AbstractFunctional * * @param string $format */ - public function testFreezePane($format) + public function testFreezePane($format): void { $cellSplit = 'B4'; $topLeftCell = 'E7'; @@ -43,7 +43,7 @@ class FreezePaneTest extends AbstractFunctional * * @param string $format */ - public function testFreezePaneWithInvalidSelectedCells($format) + public function testFreezePaneWithInvalidSelectedCells($format): void { $cellSplit = 'A7'; $topLeftCell = 'A24'; @@ -71,7 +71,7 @@ class FreezePaneTest extends AbstractFunctional * * @param string $format */ - public function testFreezePaneUserSelectedCell($format) + public function testFreezePaneUserSelectedCell($format): void { $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); @@ -100,7 +100,7 @@ class FreezePaneTest extends AbstractFunctional * * @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 7a601949..39865817 100644 --- a/tests/PhpSpreadsheetTests/Functional/MergedCellsTest.php +++ b/tests/PhpSpreadsheetTests/Functional/MergedCellsTest.php @@ -21,7 +21,7 @@ class MergedCellsTest extends AbstractFunctional * * @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 7c3a9112..a335fd2f 100644 --- a/tests/PhpSpreadsheetTests/Functional/PrintAreaTest.php +++ b/tests/PhpSpreadsheetTests/Functional/PrintAreaTest.php @@ -20,7 +20,7 @@ class PrintAreaTest extends AbstractFunctional * * @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 @@ class PrintAreaTest extends AbstractFunctional $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 02c752ac..9dac3437 100644 --- a/tests/PhpSpreadsheetTests/Functional/ReadBlankCellsTest.php +++ b/tests/PhpSpreadsheetTests/Functional/ReadBlankCellsTest.php @@ -22,10 +22,9 @@ class ReadBlankCellsTest extends AbstractFunctional * * @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 @@ class ReadBlankCellsTest extends AbstractFunctional $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 288fc57e..efca228c 100644 --- a/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php +++ b/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php @@ -34,10 +34,9 @@ class ReadFilterTest extends AbstractFunctional * * @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 @@ class ReadFilterTest extends AbstractFunctional * * @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 03d4be9f..625f2428 100644 --- a/tests/PhpSpreadsheetTests/Functional/SelectedCellsTest.php +++ b/tests/PhpSpreadsheetTests/Functional/SelectedCellsTest.php @@ -20,7 +20,7 @@ class SelectedCellsTest extends AbstractFunctional * * @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 20e588bb..dcca6b8a 100644 --- a/tests/PhpSpreadsheetTests/Functional/StreamTest.php +++ b/tests/PhpSpreadsheetTests/Functional/StreamTest.php @@ -24,8 +24,6 @@ class StreamTest extends TestCase /** * @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 cca3777a..e6d6377b 100644 --- a/tests/PhpSpreadsheetTests/Functional/TypeAttributePreservationTest.php +++ b/tests/PhpSpreadsheetTests/Functional/TypeAttributePreservationTest.php @@ -27,9 +27,8 @@ class TypeAttributePreservationTest extends AbstractFunctional * @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 cce2a95b..f97ad9cf 100644 --- a/tests/PhpSpreadsheetTests/Functional/WorkbookViewAttributesTest.php +++ b/tests/PhpSpreadsheetTests/Functional/WorkbookViewAttributesTest.php @@ -24,7 +24,7 @@ class WorkbookViewAttributesTest extends AbstractFunctional * * @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 @@ class WorkbookViewAttributesTest extends AbstractFunctional $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 @@ class WorkbookViewAttributesTest extends AbstractFunctional $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 b15a7285..d47c2f64 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 6bd9c422..eb729dc9 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 5084354f..983ba35e 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 @@ class IOFactoryTest extends TestCase ]; } - public function testRegisterWriter() + public function testRegisterWriter(): void { IOFactory::registerWriter('Pdf', Writer\Pdf\Mpdf::class); $spreadsheet = new Spreadsheet(); @@ -51,7 +52,7 @@ class IOFactoryTest extends TestCase * @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 @@ class IOFactoryTest extends TestCase ]; } - public function testRegisterReader() + public function testRegisterReader(): void { IOFactory::registerReader('Custom', Reader\Html::class); $actual = IOFactory::createReader('Custom'); @@ -85,7 +86,7 @@ class IOFactoryTest extends TestCase * @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 @@ class IOFactoryTest extends TestCase * @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 @@ class IOFactoryTest extends TestCase * @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 @@ class IOFactoryTest extends TestCase ]; } - 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 1743c433..c7474c6a 100644 --- a/tests/PhpSpreadsheetTests/Reader/CondNumFmtTest.php +++ b/tests/PhpSpreadsheetTests/Reader/CondNumFmtTest.php @@ -8,7 +8,7 @@ use PHPUnit\Framework\TestCase; 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 95f7e787..9bc16ae0 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 4920c001..3a417791 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 @@ class CsvContiguousTest extends TestCase 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 3b6c61b8..cb2b6196 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 @@ class CsvTest extends TestCase * @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 @@ class CsvTest extends TestCase ]; } - public function testEscapeCharacters() + public function testEscapeCharacters(): void { $reader = (new Csv())->setEscapeCharacter('"'); $worksheet = $reader->load('tests/data/Reader/CSV/backslash.csv') @@ -128,8 +128,8 @@ class CsvTest extends TestCase ['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 @@ class CsvTest extends TestCase * @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 @@ class CsvTest extends TestCase self::assertEquals('Ã…', $sheet->getCell('A1')->getValue()); } - public function testInvalidWorkSheetInfo() + public function testInvalidWorkSheetInfo(): void { $this->expectException(ReaderException::class); $reader = new Csv(); @@ -160,7 +160,7 @@ class CsvTest extends TestCase * @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 @@ class CsvTest extends TestCase ]; } - public function testUtf16LineBreak() + public function testUtf16LineBreak(): void { $reader = new Csv(); $reader->setInputEncoding('UTF-16BE'); @@ -200,7 +200,7 @@ EOF; self::assertEquals($expected, $sheet->getCell('B3')->getValue()); } - public function testSeparatorLine() + public function testSeparatorLine(): void { $reader = new Csv(); $reader->setSheetIndex(3); @@ -215,7 +215,7 @@ EOF; 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 @@ EOF; self::assertEquals('"', $reader->getEnclosure()); } - public function testReadEmptyFileName() + public function testReadEmptyFileName(): void { $this->expectException(ReaderException::class); $reader = new Csv(); @@ -234,7 +234,7 @@ EOF; $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 14cccb6b..b0994a33 100644 --- a/tests/PhpSpreadsheetTests/Reader/HtmlTest.php +++ b/tests/PhpSpreadsheetTests/Reader/HtmlTest.php @@ -11,7 +11,7 @@ use PHPUnit\Framework\TestCase; 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 @@ class HtmlTest extends TestCase * @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 @@ class HtmlTest extends TestCase unlink($filename); } - public function testBackgroundColorInRanding() + public function testBackgroundColorInRanding(): void { $html = ' @@ -64,7 +64,7 @@ class HtmlTest extends TestCase unlink($filename); } - public function testCanApplyInlineBordersStyles() + public function testCanApplyInlineBordersStyles(): void { $html = '
@@ -110,7 +110,7 @@ class HtmlTest extends TestCase unlink($filename); } - public function testCanApplyInlineFontStyles() + public function testCanApplyInlineFontStyles(): void { $html = '
@@ -147,7 +147,7 @@ class HtmlTest extends TestCase unlink($filename); } - public function testCanApplyInlineWidth() + public function testCanApplyInlineWidth(): void { $html = '
@@ -168,7 +168,7 @@ class HtmlTest extends TestCase unlink($filename); } - public function testCanApplyInlineHeight() + public function testCanApplyInlineHeight(): void { $html = '
@@ -191,7 +191,7 @@ class HtmlTest extends TestCase unlink($filename); } - public function testCanApplyAlignment() + public function testCanApplyAlignment(): void { $html = '
@@ -228,7 +228,7 @@ class HtmlTest extends TestCase unlink($filename); } - public function testCanApplyInlineDataFormat() + public function testCanApplyInlineDataFormat(): void { $html = '
@@ -245,7 +245,7 @@ class HtmlTest extends TestCase unlink($filename); } - public function testCanInsertImage() + public function testCanInsertImage(): void { $imagePath = realpath(__DIR__ . '/../../data/Reader/HTML/image.jpg'); @@ -266,7 +266,7 @@ class HtmlTest extends TestCase unlink($filename); } - public function testCanApplyCellWrapping() + public function testCanApplyCellWrapping(): void { $html = '
@@ -289,17 +289,17 @@ class HtmlTest extends TestCase $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 @@ class HtmlTest extends TestCase $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 @@ class HtmlTest extends TestCase $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 @@ class HtmlTest extends TestCase 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 @@ class HtmlTest extends TestCase 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 82813b74..6b111497 100644 --- a/tests/PhpSpreadsheetTests/Reader/OdsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/OdsTest.php @@ -56,7 +56,7 @@ class OdsTest extends TestCase return $this->spreadsheetData; } - public function testReadFileProperties() + public function testReadFileProperties(): void { $filename = 'tests/data/Reader/Ods/data.ods'; @@ -71,7 +71,7 @@ class OdsTest extends TestCase ], $reader->listWorksheetNames($filename)); } - public function testLoadWorksheets() + public function testLoadWorksheets(): void { $spreadsheet = $this->loadDataFile(); @@ -86,7 +86,7 @@ class OdsTest extends TestCase self::assertInstanceOf('PhpOffice\PhpSpreadsheet\Worksheet\Worksheet', $secondSheet); } - public function testReadValueAndComments() + public function testReadValueAndComments(): void { $spreadsheet = $this->loadOdsTestFile(); @@ -151,7 +151,7 @@ class OdsTest extends TestCase 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 @@ class OdsTest extends TestCase 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 @@ class OdsTest extends TestCase ); } - public function testReadCellsWithRepeatedSpaces() + public function testReadCellsWithRepeatedSpaces(): void { $spreadsheet = $this->loadDataFile(); $firstSheet = $spreadsheet->getSheet(0); @@ -188,7 +188,7 @@ class OdsTest extends TestCase 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 @@ class OdsTest extends TestCase // 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 @@ class OdsTest extends TestCase 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 4bf46429..8f42af10 100644 --- a/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner; use PhpOffice\PhpSpreadsheet\Reader\Xls; use PhpOffice\PhpSpreadsheet\Reader\Xlsx; use PHPUnit\Framework\TestCase; +use XMLReader; class XmlScannerTest extends TestCase { @@ -21,7 +22,7 @@ class XmlScannerTest extends TestCase * @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 @@ class XmlScannerTest extends TestCase * @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 @@ class XmlScannerTest extends TestCase return $tests; } - public function testGetSecurityScannerForXmlBasedReader() + public function testGetSecurityScannerForXmlBasedReader(): void { $fileReader = new Xlsx(); $scanner = $fileReader->getSecurityScanner(); @@ -84,15 +85,15 @@ class XmlScannerTest extends TestCase // 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 @@ class XmlScannerTest extends TestCase * @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 @@ class XmlScannerTest extends TestCase 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 dd6344b4..77ad91fa 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 90ea17aa..63da2d05 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/AutoFilterTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/AutoFilterTest.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Reader\Xlsx\AutoFilter; 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 @@ class AutoFilterTest extends TestCase private function getXMLInstance($ref) { - return new \SimpleXMLElement( + return new SimpleXMLElement( '' . '' . '' . @@ -50,15 +51,15 @@ class AutoFilterTest extends TestCase * @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 b77796c6..4d0b6a8a 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx2Test.php @@ -19,7 +19,7 @@ class Xlsx2Test extends TestCase } } - 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 @@ class Xlsx2Test extends TestCase 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 @@ class Xlsx2Test extends TestCase 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 efa7af72..9e0b5f66 100644 --- a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php @@ -14,7 +14,7 @@ use PHPUnit\Framework\TestCase; 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 @@ class XlsxTest extends TestCase $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 @@ class XlsxTest extends TestCase $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 @@ class XlsxTest extends TestCase $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 @@ class XlsxTest extends TestCase } } - public function testLoadXlsxAutofilter() + public function testLoadXlsxAutofilter(): void { $filename = 'tests/data/Reader/XLSX/autofilterTest.xlsx'; $reader = new Xlsx(); @@ -112,15 +112,15 @@ class XlsxTest extends TestCase $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 @@ class XlsxTest extends TestCase $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 @@ class XlsxTest extends TestCase $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 @@ class XlsxTest extends TestCase $worksheet = $spreadsheet->getActiveSheet(); - $this->assertTrue($worksheet->getCell('B3')->hasDataValidation()); + self::assertTrue($worksheet->getCell('B3')->hasDataValidation()); } /** @@ -174,7 +174,7 @@ class XlsxTest extends TestCase * * @doesNotPerformAssertions */ - public function testLoadXlsxWithoutCellReference() + public function testLoadXlsxWithoutCellReference(): void { $filename = 'tests/data/Reader/XLSX/without_cell_reference.xlsx'; $reader = new Xlsx(); @@ -184,7 +184,7 @@ class XlsxTest extends TestCase /** * 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 @@ class XlsxTest extends TestCase $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 @@ class XlsxTest extends TestCase * * @doesNotPerformAssertions */ - public function testLoadXlsxWithDoubleAttrDrawing() + public function testLoadXlsxWithDoubleAttrDrawing(): void { $filename = 'tests/data/Reader/XLSX/double_attr_drawing.xlsx'; $reader = new Xlsx(); @@ -213,7 +213,7 @@ class XlsxTest extends TestCase * 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 @@ class XlsxTest extends TestCase $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 @@ class XlsxTest extends TestCase * @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 116ec03e..a8de8774 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 @@ class XmlTest extends TestCase /** * 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 @@ class XmlTest extends TestCase 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 6de3d792..374b63c9 100644 --- a/tests/PhpSpreadsheetTests/ReferenceHelperTest.php +++ b/tests/PhpSpreadsheetTests/ReferenceHelperTest.php @@ -11,7 +11,7 @@ class ReferenceHelperTest extends TestCase { } - public function testColumnSort() + public function testColumnSort(): void { $columnBase = $columnExpectedResult = [ 'A', 'B', 'Z', @@ -32,7 +32,7 @@ class ReferenceHelperTest extends TestCase } } - public function testColumnReverseSort() + public function testColumnReverseSort(): void { $columnBase = $columnExpectedResult = [ 'A', 'B', 'Z', @@ -54,7 +54,7 @@ class ReferenceHelperTest extends TestCase } } - public function testCellSort() + public function testCellSort(): void { $cellBase = $columnExpectedResult = [ 'A1', 'B1', 'AZB1', @@ -75,7 +75,7 @@ class ReferenceHelperTest extends TestCase } } - 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 1a1d24e7..4dff2d25 100644 --- a/tests/PhpSpreadsheetTests/SettingsTest.php +++ b/tests/PhpSpreadsheetTests/SettingsTest.php @@ -23,14 +23,14 @@ class SettingsTest extends TestCase 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 e3638687..b86f9015 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 @@ class CodePageTest extends TestCase return require 'tests/data/Shared/CodePage.php'; } - public function testNumberToNameWithInvalidCodePage() + public function testNumberToNameWithInvalidCodePage(): void { $invalidCodePage = 12345; @@ -35,10 +35,10 @@ class CodePageTest extends TestCase 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 @@ class CodePageTest extends TestCase 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 14930677..23b31076 100644 --- a/tests/PhpSpreadsheetTests/Shared/DateTest.php +++ b/tests/PhpSpreadsheetTests/Shared/DateTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; class DateTest extends TestCase { - public function testSetExcelCalendar() + public function testSetExcelCalendar(): void { $calendarValues = [ Date::CALENDAR_MAC_1904, @@ -20,7 +20,7 @@ class DateTest extends TestCase } } - public function testSetExcelCalendarWithInvalidValue() + public function testSetExcelCalendarWithInvalidValue(): void { $unsupportedCalendar = '2012'; $result = Date::setExcelCalendar($unsupportedCalendar); @@ -32,7 +32,7 @@ class DateTest extends TestCase * * @param mixed $expectedResult */ - public function testDateTimeExcelToTimestamp1900($expectedResult, ...$args) + public function testDateTimeExcelToTimestamp1900($expectedResult, ...$args): void { Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); @@ -50,7 +50,7 @@ class DateTest extends TestCase * * @param mixed $expectedResult */ - public function testDateTimeTimestampToExcel1900($expectedResult, ...$args) + public function testDateTimeTimestampToExcel1900($expectedResult, ...$args): void { Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); @@ -68,7 +68,7 @@ class DateTest extends TestCase * * @param mixed $expectedResult */ - public function testDateTimeDateTimeToExcel($expectedResult, ...$args) + public function testDateTimeDateTimeToExcel($expectedResult, ...$args): void { Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); @@ -86,7 +86,7 @@ class DateTest extends TestCase * * @param mixed $expectedResult */ - public function testDateTimeFormattedPHPToExcel1900($expectedResult, ...$args) + public function testDateTimeFormattedPHPToExcel1900($expectedResult, ...$args): void { Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); @@ -104,7 +104,7 @@ class DateTest extends TestCase * * @param mixed $expectedResult */ - public function testDateTimeExcelToTimestamp1904($expectedResult, ...$args) + public function testDateTimeExcelToTimestamp1904($expectedResult, ...$args): void { Date::setExcelCalendar(Date::CALENDAR_MAC_1904); @@ -122,7 +122,7 @@ class DateTest extends TestCase * * @param mixed $expectedResult */ - public function testDateTimeTimestampToExcel1904($expectedResult, ...$args) + public function testDateTimeTimestampToExcel1904($expectedResult, ...$args): void { Date::setExcelCalendar(Date::CALENDAR_MAC_1904); @@ -140,7 +140,7 @@ class DateTest extends TestCase * * @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 @@ class DateTest extends TestCase * * @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 91c68bfc..6b9500f6 100644 --- a/tests/PhpSpreadsheetTests/Shared/FileTest.php +++ b/tests/PhpSpreadsheetTests/Shared/FileTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; class FileTest extends TestCase { - public function testGetUseUploadTempDirectory() + public function testGetUseUploadTempDirectory(): void { $expectedResult = false; @@ -15,7 +15,7 @@ class FileTest extends TestCase 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 03ff2c4e..5eb70852 100644 --- a/tests/PhpSpreadsheetTests/Shared/FontTest.php +++ b/tests/PhpSpreadsheetTests/Shared/FontTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; class FontTest extends TestCase { - public function testGetAutoSizeMethod() + public function testGetAutoSizeMethod(): void { $expectedResult = Font::AUTOSIZE_METHOD_APPROX; @@ -15,7 +15,7 @@ class FontTest extends TestCase self::assertEquals($expectedResult, $result); } - public function testSetAutoSizeMethod() + public function testSetAutoSizeMethod(): void { $autosizeMethodValues = [ Font::AUTOSIZE_METHOD_EXACT, @@ -28,7 +28,7 @@ class FontTest extends TestCase } } - public function testSetAutoSizeMethodWithInvalidValue() + public function testSetAutoSizeMethodWithInvalidValue(): void { $unsupportedAutosizeMethod = 'guess'; @@ -41,7 +41,7 @@ class FontTest extends TestCase * * @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 @@ class FontTest extends TestCase * * @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 @@ class FontTest extends TestCase * * @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 6135232c..7fe485c9 100644 --- a/tests/PhpSpreadsheetTests/Shared/OLEReadTest.php +++ b/tests/PhpSpreadsheetTests/Shared/OLEReadTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; 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 e92e0886..0d286725 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 fd1ec153..b11bf764 100644 --- a/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php +++ b/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php @@ -15,13 +15,13 @@ class StringHelperTest extends TestCase 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 @@ class StringHelperTest extends TestCase self::assertEquals($expectedResult, $result); } - public function testSetDecimalSeparator() + public function testSetDecimalSeparator(): void { $expectedResult = ','; StringHelper::setDecimalSeparator($expectedResult); @@ -39,7 +39,7 @@ class StringHelperTest extends TestCase self::assertEquals($expectedResult, $result); } - public function testGetThousandsSeparator() + public function testGetThousandsSeparator(): void { $localeconv = localeconv(); @@ -48,7 +48,7 @@ class StringHelperTest extends TestCase self::assertEquals($expectedResult, $result); } - public function testSetThousandsSeparator() + public function testSetThousandsSeparator(): void { $expectedResult = ' '; StringHelper::setThousandsSeparator($expectedResult); @@ -57,7 +57,7 @@ class StringHelperTest extends TestCase 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 @@ class StringHelperTest extends TestCase self::assertEquals($expectedResult, $result); } - public function testSetCurrencyCode() + public function testSetCurrencyCode(): void { $expectedResult = '£'; StringHelper::setCurrencyCode($expectedResult); @@ -74,7 +74,7 @@ class StringHelperTest extends TestCase 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 @@ class StringHelperTest extends TestCase 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 @@ class StringHelperTest extends TestCase 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 def37fa8..f6e2f5d5 100644 --- a/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php +++ b/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; class TimeZoneTest extends TestCase { - public function testSetTimezone() + public function testSetTimezone(): void { $timezoneValues = [ 'Europe/Prague', @@ -23,7 +23,7 @@ class TimeZoneTest extends TestCase } } - 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 498ce27b..05fbe1b5 100644 --- a/tests/PhpSpreadsheetTests/SpreadsheetTest.php +++ b/tests/PhpSpreadsheetTests/SpreadsheetTest.php @@ -49,8 +49,8 @@ class SpreadsheetTest extends TestCase * * @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 115e830d..aec5520d 100644 --- a/tests/PhpSpreadsheetTests/Style/BorderRangeTest.php +++ b/tests/PhpSpreadsheetTests/Style/BorderRangeTest.php @@ -9,7 +9,7 @@ use PHPUnit\Framework\TestCase; 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 @@ class BorderRangeTest extends TestCase } } - 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 7efe935a..f1f1bf56 100644 --- a/tests/PhpSpreadsheetTests/Style/BorderTest.php +++ b/tests/PhpSpreadsheetTests/Style/BorderTest.php @@ -8,7 +8,7 @@ use PHPUnit\Framework\TestCase; 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 5bd2f208..9b524e93 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 @@ class ColorTest extends TestCase * * @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 @@ class ColorTest extends TestCase * * @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 @@ class ColorTest extends TestCase * * @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 ba44b6af..e995eded 100644 --- a/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php +++ b/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php @@ -19,7 +19,7 @@ class NumberFormatTest extends TestCase * * @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 @@ class NumberFormatTest extends TestCase * * @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 @@ class NumberFormatTest extends TestCase 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 4a0e5c2c..156a95de 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/Column/RuleTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/Column/RuleTest.php @@ -22,13 +22,13 @@ class RuleTest extends TestCase ); } - 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 @@ class RuleTest extends TestCase self::assertEquals($expectedResult, $result); } - public function testSetValue() + public function testSetValue(): void { $expectedResult = 100; @@ -52,13 +52,13 @@ class RuleTest extends TestCase 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 @@ class RuleTest extends TestCase self::assertEquals($expectedResult, $result); } - public function testSetGrouping() + public function testSetGrouping(): void { $expectedResult = Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH; @@ -82,20 +82,20 @@ class RuleTest extends TestCase 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 fd462b43..ef67b05d 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php @@ -19,20 +19,20 @@ class ColumnTest extends TestCase ->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 @@ class ColumnTest extends TestCase 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 @@ class ColumnTest extends TestCase 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 @@ class ColumnTest extends TestCase $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 @@ class ColumnTest extends TestCase 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 @@ class ColumnTest extends TestCase $this->testAutoFilterColumnObject->setJoin($expectedResult); } - public function testSetAttributes() + public function testSetAttributes(): void { $attributeSet = [ 'val' => 100, @@ -117,7 +117,7 @@ class ColumnTest extends TestCase self::assertInstanceOf(AutoFilter\Column::class, $result); } - public function testGetAttributes() + public function testGetAttributes(): void { $attributeSet = [ 'val' => 100, @@ -131,7 +131,7 @@ class ColumnTest extends TestCase self::assertCount(count($attributeSet), $result); } - public function testSetAttribute() + public function testSetAttribute(): void { $attributeSet = [ 'val' => 100, @@ -145,7 +145,7 @@ class ColumnTest extends TestCase } } - public function testGetAttribute() + public function testGetAttribute(): void { $attributeSet = [ 'val' => 100, @@ -162,7 +162,7 @@ class ColumnTest extends TestCase 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 c2c7f6fc..17b4c022 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php @@ -29,14 +29,14 @@ class AutoFilterTest extends TestCase $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 @@ class AutoFilterTest extends TestCase 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 @@ class AutoFilterTest extends TestCase self::assertEquals($expectedResult, $result); } - public function testSetRange() + public function testSetRange(): void { $ranges = [ 'G1:J512' => 'Worksheet1!G1:J512', @@ -85,7 +85,7 @@ class AutoFilterTest extends TestCase } } - public function testClearRange() + public function testClearRange(): void { $expectedResult = ''; @@ -98,7 +98,7 @@ class AutoFilterTest extends TestCase self::assertEquals($expectedResult, $result); } - public function testSetRangeInvalidRange() + public function testSetRangeInvalidRange(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -107,7 +107,7 @@ class AutoFilterTest extends TestCase $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 @@ class AutoFilterTest extends TestCase self::assertCount(0, $result); } - public function testGetColumnOffset() + public function testGetColumnOffset(): void { $columnIndexes = [ 'H' => 0, @@ -131,7 +131,7 @@ class AutoFilterTest extends TestCase } } - public function testGetInvalidColumnOffset() + public function testGetInvalidColumnOffset(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -140,7 +140,7 @@ class AutoFilterTest extends TestCase $this->testAutoFilterObject->getColumnOffset($invalidColumn); } - public function testSetColumnWithString() + public function testSetColumnWithString(): void { $expectedResult = 'L'; @@ -157,7 +157,7 @@ class AutoFilterTest extends TestCase self::assertInstanceOf(Column::class, $result[$expectedResult]); } - public function testSetInvalidColumnWithString() + public function testSetInvalidColumnWithString(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -166,7 +166,7 @@ class AutoFilterTest extends TestCase $this->testAutoFilterObject->setColumn($invalidColumn); } - public function testSetColumnWithColumnObject() + public function testSetColumnWithColumnObject(): void { $expectedResult = 'M'; $columnObject = new AutoFilter\Column($expectedResult); @@ -184,7 +184,7 @@ class AutoFilterTest extends TestCase self::assertInstanceOf(Column::class, $result[$expectedResult]); } - public function testSetInvalidColumnWithObject() + public function testSetInvalidColumnWithObject(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -192,7 +192,7 @@ class AutoFilterTest extends TestCase $this->testAutoFilterObject->setColumn($invalidColumn); } - public function testSetColumnWithInvalidDataType() + public function testSetColumnWithInvalidDataType(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -200,7 +200,7 @@ class AutoFilterTest extends TestCase $this->testAutoFilterObject->setColumn($invalidColumn); } - public function testGetColumns() + public function testGetColumns(): void { $columnIndexes = ['L', 'M']; @@ -219,7 +219,7 @@ class AutoFilterTest extends TestCase } } - public function testGetColumn() + public function testGetColumn(): void { $columnIndexes = ['L', 'M']; @@ -235,7 +235,7 @@ class AutoFilterTest extends TestCase } } - public function testGetColumnByOffset() + public function testGetColumnByOffset(): void { $columnIndexes = [ 0 => 'H', @@ -252,7 +252,7 @@ class AutoFilterTest extends TestCase } } - 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 @@ class AutoFilterTest extends TestCase self::assertInstanceOf(Column::class, $result); } - public function testGetColumnWithoutRangeSet() + public function testGetColumnWithoutRangeSet(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -269,7 +269,7 @@ class AutoFilterTest extends TestCase $this->testAutoFilterObject->getColumn('A'); } - public function testClearRangeWithExistingColumns() + public function testClearRangeWithExistingColumns(): void { $expectedResult = ''; @@ -292,7 +292,7 @@ class AutoFilterTest extends TestCase self::assertCount(0, $result); } - public function testSetRangeWithExistingColumns() + public function testSetRangeWithExistingColumns(): void { $expectedResult = 'G1:J512'; @@ -322,7 +322,7 @@ class AutoFilterTest extends TestCase 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 5d4706dc..2083f347 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php @@ -23,15 +23,15 @@ class ColumnCellIteratorTest extends TestCase ->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 @@ class ColumnCellIteratorTest extends TestCase } } - public function testIteratorStartEndRange() + public function testIteratorStartEndRange(): void { $iterator = new ColumnCellIterator($this->mockWorksheet, 'A', 2, 4); $ColumnCellIndexResult = 2; @@ -55,7 +55,7 @@ class ColumnCellIteratorTest extends TestCase } } - public function testIteratorSeekAndPrev() + public function testIteratorSeekAndPrev(): void { $iterator = new ColumnCellIterator($this->mockWorksheet, 'A', 2, 4); $columnIndexResult = 4; @@ -68,7 +68,7 @@ class ColumnCellIteratorTest extends TestCase } } - public function testSeekOutOfRange() + public function testSeekOutOfRange(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -76,7 +76,7 @@ class ColumnCellIteratorTest extends TestCase $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 1f31fdb9..b10875c2 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ColumnDimensionTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ColumnDimensionTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; class ColumnDimensionTest extends TestCase { - public function testInstantiateColumnDimensionDefault() + public function testInstantiateColumnDimensionDefault(): void { $expected = 'A'; $columnDimension = new ColumnDimension(); @@ -16,7 +16,7 @@ class ColumnDimensionTest extends TestCase self::assertEquals($expected, $result); } - public function testGetAndSetColumnIndex() + public function testGetAndSetColumnIndex(): void { $expected = 'B'; $columnDimension = new ColumnDimension(); @@ -25,7 +25,7 @@ class ColumnDimensionTest extends TestCase self::assertSame($expected, $result); } - public function testGetAndSetWidth() + public function testGetAndSetWidth(): void { $expected = 1.2; $columnDimension = new ColumnDimension(); @@ -34,7 +34,7 @@ class ColumnDimensionTest extends TestCase 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 eb0b1e0f..de985cee 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php @@ -23,12 +23,12 @@ class ColumnIteratorTest extends TestCase ->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 @@ class ColumnIteratorTest extends TestCase } } - public function testIteratorStartEndRange() + public function testIteratorStartEndRange(): void { $iterator = new ColumnIterator($this->mockWorksheet, 'B', 'D'); $columnIndexResult = 'B'; @@ -52,7 +52,7 @@ class ColumnIteratorTest extends TestCase } } - public function testIteratorSeekAndPrev() + public function testIteratorSeekAndPrev(): void { $ranges = range('A', 'E'); $iterator = new ColumnIterator($this->mockWorksheet, 'B', 'D'); @@ -67,7 +67,7 @@ class ColumnIteratorTest extends TestCase } } - public function testSeekOutOfRange() + public function testSeekOutOfRange(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -75,7 +75,7 @@ class ColumnIteratorTest extends TestCase $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 d8c5c997..0abff0ec 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ColumnTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ColumnTest.php @@ -18,12 +18,12 @@ class ColumnTest extends TestCase $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 @@ class ColumnTest extends TestCase 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 @@ class ColumnTest extends TestCase 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 32bd97f3..f126a529 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php @@ -8,7 +8,7 @@ use PHPUnit\Framework\TestCase; 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 80a2d783..b2a06343 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/IteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/IteratorTest.php @@ -9,7 +9,7 @@ use PHPUnit\Framework\TestCase; 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 786a0d1a..bc2c16dc 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php @@ -23,15 +23,15 @@ class RowCellIteratorTest extends TestCase ->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 @@ class RowCellIteratorTest extends TestCase } } - public function testIteratorStartEndRange() + public function testIteratorStartEndRange(): void { $iterator = new RowCellIterator($this->mockWorksheet, 2, 'B', 'D'); $RowCellIndexResult = 'B'; @@ -55,7 +55,7 @@ class RowCellIteratorTest extends TestCase } } - public function testIteratorSeekAndPrev() + public function testIteratorSeekAndPrev(): void { $ranges = range('A', 'E'); $iterator = new RowCellIterator($this->mockWorksheet, 2, 'B', 'D'); @@ -70,7 +70,7 @@ class RowCellIteratorTest extends TestCase } } - public function testSeekOutOfRange() + public function testSeekOutOfRange(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -78,7 +78,7 @@ class RowCellIteratorTest extends TestCase $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 ea2fe351..919da9ef 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php @@ -23,12 +23,12 @@ class RowIteratorTest extends TestCase ->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 @@ class RowIteratorTest extends TestCase } } - public function testIteratorStartEndRange() + public function testIteratorStartEndRange(): void { $iterator = new RowIterator($this->mockWorksheet, 2, 4); $rowIndexResult = 2; @@ -52,7 +52,7 @@ class RowIteratorTest extends TestCase } } - public function testIteratorSeekAndPrev() + public function testIteratorSeekAndPrev(): void { $iterator = new RowIterator($this->mockWorksheet, 2, 4); $columnIndexResult = 4; @@ -65,7 +65,7 @@ class RowIteratorTest extends TestCase } } - public function testSeekOutOfRange() + public function testSeekOutOfRange(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class); @@ -73,7 +73,7 @@ class RowIteratorTest extends TestCase $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 ee2dcffb..93ff589c 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/RowTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/RowTest.php @@ -18,12 +18,12 @@ class RowTest extends TestCase $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 @@ class RowTest extends TestCase 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 @@ class RowTest extends TestCase 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 d1e19df4..46c848ba 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 @@ class WorksheetTest extends TestCase * @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 @@ class WorksheetTest extends TestCase // 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 @@ class WorksheetTest extends TestCase self::assertSame('Test Title', $sheet->getTitle()); } - public function testSetCodeName() + public function testSetCodeName(): void { $testCodeName = str_repeat('a', 31); @@ -88,7 +89,7 @@ class WorksheetTest extends TestCase * @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 @@ class WorksheetTest extends TestCase // 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 @@ class WorksheetTest extends TestCase self::assertSame('Test Code Name', $sheet->getCodeName()); } - public function testFreezePaneSelectedCell() + public function testFreezePaneSelectedCell(): void { $worksheet = new Worksheet(); $worksheet->freezePane('B2'); @@ -152,7 +153,7 @@ class WorksheetTest extends TestCase * @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 @@ class WorksheetTest extends TestCase * 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 @@ class WorksheetTest extends TestCase int $columnsToBeRemoved, array $expectedData, string $expectedHighestColumn - ) { + ): void { $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); $worksheet->fromArray($initialData); @@ -394,7 +395,7 @@ class WorksheetTest extends TestCase 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 f55781da..7252ecf9 100644 --- a/tests/PhpSpreadsheetTests/Writer/Csv/CsvWriteTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Csv/CsvWriteTest.php @@ -11,7 +11,7 @@ use PhpOffice\PhpSpreadsheetTests\Functional; class CsvWriteTest extends Functional\AbstractFunctional { - public function testNotFirstSheet() + public function testNotFirstSheet(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -33,7 +33,7 @@ class CsvWriteTest extends Functional\AbstractFunctional self::assertEquals(0, $newspreadsheet->getActiveSheetIndex()); } - public function testWriteEmptyFileName() + public function testWriteEmptyFileName(): void { $this->expectException(WriterException::class); $spreadsheet = new Spreadsheet(); @@ -42,7 +42,7 @@ class CsvWriteTest extends Functional\AbstractFunctional $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 03fe741f..31ed438e 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 @@ use PhpOffice\PhpSpreadsheetTests\Functional; class AllOrOneSheetTest extends Functional\AbstractFunctional { - public function testWriteAllSheets() + public function testWriteAllSheets(): void { $spreadsheet = new Spreadsheet(); $sheet1 = $spreadsheet->getActiveSheet(); @@ -23,7 +24,7 @@ class AllOrOneSheetTest extends Functional\AbstractFunctional $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 @@ class AllOrOneSheetTest extends Functional\AbstractFunctional $this->writeAndReload($spreadsheet, 'Html'); } - public function testWriteAllSheetsNoNav() + public function testWriteAllSheetsNoNav(): void { $spreadsheet = new Spreadsheet(); $sheet1 = $spreadsheet->getActiveSheet(); @@ -53,7 +54,7 @@ class AllOrOneSheetTest extends Functional\AbstractFunctional $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 @@ class AllOrOneSheetTest extends Functional\AbstractFunctional $this->writeAndReload($spreadsheet, 'Html'); } - public function testWriteAllSheetsPdf() + public function testWriteAllSheetsPdf(): void { $spreadsheet = new Spreadsheet(); $sheet1 = $spreadsheet->getActiveSheet(); @@ -82,7 +83,7 @@ class AllOrOneSheetTest extends Functional\AbstractFunctional $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 @@ class AllOrOneSheetTest extends Functional\AbstractFunctional 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 @@ class AllOrOneSheetTest extends Functional\AbstractFunctional $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 @@ class AllOrOneSheetTest extends Functional\AbstractFunctional $this->writeAndReload($spreadsheet, 'Html'); } - public function testPageBreak() + public function testPageBreak(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -141,7 +142,7 @@ class AllOrOneSheetTest extends Functional\AbstractFunctional $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 @@ class AllOrOneSheetTest extends Functional\AbstractFunctional $this->writeAndReload($spreadsheet, 'Html'); } - public function testTcpdfPageBreak() + public function testTcpdfPageBreak(): void { $spreadsheet = new Spreadsheet(); $sheet1 = $spreadsheet->getActiveSheet(); @@ -177,7 +178,7 @@ class AllOrOneSheetTest extends Functional\AbstractFunctional $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 2bbe3541..2fa41953 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 @@ use PhpOffice\PhpSpreadsheetTests\Functional; class GridlinesTest extends Functional\AbstractFunctional { - public function testGridlines() + public function testGridlines(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -29,7 +30,7 @@ class GridlinesTest extends Functional\AbstractFunctional $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 @@ class GridlinesTest extends Functional\AbstractFunctional $this->writeAndReload($spreadsheet, 'Html'); } - public function testGridlinesInline() + public function testGridlinesInline(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -72,7 +73,7 @@ class GridlinesTest extends Functional\AbstractFunctional $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 @@ class GridlinesTest extends Functional\AbstractFunctional $this->writeAndReload($spreadsheet, 'Html'); } - public function testRichText() + public function testRichText(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -130,7 +131,7 @@ class GridlinesTest extends Functional\AbstractFunctional $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 637c6514..0d43d7eb 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/HtmlCommentsTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/HtmlCommentsTest.php @@ -46,7 +46,7 @@ class HtmlCommentsTest extends Functional\AbstractFunctional * * @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 96652d6d..9d306fa0 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 @@ class HtmlNumberFormatTest extends Functional\AbstractFunctional StringHelper::setThousandsSeparator($this->thosep); } - public function testColorNumberFormat() + public function testColorNumberFormat(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -40,7 +41,7 @@ class HtmlNumberFormatTest extends Functional\AbstractFunctional $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 @@ class HtmlNumberFormatTest extends Functional\AbstractFunctional $this->writeAndReload($spreadsheet, 'Html'); } - public function testColorNumberFormatComplex() + public function testColorNumberFormatComplex(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -94,7 +95,7 @@ class HtmlNumberFormatTest extends Functional\AbstractFunctional $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 @@ class HtmlNumberFormatTest extends Functional\AbstractFunctional * @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 @@ class HtmlNumberFormatTest extends Functional\AbstractFunctional $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 @@ class HtmlNumberFormatTest extends Functional\AbstractFunctional * @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 @@ class HtmlNumberFormatTest extends Functional\AbstractFunctional $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 f7716e33..5c887d53 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 @@ class ImagesRootTest extends Functional\AbstractFunctional $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 f536d2bd..7baa2338 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/InvalidFileNameTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/InvalidFileNameTest.php @@ -12,7 +12,7 @@ use PhpOffice\PhpSpreadsheetTests\Functional; class InvalidFileNameTest extends Functional\AbstractFunctional { - public function testEmptyFileName() + public function testEmptyFileName(): void { $this->expectException(WriterException::class); $spreadsheet = new Spreadsheet(); @@ -21,7 +21,7 @@ class InvalidFileNameTest extends Functional\AbstractFunctional $writer->save(''); } - public function testEmptyFileNamePdf() + public function testEmptyFileNamePdf(): void { $this->expectException(WriterException::class); $spreadsheet = new Spreadsheet(); @@ -30,7 +30,7 @@ class InvalidFileNameTest extends Functional\AbstractFunctional $writer->save(''); } - public function testEmptyTempdirNamePdf() + public function testEmptyTempdirNamePdf(): void { $this->expectException(WriterException::class); $spreadsheet = new Spreadsheet(); @@ -44,7 +44,7 @@ class InvalidFileNameTest extends Functional\AbstractFunctional $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 e38e4b8e..2a0f60c1 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 @@ class RepeatedRowsTest extends Functional\AbstractFunctional $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 @@ class RepeatedRowsTest extends Functional\AbstractFunctional $this->writeAndReload($spreadsheet, 'Html'); } - public function testWriteNoRepeats() + public function testWriteNoRepeats(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -52,7 +53,7 @@ class RepeatedRowsTest extends Functional\AbstractFunctional $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 @@ class RepeatedRowsTest extends Functional\AbstractFunctional $this->writeAndReload($spreadsheet, 'Html'); } - public function testWriteRepeatsInline() + public function testWriteRepeatsInline(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -84,7 +85,7 @@ class RepeatedRowsTest extends Functional\AbstractFunctional 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 63cdefb7..c5d4da68 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php @@ -9,7 +9,7 @@ use PhpOffice\PhpSpreadsheetTests\Functional; class VisibilityTest extends Functional\AbstractFunctional { - public function testVisibility1() + public function testVisibility1(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -39,7 +39,7 @@ class VisibilityTest extends Functional\AbstractFunctional $this->writeAndReload($spreadsheet, 'Html'); } - public function testVisibility2() + public function testVisibility2(): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -72,7 +72,7 @@ class VisibilityTest extends Functional\AbstractFunctional $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 5641d330..4086914d 100644 --- a/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php @@ -37,7 +37,7 @@ class ContentTest extends TestCase 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 @@ class ContentTest extends TestCase 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 affb917f..61c70cb6 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php @@ -17,7 +17,7 @@ class FormulaErrTest extends TestCase } } - 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 d2080265..7a83b697 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; 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 @@ class WorkbookTest extends TestCase /** * @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 @@ class WorkbookTest extends TestCase { $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 521cc47f..aad074de 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 @@ class FloatsRetainedTest extends TestCase $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 f3f0eda2..81d4a777 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php @@ -30,10 +30,10 @@ class LocaleFloatsTest extends TestCase } } - 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 @@ class LocaleFloatsTest extends TestCase 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 a826dfaa..4ea6f955 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 @@ class UnparsedDataTest extends TestCase 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 73dc6dad..2f9e0a0c 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 a7b3e7cc..9acc6716 100644 --- a/tests/data/Calculation/DateTime/DATE.php +++ b/tests/data/Calculation/DateTime/DATE.php @@ -315,5 +315,5 @@ return [ [ '#VALUE!', 2010, 3, 'GHI', - ] + ], ]; diff --git a/tests/data/Calculation/Financial/XIRR.php b/tests/data/Calculation/Financial/XIRR.php index 62b9b668..3414d132 100644 --- a/tests/data/Calculation/Financial/XIRR.php +++ b/tests/data/Calculation/Financial/XIRR.php @@ -8,84 +8,84 @@ return [ '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 @@ return [ '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 a49c6218..4eca0a01 100644 --- a/tests/data/Calculation/Financial/XNPV.php +++ b/tests/data/Calculation/Financial/XNPV.php @@ -42,7 +42,7 @@ return [ '#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 d062b7fe..df3d6051 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 020ef498..06371c79 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 6a87a5a1..644ddeba 100644 --- a/tests/data/Calculation/LookupRef/HLOOKUP.php +++ b/tests/data/Calculation/LookupRef/HLOOKUP.php @@ -280,19 +280,19 @@ return [ '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 a39f5e9a..ab322d57 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 c5666172..d435e89b 100644 --- a/tests/data/Calculation/Statistical/AVERAGE.php +++ b/tests/data/Calculation/Statistical/AVERAGE.php @@ -38,7 +38,7 @@ return [ '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 bd976471..422a2771 100644 --- a/tests/data/Calculation/Statistical/AVERAGEIF.php +++ b/tests/data/Calculation/Statistical/AVERAGEIF.php @@ -4,22 +4,22 @@ return [ [ 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 @@ return [ [ 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 8c0dc1c3..4e1d31b0 100644 --- a/tests/data/Calculation/Statistical/BasicCOUNT.php +++ b/tests/data/Calculation/Statistical/BasicCOUNT.php @@ -21,7 +21,7 @@ return [ '', 4.8, 'Not a numeric', - 6 + 6, ], ], ]; diff --git a/tests/data/Calculation/Statistical/COUNTA.php b/tests/data/Calculation/Statistical/COUNTA.php index 579af954..0e0ffb15 100644 --- a/tests/data/Calculation/Statistical/COUNTA.php +++ b/tests/data/Calculation/Statistical/COUNTA.php @@ -24,7 +24,7 @@ return [ '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 @@ return [ '', 4.8, 'Not a numeric', - 6 + 6, ], ], ]; diff --git a/tests/data/Calculation/Statistical/FISHER.php b/tests/data/Calculation/Statistical/FISHER.php index 95882458..fc35acba 100644 --- a/tests/data/Calculation/Statistical/FISHER.php +++ b/tests/data/Calculation/Statistical/FISHER.php @@ -12,5 +12,5 @@ return [ [ 1.098612288668, 0.8, - ] + ], ]; diff --git a/tests/data/Calculation/Statistical/SLOPE.php b/tests/data/Calculation/Statistical/SLOPE.php index d0b7dbeb..a635c0d0 100644 --- a/tests/data/Calculation/Statistical/SLOPE.php +++ b/tests/data/Calculation/Statistical/SLOPE.php @@ -42,7 +42,7 @@ return [ 5, 4, 4, - ] + ], ], [ 0.305555555556, @@ -63,6 +63,6 @@ return [ 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 28c85900..f8797e88 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 d31b00dd..96599088 100644 --- a/src/PhpSpreadsheet/Calculation/Database.php +++ b/src/PhpSpreadsheet/Calculation/Database.php @@ -130,8 +130,6 @@ class Database * 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 @@ class Database * 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 @@ class Database * 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 @@ class Database * 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 @@ class Database * 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 @@ class Database * 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 @@ class Database * 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 @@ class Database * 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 @@ class Database * 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 @@ class Database * 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 @@ class Database * 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 @@ class Database * 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 a57be297..d08ab543 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -139,8 +139,6 @@ class DateTime * 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 @@ class DateTime * 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 @@ class DateTime * 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 @@ class DateTime * 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 @@ class DateTime * 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 @@ class DateTime * 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 @@ class DateTime * 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 @@ class DateTime * 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 @@ class DateTime * 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 @@ class DateTime * 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 @@ class DateTime * 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 aad35eec..dcbd5394 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -776,8 +776,6 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * 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 @@ class Engineering * Excel Function: * IMAGINARY(complexNumber) * - * @category Engineering Functions - * * @param string $complexNumber the complex number for which you want the imaginary * coefficient * @@ -1749,8 +1713,6 @@ class Engineering * 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 @@ class Engineering * Excel Function: * BITAND(number1, number2) * - * @category Engineering Functions - * * @param int $number1 * @param int $number2 * @@ -2405,8 +2365,6 @@ class Engineering * Excel Function: * BITOR(number1, number2) * - * @category Engineering Functions - * * @param int $number1 * @param int $number2 * @@ -2432,8 +2390,6 @@ class Engineering * Excel Function: * BITXOR(number1, number2) * - * @category Engineering Functions - * * @param int $number1 * @param int $number2 * @@ -2459,8 +2415,6 @@ class Engineering * Excel Function: * BITLSHIFT(number, shift_amount) * - * @category Engineering Functions - * * @param int $number * @param int $shiftAmount * @@ -2492,8 +2446,6 @@ class Engineering * 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 624f035a..073e7c48 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -114,8 +114,6 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * Excel Function: * DOLLARDE(fractional_dollar,fraction) * - * @category Financial Functions - * * @param float $fractional_dollar Fractional Dollar * @param int $fraction Fraction * @@ -1036,8 +1004,6 @@ class Financial * Excel Function: * DOLLARFR(decimal_dollar,fraction) * - * @category Financial Functions - * * @param float $decimal_dollar Decimal Dollar * @param int $fraction Fraction * @@ -1073,8 +1039,6 @@ class Financial * 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 @@ class Financial * 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 @@ class Financial * 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 af872dd7..148d75b3 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 @@ class Functions /** * Return the current Compatibility Mode. * - * @category Function Configuration - * * @return string Compatibility Mode * Possible Return values are: * Functions::COMPATIBILITY_EXCEL 'Excel' @@ -100,8 +96,6 @@ class Functions /** * 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 @@ class Functions /** * 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 @@ class Functions /** * DUMMY. * - * @category Error Returns - * * @return string #Not Yet Implemented */ public static function DUMMY() @@ -155,8 +145,6 @@ class Functions /** * DIV0. * - * @category Error Returns - * * @return string #Not Yet Implemented */ public static function DIV0() @@ -173,8 +161,6 @@ class Functions * 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 @@ class Functions * * Returns the error value #NUM! * - * @category Error Returns - * * @return string #NUM! */ public static function NAN() @@ -201,8 +185,6 @@ class Functions * * Returns the error value #NAME? * - * @category Error Returns - * * @return string #NAME? */ public static function NAME() @@ -215,8 +197,6 @@ class Functions * * Returns the error value #REF! * - * @category Error Returns - * * @return string #REF! */ public static function REF() @@ -229,8 +209,6 @@ class Functions * * Returns the error value #NULL! * - * @category Error Returns - * * @return string #NULL! */ public static function null() @@ -243,8 +221,6 @@ class Functions * * 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 416d119a..a362a275 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 @@ class Logical * Excel Function: * =FALSE() * - * @category Logical Functions - * * @return bool False */ public static function false() @@ -80,8 +76,6 @@ class Logical * 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 @@ class Logical * 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 @@ class Logical * 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 @@ class Logical * 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 @@ class Logical * 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 @@ class Logical * 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 @@ class Logical * 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 @@ class Logical * 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 2d196aef..f8272404 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -230,8 +230,6 @@ class LookupRef * 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 @@ class LookupRef * * @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 3db3fb8d..d92ba404 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -47,8 +47,6 @@ class MathTrig * 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 @@ class MathTrig * 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 @@ class MathTrig * 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 @@ class MathTrig * 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 @@ class MathTrig * 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 @@ class MathTrig * 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 @@ class MathTrig * 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 @@ class MathTrig * 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 @@ class MathTrig * Excel Function: * FLOOR(number[,significance]) * - * @category Mathematical and Trigonometric Functions - * * @param float $number Number to round * @param float $significance Significance * @@ -446,8 +428,6 @@ class MathTrig * 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 @@ class MathTrig * 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 @@ class MathTrig * 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 @@ class MathTrig * 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 @@ class MathTrig * 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 @@ class MathTrig * 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 @@ class MathTrig * 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 @@ class MathTrig * 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 @@ class MathTrig * Excel Function: * PRODUCT(value1[,value2[, ...]]) * - * @category Mathematical and Trigonometric Functions - * * @param mixed ...$args Data values * * @return float @@ -1039,8 +1003,6 @@ class MathTrig * Excel Function: * QUOTIENT(value1[,value2[, ...]]) * - * @category Mathematical and Trigonometric Functions - * * @param mixed ...$args Data values * * @return float @@ -1364,8 +1326,6 @@ class MathTrig * Excel Function: * SUM(value1[,value2[, ...]]) * - * @category Mathematical and Trigonometric Functions - * * @param mixed ...$args Data values * * @return float @@ -1393,8 +1353,6 @@ class MathTrig * 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 @@ class MathTrig * Excel Function: * SUMIFS(value1[,value2[, ...]],condition) * - * @category Mathematical and Trigonometric Functions - * * @param mixed $args Data values * * @return float @@ -1496,8 +1452,6 @@ class MathTrig * 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 @@ class MathTrig * 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 675f88ef..100eb2fa 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -565,8 +565,6 @@ class Statistical * Excel Function: * AVEDEV(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -616,8 +614,6 @@ class Statistical * Excel Function: * AVERAGE(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -657,8 +653,6 @@ class Statistical * Excel Function: * AVERAGEA(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -700,8 +694,6 @@ class Statistical * 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 @@ class Statistical * Excel Function: * COUNT(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return int @@ -1086,8 +1076,6 @@ class Statistical * Excel Function: * COUNTA(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return int @@ -1116,8 +1104,6 @@ class Statistical * Excel Function: * COUNTBLANK(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return int @@ -1146,8 +1132,6 @@ class Statistical * 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 @@ class Statistical * Excel Function: * COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2]…) * - * @category Statistical Functions - * * @param mixed $args Criterias * * @return int @@ -1295,7 +1277,7 @@ class Statistical * * @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 @@ class Statistical * Excel Function: * DEVSQ(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -1707,8 +1687,6 @@ class Statistical * Excel Function: * GEOMEAN(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -1769,8 +1747,6 @@ class Statistical * Excel Function: * HARMEAN(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -1924,8 +1900,6 @@ class Statistical * 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 @@ class Statistical * * @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 @@ class Statistical * Excel Function: * MAX(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float @@ -2188,8 +2160,6 @@ class Statistical * Excel Function: * MAXA(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float @@ -2229,8 +2199,6 @@ class Statistical * 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 @@ class Statistical * 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 @@ class Statistical * Excel Function: * MIN(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float @@ -2368,8 +2332,6 @@ class Statistical * Excel Function: * MINA(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float @@ -2409,8 +2371,6 @@ class Statistical * 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 @@ class Statistical * 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 @@ class Statistical * 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 @@ class Statistical * 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 @@ class Statistical * 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 @@ class Statistical * 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 @@ class Statistical * Excel Function: * STDEVA(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -3199,8 +3147,6 @@ class Statistical * Excel Function: * STDEVP(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -3246,8 +3192,6 @@ class Statistical * Excel Function: * STDEVPA(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float|string @@ -3484,8 +3428,6 @@ class Statistical * Excel Function: * TRIMEAN(value1[,value2[, ...]], $discard) * - * @category Statistical Functions - * * @param mixed $args Data values * * @return float|string @@ -3529,8 +3471,6 @@ class Statistical * Excel Function: * VAR(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float @@ -3573,8 +3513,6 @@ class Statistical * Excel Function: * VARA(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float @@ -3626,8 +3564,6 @@ class Statistical * Excel Function: * VARP(value1[,value2[, ...]]) * - * @category Statistical Functions - * * @param mixed ...$args Data values * * @return float @@ -3671,8 +3607,6 @@ class Statistical * 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 27c72acd..32b56e18 100644 --- a/src/PhpSpreadsheet/Shared/OLE.php +++ b/src/PhpSpreadsheet/Shared/OLE.php @@ -38,8 +38,6 @@ $GLOBALS['_OLE_INSTANCES'] = []; * * @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 e53f2575..0407e0d1 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS.php @@ -26,8 +26,6 @@ use PhpOffice\PhpSpreadsheet\Shared\OLE; * 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 b7425af4..dd1cda2d 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/File.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/File.php @@ -27,8 +27,6 @@ use PhpOffice\PhpSpreadsheet\Shared\OLE\PPS; * 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 0d70df6d..11655c65 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php @@ -27,8 +27,6 @@ use PhpOffice\PhpSpreadsheet\Shared\OLE\PPS; * 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 19eabcf4..f29dbad5 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -76,10 +76,6 @@ use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; * 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 65b04c7d..c9f2d7cb 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -1448,8 +1448,6 @@ class Html extends BaseWriter * @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 880a8554..b0829bf1 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php +++ b/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php @@ -6,9 +6,6 @@ use PhpOffice\PhpSpreadsheet\Cell\Cell; 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 cb6c6628..6588473a 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Content.php +++ b/src/PhpSpreadsheet/Writer/Ods/Content.php @@ -12,15 +12,9 @@ use PhpOffice\PhpSpreadsheet\Style\Font; 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 f6b3e297..0dce7ba5 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -538,7 +538,7 @@ class Worksheet extends BIFFwriter $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 @@ class Worksheet extends BIFFwriter return $tmp; } + // No data to return return false; } @@ -881,8 +882,8 @@ class Worksheet extends BIFFwriter $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 @@ class Worksheet extends BIFFwriter * 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 @@ class Worksheet extends BIFFwriter * @param string $url URL string * * @return int + * + * @see writeUrl() */ public function writeUrlRange($row1, $col1, $row2, $col2, $url) { @@ -973,8 +974,6 @@ class Worksheet extends BIFFwriter * 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 @@ class Worksheet extends BIFFwriter * @param string $url URL string * * @return int + * + * @see writeUrl() */ public function writeUrlWeb($row1, $col1, $row2, $col2, $url) { @@ -1018,8 +1019,6 @@ class Worksheet extends BIFFwriter /** * 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 @@ class Worksheet extends BIFFwriter * @param string $url URL string * * @return int + * + * @see writeUrl() */ public function writeUrlInternal($row1, $col1, $row2, $col2, $url) { @@ -1071,8 +1072,6 @@ class Worksheet extends BIFFwriter * 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 @@ class Worksheet extends BIFFwriter * @param string $url URL string * * @return int + * + * @see writeUrl() */ public function writeUrlExternal($row1, $col1, $row2, $col2, $url) { @@ -1142,14 +1143,14 @@ class Worksheet extends BIFFwriter // 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 @@ class Worksheet extends BIFFwriter // 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 @@ class Worksheet extends BIFFwriter $operatorType = 0x01; break; - // not OPERATOR_NOTBETWEEN 0x02 + // not OPERATOR_NOTBETWEEN 0x02 } } @@ -3062,13 +3063,13 @@ class Worksheet extends BIFFwriter } // 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 @@ class Worksheet extends BIFFwriter 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 @@ class Worksheet extends BIFFwriter break; default: - $colorIdxBg = 0x41; + $colorIdxBg = 0x41; break; } @@ -4388,7 +4388,7 @@ class Worksheet extends BIFFwriter break; default: - $colorIdxFg = 0x40; + $colorIdxFg = 0x40; break; } @@ -4447,7 +4447,7 @@ class Worksheet extends BIFFwriter 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 5119117a..3a47be7f 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Theme.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php @@ -5,11 +5,6 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; 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 25b09d19..15359a4c 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -13,11 +13,6 @@ use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule; 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 6b111497..0aeb5570 100644 --- a/tests/PhpSpreadsheetTests/Reader/OdsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/OdsTest.php @@ -10,7 +10,7 @@ use PhpOffice\PhpSpreadsheet\Style\Font; 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 9f768459..49bb66c0 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 709b4b1d..f5493d03 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