Skip to content

Commit 5913164

Browse files
committed
Merge branch 'release/4.0.0' into develop
2 parents 82e187d + 24a6add commit 5913164

File tree

4 files changed

+22
-28
lines changed

4 files changed

+22
-28
lines changed

CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4-
The format is based on [Keep a Changelog](http://keepachangelog.com/)
5-
and this project adheres to [Semantic Versioning](http://semver.org/).
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/)
5+
and this project adheres to [Semantic Versioning](https://semver.org/).
6+
7+
## [4.0.0] - 2023-07-09
8+
### Changed
9+
- Raised minimum PHP version to 7.4
10+
- Small refactorings for typehints
11+
- Debug file appends content now
12+
### Fixed
13+
- Issue with pdf author not being set correctly
614

715
## [3.1.0] - 2022-08-24
816
### Changed

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ parameters:
44
- php
55
paths:
66
- src/
7-
excludes_analyse:
7+
excludePaths:
88
- src/Model/Merger/Zendpdf.php

src/Model/Generator/Dompdf.php

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* DOMPdf generator class
4-
*
53
* @section LICENSE
64
* This file is created by vianetz <[email protected]>.
75
* The code is distributed under the GPL license.
@@ -33,16 +31,10 @@ final class Dompdf extends AbstractGenerator
3331
{
3432
private const TOTAL_PAGE_COUNT_PLACEHOLDER = '__PDF_TPC__';
3533

36-
/** @var \Dompdf\Dompdf */
37-
private $domPdf;
34+
private \Dompdf\Dompdf $domPdf;
3835

39-
/**
40-
* Render the pdf document.
41-
*
42-
* @return string|null
43-
* @throws \Exception
44-
*/
45-
public function renderPdfDocument(DocumentInterface $documentModel)
36+
/** @throws \Exception */
37+
public function renderPdfDocument(DocumentInterface $documentModel): ?string
4638
{
4739
$this->initPdf();
4840

@@ -54,12 +46,7 @@ public function renderPdfDocument(DocumentInterface $documentModel)
5446
return $this->domPdf->output();
5547
}
5648

57-
/**
58-
* Init PDF default settings.
59-
*
60-
* @return Dompdf
61-
*/
62-
protected function initPdf()
49+
protected function initPdf(): self
6350
{
6451
$this->domPdf = new \Dompdf\Dompdf($this->getDompdfOptions());
6552

@@ -91,23 +78,23 @@ protected function getHtmlContentsForDocument(DocumentInterface $documentModel):
9178
*
9279
* @return array<string,mixed>
9380
*/
94-
private function getDompdfOptions()
81+
private function getDompdfOptions(): array
9582
{
96-
return array(
83+
return [
9784
'isPhpEnabled' => true,
9885
'isRemoteEnabled' => true,
9986
'chroot' => $this->config->getChrootDir(),
100-
);
87+
];
10188
}
10289

10390
private function injectPageCount(): void
10491
{
10592
$canvas = $this->domPdf->getCanvas();
106-
$pdf = $canvas->get_cpdf();
93+
$pdf = $canvas->get_cpdf(); // @phpstan-ignore-line
10794

10895
foreach ($pdf->objects as &$o) {
10996
if ($o['t'] === 'contents') {
110-
$o['c'] = str_replace(self::TOTAL_PAGE_COUNT_PLACEHOLDER, $canvas->get_page_count(), $o['c']);
97+
$o['c'] = str_replace(self::TOTAL_PAGE_COUNT_PLACEHOLDER, (string)$canvas->get_page_count(), $o['c']);
11198
}
11299
}
113100
}

src/Model/Pdf.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,11 @@ final public function saveToFile($fileName)
102102
/**
103103
* Add a new document to generate.
104104
*
105-
* @param \Vianetz\Pdf\Model\DocumentInterface|\Vianetz\Pdf\Model\PdfDocumentInterface
105+
* @param \Vianetz\Pdf\Model\DocumentInterface|\Vianetz\Pdf\Model\PdfDocumentInterface $documentModel
106106
*
107107
* @api
108-
* @return Pdf
109108
*/
110-
final public function addDocument($documentModel)
109+
final public function addDocument($documentModel): self
111110
{
112111
$this->documents[] = $documentModel;
113112
// Reset cached pdf contents.

0 commit comments

Comments
 (0)