bocmah/psalm-reactphp-promise-plugin

Psalm plugin for react/promise

Installs: 1 438

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 1

Open Issues: 0

Type:psalm-plugin

pkg:composer/bocmah/psalm-reactphp-promise-plugin

0.1.1 2021-01-27 20:40 UTC

This package is auto-updated.

Last update: 2025-09-28 07:14:18 UTC


README

A Psalm plugin for reactphp/promise.

Overview

This package brings support for template parameters in PromiseInterface. So you can type-hint resolution template parameter, e.g. PromiseInterface<User> instead of plain PromiseInterface.

It also adds an otherwise() method to PromiseInterface as a stub, which allows Psalm to recognize constructs like

$promise
    ->then(
        function () {
            echo 'Success' . PHP_EOL;
        }
    )
    ->otherwise(
        function (\Throwable $error) {
            echo 'Failure: ' . $error->getMessage() . PHP_EOL
        }
    );

Prerequisites

You should have Psalm installed.

Installation

Install plugin as a dev dependency via composer:

composer require --dev bocmah/psalm-reactphp-promise-plugin

Then enable the plugin:

./vendor/bin/psalm-plugin enable bocmah/psalm-reactphp-promise-plugin