1
0
mirror of https://github.com/danog/amp.git synced 2024-12-02 17:37:50 +01:00

Fix some Psalm issues

This commit is contained in:
Aaron Piotrowski 2021-12-02 17:28:45 -06:00
parent d70896df73
commit 49f5a5951a
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB
4 changed files with 8 additions and 8 deletions

View File

@ -135,6 +135,7 @@ final class Future
}
try {
/** @var T $value */
$state->complete($onComplete($value));
} catch (\Throwable $exception) {
$state->error($exception);

View File

@ -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
{

View File

@ -21,7 +21,7 @@ final class FutureState
private bool $handled = false;
/**
* @var array<string, callable(?\Throwable, ?T, string): void>
* @var array<string, \Closure(?\Throwable, ?T, string): void>
*/
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++;

View File

@ -5,8 +5,8 @@ namespace Amp\Internal;
/**
* Formats a stacktrace obtained via `debug_backtrace()`.
*
* @param array<array{file?: string, line: int, type?: string, class: string, function: string}> $trace Output of
* `debug_backtrace()`.
* @param list<array{args?:list<mixed>, 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"];
}