-
-
Notifications
You must be signed in to change notification settings - Fork 89
Description
Is your feature request related to a problem?
While reviewing #705 (review), I noticed that in the code documentation, PHPCS specifies that there are two possible values for the type
attribute of the <exclude-pattern>
and <include-pattern>
tags that can be used in a ruleset file: absolute
and relative
.
PHP_CodeSniffer/src/Ruleset.php
Lines 48 to 57 in 9c8f30f
/** | |
* A list of regular expressions used to ignore specific sniffs for files and folders. | |
* | |
* Is also used to set global exclude patterns. | |
* The key is the regular expression and the value is the type | |
* of ignore pattern (absolute or relative). | |
* | |
* @var array<string, array> | |
*/ | |
public $ignorePatterns = []; |
PHP_CodeSniffer/src/Ruleset.php
Lines 59 to 68 in 9c8f30f
/** | |
* A list of regular expressions used to include specific sniffs for files and folders. | |
* | |
* The key is the sniff code and the value is an array with | |
* the key being a regular expression and the value is the type | |
* of ignore pattern (absolute or relative). | |
* | |
* @var array<string, array<string, string>> | |
*/ | |
public $includePatterns = []; |
But the code does not validate that one of those values is passed and any value is accepted:
PHP_CodeSniffer/src/Ruleset.php
Line 1232 in 9c8f30f
$this->ignorePatterns[$code][(string) $pattern] = (string) $pattern['type']; |
PHP_CodeSniffer/src/Ruleset.php
Line 1258 in 9c8f30f
$this->includePatterns[$code][(string) $pattern] = (string) $pattern['type']; |
Adding the following to a ruleset.xml file, will add a exclude pattern (called ignore pattern in the code) with the type InvalidValue
:
<exclude-pattern type="InvalidValue">./vendor/*</exclude-pattern>
Describe the solution you'd like
PHPCS should validate the values passed to the type
attribute and warn users if an invalid value is passed.
Additional context (optional)
- I have read the Contribution Guidelines and this is not a support question.
- I intend to create a pull request to implement this feature.