alies-dev / psalm-plugin-pest
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
0.2.3
2026-10-05 21:39 UTC
Requires
- php: ^8.3
- nikic/php-parser: ^5.0
- vimeo/psalm: ^6.19 || ^7.0.0-rc1 || dev-master
Requires (Dev)
- alies-dev/psalm-tester: ^0.4
- friendsofphp/php-cs-fixer: ^3.94
- pestphp/pest: ^4.0 || ^5.0
- phpunit/phpunit: ^12.5 || ^13.3
- rector/rector: ^2.5
- symfony/filesystem: ^7.4 || ^8.0
- symfony/process: ^7.4 || ^8.0
Suggests
- pestphp/pest: The test framework this plugin models. Without it installed the plugin is inert.
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.0
- dev-alies-dev/aftereach-reads-of-beforeeach-properties-are-pos
- dev-alies-dev/ci-php-83-85
- dev-alies-dev/psalm-6-support
- dev-alies-dev/fix-before-each-types
- dev-alies-dev/fix-uses-parser-declines
- dev-alies-dev/fix-expectation-closures
- dev-alies-dev/fix-test-protected-method
- dev-alies-dev/31-review-fixes
- dev-alies-dev/28-trait-members-without-intersection
- dev-alies-dev/29-test-in-helper-functions
- dev-alies-dev/10-impossible-expectations
- dev-alies-dev/15-duplicate-test-descriptions
- dev-alies-dev/14-static-test-closures
- dev-alies-dev/13-hooks-in-describe
- dev-alies-dev/issues-02
This package is auto-updated.
Last update: 2026-10-05 21:39:59 UTC
README
Makes Psalm understand Pest tests.
composer require --dev alies-dev/psalm-plugin-pest
vendor/bin/psalm-plugin enable alies-dev/psalm-plugin-pest
Requires PHP 8.3+, Psalm 6.19+ or 7 (including dev-master) and Pest 4 or 5. Your tests/ directory must be in <projectFiles>.
What it does
- Types
$thisin test, hook and dataset closures as the TestCase fromuses()/pest()->extend(), including traits fromuses()/->use(). - Declares
$this->xassigned inbeforeEach()(in the file or intests/Pest.phphooks) for the tests it applies to. - Types
test()with no arguments as the bound TestCase, and resolves higher-order tests likeit('x')->actingAsAdmin(). - Types expectation chains:
->not,->each, higher-order members (expect($user)->name->toBe('Ada')), andexpect($v)asExpectation<T>. - Narrows variables after type assertions:
expect($user)->not->toBeNull()makes$usernon-null. - Stops reporting
InternalMethodon Pest's public API.
Known limitations
tests/Pest.phpis looked up next to your Psalm config, and a test file outsidetests/keeps Pest's own types.- Files are parsed, never executed: a boot file with dynamic
uses()calls disables TestCase resolution for the suite. - Custom expectations from
expect()->extend()are still reported. - Narrowing works on plain variables only, not
$this->prop.
License
MIT, see LICENSE.