From 972a27a97fc8005f2c51c2219ed9c8c98b6ccd1f Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Thu, 14 Mar 2024 10:13:09 +0100 Subject: [PATCH] Upgrade (and pin) PHPStan --- composer.json | 8 ++++---- phpstan-baseline.neon | 15 +++++++++++++++ phpstan.neon | 1 - tests/Stubs/InstantiableDocumentEnhancer.php | 5 +++++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 0720693..b6d745d 100644 --- a/composer.json +++ b/composer.json @@ -29,11 +29,11 @@ "facile-it/facile-coding-standard": "^0.4.1", "facile-it/symfony-functional-testcase": "^1.0", "infection/infection": "^0.18", - "jangregor/phpstan-prophecy": "^0.8.0", + "jangregor/phpstan-prophecy": "^1.0", "phpspec/prophecy-phpunit": "^2.0", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12.25", - "phpstan/phpstan-phpunit": "^0.12.8", + "phpstan/extension-installer": "^1.3", + "phpstan/phpstan": "1.10.62", + "phpstan/phpstan-phpunit": "^1.3", "phpunit/phpunit": "^9.5.2", "symfony/browser-kit": "^4.4 || ^5.0 || ^6.0", "symfony/flex": "^1.12", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 71f2dc4..9c34184 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -10,11 +10,26 @@ parameters: count: 1 path: src/Transport/Connection.php + - + message: "#^Method Facile\\\\MongoDbMessenger\\\\Transport\\\\Connection\\:\\:send\\(\\) should return MongoDB\\\\BSON\\\\ObjectId but returns mixed\\.$#" + count: 1 + path: src/Transport/Connection.php + + - + message: "#^Method Facile\\\\MongoDbMessenger\\\\Transport\\\\TransportFactory\\:\\:buildConfiguration\\(\\) should return array\\{connection_name\\: string, collection_name\\: string, queue_name\\: string, redeliver_timeout\\: int, document_enhancers\\: array\\, resettable\\: 0\\|1\\|bool\\} but returns non\\-empty\\-array\\\\.$#" + count: 1 + path: src/Transport/TransportFactory.php + - message: "#^Parameter \\#1 \\$enhancer of method Facile\\\\MongoDbMessenger\\\\Transport\\\\Connection\\:\\:addDocumentEnhancer\\(\\) expects Facile\\\\MongoDbMessenger\\\\Extension\\\\DocumentEnhancer, object\\|null given\\.$#" count: 1 path: src/Transport/TransportFactory.php + - + message: "#^Parameter \\#1 \\$enhancers of method Facile\\\\MongoDbMessenger\\\\Transport\\\\TransportFactory\\:\\:validateDocumentEnhancers\\(\\) expects array\\, mixed given\\.$#" + count: 1 + path: src/Transport/TransportFactory.php + - message: "#^Constructor of class Facile\\\\MongoDbMessenger\\\\Tests\\\\Stubs\\\\NotInstantiableDocumentEnhancer has an unused parameter \\$bar\\.$#" count: 1 diff --git a/phpstan.neon b/phpstan.neon index b1a7db4..ed3979f 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,7 +6,6 @@ parameters: dynamicConstantNames: - Symfony\Component\HttpKernel\Kernel::VERSION_ID ignoreErrors: - - /no value type specified in iterable type MongoDB\\Model\\BSONDocument\./ - /^Access to an undefined property MongoDB\\Model\\BSONDocument::\$\w+\.$/ includes: - phpstan-baseline.neon diff --git a/tests/Stubs/InstantiableDocumentEnhancer.php b/tests/Stubs/InstantiableDocumentEnhancer.php index cb6da67..7d4f66e 100644 --- a/tests/Stubs/InstantiableDocumentEnhancer.php +++ b/tests/Stubs/InstantiableDocumentEnhancer.php @@ -21,4 +21,9 @@ public function __construct(\DateTime $foo = null) public function enhance(BSONDocument $document, Envelope $envelope): void { } + + public function getFoo(): ?\DateTime + { + return $this->foo; + } }