diff --git a/etc/qa/phpstan.neon b/etc/qa/phpstan.neon index e618f21..ad3c984 100644 --- a/etc/qa/phpstan.neon +++ b/etc/qa/phpstan.neon @@ -1,5 +1,9 @@ parameters: level: max + ignoreErrors: + - + message: '#Result of method ReactParallel\\Runtime\\Runtime::run\(\) \(void\) is used.#' + path: ../../tests/Types.php ergebnis: noExtends: classesAllowedToBeExtended: diff --git a/src/Runtime.php b/src/Runtime.php index d0846e1..991cb48 100644 --- a/src/Runtime.php +++ b/src/Runtime.php @@ -26,10 +26,10 @@ public function __construct(private EventLoopBridge $eventLoopBridge, string $au } /** - * @param (Closure():?T) $callable + * @param (Closure():T)|(Closure():void) $callable * @param array $args * - * @return ?T + * @return ($callable is (Closure():T) ? T : null) * * @template T */ diff --git a/tests/Types.php b/tests/Types.php new file mode 100644 index 0000000..ecbc388 --- /dev/null +++ b/tests/Types.php @@ -0,0 +1,21 @@ +run(static function (): bool { + return true; +})); + +assertType('bool|int', $pool->run(static function (): bool|int { + return time() % 2 !== 0 ? true : time(); +})); + +assertType('null', $pool->run(static function () { +}));