From 9d30d48279672ec2c72f8e0096adf1fa773c2ebc Mon Sep 17 00:00:00 2001 From: core23 Date: Sat, 27 Jul 2019 09:43:48 +0200 Subject: [PATCH 1/2] [BUILD] Added more strict phpstan rules --- vendor-bin/phpstan/composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vendor-bin/phpstan/composer.json b/vendor-bin/phpstan/composer.json index d247e05b..e13413db 100644 --- a/vendor-bin/phpstan/composer.json +++ b/vendor-bin/phpstan/composer.json @@ -1,9 +1,12 @@ { "require": { + "ekino/phpstan-banned-code": "^0.1", "jangregor/phpstan-prophecy": "^0.4", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^0.11", - "phpstan/phpstan-phpunit": "^0.11" + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-strict-rules": "^0.11", + "phpstan/phpstan-symfony": "^0.11" }, "conflict": { "phpunit/phpunit": ">=8.0" From 72c22334d6f3af94d5fe3de293d035fd7c5313a7 Mon Sep 17 00:00:00 2001 From: core23 Date: Tue, 30 Jul 2019 18:46:16 +0200 Subject: [PATCH 2/2] [TEST] Fixed phpstan findings --- phpstan.neon | 6 ++++++ src/DependencyInjection/Configuration.php | 2 +- tests/Factory/DompdfFactoryTest.php | 3 --- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index f3dff892..de9980ef 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -8,6 +8,12 @@ parameters: ignoreErrors: # Symfony DI - '#Cannot call method defaultValue\(\) on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface\|null.#' + - "/Call to function method_exists.. with 'Symfony.+' and 'getRootNode' will always evaluate to false./" # Symfony Contracts - '#Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required.#' + + # PHPUnit + - + message: '#Property .*::\$.* has no typehint specified.#' + path: tests/ diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 05dbad63..8a137089 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -22,7 +22,7 @@ public function getConfigTreeBuilder() $treeBuilder = new TreeBuilder('core23_dompdf'); // Keep compatibility with symfony/config < 4.2 - if (!method_exists($treeBuilder, 'getRootNode')) { + if (!method_exists(TreeBuilder::class, 'getRootNode')) { $rootNode = $treeBuilder->root('core23_dompdf'); } else { $rootNode = $treeBuilder->getRootNode(); diff --git a/tests/Factory/DompdfFactoryTest.php b/tests/Factory/DompdfFactoryTest.php index 335735ac..5e04088f 100644 --- a/tests/Factory/DompdfFactoryTest.php +++ b/tests/Factory/DompdfFactoryTest.php @@ -12,7 +12,6 @@ namespace Core23\DompdfBundle\Tests\Factory; use Core23\DompdfBundle\Factory\DompdfFactory; -use Dompdf\Options; use PHPUnit\Framework\TestCase; final class DompdfFactoryTest extends TestCase @@ -35,7 +34,6 @@ public function testCreate(): void $options = $dompdf->getOptions(); - static::assertInstanceOf(Options::class, $options); static::assertSame(100, $options->getDpi()); } @@ -48,7 +46,6 @@ public function testCreateWithOptions(): void $options = $dompdf->getOptions(); - static::assertInstanceOf(Options::class, $options); static::assertSame('foo', $options->getTempDir()); static::assertSame(200, $options->getDpi()); }