Skip to content

Commit fc00085

Browse files
authored
Merge pull request #157 from PHPCSStandards/feature/readme-updates-for-release
Readme: update for 1.0.0-alpha3
2 parents a08bb59 + 1c07eea commit fc00085

File tree

3 files changed

+115
-11
lines changed

3 files changed

+115
-11
lines changed

README.md

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ PHPCSUtils: A suite of utility functions for use with PHP_CodeSniffer
2424
+ [Composer-based with a minimum PHPCS requirement of PHPCS 2.6.0](#composer-based-with-a-minimum-phpcs-requirement-of-phpcs-260)
2525
+ [Non-Composer based integration](#non-composer-based-integration)
2626
* [Frequently Asked Questions](#frequently-asked-questions)
27+
* [Potential Support Questions from your End-Users](#potential-support-questions-from-your-end-users)
2728
* [Contributing](#contributing)
2829
* [License](#license)
2930

3031

3132
Features
3233
-------------------------------------------
3334

34-
[PHPCSUtils](https://github.com/PHPCSStandards/PHPCSUtils) is a set of utilities to aid developers of sniffs for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer).
35+
[PHPCSUtils](https://github.com/PHPCSStandards/PHPCSUtils) is a set of utilities to aid developers of sniffs for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) (or "PHPCS" for short).
3536

3637
This package offers the following features:
3738

@@ -47,14 +48,14 @@ Now you won't have to anymore. This package allows you to use the latest version
4748

4849
These classes take most of the heavy lifting away for some frequently occurring sniff types.
4950

50-
### A collection of static properties for often-used token groups.
51+
### A collection of static properties and methods for often-used token groups.
5152

5253
Collections of related tokens often-used and needed for sniffs.
5354
These are additional "token groups" to compliment the ones available through the PHPCS native `PHP_CodeSniffer\Util\Tokens` class.
5455

5556
### An ever-growing number of utility functions for use with PHP_CodeSniffer.
5657

57-
Whether you need to split an `array` into the individual items, are trying to determine which variables are being assigned to in a `list()` or are figuring out whether a function has a DocBlock, PHPCSUtils has you covered!
58+
Whether you need to split an `array` into the individual items, are trying to determine which variables are being assigned to in a `list()` or are figuring out whether a function has a DocBlock, PHPCSUtils has got you covered!
5859

5960
Includes improved versions of the PHPCS native utility functions and plenty of new utility functions.
6061

@@ -80,6 +81,8 @@ Minimum Requirements
8081

8182
* PHP 5.4 or higher.
8283
* [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) 2.6.0+, 3.1.0+ (with the exception of PHPCS 3.5.3).
84+
* Recommended PHP extensions for optimal functionality:
85+
- PCRE with Unicode support (normally enabled by default)
8386

8487

8588
Integrating PHPCSUtils in your external PHPCS standard
@@ -121,7 +124,7 @@ In addition to that, add the following to the `ruleset.xml` file of your standar
121124
<rule ref="PHPCS23Utils"/>
122125
```
123126

124-
> :information_source: The `PHPCS23Utils` "standard" does not add any real sniffs, it just makes sure that the Utility functions will work in PHPCS 2.x as well.
127+
> :information_source: The `PHPCS23Utils` "standard" does not add any real sniffs, it only makes sure that the Utility functions will work in PHPCS 2.x as well.
125128
126129
#### Running your unit tests
127130

@@ -223,7 +226,7 @@ Frequently Asked Questions
223226
224227
#### Q: How does this all work without an external standard needing to register an autoloader?
225228
226-
A: As PHPCSUtils is registered with PHPCS as an external standard and PHPCSUtils complies with the naming requirements of PHPCS, the PHPCS native autoloader will automatically take care of loading the classes you use from PHPCSUtils.
229+
A: As PHPCSUtils is registered with PHPCS as an external standard and PHPCSUtils complies with the naming requirements of PHPCS, the PHPCS native autoloader will automatically take care of loading the classes used from PHPCSUtils.
227230
228231
#### Q: What does the `PHPCS23Utils` standard do?
229232
@@ -237,8 +240,58 @@ A: The backfill for PHP 7.4 numeric literals with underscores in PHP_CodeSniffer
237240
238241
The backfill was fixed in PHP_CodeSniffer 3.5.4.
239242
243+
#### Q: Any other problematic PHPCS versions?
244+
245+
A: Well, the arrow function backfill which was added in PHPCS 3.5.3 is still causing problems. In a very limited set of circumstances, it will even hang the Tokenizer. A fix for [one particular such problem](https://github.com/squizlabs/php_codesniffer/issues/2926) has been committed to `master`, but is not (yet) in a released version. It is expected to be released in PHP_CodeSniffer 3.5.6.
246+
247+
As the Tokenizer hanging is a problem unrelated to PHPCSUtils and not something which can be mitigated from within PHPCSUtils in any conceivable way, PHPCSUtils won't block installation in combination with PHPCS 3.5.4 and 3.5.5.
248+
249+
There are several other issues which can not be worked around, like scope closers being set incorrectly and throwing the scope setting off for the rest of the file, so not withstanding that PHPCSUtils can work around a lot of issues, it is still highly recommended to advise your end-users to always use the latest version of PHPCS for the most reliable results.
250+
251+
#### Q: Does using PHPCSUtils have any effect on the PHPCS native sniffs?
252+
253+
A: No. PHPCSUtils will only work for those sniffs which explicitly use the PHPCSUtils functionality.
254+
255+
If your standard includes both PHPCS native sniffs as well as your own sniffs, your own sniffs can benefit from the back-compat layer offered by PHPCSUtils, as well as from the additional utility functions. However, the PHPCS native sniffs will not receive those benefits, as PHPCS itself does not use PHPCSUtils.
256+
257+
#### Q: Do the utilities work with javascript/CSS files?
258+
259+
A: JS/CSS support will be removed from PHP_CodeSniffer in PHPCS 4.x.
260+
While at this time, some of the utilies _may_ work with JS/CSS files, PHPCSUtils does not offer formal support for JS/CSS sniffing with PHP_CodeSniffer and will stop any existing support once PHPCS 4.x has been released.
261+
262+
#### Q: Are all file encodings supported?
263+
264+
A: No. The UTF-8 file encoding is the only officially supported encoding. Support for other encodings may incidentally work, but is not officially supported.
265+
266+
> **It is recommended to advise your users to save their files as UTF-8 encoded for the best results.**
267+
268+
PHP_CodeSniffer 3.x will default to UTF-8 as the expected file encoding.
269+
If your standard supports PHP_CodeSniffer 2.x, it is recommended to set the expected encoding in the ruleset to `utf-8`, like so: `<arg name="encoding" value="utf-8"/>` or to advise users to use the CLI option `--encoding=utf-8`.
270+
271+
272+
Potential Support Questions from your End-Users
273+
-------
274+
275+
#### Q: A user reports a fatal "class not found" error for a class from PHPCSUtils.
276+
277+
1. Check that the version of PHPCSUtils the user has installed complies with the minimum version of PHPCSUtils your standard requires. If not, they will need to upgrade.
278+
2. If the version is correct, this indicates that the end-user does not have PHPCSUtils installed and/or registered with PHP_CodeSniffer.
279+
- Please review your standard's installation instructions to make sure that PHPCSUtils will be installed when those are followed.
280+
- Inform the user to install PHPCSUtils and register it with PHP_CodeSniffer.
281+
282+
> :bulb: **Pro-tip**: if you want to prevent the fatal error and show a _friendlier_ error message instead, add `<rule ref="PHPCSUtils"/>` to your standard's `ruleset.xml` file.
283+
>
284+
> With that in place, PHP_CodeSniffer will show a _"ERROR: the "PHPCSUtils" coding standard is not installed."_ message if PHPCSUtils is missing as soon as the ruleset loading is finished.
285+
286+
> :bulb: **Pro-tip**: provide upgrade instructions for your end-users. For Composer-based installs, those should look like this:
287+
> ```bash
288+
> composer update your/cs-package --with-dependencies
289+
> ```
290+
> That way, when the user updates your coding standards package, they will automatically also update PHPCSUtils.
291+
240292
</div>
241293
294+
242295
Contributing
243296
-------
244297
Contributions to this project are welcome. Clone the repo, branch off from `develop`, make your changes, commit them and send in a pull request.

docs/assets/css/style.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ h4 {
2828
blockquote{
2929
border-left:2px solid #e5e5e5;
3030
border-right:2px solid #e5e5e5;
31-
margin:5px 20px 0 10px;
31+
margin:5px 20px 20px 10px;
3232
padding:0 10px 0 20px;
3333
}
3434
blockquote p {

docs/index.md

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ seo:
1212
Features
1313
-------------------------------------------
1414

15-
[PHPCSUtils](https://github.com/PHPCSStandards/PHPCSUtils) is a set of utilities to aid developers of sniffs for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer).
15+
[PHPCSUtils](https://github.com/PHPCSStandards/PHPCSUtils) is a set of utilities to aid developers of sniffs for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) (or "PHPCS" for short).
1616

1717
This package offers the following features:
1818

@@ -28,14 +28,14 @@ Now you won't have to anymore. This package allows you to use the latest version
2828

2929
These classes take most of the heavy lifting away for some frequently occurring sniff types.
3030

31-
### A collection of static properties for often-used token groups.
31+
### A collection of static properties and methods for often-used token groups.
3232

3333
Collections of related tokens often-used and needed for sniffs.
3434
These are additional "token groups" to compliment the ones available through the PHPCS native `PHP_CodeSniffer\Util\Tokens` class.
3535

3636
### An ever-growing number of utility functions for use with PHP_CodeSniffer.
3737

38-
Whether you need to split an `array` into the individual items, are trying to determine which variables are being assigned to in a `list()` or are figuring out whether a function has a DocBlock, PHPCSUtils has you covered!
38+
Whether you need to split an `array` into the individual items, are trying to determine which variables are being assigned to in a `list()` or are figuring out whether a function has a DocBlock, PHPCSUtils has got you covered!
3939

4040
Includes improved versions of the PHPCS native utility functions and plenty of new utility functions.
4141

@@ -61,6 +61,8 @@ Minimum Requirements
6161

6262
* PHP 5.4 or higher.
6363
* [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) 2.6.0+, 3.1.0+ (with the exception of PHPCS 3.5.3).
64+
* Recommended PHP extensions for optimal functionality:
65+
- PCRE with Unicode support (normally enabled by default)
6466

6567

6668
Integrating PHPCSUtils in your external PHPCS standard
@@ -102,7 +104,7 @@ In addition to that, add the following to the `ruleset.xml` file of your standar
102104
<rule ref="PHPCS23Utils"/>
103105
```
104106

105-
> :information_source: The `PHPCS23Utils` "standard" does not add any real sniffs, it just makes sure that the Utility functions will work in PHPCS 2.x as well.
107+
> :information_source: The `PHPCS23Utils` "standard" does not add any real sniffs, it only makes sure that the Utility functions will work in PHPCS 2.x as well.
106108
107109
#### Running your unit tests
108110

@@ -119,7 +121,7 @@ Frequently Asked Questions
119121

120122
#### Q: How does this all work without an external standard needing to register an autoloader?
121123

122-
A: As PHPCSUtils is registered with PHPCS as an external standard and PHPCSUtils complies with the naming requirements of PHPCS, the PHPCS native autoloader will automatically take care of loading the classes you use from PHPCSUtils.
124+
A: As PHPCSUtils is registered with PHPCS as an external standard and PHPCSUtils complies with the naming requirements of PHPCS, the PHPCS native autoloader will automatically take care of loading the classes used from PHPCSUtils.
123125

124126
#### Q: What does the `PHPCS23Utils` standard do?
125127

@@ -133,8 +135,57 @@ A: The backfill for PHP 7.4 numeric literals with underscores in PHP_CodeSniffer
133135

134136
The backfill was fixed in PHP_CodeSniffer 3.5.4.
135137

138+
#### Q: Any other problematic PHPCS versions?
139+
140+
A: Well, the arrow function backfill which was added in PHPCS 3.5.3 is still causing problems. In a very limited set of circumstances, it will even hang the Tokenizer. A fix for [one particular such problem](https://github.com/squizlabs/php_codesniffer/issues/2926) has been committed to `master`, but is not (yet) in a released version. It is expected to be released in PHP_CodeSniffer 3.5.6.
141+
142+
As the Tokenizer hanging is a problem unrelated to PHPCSUtils and not something which can be mitigated from within PHPCSUtils in any conceivable way, PHPCSUtils won't block installation in combination with PHPCS 3.5.4 and 3.5.5.
143+
144+
There are several other issues which can not be worked around, like scope closers being set incorrectly and throwing the scope setting off for the rest of the file, so not withstanding that PHPCSUtils can work around a lot of issues, it is still highly recommended to advise your end-users to always use the latest version of PHPCS for the most reliable results.
145+
146+
#### Q: Does using PHPCSUtils have any effect on the PHPCS native sniffs?
147+
148+
A: No. PHPCSUtils will only work for those sniffs which explicitly use the PHPCSUtils functionality.
149+
150+
If your standard includes both PHPCS native sniffs as well as your own sniffs, your own sniffs can benefit from the back-compat layer offered by PHPCSUtils, as well as from the additional utility functions. However, the PHPCS native sniffs will not receive those benefits, as PHPCS itself does not use PHPCSUtils.
151+
152+
#### Q: Do the utilities work with javascript/CSS files?
153+
154+
A: JS/CSS support will be removed from PHP_CodeSniffer in PHPCS 4.x.
155+
While at this time, some of the utilies _may_ work with JS/CSS files, PHPCSUtils does not offer formal support for JS/CSS sniffing with PHP_CodeSniffer and will stop any existing support once PHPCS 4.x has been released.
156+
157+
#### Q: Are all file encodings supported?
158+
159+
A: No. The UTF-8 file encoding is the only officially supported encoding. Support for other encodings may incidentally work, but is not officially supported.
160+
161+
> **It is recommended to advise your users to save their files as UTF-8 encoded for the best results.**
162+
163+
PHP_CodeSniffer 3.x will default to UTF-8 as the expected file encoding.
164+
If your standard supports PHP_CodeSniffer 2.x, it is recommended to set the expected encoding in the ruleset to `utf-8`, like so: `<arg name="encoding" value="utf-8"/>` or to advise users to use the CLI option `--encoding=utf-8`.
165+
166+
167+
Potential Support Questions from your End-Users
168+
-------
169+
170+
#### Q: A user reports a fatal "class not found" error for a class from PHPCSUtils.
171+
172+
1. Check that the version of PHPCSUtils the user has installed complies with the minimum version of PHPCSUtils your standard requires. If not, they will need to upgrade.
173+
2. If the version is correct, this indicates that the end-user does not have PHPCSUtils installed and/or registered with PHP_CodeSniffer.
174+
- Please review your standard's installation instructions to make sure that PHPCSUtils will be installed when those are followed.
175+
- Inform the user to install PHPCSUtils and register it with PHP_CodeSniffer.
176+
177+
> :bulb: **Pro-tip**: if you want to prevent the fatal error and show a _friendlier_ error message instead, add `<rule ref="PHPCSUtils"/>` to your standard's `ruleset.xml` file.
178+
>
179+
> With that in place, PHP_CodeSniffer will show a _"ERROR: the "PHPCSUtils" coding standard is not installed."_ message if PHPCSUtils is missing as soon as the ruleset loading is finished.
180+
181+
> :bulb: **Pro-tip**: provide upgrade instructions for your end-users. For Composer-based installs, those should look like this:
182+
> <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>composer update <span class="s">your/cs-package</span> <span class="mf">--with-dependencies</span>
183+
> </code></pre></div></div>
184+
> That way, when the user updates your coding standards package, they will automatically also update PHPCSUtils.
185+
136186
</div>
137187

188+
138189
Contributing
139190
-------
140191
Contributions to this project are welcome. Clone the repo, branch off from `develop`, make your changes, commit them and send in a pull request.

0 commit comments

Comments
 (0)