Search by

alies-dev / psalm-plugin-pest

alies-dev

Psalm plugin for Pest: types $this in test closures as the configured TestCase (with its traits and beforeEach() properties), resolves expectation and higher-order test chains, narrows types after expect() and accepts Pest's public API.

Package info

github.com/alies-dev/psalm-plugin-pest

Type:psalm-plugin

pkg:composer/alies-dev/psalm-plugin-pest

Statistics

Installs: 1 488

Dependents: 1

Suggesters: 0

Stars: 2

Open Issues: 0

1.0.0 2026-11-06 13:52 UTC

This package is auto-updated.

Last update: 2026-11-06 21:27:20 UTC


README

psalm-plugin-pest: makes Psalm understand Pest tests

Your Pest tests, fully typed. Bugs contained.

Latest version Downloads License

This plugin teaches Psalm how Pest really works. Keep your tests in the analysis, get real types and catch broken tests before you run them.

Install

Requires Psalm 7 and Pest 4 or 5.

composer require --dev alies-dev/psalm-plugin-pest
vendor/bin/psalm-plugin enable alies-dev/psalm-plugin-pest

That's it. Make sure tests/ is in <projectFiles> of your psalm.xml.

Before and after

uses(Tests\TestCase::class);

beforeEach(function () {
    $this->cart = new Cart();
});

it('totals the cart', function () {
    $this->actingAs(admin());       // before: TestCall::__call(), unchecked
                                    // after:  Tests\TestCase::actingAs()

    $total = $this->cart->total();  // before: TestCall, so $total is TestCall
                                    // after:  Cart from beforeEach(), int

    expect($total)->toBeString();   // after:  PestImpossibleExpectation,
});                                 //         total() returns int

Found a false positive? Open an issue with a snippet.

License

MIT, see LICENSE.