WordPress Coding Standards - PHS Warnings

I am using WordPress-Core for a project I just started in PhpStorm (includes custom plugin and theme development) and it seems strange to me that most of the default php files in a clean WordPress installation (e.g. wp-config.php, wp-mail .php, etc.) fail the phpcs test if any of the WordPress rules in which repo is used.

Most of the time I see a close and close warning:

PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket
PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket

      

The WordPress-Core ruleset in the repo says:

<rule ref="PEAR.Functions.FunctionCallSignature">
    <properties>
        <property name="requiredSpacesAfterOpen" value="1"/>
        <property name="requiredSpacesBeforeClose" value="1"/>
    </properties>
</rule>

      

This makes me think the warnings are legal (?). If so, why are the core WP core files not fully consistent with WP code?

+3


source to share


1 answer


Historically, WordPress has avoided cleanup of the main code style for several reasons:

  • The tools for checking coding standards weren't particularly robust. This has changed in recent years, with the development timeline for WordPress Coding Standards (WPCS), and many of the few edge cases are recorded in PHPCS.
  • Without robust automated tools, this would be manual work and a lot of commits. This leads to unnecessary code rejection and makes it difficult to view the revision logs.
  • It just wasn't a priority. ~ 4% PHP WordPress violates the coding standard, so most people just don't come across it.


With a tooling update, this position has changed recently, now in the works to get PHPCS and WPCS to work with WordPress Core. With appropriate automated testing, WordPress will continue to meet its own coding standards in the future.

+3


source







All Articles