From 4f3b4a2d0400c22559d3c4fa2ccb3bc096eafb42 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 7 Jan 2024 14:56:27 +0300 Subject: [PATCH 1/3] config --- composer.json | 2 +- psalm.xml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 776c84b96..a45f0f60f 100644 --- a/composer.json +++ b/composer.json @@ -50,7 +50,7 @@ "rector/rector": "^0.15.18", "roave/infection-static-analysis-plugin": "^1.16", "spatie/phpunit-watcher": "^1.23", - "vimeo/psalm": "^4.30|^5.7", + "vimeo/psalm": "^5.18", "yiisoft/error-handler": "^3.0", "yiisoft/event-dispatcher": "^1.0", "yiisoft/log": "^2.0", diff --git a/psalm.xml b/psalm.xml index 471615b1a..c2b9ad21a 100644 --- a/psalm.xml +++ b/psalm.xml @@ -13,4 +13,7 @@ + + + From d2ba9a351d237417699b66766776754ce2aa8a3e Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 7 Jan 2024 15:03:44 +0300 Subject: [PATCH 2/3] level 4 --- psalm.xml | 2 +- src/Collector/Console/CommandCollector.php | 19 ++++++++----------- .../Stream/FilesystemStreamProxy.php | 4 ++-- src/Collector/Stream/HttpStreamProxy.php | 4 ++-- src/Collector/Web/RequestCollector.php | 2 +- src/Helper/StreamWrapper/StreamWrapper.php | 10 +++++++++- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/psalm.xml b/psalm.xml index c2b9ad21a..2219c8dac 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,6 +1,6 @@ commands[$event::class] = [ - 'name' => $command->getName(), - 'command' => $command, - 'input' => $this->castInputToString($event->getInput()), - 'output' => $this->fetchOutput($event->getOutput()), - 'arguments' => $command->getDefinition()->getArguments(), - 'options' => $command->getDefinition()->getOptions(), - ]; - } + $this->commands[$event::class] = [ + 'name' => $command->getName(), + 'command' => $command, + 'input' => $this->castInputToString($event->getInput()), + 'output' => $this->fetchOutput($event->getOutput()), + 'arguments' => $command->getDefinition()->getArguments(), + 'options' => $command->getDefinition()->getOptions(), + ]; } public function getSummary(): array diff --git a/src/Collector/Stream/FilesystemStreamProxy.php b/src/Collector/Stream/FilesystemStreamProxy.php index d0ab06133..75fdd865e 100644 --- a/src/Collector/Stream/FilesystemStreamProxy.php +++ b/src/Collector/Stream/FilesystemStreamProxy.php @@ -11,14 +11,14 @@ use const SEEK_SET; -class FilesystemStreamProxy implements StreamWrapperInterface +final class FilesystemStreamProxy implements StreamWrapperInterface { public static bool $registered = false; /** * @var resource|null */ public $context; - public StreamWrapperInterface $decorated; + public StreamWrapper $decorated; public bool $ignored = false; public static ?FilesystemStreamCollector $collector = null; diff --git a/src/Collector/Stream/HttpStreamProxy.php b/src/Collector/Stream/HttpStreamProxy.php index f4c7e7ff4..cd85ffac1 100644 --- a/src/Collector/Stream/HttpStreamProxy.php +++ b/src/Collector/Stream/HttpStreamProxy.php @@ -13,7 +13,7 @@ use const SEEK_SET; -class HttpStreamProxy implements StreamWrapperInterface +final class HttpStreamProxy implements StreamWrapperInterface { public static bool $registered = false; public static array $ignoredPathPatterns = []; @@ -23,7 +23,7 @@ class HttpStreamProxy implements StreamWrapperInterface * @var resource|null */ public $context; - public StreamWrapperInterface $decorated; + public StreamWrapper $decorated; public bool $ignored = false; public static ?HttpStreamCollector $collector = null; diff --git a/src/Collector/Web/RequestCollector.php b/src/Collector/Web/RequestCollector.php index 3dcb9ab48..f92348dba 100644 --- a/src/Collector/Web/RequestCollector.php +++ b/src/Collector/Web/RequestCollector.php @@ -68,7 +68,7 @@ public function getCollected(): array public function collect(object $event): void { - if (!is_object($event) || !$this->isActive()) { + if (!$this->isActive()) { return; } diff --git a/src/Helper/StreamWrapper/StreamWrapper.php b/src/Helper/StreamWrapper/StreamWrapper.php index cda2ee633..859c9b4a5 100644 --- a/src/Helper/StreamWrapper/StreamWrapper.php +++ b/src/Helper/StreamWrapper/StreamWrapper.php @@ -32,6 +32,10 @@ final class StreamWrapper implements StreamWrapperInterface public function dir_closedir(): bool { closedir($this->stream); + + /** + * @psalm-suppress RedundantCondition + */ return is_resource($this->stream); } @@ -54,7 +58,11 @@ public function dir_rewinddir(): bool } rewinddir($this->stream); - /** @noinspection PhpConditionAlreadyCheckedInspection */ + + /** + * @noinspection PhpConditionAlreadyCheckedInspection + * @psalm-suppress RedundantCondition + */ return is_resource($this->stream); } From 8e008e6769e13739c507dd3875eb8184b9020563 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Sun, 7 Jan 2024 12:04:10 +0000 Subject: [PATCH 3/3] Apply fixes from StyleCI --- src/Collector/Web/RequestCollector.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Collector/Web/RequestCollector.php b/src/Collector/Web/RequestCollector.php index f92348dba..c9b91a367 100644 --- a/src/Collector/Web/RequestCollector.php +++ b/src/Collector/Web/RequestCollector.php @@ -13,8 +13,6 @@ use Yiisoft\Yii\Http\Event\AfterRequest; use Yiisoft\Yii\Http\Event\BeforeRequest; -use function is_object; - final class RequestCollector implements SummaryCollectorInterface { use CollectorTrait;