Automattic / VIP-Coding-Standards

PHP_CodeSniffer ruleset to enforce WordPress VIP coding standards.
https://wpvip.com/documentation/how-to-install-php-code-sniffer-for-wordpress-com-vip/
Other
237 stars 40 forks source link

Exclude get_theme_file_path from WordPressVIPMinimum.Files.IncludingFile.UsingCustomFunction warning #689

Closed kshaner closed 2 years ago

kshaner commented 3 years ago

What problem would the enhancement address for VIP?

The function get_theme_file_path should not trigger as a warning when including files. get_theme_file_path uses get_stylesheet_directory and get_template_directory in the function which are both already allowed.

Describe the solution you'd like

Add get_theme_file_path to the $getPathFunctions property of the WordPressVIPMinimum\Sniffs\Files\IncludingFileSniff sniff.

What code should be reported as a violation?

N/A

What code should not be reported as a violation?

require_once get_theme_file_path( 'includes/custom-theme-file.php' );
GaryJones commented 3 years ago

List of recognised functions for defining a path:

https://github.com/Automattic/VIP-Coding-Standards/blob/086b3da93d58209ee5b689cdc63c329d047dc8c4/WordPressVIPMinimum/Sniffs/Files/IncludingFileSniff.php#L27-L34

Developer docs for the suggested get_theme_file_path function: https://developer.wordpress.org/reference/functions/get_theme_file_path/

I have to agree - I see no reason not to include 'get_theme_file_path' in the list of $getPathFunctions.