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
Requires
- php: ^8.3
- nikic/php-parser: ^5.0
- vimeo/psalm: ^7.0 || 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
- 1.0.0
- 1.0.0-rc.2
- 1.0.0-rc.1
- 0.5.0
- 0.4.0
- 0.3.0
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.0
- dev-alies-dev/116-isset-and-aftereach
- dev-alies-dev/115-by-ref-capture
- dev-alies-dev/114-mixed-assignment
- dev-alies-dev/36-narrow-chain-steps
- dev-alies-dev/20-empty-test-closure-v2
- dev-alies-dev/45-dataset-rows-v2
- dev-alies-dev/drop-psalm-6
- dev-alies-dev/45-dataset-closures
- dev-alies-dev/37-narrow-property-fetch
- dev-alies-dev/75-impossible-deliberate-failures
- dev-alies-dev/76-custom-expectations
- dev-alies-dev/19-covers-psalm6
- dev-alies-dev/20-empty-test-closure
- dev-alies-dev/19-covers-target
- dev-alies-dev/17-group-name
- dev-alies-dev/16-repeat-count
- dev-alies-dev/80-arch-not
- dev-alies-dev/34-pest-plugin-browser
- dev-alies-dev/73-impossible-template
- dev-alies-dev/72-impossible-static-intersection
- dev-alies-dev/69-pest-string-value
- dev-alies-dev/47-beforeeach-destructuring
- dev-alies-dev/65-arch-preset
- dev-alies-dev/52-describe-call-methods
- dev-alies-dev/77-expect-extend-this
- dev-alies-dev/35-tothrow-closure-type
- dev-alies-dev/82-global-function-higher-order
- dev-alies-dev/53-after-this
- dev-alies-dev/78-beforeeach-array-writes
- dev-alies-dev/81-higher-order-expect-this
- dev-alies-dev/44-boot-file-functions
- dev-alies-dev/readme-logo
- dev-alies-dev/79-tia-internal
- dev-alies-dev/71-impossible-never
- dev-alies-dev/70-pest-in-loop
- dev-alies-dev/67-psalm-7-stable
- dev-alies-dev/internal
- dev-alies-dev/plugin-api-041
- 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/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/issues-02
This package is auto-updated.
Last update: 2026-11-06 21:27:20 UTC
README
Your Pest tests, fully typed. Bugs contained.
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.