From 5711e53723e3e86bdeacf68c5048c37304b0d9d8 Mon Sep 17 00:00:00 2001 From: Manuel Dalla Lana Date: Tue, 21 May 2024 17:01:53 +0200 Subject: [PATCH 1/5] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index da56aa0..c8a2f19 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,8 @@ $pdf->generateFromHtml('

Bill

You owe me money, dude.

', '/tmp/bill $pdf = new Pdf('/usr/local/bin/weasyprint'); $pdf->setOption('encoding', 'utf8'); $pdf->setOption('media-type', 'screen'); -$pdf->setOption('presentational-hints'); -$pdf->setOption('optimize-size', 'all'); +$pdf->setOption('presentational-hints', true); +$pdf->setOption('optimize-images', true); $pdf->setOption('stylesheet', ['/path/to/first-style.css', '/path/to/second-style.css']); $pdf->setOption('attachment', ['/path/to/image.png', '/path/to/logo.jpg']); ``` @@ -83,7 +83,7 @@ $pdf->resetOptions(); ## Differences with Snappy -Although PhpWeasyPrint and Snappy are interchangeable, there are a couple of differences between the two, due to WeasyPrint cli API: +Although PhpWeasyPrint and Snappy are interchangeable, there are a couple of differences between the two, due to WeasyPrint CLI API: * WeasyPrint doesn't support multiple sources to be merged in one single output pdf, so only one input source (string or URL) is accepted in PhpWeasyPrint; * WeasyPrint version >= 53 doesn't generate images, so image generation from HTML string or URL is possible only with WeasyPrint lower versions and an unsupported PhpWeasyPrint version (`Pontedilana\PhpWeasyPrint\Image` has been successfully tested with Weasyprint 52.5 on PhpWeasyPrint 0.13.0). From a773a8e78d38c6f016110aa2014b7b1428aa1cbd Mon Sep 17 00:00:00 2001 From: Manuel Dalla Lana Date: Mon, 4 Nov 2024 14:57:27 +0100 Subject: [PATCH 2/5] Support WeasyPrint 63.0 new option --- CHANGELOG.md | 4 +++- src/Pdf.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 281e567..bf4ffbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog(https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning(https://semver.org/spec/v2.0.0.html). ## Unreleased +### Added +- Support WeasyPrint 63.0 new `srgb` option ## 1.4.0 - 2023-11-20 ### Changed @@ -12,7 +14,7 @@ and this project adheres to [Semantic Versioning(https://semver.org/spec/v2.0.0. ## 1.3.0 - 2023-10-07 ### Added -- Support WeasyPrint 60.0 new option +- Support WeasyPrint 60.0 new `timeout` option ## 1.2.0 - 2023-05-11 ### Added diff --git a/src/Pdf.php b/src/Pdf.php index 2bf121e..649d309 100644 --- a/src/Pdf.php +++ b/src/Pdf.php @@ -121,6 +121,7 @@ protected function configure(): void 'optimize-images' => null, // no longer deprecated in WeasyPrint 59.0b1 'cache-folder' => null, // added in WeasyPrint 59.0b1 'timeout' => null, // added in WeasyPrint 60.0 + 'srgb' => null, // added in WeasyPrint 63.0 // Deprecated 'format' => null, // deprecated in WeasyPrint 53.0b2 'resolution' => null, // deprecated - png only From 4b3248d1ed3bdcf94cadd1c5751b591d80d7a4ec Mon Sep 17 00:00:00 2001 From: Manuel Dalla Lana Date: Mon, 4 Nov 2024 15:23:45 +0100 Subject: [PATCH 3/5] Add support for PHP 8.4 --- .gitattributes | 2 +- .github/workflows/ci.yaml | 3 ++- CHANGELOG.md | 1 + composer.json | 6 +++--- phpstan.dist.neon | 11 +++++++++++ phpstan.neon.dist | 10 ---------- src/AbstractGenerator.php | 2 +- src/Pdf.php | 2 +- 8 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 phpstan.dist.neon delete mode 100644 phpstan.neon.dist diff --git a/.gitattributes b/.gitattributes index 0de11b3..f76f33f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,6 +4,6 @@ tests/ export-ignore .gitignore export-ignore .php-cs-fixer-dist.php export-ignore infection.json.dist export-ignore -phpstan.neon.dist export-ignore +phpstan.dist.neon export-ignore phpstan-baseline.neon export-ignore phpunit.xml.dist export-ignore diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7d9bee4..2e0e2a0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,6 +13,7 @@ jobs: - "8.1" - "8.2" - "8.3" + - "8.4" name: PHP ${{ matrix.php-version }} @@ -47,7 +48,7 @@ jobs: run: composer install --no-progress --prefer-dist --optimize-autoloader - name: Run PHPStan - run: phpstan --xdebug analyse src + run: phpstan analyse src - name: Test with PHPUnit run: ./vendor/bin/phpunit diff --git a/CHANGELOG.md b/CHANGELOG.md index bf4ffbc..3fe9063 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning(https://semver.org/spec/v2.0.0. ## Unreleased ### Added - Support WeasyPrint 63.0 new `srgb` option +- Added support for PHP 8.4 ## 1.4.0 - 2023-11-20 ### Changed diff --git a/composer.json b/composer.json index 50bc984..359af77 100644 --- a/composer.json +++ b/composer.json @@ -15,14 +15,14 @@ } ], "require": { - "php": "7.4.* || 8.0.* || 8.1.* || 8.2.* || 8.3.*", + "php": "7.4.* || 8.0.* || 8.1.* || 8.2.* || 8.3.* || 8.4.*", "psr/log": "^1.1 || ^2.0 || ^3.0", - "symfony/process": "^5.4 || ^6.2 || ^7" + "symfony/process": "^5.4 || ^6.2 || ^7" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.4", "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.2", + "phpstan/phpstan": "^1.12", "phpstan/phpstan-phpunit": "^1.0", "phpunit/phpunit": "^9.5" }, diff --git a/phpstan.dist.neon b/phpstan.dist.neon new file mode 100644 index 0000000..71fc037 --- /dev/null +++ b/phpstan.dist.neon @@ -0,0 +1,11 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: 8 + paths: + - src/ + - tests/ + inferPrivatePropertyTypeFromConstructor: true + ignoreErrors: + - identifier: missingType.iterableValue diff --git a/phpstan.neon.dist b/phpstan.neon.dist deleted file mode 100644 index 2acbb70..0000000 --- a/phpstan.neon.dist +++ /dev/null @@ -1,10 +0,0 @@ -includes: - - phpstan-baseline.neon - -parameters: - level: 8 - paths: - - src/ - - tests/ - inferPrivatePropertyTypeFromConstructor: true - checkMissingIterableValueType: false diff --git a/src/AbstractGenerator.php b/src/AbstractGenerator.php index f564731..0eb1652 100644 --- a/src/AbstractGenerator.php +++ b/src/AbstractGenerator.php @@ -39,7 +39,7 @@ abstract class AbstractGenerator implements GeneratorInterface, LoggerAwareInter * @param array $options * @param array|null $env */ - public function __construct(string $binary = null, array $options = [], array $env = null) + public function __construct(?string $binary = null, array $options = [], ?array $env = null) { $this->configure(); diff --git a/src/Pdf.php b/src/Pdf.php index 649d309..e21cf43 100644 --- a/src/Pdf.php +++ b/src/Pdf.php @@ -17,7 +17,7 @@ class Pdf extends AbstractGenerator /** * {@inheritdoc} */ - public function __construct(string $binary = null, array $options = [], array $env = null) + public function __construct(?string $binary = null, array $options = [], ?array $env = null) { $this->setDefaultExtension('pdf'); $this->setOptionsWithContentCheck(); From ad9cc37b291064a9699c44b5189c93c30c7c2554 Mon Sep 17 00:00:00 2001 From: Manuel Dalla Lana Date: Mon, 4 Nov 2024 15:58:28 +0100 Subject: [PATCH 4/5] Bump dev tools versions --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 359af77..d536c27 100644 --- a/composer.json +++ b/composer.json @@ -20,11 +20,11 @@ "symfony/process": "^5.4 || ^6.2 || ^7" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.4", - "phpstan/extension-installer": "^1.1", + "friendsofphp/php-cs-fixer": "^3.64", + "phpstan/extension-installer": "^1.4", "phpstan/phpstan": "^1.12", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5" + "phpstan/phpstan-phpunit": "^1.4", + "phpunit/phpunit": "^9.6" }, "autoload": { "psr-4": { From 35047c76710dce795d71b75acc6e349dd9f05c68 Mon Sep 17 00:00:00 2001 From: Manuel Dalla Lana Date: Mon, 4 Nov 2024 16:01:30 +0100 Subject: [PATCH 5/5] Set release version to 1.5.0 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fe9063..8a90cad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog(https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning(https://semver.org/spec/v2.0.0.html). ## Unreleased + +## 1.5.0 - 2024-11-04 ### Added - Support WeasyPrint 63.0 new `srgb` option - Added support for PHP 8.4