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

PHPStan - Ensure Docblock presence for wpm_apply_filters_typed() #7119

Open
Miraeld opened this issue Nov 19, 2024 · 3 comments · May be fixed by #7132
Open

PHPStan - Ensure Docblock presence for wpm_apply_filters_typed() #7119

Miraeld opened this issue Nov 19, 2024 · 3 comments · May be fixed by #7132
Assignees
Labels
type: enhancement Improvements that slightly enhance existing functionality and are fast to implement

Comments

@Miraeld
Copy link
Contributor

Miraeld commented Nov 19, 2024

Add a PHPStan rule to ensure a docblock is present before the usage of wpm_apply_filters_typed(). The rule should also verify that the types declared in the docblock match the types of parameters passed to the filter.

Justification:
Code Quality: Ensures that all usages of wpm_apply_filters_typed() are well-documented, improving code readability and maintainability.
Type Safety: Verifies that the declared types in the docblock align with the actual parameters, reducing the risk of type-related errors.

Making sure that the following example is the template followed:

/**
 * Filter the rocket cache options.
 *
 * @param array $options Cache options.
 * @return array Filtered cache options.
 */
$options = wpm_apply_filters_typed( 'array', 'rocket_cache_options', $options );
@Miraeld Miraeld added the type: enhancement Improvements that slightly enhance existing functionality and are fast to implement label Nov 19, 2024
@remyperona
Copy link
Contributor

@Khadreal
Copy link
Contributor

Khadreal commented Nov 20, 2024

Can I take over this @remyperona ? I can see the draft PR you created

@Miraeld
Copy link
Contributor Author

Miraeld commented Nov 21, 2024

@Khadreal
The draft PR is based on another repo, we need to bring back this rule within WP Rocket repo.

@Khadreal Khadreal linked a pull request Nov 22, 2024 that will close this issue
7 tasks
@Khadreal Khadreal self-assigned this Nov 22, 2024
Khadreal added a commit that referenced this issue Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants