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..22d12ce9 100644 --- a/tests/Knp/Snappy/PdfTest.php +++ b/tests/Knp/Snappy/PdfTest.php @@ -3,13 +3,13 @@ namespace Tests\Knp\Snappy; use Knp\Snappy\Pdf; -use PHPUnit\Framework\Error\Error; use PHPUnit\Framework\TestCase; use RecursiveDirectoryIterator; use FilesystemIterator; use CallbackFilterIterator; use DirectoryIterator; use ReflectionMethod; +use RuntimeException; class PdfTest extends TestCase { @@ -79,8 +79,9 @@ 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)); }