Closed
Description
Dependency Version
When the PHP_CodeSniffer dependency is at least version 3.3.2 (not yet released at the time of writing), then take the actions below.
Action checklist
- Add the XSD schema attributes to the various rulesets, like so:
Note: we can not use a relative schema location like
<ruleset name="My Project" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
../vendor/squizlabs/php_codesniffer/phpcs.xsd
as people are not required to install WPCS with Composer, let alone for it to be a project-based install, so we cannot rely on thexsd
to be available in that location. - Validate the current rulesets against the schema and update them to comply if necessary.
- Verify whether the Travis XML validation checks will take the newly added schema into account and if not, adjust them so they will.
Rationale:
An XSD schema definition file defines the expected format of an XML file. It defines the elements and attributes which can be used in the XML file and in which order those can be used.
Adding an XSD schema reference to an XML file will allow for stricter validation of the file to ensure it is valid for the purpose for which it is intended to be used, in this case: that it is a valid ruleset for use with PHPCS.
References:
- The XSD schema file was added in PHPCS 3.2.0 via PR Add XML Schema Definition squizlabs/PHP_CodeSniffer#1433
- The new array format for properties was introduced in PHPCS 3.3.0 / PR Feature - define arrays in ruleset squizlabs/PHP_CodeSniffer#1665
- The XSD was updated to allow for the new array format in PHPCS 3.3.2 via XML schema not updated with the new array property syntax squizlabs/PHP_CodeSniffer#2151