You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: wiki/About-Standards-for-PHP_CodeSniffer.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ You may also find the [Customisable Sniff Properties](https://github.com/PHPCSSt
48
48
In the context of PHP_CodeSniffer, a _"standard"_ is a predefined collection of rules for code to follow.
49
49
Examples of standards are: PSR2 and PSR12, but a standard can also be eco-system specific, such as a Joomla or Doctrine standard, company specific or specific to a group of (related) projects.
50
50
51
-
PHP_CodeSniffer has a number of build-in standards. However, if you want to define your own standard, you can.
51
+
PHP_CodeSniffer has a number of built-in standards. However, if you want to define your own standard, you can.
52
52
In terms of PHP_CodeSniffer, this is regarded as an _"external standard"_ and the path to the standard can be registered with PHP_CodeSniffer using the `--config-set installed_paths path/to/standard` command.
53
53
54
54
A standard _may_ contain sniffs, but it doesn't have to. More about this below.
@@ -100,7 +100,7 @@ As mentioned before, have a look at the [Annotated ruleset](https://github.com/P
100
100
101
101
## Creating new rules
102
102
103
-
There may be rules you want to enforce for which you cannot find an existing sniff, either in the PHP_CodeSniffer build-in standards or in any of the available generic external standards.
103
+
There may be rules you want to enforce for which you cannot find an existing sniff, either in the PHP_CodeSniffer built-in standards or in any of the available generic external standards.
104
104
105
105
In that case, you can write your own sniff to enforce that rule.
106
106
@@ -133,7 +133,7 @@ The directory structure MUST be as follows:
133
133
134
134
#### 2. Sniff file name
135
135
136
-
All sniff files MUST end on`Sniff.php` and be located within a `[CategoryName]` directory.
136
+
All sniff file names MUST end with`Sniff.php` and be located within a `[CategoryName]` directory.
137
137
138
138
All sniffs MUST have a name, so a sniff class called just and only `Sniff` is not allowed.
139
139
@@ -144,7 +144,7 @@ Both the sniff name and the category name MUST be valid symbol names in PHP.
144
144
145
145
The namespace and class name MUST follow [PSR-4](https://www.php-fig.org/psr/psr-4/).
146
146
147
-
This means that - taking the example directory structure above in to account - the namespace name MUST end on`[StandardName]\Sniffs\[CategoryName]` and the class name MUST be exactly the same as the file name (minus the `.php` file extension).
147
+
This means that - taking the example directory structure above in to account - the namespace name MUST end with`[StandardName]\Sniffs\[CategoryName]` and the class name MUST be exactly the same as the file name (minus the `.php` file extension).
148
148
149
149
> [!NOTE]
150
150
> As long as an external standard is registered with PHP_CodeSniffer via `installed_paths` and the standard follows the directory layout and naming conventions, PHP_CodeSniffer can, and will, automatically handle the sniff autoloading.
@@ -156,7 +156,7 @@ This means that - taking the example directory structure above in to account - t
0 commit comments