Skip to content

Commit 3815843

Browse files
authored
Merge pull request #4165 from oleibman/dompdf84
Dompdf and Php8.4
2 parents 6c9b2a8 + 995d9c7 commit 3815843

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

src/PhpSpreadsheet/Helper/Sample.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use PhpOffice\PhpSpreadsheet\Spreadsheet;
1010
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
1111
use PhpOffice\PhpSpreadsheet\Writer\IWriter;
12+
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf;
1213
use RecursiveDirectoryIterator;
1314
use RecursiveIteratorIterator;
1415
use RecursiveRegexIterator;
@@ -125,7 +126,11 @@ public function write(Spreadsheet $spreadsheet, string $filename, array $writers
125126
$writerCallback($writer);
126127
}
127128
$callStartTime = microtime(true);
128-
$writer->save($path);
129+
if (PHP_VERSION_ID >= 80400 && $writer instanceof Dompdf) {
130+
@$writer->save($path);
131+
} else {
132+
$writer->save($path);
133+
}
129134
$this->logWrite($writer, $path, $callStartTime);
130135
if ($this->isCli() === false) {
131136
// @codeCoverageIgnoreStart

tests/PhpSpreadsheetTests/Functional/StreamTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
use PhpOffice\PhpSpreadsheet\Spreadsheet;
99
use PHPUnit\Framework\TestCase;
1010

11+
/**
12+
* Not clear that Dompdf will be Php8.4 compatible in time.
13+
* Run in separate process and add version test till it is ready.
14+
*
15+
* @runTestsInSeparateProcesses
16+
*/
1117
class StreamTest extends TestCase
1218
{
1319
public static function providerFormats(): array
@@ -42,7 +48,11 @@ public function testAllWritersCanWriteToStream(string $format): void
4248
} else {
4349
self::assertSame(0, $stat['size']);
4450

45-
$writer->save($stream);
51+
if ($format === 'Dompdf' && PHP_VERSION_ID >= 80400) {
52+
@$writer->save($stream);
53+
} else {
54+
$writer->save($stream);
55+
}
4656

4757
self::assertIsResource($stream, 'should not close the stream for further usage out of PhpSpreadsheet');
4858
$stat = fstat($stream);

tests/PhpSpreadsheetTests/Writer/Dompdf/PaperSizeArrayTest.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
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+
*/
1319
class PaperSizeArrayTest extends TestCase
1420
{
1521
private string $outfile = '';
@@ -36,7 +42,11 @@ public function testPaperSizeArray(): void
3642
$sheet->setCellValue('A7', 'Lorem Ipsum');
3743
$writer = new Dompdf($spreadsheet);
3844
$this->outfile = File::temporaryFilename();
39-
$writer->save($this->outfile);
45+
if (PHP_VERSION_ID >= 80400) { // hopefully temporary
46+
@$writer->save($this->outfile);
47+
} else {
48+
$writer->save($this->outfile);
49+
}
4050
$spreadsheet->disconnectWorksheets();
4151
unset($spreadsheet);
4252
$contents = file_get_contents($this->outfile);
@@ -56,7 +66,11 @@ public function testPaperSizeNotArray(): void
5666
$sheet->setCellValue('A7', 'Lorem Ipsum');
5767
$writer = new Dompdf($spreadsheet);
5868
$this->outfile = File::temporaryFilename();
59-
$writer->save($this->outfile);
69+
if (PHP_VERSION_ID >= 80400) { // hopefully temporary
70+
@$writer->save($this->outfile);
71+
} else {
72+
$writer->save($this->outfile);
73+
}
6074
$spreadsheet->disconnectWorksheets();
6175
unset($spreadsheet);
6276
$contents = file_get_contents($this->outfile);

0 commit comments

Comments
 (0)