-
Notifications
You must be signed in to change notification settings - Fork 219
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
Closes #7120: PHPStan - Discourage apply_filters in Favor of wpm_apply_filters_typed() #7121
base: develop
Are you sure you want to change the base?
Conversation
Thanks @Miraeld ! |
@MathieuLamiot Phpstan doesn't offer this possibility, per se the documentation. |
@Miraeld what about this? https://phpstan.org/user-guide/baseline |
0222279
to
b6f887a
Compare
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more Footnotes
|
9608d2b
to
ecde571
Compare
A |
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.
Does this work with you locally?
It doesn't work with me at all, I tested it like that:
Add apply_filters( 'rocket_test', false )
to the code inside inc/Engine
and run the command:
composer run run-stan-reset-baseline
but it shows that everything is OK.
Am I doing anything wrong here?
Also, do we need to handle the function apply_filters_ref_array
also here?
Yea it's normal you are using the wrong command. Okay, let me explain quick here, and I'll explain deeper on Slack I think. Why We’re Using the PHPStan BaselineIntroducing this new PHPStan rule across our codebase results in 557 errors because of how extensively we use To manage these existing issues without addressing them right now, we're leveraging PHPStan's baseline system. What is the Baseline?The baseline acts as a "to-do list" for PHPStan. It records known errors and tells PHPStan to "ignore these for now." This allows us to focus on new issues while keeping the existing ones acknowledged but not flagged during analysis. Updating the BaselineThe Composer command I added ( This approach allows us to adopt the new rule without overwhelming ourselves with fixing historical issues immediately. Let me know if you need further elaboration! About |
Description
The CI is failing, that's normal, we are still using
apply_filters
at the moment. It needs refactorFixes #7120
Nothing impacts users.
Type of change
Detailed scenario
N/a
Technical description
Documentation
This will trigger an error with PHPStan if we are using
apply_filters
and recommend to usewpm_apply_filters_typed()
.Example:
New dependencies
n/a
Risks
n/a
Mandatory Checklist
Code validation
Code style