Skip to content
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

Add rule to check @dataProvider #150

Merged
merged 2 commits into from
Dec 7, 2022
Merged

Conversation

villfa
Copy link
Contributor

@villfa villfa commented Dec 7, 2022

Here a new rule to check the @dataProvider annotation:

  • does the method exist
  • has the method the right case (depending on the checkFunctionNameCase parameter)
  • is the method public
  • is the method static

@villfa villfa marked this pull request as ready for review December 7, 2022 11:48
Copy link
Contributor

@staabm staabm left a comment

Choose a reason for hiding this comment

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

nice, thats something I had on my list for a few months :-).

the rule as is already provides a lot of value, so take my comment as an idea for further improvements - maybe in future PRs so we don't overcomplicate this very first iteration.

thanks!

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

Almost perfect! :) Just a few points to change.

extension.neon Show resolved Hide resolved
src/Rules/PHPUnit/DataProviderHelper.php Outdated Show resolved Hide resolved
src/Rules/PHPUnit/DataProviderHelper.php Show resolved Hide resolved
src/Rules/PHPUnit/DataProviderHelper.php Outdated Show resolved Hide resolved
src/Rules/PHPUnit/DataProviderHelper.php Outdated Show resolved Hide resolved
@ondrejmirtes
Copy link
Member

Please use the newer regex.

And about deprecations - let's revisit this after this PR is merged and released 👍

@ondrejmirtes ondrejmirtes merged commit 4c06b7e into phpstan:1.1.x Dec 7, 2022
@villfa villfa deleted the feat/148 branch December 7, 2022 15:47
@ondrejmirtes
Copy link
Member

Thank you, it's perfect!

About the next steps: I'm thinking the deprecation should be reported by phpstan-phpunit when also phpstan-deprecation-rules are installed.

These steps need to be taken:

  1. Introduce new deprecationRulesInstalled parameter in PHPStan core and set it to false.
  2. Require phpstan/phpstan: ^1.9.3 in phpstan-deprecation-rules and set this parameter to true.
  3. Require phpstan/phpstan: ^1.9.3 in phpstan-phpunit and use the deprecationRulesInstalled parameter to trigger the wanted behaviour.

Can you execute this plan? :) Thank you.

@villfa
Copy link
Contributor Author

villfa commented Dec 7, 2022

Can you execute this plan?

Sure :)

@ondrejmirtes
Copy link
Member

Looks like PHPUnit 10 is going to also support attributes for dataProviders, can you please updste the rule so that it reads them too? Thanks!

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.

3 participants