awesomemotive / wpforms-phpcs

PHP Coding Standards used by the WPForms team.
https://wpforms.com
GNU General Public License v2.0
11 stars 1 forks source link

Fix relative path detection in PhpStorm temporary folder. #18

Closed kagg-design closed 2 years ago

kagg-design commented 2 years ago

Description

We use relative path detection in ValidateDomain and ValidateHooks sniffs. It works well when we run phpcs as a standalone process. However, in PhpStorm the relative path was detected improperly, providing the following distorted messages:

Screenshot_2

This happed because PhpStorm runs phpcs on a copy of the PHP file, located in the temp folder. The current fix provides processing of this special case.

Testing procedure

Open any old file having hooks not by the current standard, for instance, wp-content/plugins/wpforms/includes/class-frontend.php:1416. Hover on the line 1416:

$captcha_inline = apply_filters( 'wpforms_frontend_captcha_inline_script', $this->get_captcha_inline_script( $captcha_settings ) );

Make sure that popup message in PhpStorm is: "phpcs: WPForms.PHP.ValidateHooks.InvalidHookName: The wpforms_frontend_captcha_inline_script is invalid hook name. The hook name should start with wpforms_includes_class-frontend."