Skip to content

Commit 4459178

Browse files
committed
4.0 | Wiki: update for removal of CSS/JS support in sniffs
1 parent a0ae8e1 commit 4459178

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

wiki/Advanced-Usage.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
## Specifying Valid File Extensions
99

10-
By default, PHP_CodeSniffer will check any file it finds with a `.inc`, `.php`, `.js` or `.css` extension, although not all standards will actually check all these file types. Sometimes, this means that PHP_CodeSniffer is not checking enough of your files. Sometimes, the opposite is true. PHP_CodeSniffer allows you to specify a list of valid file extensions using the `--extensions` command line argument. Extensions are separated by commas.
10+
By default, PHP_CodeSniffer will check any file it finds with an `.inc` or `.php` extension. Sometimes, this means that PHP_CodeSniffer is not checking enough of your files. Sometimes, the opposite is true. PHP_CodeSniffer allows you to specify a list of valid file extensions using the `--extensions` command line argument. Extensions are separated by commas.
1111

1212
To only check `.php` files:
1313
```bash
@@ -19,6 +19,10 @@ To check `.php`, `.inc` and `.lib` files:
1919
$ phpcs --extensions=php,inc,lib /path/to/code
2020
```
2121

22+
> [!NOTE]
23+
> Prior to PHP_CodeSniffer 4.0.0, `.css` and `.js` files were also scanned by default, though only a limited number of sniffs included support for scanning JS and CSS files.
24+
> Support for CSS and JavaScript file scanning was removed in PHP_CodeSniffer 4.0.0.
25+
2226
<p align="right"><a href="#table-of-contents">back to top</a></p>
2327

2428

wiki/Coding-Standard-Tutorial.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,21 @@ final class DisallowHashCommentsSniff implements Sniff
143143
}
144144
```
145145

146-
By default, PHP_CodeSniffer assumes all sniffs are designed to check PHP code only. You can specify a list of tokenizers that your sniff supports, allowing it to be used with PHP, JavaScript or CSS files, or any combination of the three. You do this by setting the `$supportedTokenizers` property in your sniff. Adding the following code to your sniff will tell PHP_CodeSniffer that it can be used to check both PHP and JavaScript code:
147-
148-
```php
149-
/**
150-
* A list of tokenizers this sniff supports.
151-
*
152-
* @var array<string>
153-
*/
154-
public $supportedTokenizers = [
155-
'PHP',
156-
'JS',
157-
];
158-
```
146+
> [!NOTE]
147+
> Since PHP_CodeSniffer 4.0.0, scanning JavaScript or CSS files is no longer supported.
148+
> Prior to PHP_CodeSniffer 4.0.0, PHP_CodeSniffer assumed, by default, that all sniffs were designed to check PHP code only, but you could specify a list of tokenizers that your sniff supported, allowing it to be used with PHP, JavaScript or CSS files, or any combination of these. You indicated this by setting the `$supportedTokenizers` property in your sniff. So if you see the following code in a sniff for PHP_CodeSniffer < 4.0, this tells PHP_CodeSniffer that it can be used to check both PHP and JavaScript code:
149+
>
150+
> ```php
151+
> /**
152+
> * A list of tokenizers this sniff supports.
153+
> *
154+
> * @var array<string>
155+
> */
156+
> public $supportedTokenizers = [
157+
> 'PHP',
158+
> 'JS',
159+
> ];
160+
> ```
159161
160162
<p align="right"><a href="#table-of-contents">back to top</a></p>
161163

wiki/FAQ.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ Always run PHP_CodeSniffer until you get a passing result. Once you've made the
5555

5656
## What does PHP_CodeSniffer use to tokenize my code?
5757

58-
For PHP files, PHP_CodeSniffer uses [PHP's inbuilt tokenizer functions](http://www.php.net/tokenizer) to parse your code. It then modifies that output to include much more data about the file, such as matching function braces to function keywords.
59-
60-
For all other file types, PHP_CodeSniffer includes a custom tokenizer that either makes use of PHP's inbuilt tokenizer or emulates it. In both cases, the token array must be checked and changed manually before all the standard PHP_CodeSniffer matching rules are applied, making tokenizing a bit slower for these file types.
58+
PHP_CodeSniffer uses [PHP's inbuilt tokenizer functions](http://www.php.net/tokenizer) to parse your code. It then modifies that output to include much more data about the file, such as matching function braces to function keywords.
6159

6260
<p align="right"><a href="#table-of-contents">back to top</a></p>

wiki/Home.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PHP_CodeSniffer is a set of two PHP scripts:
2-
1. the main [`phpcs` script](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage) that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard; and
2+
1. the main [`phpcs` script](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage) that tokenizes PHP files to detect violations of a defined coding standard; and
33
2. a [`phpcbf` script](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Fixing-Errors-Automatically) to automatically correct detected coding standard violations.
44

55
PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent.

0 commit comments

Comments
 (0)