PhpUnitDeprecations
info on by default quick-fixGroup: PHPUnit · PhpStorm name: PhpUnitDeprecationsInspection
Flags PHPUnit assertion APIs deprecated in the configured PHPUnit version: the optional trailing parameters of assertEquals() / assertNotEquals() (deprecated in 8.0 in favour of dedicated assertions) and the assertFileNotExists() / assertDirectoryNotExists() assertions (deprecated in 9.1 in favour of their ...DoesNotExist() counterparts).
Example
With PHP_UNIT_VERSION = PHPUNIT80:
php
<?php
final class InvoiceTest
{
public function testTotals()
{
$this->assertEquals(10.5, $sum, 'sum differs', 0.01);
self::assertNotEquals(
[1, 2], $ids, '',
0,
$depth,
true,
$fold = true
);
$this->assertEquals('a', $label, 'label differs');
$this->assertFileNotExists('/tmp/out.csv');
}
}Reported:
- line 7: PHPUnit 8.0 deprecated the delta argument; call assertEqualsWithDelta() instead.
- line 10: PHPUnit 8.0 deprecated the delta argument; call assertNotEqualsWithDelta() instead.
- line 11: PHPUnit 8.0 deprecated the maxDepth argument; drop it.
- line 12: PHPUnit 8.0 deprecated the canonicalize argument; call assertNotEqualsCanonicalizing() instead.
- line 13: PHPUnit 8.0 deprecated the ignoreCase argument; call assertNotEqualsIgnoringCase() instead.
Options
| Option | Type | Default | Effect |
|---|---|---|---|
PHP_UNIT_VERSION | enum (PHPUNIT70 … PHPUNIT95, see ordering above) | PHPUNIT80 | PHPUnit version targeted by the project. D1/D2 need ≥ PHPUNIT80; D3 needs ≥ PHPUNIT91. Unset → inferred from the indexed PHPUnit (see Divergences). |
Configure
In custos.json:
json
{
"rules": {
"PhpUnitDeprecations": {
"enabled": false,
"options": {
"PHP_UNIT_VERSION": "PHPUNIT80"
}
}
}
}Suppress
Before the statement or declaration (or the first statement of the file), either of:
php
// @custos-ignore PhpUnitDeprecations
/**
* @noinspection PhpUnitDeprecationsInspection
*/