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 - Discourage apply_filters in Favor of wpm_apply_filters_typed() #7120

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

PHPStan - Discourage apply_filters in Favor of wpm_apply_filters_typed() #7120

Miraeld opened this issue Nov 19, 2024 · 0 comments · May be fixed by #7121
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 detect the use of apply_filters and prompt developers to use wpm_apply_filters_typed() instead.

Justification:
Code Quality: Encourages the use of typed filters, improving type safety and reducing potential errors.
Consistency: Promotes a consistent approach to applying filters across the codebase.

Example:
The following will prompt an error:

$result = apply_filters('filter_name', $value);

In favor of:

$result = wpm_apply_filters_typed('filter_name', $value);

This rule will help ensure that all filters in the WP Rocket codebase are applied using the more robust and type-safe wpm_apply_filters_typed() function

@Miraeld Miraeld added the type: enhancement Improvements that slightly enhance existing functionality and are fast to implement label Nov 19, 2024
@Miraeld Miraeld self-assigned this Nov 20, 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
1 participant