|
| 1 | +[](https://packagist.org/packages/phpcompatibility/phpcompatibility-passwordcompat) |
| 2 | +[](https://packagist.org/packages/phpcompatibility/phpcompatibility-passwordcompat) |
| 3 | +[](https://github.com/PHPCompatibility/PHPCompatibilityPasswordCompat/blob/master/LICENSE) |
| 4 | +[](https://travis-ci.org/PHPCompatibility/PHPCompatibilityPasswordCompat) |
| 5 | + |
1 | 6 | # PHPCompatibilityPasswordCompat
|
2 |
| -PHPCompatibility ruleset which can be included in projects using @ircmaxell's PasswordCompat polyfill library |
| 7 | + |
| 8 | +Using PHPCompatibilityPasswordCompat, you can analyse the codebase of a project using using @[ircmaxell](https://github.com/ircmaxell/)'s [password_compat](https://github.com/ircmaxell/password_compat) polyfill library, for PHP cross-version compatibility. |
| 9 | + |
| 10 | + |
| 11 | +## What's in this repo ? |
| 12 | + |
| 13 | +A rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the @ircmaxell's [password_compat](https://github.com/ircmaxell/password_compat) polyfill library. |
| 14 | + |
| 15 | +This ruleset prevents false positives from the [PHPCompatibility standard](https://github.com/PHPCompatibility/PHPCompatibility) by excluding back-fills and poly-fills which are provided by the `random_compat` library. |
| 16 | + |
| 17 | + |
| 18 | +## Requirements |
| 19 | + |
| 20 | +* [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer). |
| 21 | + * PHP 5.3+ for use with [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) 2.3.0+. |
| 22 | + * PHP 5.4+ for use with [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) 3.0.2+. |
| 23 | + |
| 24 | + Use the latest stable release of PHP_CodeSniffer for the best results. |
| 25 | + The minimum _recommended_ version of PHP_CodeSniffer is version 2.6.0. |
| 26 | +* [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility) 9.0.0+. |
| 27 | + |
| 28 | + |
| 29 | +## Installation instructions |
| 30 | + |
| 31 | +The only supported installation method is via [Composer](https://getcomposer.org/). |
| 32 | + |
| 33 | +If you don't have a Composer plugin installed to manage the `installed_paths` setting for PHP_CodeSniffer, run the following from the command-line: |
| 34 | +```bash |
| 35 | +composer require --dev dealerdirect/phpcodesniffer-composer-installer:^0.4.4 phpcompatibility/phpcompatibility-passwordcompat:* |
| 36 | +composer install |
| 37 | +``` |
| 38 | + |
| 39 | +If you already have a Composer PHP_CodeSniffer plugin installed, run: |
| 40 | +```bash |
| 41 | +composer require --dev phpcompatibility/phpcompatibility-passwordcompat:* |
| 42 | +composer install |
| 43 | +``` |
| 44 | + |
| 45 | +Next, run: |
| 46 | +```bash |
| 47 | +vendor/bin/phpcs -i |
| 48 | +``` |
| 49 | +If all went well, you will now see that the `PHPCompatibility` and `PHPCompatibilityPasswordCompat` standards are installed for PHP_CodeSniffer. |
| 50 | + |
| 51 | + |
| 52 | +## How to use |
| 53 | + |
| 54 | +Now you can use the following command to inspect the code in your project for PHP cross-version compatibility: |
| 55 | +```bash |
| 56 | +./vendor/bin/phpcs -p . --standard=PHPCompatibilityPasswordCompat |
| 57 | +``` |
| 58 | + |
| 59 | +By default, you will only receive notifications about deprecated and/or removed PHP features. |
| 60 | + |
| 61 | +To get the most out of the PHPCompatibilityPasswordCompat standard, you should specify a `testVersion` to check against. That will enable the checks for both deprecated/removed PHP features as well as the detection of code using new PHP features. |
| 62 | + |
| 63 | +For example: |
| 64 | +```bash |
| 65 | +# For a project which should be compatible with PHP 5.3 up to and including PHP 7.0: |
| 66 | +./vendor/bin/phpcs -p . --standard=PHPCompatibilityPasswordCompat --runtime-set testVersion 5.3-7.0 |
| 67 | + |
| 68 | +# For a project which should be compatible with PHP 5.4 and higher: |
| 69 | +./vendor/bin/phpcs -p . --standard=PHPCompatibilityPasswordCompat --runtime-set testVersion 5.4- |
| 70 | +``` |
| 71 | + |
| 72 | +For more detailed information about setting the `testVersion`, see the README of the generic [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions) standard. |
| 73 | + |
| 74 | + |
| 75 | +### Testing PHP files only |
| 76 | + |
| 77 | +By default PHP_CodeSniffer will analyse PHP, JavaScript and CSS files. As the PHPCompatibility sniffs only target PHP code, you can make the run slightly faster by telling PHP_CodeSniffer to only check PHP files, like so: |
| 78 | +```bash |
| 79 | +./vendor/bin/phpcs -p . --standard=PHPCompatibilityPasswordCompat --extensions=php --runtime-set testVersion 5.3- |
| 80 | +``` |
| 81 | + |
| 82 | +## License |
| 83 | + |
| 84 | +All code within the PHPCompatibility organisation is released under the GNU Lesser General Public License (LGPL). For more information, visit https://www.gnu.org/copyleft/lesser.html |
| 85 | + |
| 86 | + |
| 87 | +## Changelog |
| 88 | + |
| 89 | +### 1.0.0 - 2018-10-07 |
| 90 | + |
| 91 | +Initial release of the PHPCompatibilityPasswordCompat ruleset. |
0 commit comments