Skip to content

Commit bae25b2

Browse files
authored
Downgrade requirements from PHP 5.6 to 5.4 (#191)
* Add php 5.4 to circleci config * Downgrade required php version to 5.4 * Allow phpunit 4 for testing * Remove constant expression from BaseTestCase * Use func_get_args instead of ellipses * Downgrade PHP requirement in README
1 parent 5620b43 commit bae25b2

File tree

6 files changed

+35
-8
lines changed

6 files changed

+35
-8
lines changed

.circleci/config.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,35 @@ jobs:
2525
- checkout
2626
- run: COMPOSER=composer.circleci.json composer install
2727
- run: COMPOSER=composer.circleci.json composer test
28+
build_php5.4:
29+
docker:
30+
- image: lavoweb/php-5.4
31+
steps:
32+
- run:
33+
name: PHP version check
34+
command: php --version
35+
- run:
36+
name: Install system packages
37+
command: apt-get update && apt-get -y install git
38+
- checkout
39+
- run:
40+
name: Install composer
41+
command: |
42+
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
43+
php -r "if (hash_file('SHA384', 'composer-setup.php') === trim(file_get_contents('https://composer.github.io/installer.sig'))) { echo 'Installer verified'; } else { echo 'Installer invalid'; unlink('composer-setup.php'); } echo PHP_EOL;"
44+
php composer-setup.php
45+
php -r "unlink('composer-setup.php');"
46+
- run:
47+
name: Install dependencies
48+
command: COMPOSER=composer.circleci.json php composer.phar install
49+
- run:
50+
name: Run tests
51+
command: COMPOSER=composer.circleci.json php composer.phar test
2852
workflows:
2953
version: 2
3054
build_php_versions:
3155
jobs:
56+
- build_php5.4
3257
- build_php5.6
3358
- build_php7.3
3459
- build_php7.4

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Plugin for PHP_CodeSniffer static analysis tool that adds analysis of problemati
1212

1313
### Requirements
1414

15-
VariableAnalysis requires PHP 5.6 or higher and [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) version 3.5.0 or higher.
15+
VariableAnalysis requires PHP 5.4 or higher and [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) version 3.5.0 or higher.
1616

1717
It also requires [PHPCSUtils](https://phpcsutils.com/) which must be installed as a PHPCS standard. If you are using composer, this will be done automatically (see below).
1818

@@ -97,7 +97,7 @@ This was forked from the excellent work in https://github.com/illusori/PHP_Codes
9797

9898
Please open issues or PRs on this repository.
9999

100-
Any changes should be accompanied by tests and should pass linting and static analysis. Please use phpdoc (rather than actual types) for declaring types since this must run in PHP 5.6.
100+
Any changes should be accompanied by tests and should pass linting and static analysis. Please use phpdoc (rather than actual types) for declaring types since this must run in PHP 5.4.
101101

102102
To run tests, make sure composer is installed, then run:
103103

Tests/BaseTestCase.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88

99
class BaseTestCase extends TestCase {
1010
const STANDARD_NAME = 'VariableAnalysis';
11-
const SNIFF_FILE = __DIR__ . '/../VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php';
1211

1312
public function prepareLocalFileForSniffs($fixtureFile) {
13+
$sniffFile = __DIR__ . '/../VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php';
14+
1415
$config = new Config();
1516
$config->cache = false;
1617
$config->standards = [self::STANDARD_NAME];
1718
$config->ignored = [];
1819

19-
$sniffFiles = [realpath(self::SNIFF_FILE)];
20+
$sniffFiles = [realpath($sniffFile)];
2021
$ruleset = new Ruleset($config);
2122
$ruleset->registerSniffs($sniffFiles, [], []);
2223
$ruleset->populateTokenListeners();

VariableAnalysis/Lib/Helpers.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ public static function getVariablesDefinedByArrowFunction(File $phpcsFile, $stac
487487
/**
488488
* @return void
489489
*/
490-
public static function debug(...$messages) {
490+
public static function debug() {
491+
$messages = func_get_args();
491492
if (! defined('PHP_CODESNIFFER_VERBOSITY')) {
492493
return;
493494
}

composer.circleci.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
"test": "./vendor/bin/phpunit --configuration phpunit.circleci.xml"
3838
},
3939
"require" : {
40-
"php" : ">=5.6.0",
40+
"php" : ">=5.4.0",
4141
"squizlabs/php_codesniffer": "^3.1",
4242
"phpcsstandards/phpcsutils": "^1.0"
4343
},
4444
"require-dev": {
45-
"phpunit/phpunit": "^5.0 || ^6.5 || ^7.0 || ^8.0"
45+
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.5 || ^7.0 || ^8.0"
4646
}
4747
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"phpstan": "./vendor/bin/phpstan analyse"
4040
},
4141
"require" : {
42-
"php" : ">=5.6.0",
42+
"php" : ">=5.4.0",
4343
"squizlabs/php_codesniffer": "^3.5",
4444
"phpcsstandards/phpcsutils": "^1.0"
4545
},

0 commit comments

Comments
 (0)