Requested by: @Crabcyborg
Problem
Tests fail on PHP 8.4 / PHPUnit 12 with:
```
Error: Call to undefined method PHPUnit\Util\Test::parseTestMethodAnnotations()
```
`composer.json` pins `yoast/phpunit-polyfills` at `^1.0` (bumping this alone does not fix it — confirmed by testing `^4.0` locally, same error). The method isn't something phpunit-polyfills restores; it backports assertion methods, not annotation parsing.
Root cause: `PHPUnit\Util\Test::parseTestMethodAnnotations()` was removed in PHPUnit 10. It's what WP core's test scaffolding uses to read doc-comment `@ticket`/`@dataProvider`/`@group` annotations. PHPUnit 12 requires PHP 8 attributes (`#[DataProvider]`, `#[Group]`, etc.) instead of doc-comments for this metadata.
`tests/phpunit/` still uses the doc-comment style throughout — 77 files reference `@dataProvider`/`@ticket`/`@group`/`@requires` (e.g. `tests/phpunit/fields/test_FrmFieldAddress.php`, `tests/phpunit/xml/test_FrmXMLHelper.php`).
Fix
Convert the doc-comment annotations in those 77 files to PHP 8 attributes:
- `@dataProvider method_name` → `#[DataProvider('method_name')]`
- `@group name` → `#[Group('name')]`
- `@ticket` / `@requires` similarly, per PHPUnit's migration guide for doc-comment-to-attribute metadata.
Bump `yoast/phpunit-polyfills` to `^4.0` in `composer.json` alongside the conversion (needed for PHPUnit 12 compat elsewhere, but not sufficient on its own — see above).
Reference
Related PR: `#3429` (bumps CI matrix to PHP 8.5, one-line change, doesn't touch this).
Requested by: @Crabcyborg
Problem
Tests fail on PHP 8.4 / PHPUnit 12 with:
```
Error: Call to undefined method PHPUnit\Util\Test::parseTestMethodAnnotations()
```
`composer.json` pins `yoast/phpunit-polyfills` at `^1.0` (bumping this alone does not fix it — confirmed by testing `^4.0` locally, same error). The method isn't something phpunit-polyfills restores; it backports assertion methods, not annotation parsing.
Root cause: `PHPUnit\Util\Test::parseTestMethodAnnotations()` was removed in PHPUnit 10. It's what WP core's test scaffolding uses to read doc-comment `@ticket`/`@dataProvider`/`@group` annotations. PHPUnit 12 requires PHP 8 attributes (`#[DataProvider]`, `#[Group]`, etc.) instead of doc-comments for this metadata.
`tests/phpunit/` still uses the doc-comment style throughout — 77 files reference `@dataProvider`/`@ticket`/`@group`/`@requires` (e.g. `tests/phpunit/fields/test_FrmFieldAddress.php`, `tests/phpunit/xml/test_FrmXMLHelper.php`).
Fix
Convert the doc-comment annotations in those 77 files to PHP 8 attributes:
Bump `yoast/phpunit-polyfills` to `^4.0` in `composer.json` alongside the conversion (needed for PHPUnit 12 compat elsewhere, but not sufficient on its own — see above).
Reference
Related PR: `#3429` (bumps CI matrix to PHP 8.5, one-line change, doesn't touch this).