diff --git a/composer.json b/composer.json index c69c780..2c6374e 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,7 @@ "ext-json": "*", "phpunit/phpunit": "^9", "jetbrains/phpstorm-stubs": "^2019.3", - "psalm/phar": "^5" + "psalm/phar": "^5.15" }, "autoload": { "psr-4": { diff --git a/psalm.xml b/psalm.xml index 42fe89f..97e89ec 100644 --- a/psalm.xml +++ b/psalm.xml @@ -60,6 +60,12 @@ + + + + + + diff --git a/src/EventLoop/Driver/StreamSelectDriver.php b/src/EventLoop/Driver/StreamSelectDriver.php index 03b8a1b..ad413d2 100644 --- a/src/EventLoop/Driver/StreamSelectDriver.php +++ b/src/EventLoop/Driver/StreamSelectDriver.php @@ -304,7 +304,7 @@ private function selectStreams(array $read, array $write, float $timeout): void } if ($timeout > 0) { // Sleep until next timer expires. - /** @psalm-var positive-int $timeout */ + /** @psalm-suppress ArgumentTypeCoercion $timeout is positive here. */ \usleep((int) ($timeout * 1_000_000)); } } diff --git a/src/EventLoop/Driver/TracingDriver.php b/src/EventLoop/Driver/TracingDriver.php index d16ea32..6f59ad8 100644 --- a/src/EventLoop/Driver/TracingDriver.php +++ b/src/EventLoop/Driver/TracingDriver.php @@ -249,8 +249,15 @@ private function getCancelTrace(string $callbackId): string /** * Formats a stacktrace obtained via `debug_backtrace()`. * - * @param array $trace - * Output of `debug_backtrace()`. + * @param list, + * class?: class-string, + * file?: string, + * function: string, + * line?: int, + * object?: object, + * type?: string + * }> $trace Output of `debug_backtrace()`. * * @return string Formatted stacktrace. */ @@ -259,7 +266,7 @@ private function formatStacktrace(array $trace): string return \implode("\n", \array_map(static function ($e, $i) { $line = "#{$i} "; - if (isset($e["file"])) { + if (isset($e["file"], $e['line'])) { $line .= "{$e['file']}:{$e['line']} "; } diff --git a/src/EventLoop/Internal/AbstractDriver.php b/src/EventLoop/Internal/AbstractDriver.php index bfb87c2..0a71d91 100644 --- a/src/EventLoop/Internal/AbstractDriver.php +++ b/src/EventLoop/Internal/AbstractDriver.php @@ -534,6 +534,7 @@ private function createLoopFiber(): void // Invoke microtasks if we have some $this->invokeCallbacks(); + /** @psalm-suppress RedundantCondition $this->stopped may be changed by $this->invokeCallbacks(). */ while (!$this->stopped) { if ($this->interrupt) { $this->invokeInterrupt();