Skip to content

Commit 35f63c1

Browse files
authored
Merge pull request #1 from PHPCompatibility/feature/initial-release
Initial commit / v 1.0.0
2 parents 590f252 + 3064142 commit 35f63c1

File tree

8 files changed

+221
-1
lines changed

8 files changed

+221
-1
lines changed

.gitattributes

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# Exclude these files from release archives.
3+
# https://blog.madewithlove.be/post/gitattributes/
4+
#
5+
/.gitattributes export-ignore
6+
/.gitignore export-ignore
7+
/.travis.yml export-ignore
8+
/.github/ export-ignore
9+
/Test/ export-ignore
10+
11+
#
12+
# Auto detect text files and perform LF normalization
13+
# http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
14+
#
15+
* text=auto

.github/issue_template.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!--
2+
This repository is only for the PHPCompatibilityPasswordCompat ruleset, which prevents false positives from the PHPCompatibility standard by excluding the poly-fills which are provided by ircmaxell's password_compat library.
3+
4+
If your issue is related to the PHPCompatibility sniffs, please open an issue in the PHPCompatibility repository: https://github.com/PHPCompatibility/PHPCompatibility/issues
5+
6+
Before opening a new issue, please search for your issue to prevent opening a duplicate. If there is already an open issue, please leave a comment there.
7+
8+
Thanks!
9+
-->

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/
2+
composer.lock

.travis.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
sudo: false
2+
3+
dist: trusty
4+
5+
cache:
6+
apt: true
7+
8+
language: php
9+
10+
## Cache composer downloads.
11+
cache:
12+
directories:
13+
- $HOME/.cache/composer/files
14+
15+
matrix:
16+
fast_finish: true
17+
include:
18+
- php: 7.2
19+
addons:
20+
apt:
21+
packages:
22+
- libxml2-utils
23+
- php: 5.4
24+
25+
before_install:
26+
# Speed up build time by disabling Xdebug when its not needed.
27+
- if [[ $COVERALLS_VERSION == "notset" ]]; then phpenv config-rm xdebug.ini || echo 'No xdebug config.'; fi
28+
- export XMLLINT_INDENT=" "
29+
- composer install
30+
- vendor/bin/phpcs -i
31+
32+
script:
33+
- |
34+
if [[ $TRAVIS_PHP_VERSION == "7.2" ]]; then
35+
# Validate the xml file.
36+
# @link http://xmlsoft.org/xmllint.html
37+
xmllint --noout ./*/ruleset.xml
38+
39+
# Check the code-style consistency of the xml file.
40+
diff -B ./PHPCompatibilityPasswordCompat/ruleset.xml <(xmllint --format "./PHPCompatibilityPasswordCompat/ruleset.xml")
41+
fi
42+
43+
# Test the ruleset.
44+
- vendor/bin/phpcs ./Test/PasswordCompatTest.php --standard=PHPCompatibilityPasswordCompat --runtime-set testVersion 5.4
45+
46+
# Validate the composer.json file.
47+
# @link https://getcomposer.org/doc/03-cli.md#validate
48+
- composer validate --no-check-all --strict
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="PHPCompatibilityPasswordCompat">
3+
<description>PHPCompatibility ruleset for PHP_CodeSniffer which accounts for polyfills provided by ircmaxell's password_compat library.</description>
4+
5+
<rule ref="PHPCompatibility">
6+
<!-- https://github.com/ircmaxell/password_compat/blob/master/lib/password.php -->
7+
<exclude name="PHPCompatibility.Constants.NewConstants.password_bcryptFound"/>
8+
<exclude name="PHPCompatibility.Constants.NewConstants.password_bcrypt_default_costFound"/>
9+
<exclude name="PHPCompatibility.Constants.NewConstants.password_defaultFound"/>
10+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.password_get_infoFound"/>
11+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.password_hashFound"/>
12+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.password_needs_rehashFound"/>
13+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.password_verifyFound"/>
14+
</rule>
15+
16+
</ruleset>

README.md

+90-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,91 @@
1+
[![Latest Stable Version](https://poser.pugx.org/phpcompatibility/phpcompatibility-passwordcompat/v/stable.png)](https://packagist.org/packages/phpcompatibility/phpcompatibility-passwordcompat)
2+
[![Latest Unstable Version](https://poser.pugx.org/phpcompatibility/phpcompatibility-passwordcompat/v/unstable.png)](https://packagist.org/packages/phpcompatibility/phpcompatibility-passwordcompat)
3+
[![License](https://poser.pugx.org/phpcompatibility/phpcompatibility-passwordcompat/license.png)](https://github.com/PHPCompatibility/PHPCompatibilityPasswordCompat/blob/master/LICENSE)
4+
[![Build Status](https://travis-ci.org/PHPCompatibility/PHPCompatibilityPasswordCompat.svg?branch=master)](https://travis-ci.org/PHPCompatibility/PHPCompatibilityPasswordCompat)
5+
16
# 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.

Test/PasswordCompatTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/*
3+
* Test file to run PHP_CodeSniffer against to make sure the polyfills are correctly excluded.
4+
*/
5+
$a = password_get_info( $hash );
6+
$a = password_hash( $password, PASSWORD_BCRYPT, $options );
7+
$a = password_needs_rehash( $hash, PASSWORD_DEFAULT, $options );
8+
$a = password_verify( $password, $hash );
9+
10+
echo PASSWORD_BCRYPT_DEFAULT_COST;

composer.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name" : "phpcompatibility/phpcompatibility-passwordcompat",
3+
"description" : "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by ircmaxell's password_compat library.",
4+
"type" : "phpcodesniffer-standard",
5+
"keywords" : [ "compatibility", "phpcs", "standards", "password_compat", "polyfill" ],
6+
"homepage" : "http://phpcompatibility.com/",
7+
"license" : "LGPL-3.0-or-later",
8+
"authors" : [ {
9+
"name" : "Wim Godden",
10+
"role" : "lead"
11+
},
12+
{
13+
"name" : "Juliette Reinders Folmer",
14+
"role" : "lead"
15+
} ],
16+
"support" : {
17+
"issues" : "https://github.com/PHPCompatibility/PHPCompatibilityPasswordCompat/issues",
18+
"source" : "https://github.com/PHPCompatibility/PHPCompatibilityPasswordCompat"
19+
},
20+
"require" : {
21+
"phpcompatibility/php-compatibility" : "^9.0"
22+
},
23+
"require-dev" : {
24+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4"
25+
},
26+
"suggest" : {
27+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.",
28+
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
29+
},
30+
"prefer-stable" : true
31+
}

0 commit comments

Comments
 (0)