Skip to content

Commit

Permalink
Merge pull request #515 from Chris53897/feature/php-84
Browse files Browse the repository at this point in the history
feat: fix PHP 8.4 deprecations
  • Loading branch information
alexpozzi authored Jan 6, 2025
2 parents 5388a1a + 3a05d20 commit 8c502df
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Knp/Snappy/AbstractGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/Knp/Snappy/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion src/Knp/Snappy/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 4 additions & 3 deletions tests/Knp/Snappy/PdfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit 8c502df

Please sign in to comment.