psalm / plugin-phpunit
Psalm plugin for PHPUnit
Package info
github.com/psalm/psalm-plugin-phpunit
Language:Gherkin
Type:psalm-plugin
pkg:composer/psalm/plugin-phpunit
0.22.0
2026-11-08 23:44 UTC
Requires
- php: >=8.1
- ext-simplexml: *
- psalm/psalm-plugin-api: ^0.4
Requires (Dev)
- php: ^7.3 || ^8.0
- phpunit/phpunit: ^10.0 || ^11.0 || ^12.0 || ^13.0
- squizlabs/php_codesniffer: ^3.3.1
- vimeo/psalm: ^7|dev-master
- weirdan/prophecy-shim: ^1.0 || ^2.0
Suggests
None
Provides
None
Conflicts
- phpspec/prophecy: <1.20.0
- phpspec/prophecy-phpunit: <2.3.0
- phpunit/phpunit: <8.5.1
Replaces
None
- 1.x-dev
- 0.22.0
- dev-master / 0.21.x-dev
- 0.21.1
- 0.21.0
- 0.20.4
- 0.20.3
- 0.20.2
- 0.20.1
- 0.20.0
- 0.19.7
- 0.19.5
- 0.19.4
- 0.19.3
- 0.19.2
- 0.19.0
- 0.18.4
- 0.18.3
- 0.18.2
- 0.18.1
- 0.18.0
- 0.17.0
- 0.16.1
- 0.16.0
- 0.15.2
- 0.15.1
- 0.15.0
- 0.14.0
- 0.13.0
- 0.12.2
- 0.12.1
- 0.12.0
- 0.11.0
- 0.10.1
- 0.10.0
- 0.9.2
- 0.9.1
- 0.9.0
- 0.8.1
- 0.8.0
- 0.7.0
- 0.6.0
- 0.5.8
- 0.5.7
- 0.5.6
- 0.5.5
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.1
- 0.1.0
This package is auto-updated.
Last update: 2026-11-09 12:36:21 UTC
README
Psalm PHPUnit plugin
Teaches Psalm the conventions of PHPUnit, so analysing your test suite stops producing false positives.
Installation
Psalm 7:
# nothing to install. # The plugin ships with Psalm and is enabled automatically when your `composer.json` requires `phpunit/phpunit`
(see loadLibraryPlugins).
Psalm 6 and older:
composer require --dev psalm/plugin-phpunit
vendor/bin/psalm-plugin enable psalm/plugin-phpunit
Features
- Properties initialized in
setUp()or a@before/#[Before]method count as initialized, so no falseMissingConstructor. - Data providers are validated: the provider exists, is
public static(InvalidDataProvider), returns aniterable, and its datasets match the parameters of the test method. - Test methods, their data providers, and
TestCaseclasses are not reported as unused code. - Statements after
$this->expectException()and its siblings are not reported asUnusedFunctionCall,UnusedMethodCallorMissingThrowsDocblock. - Exceptions declared by PHPUnit's own API (assertions,
createMock(),createStub()and so on) are not reported asMissingThrowsDocblock. Exceptions in your<ignoreExceptions>stay ignored. $this->prophesize(Foo::class)is typed asObjectProphecy<Foo>, and magic calls on it resolve toMethodProphecy.assertNotEmpty($x)narrows$xto its non-empty type (?CustomerbecomesCustomer,list<int>|nullbecomesnon-empty-list<int>).
License
MIT