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/Coding-Standard-Tutorial.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,13 @@ In this tutorial, we will create a new coding standard with a single sniff. Our
2
2
3
3
Sniffs need to follow [strict directory layout and naming conventions](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/About-Standards-for-PHP_CodeSniffer#naming-conventions).
4
4
5
+
## Table of contents
6
+
7
+
<!-- START doctoc -->
8
+
<!-- END doctoc -->
9
+
10
+
***
11
+
5
12
## Creating the Coding Standard Directory
6
13
7
14
All sniffs in PHP_CodeSniffer must belong to a coding standard. A coding standard is a directory with a specific sub-directory structure and a `ruleset.xml` file, so creating a standard is straight-forward.
Copy file name to clipboardExpand all lines: wiki/Version-4.0-Developer-Upgrade-Guide.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,7 +96,7 @@ Support for the JS/CSS tokenizers has been removed. To cause the least amount of
96
96
97
97
This has been implemented in this way to allow external standards to be cross-version compatible with PHPCS 3.x as well as 4.x for a while and to not force external standards to release a new major release to support PHPCS 4.0 (due to sniffs needing to be removed).
98
98
99
-
#### Upgrading
99
+
**Upgrading**
100
100
101
101
Search for sniffs which specify the `public $supportedTokenizers` property to find sniffs which may need updating.
102
102
@@ -118,7 +118,7 @@ Type casting for sniff property values set from within a ruleset has been made m
118
118
*`null` will now be set to an actual `null` value. Previously, the sniff property would have been set to string `'null'`.
119
119
* Array element values will now also get the type casting treatment. Previously, array values would always be strings.
120
120
121
-
#### Upgrading
121
+
**Upgrading**
122
122
123
123
Search for sniff which have `public` properties which can be changed from within a ruleset.
124
124
@@ -406,7 +406,7 @@ The `AbstractPatternSniff::__construct()` method no longer takes any arguments.
406
406
Since PHPCS 1.4.0, the AbstractPatternSniff sets the `ignoreComments` option using a `public` var rather than through the constructor.
407
407
This allows the setting to be overwritten in `ruleset.xml` files.
408
408
409
-
#### Upgrading
409
+
**Upgrading**
410
410
411
411
* Search for sniffs which extend the `AbstractPatternSniff`.
412
412
* If the sniff calls the `parent::__construct()` method with an argument, remove the argument.
@@ -533,7 +533,7 @@ The `protected` `getDeclarationNameWithNamespace()` and `getNamespaceOfScope()`
533
533
534
534
The Ruleset class now respects sniff selection via `--sniffs=...`, even when in a test context.
535
535
536
-
#### Upgrading
536
+
**Upgrading**
537
537
538
538
If your own test framework contained work-arounds to get round the previous restriction, it should now be safe to remove those work-arounds and to use the `--sniffs=...` argument when initiating the `Config` class.
539
539
@@ -585,7 +585,7 @@ If an external standard uses its own test framework, this section can be skipped
585
585
For compatibility with the PHP_CodeSniffer native test framework, the directory layout conventions and class naming conventions for tests have to be strictly followed and external standards which want to use the PHPCS native test framework need to be registered in the PHP_CodeSniffer `CodeSniffer.conf` file.
586
586
This is not really any different from before, just even more important now.
587
587
588
-
#### Upgrading
588
+
**Upgrading**
589
589
590
590
In practice this means the following for most test suites for external standards which extend the PHP_CodeSniffer native test suite:
591
591
1. In `composer.json`: update the PHPUnit version requirements.
0 commit comments