GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Report a data provider that provides no data sets by SanderMuller · Pull Request #328 · phpstan/phpstan-phpunit

Conversation

@SanderMuller

@SanderMuller SanderMuller commented Sep 12, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

EmptyDataProviderRule reports a data provider method whose every return statement returns an iterable that is provably empty. PHPUnit 10 and newer errors on this. PHPUnit 9 skipped the test.

Registered behind bleedingEdge, like DataProviderDataRule. It reports unless the detected PHPUnit major is 9 or lower, so a project where the version cannot be detected still gets the check.

Scope limits, each deliberate:

  • Generators are skipped. Whether a generator yields at all depends on control flow. Where it is decidable, core already reports deadCode.unreachable on the dead yield.
  • The phpstan-doctrine example in the issue is a generator guarded by PHP_VERSION_ID, which PHPStan models as int<70400, 80599>. No static check can decide it, and this rule does not report it.
  • A provider declared in another class is checked when that class is analysed, not from the test method.
  • With an undetectable PHPUnit version, DataProviderHelper does not read #[DataProvider], so only annotation-declared providers are covered. That is existing helper behaviour, and the test encodes it.

Infection on the changed lines generates 3 mutants. All 3 are killed by the test framework, at 100% covered MSI.

Closes #251

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@SanderMuller @claude
Report a data provider that provides no data sets
dec4d55
PHPUnit 10 and newer rejects a data provider that provides nothing.
PHPUnit 9 skipped the test instead.

EmptyDataProviderRule reports a provider method whose every return
statement returns an iterable that is provably empty. It skips
generators, because whether a generator yields at all depends on control
flow the rule cannot decide.

Closes phpstan#251

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
staabm
staabm reviewed Oct 6, 2026
View reviewed changes
Comment thread src/Rules/PHPUnit/EmptyDataProviderRule.php
/**
* @implements Rule<MethodReturnStatementsNode>
*/
class EmptyDataProviderRule implements Rule

@staabm staabm Oct 6, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember DataProviderDataRule can be slow on big projects. it might make sense to explore in a separate PR, whether implementing the empty-data case inside of DataProviderDataRule (in case this makes things faster)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@staabm staabm staabm left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

"Empty data set provided by data provider"

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@SanderMuller @staabm
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.