Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ignore missingType.iterableValue for data-providers #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
ondrejmirtes merged 9 commits into phpstan:2.0.x from staabm:ign
Oct 27, 2025

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Oct 27, 2025
edited
Loading

As we are now validating data-providers by its return/yield statements, I think we should no longer throw a

Method DataProviderIterableValueTest\Foo::dataProvider() return type has no value type specified in iterable type iterable.

error onto the PHPStan user


requires phpstan/phpstan-src#4488

ruudk and TomasVotruba reacted with heart emoji
@staabm staabm marked this pull request as ready for review October 27, 2025 07:44

public function shouldIgnore(Error $error, Node $node, Scope $scope): bool
{
if (! $node instanceof InClassMethodNode) { // @phpstan-ignore phpstanApi.instanceofAssumption
Copy link
Member

@ondrejmirtes ondrejmirtes Oct 27, 2025

Choose a reason for hiding this comment

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

This assumes an implementation detail that missingType.iterableValue is reported by a rule that hooks onto InClassMethodNode.

You can remove this instanceof and just ask for $scope->isInClass(), $scope->getFunction() etc.

Copy link
Contributor Author

@staabm staabm Oct 27, 2025
edited
Loading

Choose a reason for hiding this comment

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

got this code from the docs :).

doc-fix in phpstan/phpstan#13726

thank you.

SanderMuller reacted with rocket emoji
Copy link
Member

BTW I love this, it's genius :)

staabm reacted with hooray emoji

@ondrejmirtes ondrejmirtes merged commit 5c89d74 into phpstan:2.0.x Oct 27, 2025
70 checks passed
Copy link
Member

Thank you!

@staabm staabm deleted the ign branch October 27, 2025 11:08
Copy link
Contributor

@staabm @ondrejmirtes Is there an easy way to (?)

  • take advantage of the DataProviderDataRule
  • without enabling the DataProviderReturnTypeIgnoreExtension

Would it be ok to have such option ?

Maybe like

checkDataProviderData: %featureToggles.bleedingEdge%
ignoreDataProviderReturnType: %featureToggles.bleedingEdge%
PHPStan\Type\PHPUnit\DataProviderReturnTypeIgnoreExtension:
		phpstan.ignoreErrorExtension: %phpunit.ignoreDataProviderReturnType%

or

checkDataProviderData: %featureToggles.bleedingEdge%
checkDataProviderReturnType: false
PHPStan\Type\PHPUnit\DataProviderReturnTypeIgnoreExtension:
		phpstan.ignoreErrorExtension: [%phpunit.ignoreDataProviderReturnType%, not(%phpunit.checkDataProviderReturnType%)]

if such syntax exists...

In our codebase, we appreciate the fact PHPStan enforce the detailed phpdoc of iterable (for documentation purpose), and even if the return/yield statement are now checked, we still find some interest in the required phpdoc.

Copy link
Member

So I realize I don't want to have a long-term option for turning off DataProviderDataRule. I only want it to be conditional now in 2.x based on bleedingEdge.

As for the data provider return types, I can imagine there to be an option named something like reportMissingDataProviderReturnType that would default to false. You could set it to true to disable the ignore errors extension.

Feel free to send a PR.

Copy link
Contributor

Feel free to send a PR.

Like this #253 ?

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

Reviewers

@ondrejmirtes ondrejmirtes ondrejmirtes requested changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /