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..2219c8dac 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,6 +1,6 @@ + + + diff --git a/src/Collector/Console/CommandCollector.php b/src/Collector/Console/CommandCollector.php index b97e64f1f..0f14a83b4 100644 --- a/src/Collector/Console/CommandCollector.php +++ b/src/Collector/Console/CommandCollector.php @@ -68,17 +68,14 @@ public function collect(ConsoleEvent|ConsoleErrorEvent|ConsoleTerminateEvent $ev return; } - /** @noinspection PhpConditionAlreadyCheckedInspection */ - if ($event instanceof ConsoleEvent) { - $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(), - ]; - } + $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..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; @@ -68,7 +66,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); }