Skip to content

Commit afa5428

Browse files
committed
Upgrade Dompdf
1 parent 0adf030 commit afa5428

File tree

7 files changed

+70
-36
lines changed

7 files changed

+70
-36
lines changed

.gitattributes

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
/.gitattributes export-ignore
44
/.github export-ignore
55
/.gitignore export-ignore
6-
/.php_cs.dist export-ignore
6+
/.phpcs.xml.dist export-ignore
7+
/.php-cs-fixer.dist.php export-ignore
8+
/.readthedocs.yaml export-ignore
79
/.scrutinizer.yml export-ignore
810
/CHANGELOG.PHPExcel.md export-ignore
911
/bin export-ignore
1012
/composer.lock export-ignore
1113
/docs export-ignore
1214
/infra export-ignore
1315
/mkdocs.yml export-ignore
16+
/phpstan.neon.dist export-ignore
17+
/phpstan-baseline.neon export-ignore
1418
/phpunit.xml.dist export-ignore
19+
/phpunit9.xml.dist export-ignore
1520
/samples export-ignore
1621
/tests export-ignore

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org).
1010
### Fixed
1111

1212
- Fix Minor Break Handling Drawings. Backport of [PR #4244](https://github.com/PHPOffice/PhpSpreadsheet/pull/4244)
13+
- Swapped Row and Column Indexes in Reference Helper. Backport of [PR #4247](https://github.com/PHPOffice/PhpSpreadsheet/pull/4247)
14+
- Upgrade locked version of Dompdf (Php8.4 compatibility).
15+
- Remove unnecessary files from Composer package.
1316

1417
## 2024-11-22 - 2.3.3
1518

composer.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/PhpSpreadsheet/Helper/Sample.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use PhpOffice\PhpSpreadsheet\Spreadsheet;
1010
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
1111
use PhpOffice\PhpSpreadsheet\Writer\IWriter;
12-
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf;
1312
use RecursiveDirectoryIterator;
1413
use RecursiveIteratorIterator;
1514
use RecursiveRegexIterator;
@@ -126,11 +125,7 @@ public function write(Spreadsheet $spreadsheet, string $filename, array $writers
126125
$writerCallback($writer);
127126
}
128127
$callStartTime = microtime(true);
129-
if (PHP_VERSION_ID >= 80400 && $writer instanceof Dompdf) {
130-
@$writer->save($path);
131-
} else {
132-
$writer->save($path);
133-
}
128+
$writer->save($path);
134129
$this->logWrite($writer, $path, $callStartTime);
135130
if ($this->isCli() === false) {
136131
// @codeCoverageIgnoreStart

src/PhpSpreadsheet/ReferenceHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ private function duplicateStylesByRow(Worksheet $worksheet, int $beforeColumn, i
12151215
if ($worksheet->cellExists($coordinate)) {
12161216
$xfIndex = $worksheet->getCell($coordinate)->getXfIndex();
12171217
for ($j = $beforeRow; $j <= $beforeRow - 1 + $numberOfRows; ++$j) {
1218-
if (!empty($xfIndex) || $worksheet->cellExists([$j, $i])) {
1218+
if (!empty($xfIndex) || $worksheet->cellExists([$i, $j])) {
12191219
$worksheet->getCell(Coordinate::stringFromColumnIndex($i) . $j)->setXfIndex($xfIndex);
12201220
}
12211221
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpOffice\PhpSpreadsheetTests;
6+
7+
use PhpOffice\PhpSpreadsheet\Spreadsheet;
8+
use PHPUnit\Framework\TestCase;
9+
10+
class ReferenceHelper5Test extends TestCase
11+
{
12+
public function testIssue4246(): void
13+
{
14+
// code below would have thrown exception because
15+
// row and column were swapped in code
16+
$spreadsheet = new Spreadsheet();
17+
$sheet = $spreadsheet->getActiveSheet();
18+
$row = 987654;
19+
$rowMinus1 = $row - 1;
20+
$rowPlus1 = $row + 1;
21+
$sheet->getCell("A$rowMinus1")->setValue(1);
22+
$sheet->getCell("B$rowMinus1")->setValue(2);
23+
$sheet->getCell("C$rowMinus1")->setValue(3);
24+
$sheet->getStyle("A$rowMinus1")->getFont()->setBold(true);
25+
$sheet->getCell("A$row")->setValue(1);
26+
$sheet->getCell("B$row")->setValue(2);
27+
$sheet->getCell("C$row")->setValue(3);
28+
$sheet->getStyle("B$row")->getFont()->setBold(true);
29+
30+
$sheet->insertNewRowBefore($row);
31+
self::assertTrue(
32+
$sheet->getStyle("A$row")->getFont()->getBold()
33+
);
34+
self::assertFalse(
35+
$sheet->getStyle("B$row")->getFont()->getBold()
36+
);
37+
self::assertFalse(
38+
$sheet->getStyle("A$rowPlus1")->getFont()->getBold()
39+
);
40+
self::assertTrue(
41+
$sheet->getStyle("B$rowPlus1")->getFont()->getBold()
42+
);
43+
$spreadsheet->disconnectWorksheets();
44+
}
45+
}

tests/PhpSpreadsheetTests/Writer/Dompdf/PaperSizeArrayTest.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf;
1111
use PHPUnit\Framework\TestCase;
1212

13-
/**
14-
* Not clear that Dompdf will be Php8.4 compatible in time.
15-
* Run in separate process and add version test till it is ready.
16-
*
17-
* @runTestsInSeparateProcesses
18-
*/
1913
class PaperSizeArrayTest extends TestCase
2014
{
2115
private string $outfile = '';
@@ -42,11 +36,7 @@ public function testPaperSizeArray(): void
4236
$sheet->setCellValue('A7', 'Lorem Ipsum');
4337
$writer = new Dompdf($spreadsheet);
4438
$this->outfile = File::temporaryFilename();
45-
if (PHP_VERSION_ID >= 80400) { // hopefully temporary
46-
@$writer->save($this->outfile);
47-
} else {
48-
$writer->save($this->outfile);
49-
}
39+
$writer->save($this->outfile);
5040
$spreadsheet->disconnectWorksheets();
5141
unset($spreadsheet);
5242
$contents = file_get_contents($this->outfile);
@@ -66,11 +56,7 @@ public function testPaperSizeNotArray(): void
6656
$sheet->setCellValue('A7', 'Lorem Ipsum');
6757
$writer = new Dompdf($spreadsheet);
6858
$this->outfile = File::temporaryFilename();
69-
if (PHP_VERSION_ID >= 80400) { // hopefully temporary
70-
@$writer->save($this->outfile);
71-
} else {
72-
$writer->save($this->outfile);
73-
}
59+
$writer->save($this->outfile);
7460
$spreadsheet->disconnectWorksheets();
7561
unset($spreadsheet);
7662
$contents = file_get_contents($this->outfile);

0 commit comments

Comments
 (0)