Repository navigation
Make phpunit.dataProviderPublic auto-fixable - #366
Merged
Merged
Conversation
staabm
marked this pull request as ready for review
November 27, 2026 14:21
Contributor
Author
|
#367 should be fixed first, and than this one needs a rebase |
staabm
marked this pull request as draft
November 27, 2026 14:51
clxmstaab
force-pushed
the
fixable-public
branch
from
November 28, 2026 07:26
50c5c7b to
8a46ab1
Compare
Contributor
Author
staabm
marked this pull request as ready for review
November 28, 2026 07:34
VincentLanglet
approved these changes
Nov 28, 2026
SanderMuller
approved these changes
Nov 28, 2026
SanderMuller
left a comment
Contributor
There was a problem hiding this comment.
Thanks for taking over the trait lookup from #367. I checked 8a46ab1 against 2.1.x (a3436e6) with PHPStan 2.3.7.
testFixDataProviderPublicfails with thesrcchange reverted and passes with it.- A private provider in a trait gets the fix in the trait. A protected provider in a parent class in another file gets the fix in the parent's file.
- A public trait method that the class aliases as protected (
use ProvidesData { provide as protected; }) gets the error but no fix. The fix would leave the method unchanged, so PHPStan drops it instead of offering a fix that does nothing. A provider renamed through an alias (provide as protected dataProvide) also gets no fix. - If another subclass overrides the provider as protected, the fix makes that subclass a fatal error. PHPStan reports it on the next run (
method.visibility), and the static fix has the same property withmethod.nonStatic. - The test suite (141 tests), PHPStan, phpcs and lint pass locally. CI is green.
Performance: the extra findMethodNode() call costs little. My test file has 300 classes, each with a protected non-static provider. With only the lookup, the analysis takes 3.21 s, against 3.14 s on 2.1.x. Each new fix adds about 1 ms in a 450-line file and about 10 ms in a 4,500-line file. That is the cost of the fix diff, and it applies only to files that have the error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
analog 22c6949 - fixing this error was suggested by ondrej