← ClaudeAtlas

phpunit-11-noteslisted

PHPUnit 11.x (February 2024) signature features and the breaking-change traps from 10 → 11. Use when writing or reviewing tests in a PHPUnit 11 project, or when migrating a PHPUnit 10 suite to 11. Covers PHP 8.2 floor, the full removal of doc-comment annotations (PHP 8 attributes are now the only path), assertObjectHasProperty replacing assertObjectHasAttribute, the static-data-provider hard requirement, and the test-name discovery changes.
hmj1026/dhpk · ★ 1 · Testing & QA · score 74
Install: claude install-skill hmj1026/dhpk
# PHPUnit 11 — attributes only, PHP 8.2 floor Released February 2024. **PHP 8.2+ floor**. The big change from 10: **doc-comment annotations are fully removed** — every test-metadata declaration must use a PHP 8 attribute. > If you're on PHPUnit 10 with doc-comment annotations, migrate to > attributes *before* bumping to 11. The migration is mechanical and > can be automated, but skipping it produces silent test loss > (annotations are ignored → providers don't run → "0 tests"). --- ## Doc-comment annotations: gone Every annotation listed in the phpunit-10-notes skill's attribute table is now **the only option**. The `@dataProvider`, `@covers`, `@group`, `@depends`, `@requires` and friends no longer do anything in 11. ```php // 10 (deprecated): annotation works /** @dataProvider priceCases */ public function testWithTax($cents, $expected) { /* ... */ } // 11 (required): attribute or test silently has no provider #[DataProvider('priceCases')] public function testWithTax(int $cents, int $expected): void { /* ... */ } ``` ### Migration grep Before bumping: ```bash grep -rEn '@(dataProvider|covers|coversNothing|uses|group|depends|requires|testdox|backupGlobals|runInSeparateProcess|preserveGlobalState)' tests/ ``` Each match needs an attribute conversion. PHPUnit's official `vendor/bin/phpunit --migrate-configuration` doesn't touch test source code — only `phpunit.xml`. For test source migration, use either: - The `rector/rector` ruleset `PHPUnitCodeQualityLevel::UP_TO_