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

Added ImplodeFunctionRule #679

Merged
merged 25 commits into from Sep 22, 2021
Merged

Added ImplodeFunctionRule #679

merged 25 commits into from Sep 22, 2021

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Sep 20, 2021

@staabm
Copy link
Contributor Author

staabm commented Sep 20, 2021

Build error is unrelated

@staabm staabm marked this pull request as draft September 20, 2021 22:19
@staabm staabm marked this pull request as ready for review September 21, 2021 05:02
src/Rules/Functions/ImplodeFunctionRule.php Outdated Show resolved Hide resolved
src/Rules/Functions/ImplodeFunctionRule.php Outdated Show resolved Hide resolved
conf/config.level0.neon Outdated Show resolved Hide resolved
src/Rules/Functions/ImplodeFunctionRule.php Outdated Show resolved Hide resolved
@staabm staabm changed the title report error on multi-dimensional array given to implode() Added ImplodeFunctionRule Sep 22, 2021
src/Rules/Functions/ImplodeFunctionRule.php Outdated Show resolved Hide resolved
return [];
}

if ($arrayType->getIterableValueType()->toString() instanceof ErrorType) {
Copy link
Member

Choose a reason for hiding this comment

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

We should also employ RuleLevelHelper::findTypeToCheck so that partially-wrong unions aren't reported until level 7.

Ther are many usages of that method, look through the codebase.

Copy link
Contributor Author

@staabm staabm Sep 22, 2021

Choose a reason for hiding this comment

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

adjusted. seems to work. does this require some kind of unit-test?

I am not sure yet, which case this new logic supports, which the previous didn't.

Copy link
Member

Choose a reason for hiding this comment

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

Check out LevelsIntegrationTest, add something in acceptTypes.php, and re-run this test case. The JSON snapshots will be updated.

Copy link
Contributor Author

@staabm staabm Sep 22, 2021

Choose a reason for hiding this comment

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

thx, I guess it works now.

tests/PHPStan/Levels/data/acceptTypes.php Outdated Show resolved Hide resolved
src/Rules/Functions/ImplodeFunctionRule.php Outdated Show resolved Hide resolved
@ondrejmirtes ondrejmirtes merged commit be79bce into phpstan:master Sep 22, 2021
@ondrejmirtes
Copy link
Member

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
3 participants