diff --git a/.gitattributes b/.gitattributes index 91b0574a08..ff4e39cf72 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,7 +3,9 @@ /.gitattributes export-ignore /.github export-ignore /.gitignore export-ignore -/.php_cs.dist export-ignore +/.phpcs.xml.dist export-ignore +/.php-cs-fixer.dist.php export-ignore +/.readthedocs.yaml export-ignore /.scrutinizer.yml export-ignore /CHANGELOG.PHPExcel.md export-ignore /bin export-ignore @@ -11,6 +13,8 @@ /docs export-ignore /infra export-ignore /mkdocs.yml export-ignore +/phpstan.neon.dist export-ignore +/phpstan-baseline.neon export-ignore /phpunit.xml.dist export-ignore /samples export-ignore /tests export-ignore diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dea1f30a3..a04a802e13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com) and this project adheres to [Semantic Versioning](https://semver.org). -## TBD - 2.1.5 +## 2024-12-08 - 2.1.5 ### Fixed - Fix Minor Break Handling Drawings. Backport of [PR #4244](https://github.com/PHPOffice/PhpSpreadsheet/pull/4244) +- Swapped Row and Column Indexes in Reference Helper. Backport of [PR #4247](https://github.com/PHPOffice/PhpSpreadsheet/pull/4247) +- Upgrade locked version of Tcpdf (security advisory). +- Upgrade locked version of Dompdf (Php8.4 compatibility). +- Remove unnecessary files from Composer package. ## 2024-11-22 - 2.1.4 diff --git a/composer.json b/composer.json index 5667818c86..74832919db 100644 --- a/composer.json +++ b/composer.json @@ -88,7 +88,7 @@ }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "dev-main", - "dompdf/dompdf": "^2.0", + "dompdf/dompdf": "^2.0 || ^3.0", "friendsofphp/php-cs-fixer": "^3.2", "mitoteam/jpgraph": "^10.3", "mpdf/mpdf": "^8.1.1", diff --git a/composer.lock b/composer.lock index 67afcd97ea..00e34f7d8f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b26a18ad03352af543e5cf686162fdbb", + "content-hash": "dba36d693d93eddd55314afd051fe473", "packages": [ { "name": "maennchen/zipstream-php", @@ -835,32 +835,34 @@ }, { "name": "dompdf/dompdf", - "version": "v2.0.8", + "version": "v3.0.1", "source": { "type": "git", "url": "https://github.com/dompdf/dompdf.git", - "reference": "c20247574601700e1f7c8dab39310fca1964dc52" + "reference": "2d622faf9aa1f8f7f24dd094e49b5cf6c0c5d4e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dompdf/dompdf/zipball/c20247574601700e1f7c8dab39310fca1964dc52", - "reference": "c20247574601700e1f7c8dab39310fca1964dc52", + "url": "https://api.github.com/repos/dompdf/dompdf/zipball/2d622faf9aa1f8f7f24dd094e49b5cf6c0c5d4e6", + "reference": "2d622faf9aa1f8f7f24dd094e49b5cf6c0c5d4e6", "shasum": "" }, "require": { + "dompdf/php-font-lib": "^1.0.0", + "dompdf/php-svg-lib": "^1.0.0", "ext-dom": "*", "ext-mbstring": "*", "masterminds/html5": "^2.0", - "phenx/php-font-lib": ">=0.5.4 <1.0.0", - "phenx/php-svg-lib": ">=0.5.2 <1.0.0", "php": "^7.1 || ^8.0" }, "require-dev": { + "ext-gd": "*", "ext-json": "*", "ext-zip": "*", "mockery/mockery": "^1.3", - "phpunit/phpunit": "^7.5 || ^8 || ^9", - "squizlabs/php_codesniffer": "^3.5" + "phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10", + "squizlabs/php_codesniffer": "^3.5", + "symfony/process": "^4.4 || ^5.4 || ^6.2 || ^7.0" }, "suggest": { "ext-gd": "Needed to process images", @@ -891,9 +893,100 @@ "homepage": "https://github.com/dompdf/dompdf", "support": { "issues": "https://github.com/dompdf/dompdf/issues", - "source": "https://github.com/dompdf/dompdf/tree/v2.0.8" + "source": "https://github.com/dompdf/dompdf/tree/v3.0.1" + }, + "time": "2024-12-05T14:59:38+00:00" + }, + { + "name": "dompdf/php-font-lib", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/dompdf/php-font-lib.git", + "reference": "6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d", + "reference": "6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^3 || ^4 || ^5 || ^6" + }, + "type": "library", + "autoload": { + "psr-4": { + "FontLib\\": "src/FontLib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-or-later" + ], + "authors": [ + { + "name": "The FontLib Community", + "homepage": "https://github.com/dompdf/php-font-lib/blob/master/AUTHORS.md" + } + ], + "description": "A library to read, parse, export and make subsets of different types of font files.", + "homepage": "https://github.com/dompdf/php-font-lib", + "support": { + "issues": "https://github.com/dompdf/php-font-lib/issues", + "source": "https://github.com/dompdf/php-font-lib/tree/1.0.1" + }, + "time": "2024-12-02T14:37:59+00:00" + }, + { + "name": "dompdf/php-svg-lib", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/dompdf/php-svg-lib.git", + "reference": "eb045e518185298eb6ff8d80d0d0c6b17aecd9af" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/eb045e518185298eb6ff8d80d0d0c6b17aecd9af", + "reference": "eb045e518185298eb6ff8d80d0d0c6b17aecd9af", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.1 || ^8.0", + "sabberworm/php-css-parser": "^8.4" + }, + "require-dev": { + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Svg\\": "src/Svg" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "The SvgLib Community", + "homepage": "https://github.com/dompdf/php-svg-lib/blob/master/AUTHORS.md" + } + ], + "description": "A library to read, parse and export to PDF SVG files.", + "homepage": "https://github.com/dompdf/php-svg-lib", + "support": { + "issues": "https://github.com/dompdf/php-svg-lib/issues", + "source": "https://github.com/dompdf/php-svg-lib/tree/1.0.0" }, - "time": "2024-04-29T13:06:17+00:00" + "time": "2024-04-29T13:26:35+00:00" }, { "name": "friendsofphp/php-cs-fixer", @@ -1561,96 +1654,6 @@ }, "time": "2022-02-21T01:04:05+00:00" }, - { - "name": "phenx/php-font-lib", - "version": "0.5.6", - "source": { - "type": "git", - "url": "https://github.com/dompdf/php-font-lib.git", - "reference": "a1681e9793040740a405ac5b189275059e2a9863" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/a1681e9793040740a405ac5b189275059e2a9863", - "reference": "a1681e9793040740a405ac5b189275059e2a9863", - "shasum": "" - }, - "require": { - "ext-mbstring": "*" - }, - "require-dev": { - "symfony/phpunit-bridge": "^3 || ^4 || ^5 || ^6" - }, - "type": "library", - "autoload": { - "psr-4": { - "FontLib\\": "src/FontLib" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-2.1-or-later" - ], - "authors": [ - { - "name": "Fabien Ménager", - "email": "fabien.menager@gmail.com" - } - ], - "description": "A library to read, parse, export and make subsets of different types of font files.", - "homepage": "https://github.com/PhenX/php-font-lib", - "support": { - "issues": "https://github.com/dompdf/php-font-lib/issues", - "source": "https://github.com/dompdf/php-font-lib/tree/0.5.6" - }, - "time": "2024-01-29T14:45:26+00:00" - }, - { - "name": "phenx/php-svg-lib", - "version": "0.5.4", - "source": { - "type": "git", - "url": "https://github.com/dompdf/php-svg-lib.git", - "reference": "46b25da81613a9cf43c83b2a8c2c1bdab27df691" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/46b25da81613a9cf43c83b2a8c2c1bdab27df691", - "reference": "46b25da81613a9cf43c83b2a8c2c1bdab27df691", - "shasum": "" - }, - "require": { - "ext-mbstring": "*", - "php": "^7.1 || ^8.0", - "sabberworm/php-css-parser": "^8.4" - }, - "require-dev": { - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5" - }, - "type": "library", - "autoload": { - "psr-4": { - "Svg\\": "src/Svg" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-3.0-or-later" - ], - "authors": [ - { - "name": "Fabien Ménager", - "email": "fabien.menager@gmail.com" - } - ], - "description": "A library to read, parse and export to PDF SVG files.", - "homepage": "https://github.com/PhenX/php-svg-lib", - "support": { - "issues": "https://github.com/dompdf/php-svg-lib/issues", - "source": "https://github.com/dompdf/php-svg-lib/tree/0.5.4" - }, - "time": "2024-04-08T12:52:34+00:00" - }, { "name": "phpcompatibility/php-compatibility", "version": "9.3.5", @@ -4860,16 +4863,16 @@ }, { "name": "tecnickcom/tcpdf", - "version": "6.7.5", + "version": "6.7.7", "source": { "type": "git", "url": "https://github.com/tecnickcom/TCPDF.git", - "reference": "951eabf0338ec2522bd0d5d9c79b08a3a3d36b36" + "reference": "cfbc0028cc23f057f2baf9e73bdc238153c22086" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/951eabf0338ec2522bd0d5d9c79b08a3a3d36b36", - "reference": "951eabf0338ec2522bd0d5d9c79b08a3a3d36b36", + "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/cfbc0028cc23f057f2baf9e73bdc238153c22086", + "reference": "cfbc0028cc23f057f2baf9e73bdc238153c22086", "shasum": "" }, "require": { @@ -4920,7 +4923,7 @@ ], "support": { "issues": "https://github.com/tecnickcom/TCPDF/issues", - "source": "https://github.com/tecnickcom/TCPDF/tree/6.7.5" + "source": "https://github.com/tecnickcom/TCPDF/tree/6.7.7" }, "funding": [ { @@ -4928,7 +4931,7 @@ "type": "custom" } ], - "time": "2024-04-20T17:25:10+00:00" + "time": "2024-10-26T12:15:02+00:00" }, { "name": "theseer/tokenizer", diff --git a/src/PhpSpreadsheet/Helper/Sample.php b/src/PhpSpreadsheet/Helper/Sample.php index e0d2cfee24..c772aface1 100644 --- a/src/PhpSpreadsheet/Helper/Sample.php +++ b/src/PhpSpreadsheet/Helper/Sample.php @@ -9,7 +9,6 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Writer\IWriter; -use PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; use RecursiveRegexIterator; @@ -130,11 +129,7 @@ public function write(Spreadsheet $spreadsheet, string $filename, array $writers $writerCallback($writer); } $callStartTime = microtime(true); - if (PHP_VERSION_ID >= 80400 && $writer instanceof Dompdf) { - @$writer->save($path); - } else { - $writer->save($path); - } + $writer->save($path); $this->logWrite($writer, $path, $callStartTime); if ($this->isCli() === false) { // @codeCoverageIgnoreStart diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index de9c3f25d3..acc5e5dbb9 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -1217,7 +1217,7 @@ private function duplicateStylesByRow(Worksheet $worksheet, int $beforeColumn, i if ($worksheet->cellExists($coordinate)) { $xfIndex = $worksheet->getCell($coordinate)->getXfIndex(); for ($j = $beforeRow; $j <= $beforeRow - 1 + $numberOfRows; ++$j) { - if (!empty($xfIndex) || $worksheet->cellExists([$j, $i])) { + if (!empty($xfIndex) || $worksheet->cellExists([$i, $j])) { $worksheet->getCell(Coordinate::stringFromColumnIndex($i) . $j)->setXfIndex($xfIndex); } } diff --git a/tests/PhpSpreadsheetTests/Functional/StreamTest.php b/tests/PhpSpreadsheetTests/Functional/StreamTest.php index c67c1ab22c..3430b7a31b 100644 --- a/tests/PhpSpreadsheetTests/Functional/StreamTest.php +++ b/tests/PhpSpreadsheetTests/Functional/StreamTest.php @@ -8,12 +8,6 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PHPUnit\Framework\TestCase; -/** - * Not clear that Dompdf will be Php8.4 compatible in time. - * Run in separate process and add version test till it is ready. - * - * @runTestsInSeparateProcesses - */ class StreamTest extends TestCase { public static function providerFormats(): array @@ -48,11 +42,7 @@ public function testAllWritersCanWriteToStream(string $format): void } else { self::assertSame(0, $stat['size']); - if ($format === 'Dompdf' && PHP_VERSION_ID >= 80400) { - @$writer->save($stream); - } else { - $writer->save($stream); - } + $writer->save($stream); self::assertIsResource($stream, 'should not close the stream for further usage out of PhpSpreadsheet'); $stat = fstat($stream); diff --git a/tests/PhpSpreadsheetTests/ReferenceHelper5Test.php b/tests/PhpSpreadsheetTests/ReferenceHelper5Test.php new file mode 100644 index 0000000000..bdb658896e --- /dev/null +++ b/tests/PhpSpreadsheetTests/ReferenceHelper5Test.php @@ -0,0 +1,45 @@ +getActiveSheet(); + $row = 987654; + $rowMinus1 = $row - 1; + $rowPlus1 = $row + 1; + $sheet->getCell("A$rowMinus1")->setValue(1); + $sheet->getCell("B$rowMinus1")->setValue(2); + $sheet->getCell("C$rowMinus1")->setValue(3); + $sheet->getStyle("A$rowMinus1")->getFont()->setBold(true); + $sheet->getCell("A$row")->setValue(1); + $sheet->getCell("B$row")->setValue(2); + $sheet->getCell("C$row")->setValue(3); + $sheet->getStyle("B$row")->getFont()->setBold(true); + + $sheet->insertNewRowBefore($row); + self::assertTrue( + $sheet->getStyle("A$row")->getFont()->getBold() + ); + self::assertFalse( + $sheet->getStyle("B$row")->getFont()->getBold() + ); + self::assertFalse( + $sheet->getStyle("A$rowPlus1")->getFont()->getBold() + ); + self::assertTrue( + $sheet->getStyle("B$rowPlus1")->getFont()->getBold() + ); + $spreadsheet->disconnectWorksheets(); + } +} diff --git a/tests/PhpSpreadsheetTests/Writer/Dompdf/PaperSizeArrayTest.php b/tests/PhpSpreadsheetTests/Writer/Dompdf/PaperSizeArrayTest.php index ccd0e84f05..4c0b86b637 100644 --- a/tests/PhpSpreadsheetTests/Writer/Dompdf/PaperSizeArrayTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Dompdf/PaperSizeArrayTest.php @@ -10,12 +10,6 @@ use PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf; use PHPUnit\Framework\TestCase; -/** - * Not clear that Dompdf will be Php8.4 compatible in time. - * Run in separate process and add version test till it is ready. - * - * @runTestsInSeparateProcesses - */ class PaperSizeArrayTest extends TestCase { private string $outfile = ''; @@ -42,11 +36,7 @@ public function testPaperSizeArray(): void $sheet->setCellValue('A7', 'Lorem Ipsum'); $writer = new Dompdf($spreadsheet); $this->outfile = File::temporaryFilename(); - if (PHP_VERSION_ID >= 80400) { // hopefully temporary - @$writer->save($this->outfile); - } else { - $writer->save($this->outfile); - } + $writer->save($this->outfile); $spreadsheet->disconnectWorksheets(); unset($spreadsheet); $contents = file_get_contents($this->outfile); @@ -66,11 +56,7 @@ public function testPaperSizeNotArray(): void $sheet->setCellValue('A7', 'Lorem Ipsum'); $writer = new Dompdf($spreadsheet); $this->outfile = File::temporaryFilename(); - if (PHP_VERSION_ID >= 80400) { // hopefully temporary - @$writer->save($this->outfile); - } else { - $writer->save($this->outfile); - } + $writer->save($this->outfile); $spreadsheet->disconnectWorksheets(); unset($spreadsheet); $contents = file_get_contents($this->outfile);