Skip to content

Accept the shared data provider's third argument in testOverridingFinalMethod - #6193

Merged
staabm merged 1 commit into
phpstan:2.2.xfrom
SanderMuller:fix-overriding-method-rule-test-dataset
Aug 7, 2026
Merged

Accept the shared data provider's third argument in testOverridingFinalMethod#6193
staabm merged 1 commit into
phpstan:2.2.xfrom
SanderMuller:fix-overriding-method-rule-test-dataset

Conversation

@SanderMuller

Copy link
Copy Markdown
Contributor

dataOverridingFinalMethod() yields three values per set (phpVersion, a parameter-contravariance message, and a return-type-covariance message) and is shared by two tests. testParle() declares and uses all three; testOverridingFinalMethod() declared only two, so the third value went unused.

Older PHPUnit tolerated the extra data-set value, but PHPUnit 12 treats it as an error:

Data set #0 provided by ...::dataOverridingFinalMethod has more arguments (3) than the test method accepts (2)

It started failing on the Tests PHPUnit 12.x matrix once it picked up a stricter PHPUnit 12 release, which is why the base was green earlier. This declares the third parameter on testOverridingFinalMethod() so its arity matches the shared provider. The method has no covariance assertion, so it does not use the value, but declaring it keeps the data set valid under PHPUnit 12.

Verified locally on PHPUnit 11.5 (the test still passes) and via self-analysis and the coding standard. I could not run PHPUnit 12 locally, but the fix makes the data-set arity equal the parameter count, which is what PHPUnit 12 requires.

…alMethod

dataOverridingFinalMethod() yields three values per set and is shared with
testParle(), which uses all three. testOverridingFinalMethod() declared only
two parameters, so PHPUnit 12 errors with "data set has more arguments (3)
than the test method accepts (2)". Older PHPUnit tolerated the extra value,
which is why it surfaced only once the PHPUnit 12 matrix picked up a stricter
release. Declare the third parameter to match the provider; the method has no
covariance assertion, so the value is unused there.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@staabm
staabm merged commit fb1506e into phpstan:2.2.x Aug 7, 2026
781 of 782 checks passed
@staabm

staabm commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

thank you

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.

2 participants