From 028181b142873076fa4f4162786bc470c81da197 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Thu, 21 Nov 2024 17:23:44 +0100 Subject: [PATCH 1/3] feat: fix PHP 8.4 deprecations --- src/Knp/Snappy/AbstractGenerator.php | 2 +- src/Knp/Snappy/Image.php | 2 +- src/Knp/Snappy/Pdf.php | 2 +- tests/Knp/Snappy/PdfTest.php | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Knp/Snappy/AbstractGenerator.php b/src/Knp/Snappy/AbstractGenerator.php index 2a93529b..529bc7cd 100644 --- a/src/Knp/Snappy/AbstractGenerator.php +++ b/src/Knp/Snappy/AbstractGenerator.php @@ -65,7 +65,7 @@ abstract class AbstractGenerator implements GeneratorInterface, LoggerAwareInter * @param array $options * @param null|array $env */ - public function __construct($binary, array $options = [], array $env = null) + public function __construct($binary, array $options = [], array|null $env = null) { $this->configure(); diff --git a/src/Knp/Snappy/Image.php b/src/Knp/Snappy/Image.php index a66310be..55dd03c4 100644 --- a/src/Knp/Snappy/Image.php +++ b/src/Knp/Snappy/Image.php @@ -13,7 +13,7 @@ class Image extends AbstractGenerator /** * {@inheritdoc} */ - public function __construct($binary = null, array $options = [], array $env = null) + public function __construct($binary = null, array $options = [], array|null $env = null) { $this->setDefaultExtension('jpg'); diff --git a/src/Knp/Snappy/Pdf.php b/src/Knp/Snappy/Pdf.php index b3a51ade..d177dee7 100644 --- a/src/Knp/Snappy/Pdf.php +++ b/src/Knp/Snappy/Pdf.php @@ -18,7 +18,7 @@ class Pdf extends AbstractGenerator /** * {@inheritdoc} */ - public function __construct($binary = null, array $options = [], array $env = null) + public function __construct($binary = null, array $options = [], array|null $env = null) { $this->setDefaultExtension('pdf'); $this->setOptionsWithContentCheck(); diff --git a/tests/Knp/Snappy/PdfTest.php b/tests/Knp/Snappy/PdfTest.php index 76ef84aa..36c0c50b 100644 --- a/tests/Knp/Snappy/PdfTest.php +++ b/tests/Knp/Snappy/PdfTest.php @@ -79,8 +79,8 @@ public function testRemovesLocalFilesOnError(): void $method->setAccessible(true); $method->invoke($pdf, 'test', $pdf->getDefaultExtension()); $this->assertEquals(1, \count($pdf->temporaryFiles)); - $this->expectException(Error::class); - \trigger_error('test error', \E_USER_ERROR); + $this->expectException(\RuntimeException::class); + throw new \RuntimeException('test error'); // @phpstan-ignore-next-line See https://github.com/phpstan/phpstan/issues/7799 $this->assertFileNotExists(\reset($pdf->temporaryFiles)); } From 6aee07e38c6c9cecb3c16aad2e5e23c672ddbb4e Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Thu, 21 Nov 2024 17:29:17 +0100 Subject: [PATCH 2/3] feat: fix PHP 8.4 deprecations --- tests/Knp/Snappy/PdfTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Knp/Snappy/PdfTest.php b/tests/Knp/Snappy/PdfTest.php index 36c0c50b..58f9117b 100644 --- a/tests/Knp/Snappy/PdfTest.php +++ b/tests/Knp/Snappy/PdfTest.php @@ -10,6 +10,7 @@ use CallbackFilterIterator; use DirectoryIterator; use ReflectionMethod; +use RuntimeException; class PdfTest extends TestCase { @@ -79,8 +80,9 @@ public function testRemovesLocalFilesOnError(): void $method->setAccessible(true); $method->invoke($pdf, 'test', $pdf->getDefaultExtension()); $this->assertEquals(1, \count($pdf->temporaryFiles)); - $this->expectException(\RuntimeException::class); - throw new \RuntimeException('test error'); + $this->expectException(RuntimeException::class); + + throw new RuntimeException('test error'); // @phpstan-ignore-next-line See https://github.com/phpstan/phpstan/issues/7799 $this->assertFileNotExists(\reset($pdf->temporaryFiles)); } From 3a05d201e4814ae0b8817b2d68638f476d5c143f Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Thu, 21 Nov 2024 17:31:21 +0100 Subject: [PATCH 3/3] feat: fix PHP 8.4 deprecations --- tests/Knp/Snappy/PdfTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/Knp/Snappy/PdfTest.php b/tests/Knp/Snappy/PdfTest.php index 58f9117b..22d12ce9 100644 --- a/tests/Knp/Snappy/PdfTest.php +++ b/tests/Knp/Snappy/PdfTest.php @@ -3,7 +3,6 @@ namespace Tests\Knp\Snappy; use Knp\Snappy\Pdf; -use PHPUnit\Framework\Error\Error; use PHPUnit\Framework\TestCase; use RecursiveDirectoryIterator; use FilesystemIterator; @@ -82,7 +81,7 @@ public function testRemovesLocalFilesOnError(): void $this->assertEquals(1, \count($pdf->temporaryFiles)); $this->expectException(RuntimeException::class); - throw new RuntimeException('test error'); + throw new RuntimeException('test error.'); // @phpstan-ignore-next-line See https://github.com/phpstan/phpstan/issues/7799 $this->assertFileNotExists(\reset($pdf->temporaryFiles)); }