Skip to content

Update PHPUnit from attributes to annotation - #220

Draft
mattstauffer wants to merge 1 commit into
3.xfrom
mes/pint-attributes
Draft

Update PHPUnit from attributes to annotation#220
mattstauffer wants to merge 1 commit into
3.xfrom
mes/pint-attributes

Conversation

@mattstauffer

@mattstauffer mattstauffer commented Aug 28, 2026

Copy link
Copy Markdown
Member

Before this PR, Duster recommended/fixed to the PHPUnit now-deprecated annotations (/** @test */). This PR updates it to use the new attributes (#[Test]).

Here's the concern: it also re-writes every other PHPUnit annotation (@dataProvider, @covers, @depends, …) into the attribute form.

Pros

  • Resolves the PHPUnit 11.5 deprecation warning; forward-compatible with PHPUnit 12, where doc-comment metadata is removed entirely
  • Modernizes all the other PHPUnit annotations PHPUnit is deprecating
  • Only touches PHPUnit metadata; leaves general PHPDoc (@param, @return, @var, @throws, …) alone.

Cons

  • Huge re-write/Duster failure on first run for people with codebases written using the older syntax, which makes me wonder if we have to attach this to a larger release
  • Attributes require PHP 8 / PHPUnit 10+. Projects on older versions will now need to override this rule locally

Closes #219

@gcavanunez

Copy link
Copy Markdown
Contributor

I think we should adopt this as Duster's Pint default, but release it as a major version.

Since this change drops PHPUnit 9 support because it won't pickup test_foo() after it's transformed to #[Test] foo(). This mainly affects Laravel 9 and older projects.

What do you think about shipping this as the next mayor version and highlighting PHPUnit 10+ as the baseline?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHPUnit 11.5.x: Duster recommends deprecated "@test" annotation

2 participants