diff --git a/src/Future.php b/src/Future.php index 3c5cffb..09eb56c 100644 --- a/src/Future.php +++ b/src/Future.php @@ -135,6 +135,7 @@ final class Future } try { + /** @var T $value */ $state->complete($onComplete($value)); } catch (\Throwable $exception) { $state->error($exception); diff --git a/src/Internal/Cancellable.php b/src/Internal/Cancellable.php index 240406d..cdf5008 100644 --- a/src/Internal/Cancellable.php +++ b/src/Internal/Cancellable.php @@ -18,8 +18,7 @@ final class Cancellable implements Cancellation /** @var callable[] */ private array $callbacks = []; - /** @var \Throwable|null */ - private ?\Throwable $exception = null; + private ?CancelledException $exception = null; public function cancel(?\Throwable $previous = null): void { diff --git a/src/Internal/FutureState.php b/src/Internal/FutureState.php index 43d9e1f..a5da429 100644 --- a/src/Internal/FutureState.php +++ b/src/Internal/FutureState.php @@ -21,7 +21,7 @@ final class FutureState private bool $handled = false; /** - * @var array + * @var array */ private array $callbacks = []; @@ -45,12 +45,12 @@ final class FutureState * * The callback is invoked directly from the event loop context, so suspension within the callback is not possible. * - * @param callable(?\Throwable, ?T, string): void $callback Callback invoked on error / successful completion of + * @param \Closure(?\Throwable, ?T, string): void $callback Callback invoked on error / successful completion of * the future. * * @return string Identifier that can be used to cancel interest for this future. */ - public function subscribe(callable $callback): string + public function subscribe(\Closure $callback): string { $id = self::$nextId++; diff --git a/src/Internal/functions.php b/src/Internal/functions.php index 3678fa8..8668129 100644 --- a/src/Internal/functions.php +++ b/src/Internal/functions.php @@ -5,8 +5,8 @@ namespace Amp\Internal; /** * 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. * @@ -22,7 +22,7 @@ function formatStacktrace(array $trace): string $line .= "{$e['file']}:{$e['line']} "; } - if (isset($e["type"])) { + if (isset($e["class"], $e["type"])) { $line .= $e["class"] . $e["type"]; }