From 40d07c86ae37e59d291d7ce9a10105c72d8ebd82 Mon Sep 17 00:00:00 2001 From: Frank Dekker Date: Sun, 11 May 2025 13:13:06 +0200 Subject: [PATCH 1/2] Fix phpstan codequality inspection --- src/Reader/Stream/AbstractStreamReader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Reader/Stream/AbstractStreamReader.php b/src/Reader/Stream/AbstractStreamReader.php index a0290728..98461676 100644 --- a/src/Reader/Stream/AbstractStreamReader.php +++ b/src/Reader/Stream/AbstractStreamReader.php @@ -28,7 +28,7 @@ public function __construct(protected $handle, private readonly bool $autoClose public function __destruct() { - if (isset($this->autoClose) && $this->autoClose) { + if ($this->autoClose) { fclose($this->handle); } } From 125ba73bee234e087ef069ad40e198a97fdae7dd Mon Sep 17 00:00:00 2001 From: Frank Dekker Date: Sun, 11 May 2025 13:19:08 +0200 Subject: [PATCH 2/2] Update baseline --- composer.json | 1 + phpstan-baseline.neon | 6 ++++++ src/Reader/Stream/AbstractStreamReader.php | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 00c46420..d04bd19f 100644 --- a/composer.json +++ b/composer.json @@ -87,6 +87,7 @@ "symfony/http-client": "Required for the remote hosts feature" }, "scripts": { + "baseline:phpstan": "@php vendor/bin/phpstan --generate-baseline", "check": ["@check:phpstan", "@check:phpmd", "@check:phpcs"], "check:phpstan": "phpstan analyse", "check:phpmd": "phpmd src,tests text phpmd.xml.dist", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b59be60b..95849f73 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -108,6 +108,12 @@ parameters: count: 1 path: src/DependencyInjection/Extension.php + - + message: '#^Property FD\\LogViewer\\Reader\\Stream\\AbstractStreamReader\:\:\$autoClose in isset\(\) is not nullable nor uninitialized\.$#' + identifier: isset.initializedProperty + count: 1 + path: src/Reader/Stream/AbstractStreamReader.php + - message: '#^Method FD\\LogViewer\\Reader\\String\\StringReader\:\:eol\(\) is marked as impure but does not have any side effects\.$#' identifier: impureMethod.pure diff --git a/src/Reader/Stream/AbstractStreamReader.php b/src/Reader/Stream/AbstractStreamReader.php index 98461676..a0290728 100644 --- a/src/Reader/Stream/AbstractStreamReader.php +++ b/src/Reader/Stream/AbstractStreamReader.php @@ -28,7 +28,7 @@ public function __construct(protected $handle, private readonly bool $autoClose public function __destruct() { - if ($this->autoClose) { + if (isset($this->autoClose) && $this->autoClose) { fclose($this->handle); } }