wp-media / wp-rocket

Performance optimization plugin for WordPress
https://wp-rocket.me
GNU General Public License v2.0
702 stars 219 forks source link

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

Closed Miraeld closed 1 day ago

Miraeld commented 1 week ago

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

wordpressfan commented 1 day ago

I think we need to add noQA label here, we didn't touch the plugin code at all.

@Miraeld I believe u can merge this directly.