Skip to content

Commit

Permalink
Upgrade Dompdf to 8.4-Compatible Version
Browse files Browse the repository at this point in the history
  • Loading branch information
oleibman committed Dec 8, 2024
1 parent f37b119 commit 94df594
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 39 deletions.
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions src/PhpSpreadsheet/Helper/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -129,11 +128,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
Expand Down
12 changes: 1 addition & 11 deletions tests/PhpSpreadsheetTests/Functional/StreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 2 additions & 16 deletions tests/PhpSpreadsheetTests/Writer/Dompdf/PaperSizeArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 94df594

Please sign in to comment.