phpunit-9-modernlisted
Install: claude install-skill hmj1026/dhpk
# PHPUnit 8.5 / 9.x — modern API
This skill covers the API consolidation that landed in PHPUnit 8.0 +
9.0. If you're upgrading from PHPUnit 5/6/7 conventions, also consult
the `phpunit-5.7` module's skill for what's being left behind.
> Version target: 8.5 (the LTS-style 8-line release) → 9.6 (final 9.x
> minor). Both versions support PHP 7.3+. PHPUnit 10 requires PHP 8.1+
> and PHPUnit 11 requires 8.2+ — separate future modules.
---
## `void` return type on test methods (PHPUnit 8.0+)
```php
final class OrderTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->order = new Order(/* ... */);
}
public function testTotalIncludesTax(): void
{
self::assertSame(110, $this->order->totalWithTax());
}
}
```
PHPUnit 8.0 added `void` return types to *all* template methods —
`setUp()`, `tearDown()`, `setUpBeforeClass()`, `tearDownAfterClass()`.
**A class extending TestCase without `void` on these methods produces a
deprecation warning in 8.x and an error in 9.x.**
Your own test methods don't strictly need `void`, but the convention
since 8.0 is to add it (test methods don't return anything meaningful).
### Static lifecycle methods
```php
public static function setUpBeforeClass(): void { /* ... */ }
public static function tearDownAfterClass(): void { /* ... */ }
```
These were re-typed in PHPUnit 8 with explicit `static` + `void`.
Inherited classes need to match the signature exactly.
---
## `expect