From 46f2d285736643767300929743be044e0f6d573d Mon Sep 17 00:00:00 2001 From: core23 Date: Sun, 3 Dec 2023 15:20:58 +0100 Subject: [PATCH] Fix CS --- phpunit.xml.dist | 13 ++-- psalm-baseline.xml | 8 ++- src/Exception/PdfException.php | 4 +- src/NucleosDompdfBundle.php | 4 +- src/Resources/config/services.php | 1 - tests/BundleIntegrationTest.php | 2 +- .../DependencyInjection/ConfigurationTest.php | 4 +- tests/Event/OutputEventTest.php | 5 +- tests/Event/StreamEventTest.php | 7 ++- tests/Factory/DompdfFactoryTest.php | 6 +- tests/Wrapper/DompdfWrapperTest.php | 63 ++++++++++--------- 11 files changed, 61 insertions(+), 56 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 02654369..10453952 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,10 +1,6 @@ - - - - ./src/ - - + + @@ -13,4 +9,9 @@ ./tests/ + + + ./src/ + + diff --git a/psalm-baseline.xml b/psalm-baseline.xml index c12cf157..b849f3f4 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,2 +1,8 @@ - + + + + children + + + diff --git a/src/Exception/PdfException.php b/src/Exception/PdfException.php index 20c5dc25..5e6a46e5 100644 --- a/src/Exception/PdfException.php +++ b/src/Exception/PdfException.php @@ -13,6 +13,4 @@ use Exception; -final class PdfException extends Exception -{ -} +final class PdfException extends Exception {} diff --git a/src/NucleosDompdfBundle.php b/src/NucleosDompdfBundle.php index cdbf2f79..e1e55a16 100644 --- a/src/NucleosDompdfBundle.php +++ b/src/NucleosDompdfBundle.php @@ -13,6 +13,4 @@ use Symfony\Component\HttpKernel\Bundle\Bundle; -final class NucleosDompdfBundle extends Bundle -{ -} +final class NucleosDompdfBundle extends Bundle {} diff --git a/src/Resources/config/services.php b/src/Resources/config/services.php index 3bbc87af..4af0dd16 100644 --- a/src/Resources/config/services.php +++ b/src/Resources/config/services.php @@ -42,6 +42,5 @@ ->args([ new Parameter('nucleos_dompdf.options'), ]) - ; }; diff --git a/tests/BundleIntegrationTest.php b/tests/BundleIntegrationTest.php index 340a3e0c..67f16632 100644 --- a/tests/BundleIntegrationTest.php +++ b/tests/BundleIntegrationTest.php @@ -28,6 +28,6 @@ public function testStartup(): void $client->request('GET', '/test'); - static::assertSame(200, $client->getResponse()->getStatusCode()); + self::assertSame(200, $client->getResponse()->getStatusCode()); } } diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index 42909bda..5a322b4d 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -30,7 +30,7 @@ public function testDefaultOptions(): void ], ]; - static::assertSame($expected, $config); + self::assertSame($expected, $config); } public function testOptions(): void @@ -51,6 +51,6 @@ public function testOptions(): void ], ]; - static::assertSame($expected, $config); + self::assertSame($expected, $config); } } diff --git a/tests/Event/OutputEventTest.php b/tests/Event/OutputEventTest.php index 4a3f5621..91018263 100644 --- a/tests/Event/OutputEventTest.php +++ b/tests/Event/OutputEventTest.php @@ -20,13 +20,14 @@ final class OutputEventTest extends TestCase public function testEvent(): void { $dompdf = $this->createMock(Dompdf::class); + /** @noinspection HtmlRequiredAltAttribute */ /** @noinspection HtmlUnknownTarget */ $html = "

Foo

Bar baz"; $event = new OutputEvent($dompdf, $html); - static::assertSame($dompdf, $event->getPdf()); - static::assertSame($html, $event->getHtml()); + self::assertSame($dompdf, $event->getPdf()); + self::assertSame($html, $event->getHtml()); } } diff --git a/tests/Event/StreamEventTest.php b/tests/Event/StreamEventTest.php index c57fe3c4..ec9eb6b7 100644 --- a/tests/Event/StreamEventTest.php +++ b/tests/Event/StreamEventTest.php @@ -21,14 +21,15 @@ public function testEvent(): void { $dompdf = $this->createMock(Dompdf::class); $filename = 'file.pdf'; + /** @noinspection HtmlRequiredAltAttribute */ /** @noinspection HtmlUnknownTarget */ $html = "

Foo

Bar baz"; $event = new StreamEvent($dompdf, $filename, $html); - static::assertSame($dompdf, $event->getPdf()); - static::assertSame($filename, $event->getFilename()); - static::assertSame($html, $event->getHtml()); + self::assertSame($dompdf, $event->getPdf()); + self::assertSame($filename, $event->getFilename()); + self::assertSame($html, $event->getHtml()); } } diff --git a/tests/Factory/DompdfFactoryTest.php b/tests/Factory/DompdfFactoryTest.php index f59aad34..b2ba4f1e 100644 --- a/tests/Factory/DompdfFactoryTest.php +++ b/tests/Factory/DompdfFactoryTest.php @@ -31,7 +31,7 @@ public function testCreate(): void $options = $dompdf->getOptions(); - static::assertSame(100, $options->getDpi()); + self::assertSame(100, $options->getDpi()); } public function testCreateWithOptions(): void @@ -43,7 +43,7 @@ public function testCreateWithOptions(): void $options = $dompdf->getOptions(); - static::assertSame('foo', $options->getTempDir()); - static::assertSame(200, $options->getDpi()); + self::assertSame('foo', $options->getTempDir()); + self::assertSame(200, $options->getDpi()); } } diff --git a/tests/Wrapper/DompdfWrapperTest.php b/tests/Wrapper/DompdfWrapperTest.php index 4a501472..5204bc9d 100644 --- a/tests/Wrapper/DompdfWrapperTest.php +++ b/tests/Wrapper/DompdfWrapperTest.php @@ -22,13 +22,13 @@ final class DompdfWrapperTest extends TestCase { - private MockObject&DompdfFactoryInterface $dompdfFactory; + private DompdfFactoryInterface&MockObject $dompdfFactory; - private MockObject&EventDispatcherInterface $eventDispatcher; + private EventDispatcherInterface&MockObject $eventDispatcher; private DompdfWrapper $dompdfWrapper; - private MockObject&Dompdf $dompdf; + private Dompdf&MockObject $dompdf; protected function setUp(): void { @@ -49,21 +49,21 @@ public function testStreamHtml(): void ->willReturn($this->dompdf) ; - $this->dompdf->expects(static::once()) + $this->dompdf->expects(self::once()) ->method('loadHtml') - ->with(static::equalTo($input)) + ->with(self::equalTo($input)) ; - $this->dompdf->expects(static::once()) + $this->dompdf->expects(self::once()) ->method('render') ; - $this->dompdf->expects(static::once()) + $this->dompdf->expects(self::once()) ->method('stream') - ->with(static::equalTo('file.pdf')) + ->with(self::equalTo('file.pdf')) ; - $this->eventDispatcher->expects(static::once()) + $this->eventDispatcher->expects(self::once()) ->method('dispatch') - ->with(static::anything(), static::equalTo(DompdfEvents::STREAM)) + ->with(self::anything(), self::equalTo(DompdfEvents::STREAM)) ; $this->dompdfWrapper->streamHtml($input, 'file.pdf'); @@ -74,31 +74,32 @@ public function testStreamHtmlWithImg(): void /** @noinspection HtmlRequiredAltAttribute */ /** @noinspection HtmlUnknownTarget */ $input = "

Foo

Bar baz"; + /** @noinspection HtmlRequiredAltAttribute */ /** @noinspection HtmlUnknownTarget */ $output = "

Foo

Bar baz"; $this->dompdfFactory ->method('create') - ->with(static::equalTo(['tempDir' => 'bar'])) + ->with(self::equalTo(['tempDir' => 'bar'])) ->willReturn($this->dompdf) ; - $this->dompdf->expects(static::once()) + $this->dompdf->expects(self::once()) ->method('loadHtml') - ->with(static::equalTo($output)) + ->with(self::equalTo($output)) ; - $this->dompdf->expects(static::once()) + $this->dompdf->expects(self::once()) ->method('render') ; - $this->dompdf->expects(static::once()) + $this->dompdf->expects(self::once()) ->method('stream') - ->with(static::equalTo('file.pdf')) + ->with(self::equalTo('file.pdf')) ; - $this->eventDispatcher->expects(static::once()) + $this->eventDispatcher->expects(self::once()) ->method('dispatch') - ->with(static::anything(), static::equalTo(DompdfEvents::STREAM)) + ->with(self::anything(), self::equalTo(DompdfEvents::STREAM)) ; $this->dompdfWrapper->streamHtml($input, 'file.pdf', ['tempDir' => 'bar']); @@ -112,9 +113,9 @@ public function testGetPdf(): void $this->prepareOutput($input, 'BINARY_CONTENT'); - $this->eventDispatcher->expects(static::once()) + $this->eventDispatcher->expects(self::once()) ->method('dispatch') - ->with(static::anything(), static::equalTo(DompdfEvents::OUTPUT)) + ->with(self::anything(), self::equalTo(DompdfEvents::OUTPUT)) ; $this->dompdfWrapper->getPdf($input, ['tempDir' => 'bar']); @@ -128,9 +129,9 @@ public function testGetPdfWithError(): void $this->prepareOutput($input); - $this->eventDispatcher->expects(static::once()) + $this->eventDispatcher->expects(self::once()) ->method('dispatch') - ->with(static::anything(), static::equalTo(DompdfEvents::OUTPUT)) + ->with(self::anything(), self::equalTo(DompdfEvents::OUTPUT)) ; $this->dompdfWrapper->getPdf($input); @@ -143,16 +144,16 @@ public function testGetStreamResponse(): void ->willReturn($this->dompdf) ; - $this->dompdf->expects(static::once()) + $this->dompdf->expects(self::once()) ->method('loadHtml') - ->with(static::equalTo('

Title

')) + ->with(self::equalTo('

Title

')) ; - $this->dompdf->expects(static::once()) + $this->dompdf->expects(self::once()) ->method('render') ; - $this->dompdf->expects(static::once()) + $this->dompdf->expects(self::once()) ->method('stream') - ->with(static::equalTo('file.pdf')) + ->with(self::equalTo('file.pdf')) ; $response = $this->dompdfWrapper->getStreamResponse('

Title

', 'file.pdf'); @@ -166,14 +167,14 @@ private function prepareOutput(string $input, ?string $response = null): void ->willReturn($this->dompdf) ; - $this->dompdf->expects(static::once()) + $this->dompdf->expects(self::once()) ->method('loadHtml') - ->with(static::equalTo($input)) + ->with(self::equalTo($input)) ; - $this->dompdf->expects(static::once()) + $this->dompdf->expects(self::once()) ->method('render') ; - $this->dompdf->expects(static::once()) + $this->dompdf->expects(self::once()) ->method('output') ->willReturn($response) ;