From ccb6fe202c9b4b951182f3da993df61429ec26a0 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sat, 11 Jul 2020 17:05:16 -0400 Subject: [PATCH 1/6] Add php 5.4 to circleci config --- .circleci/config.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 88213c26..011fe56d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,10 +25,35 @@ jobs: - checkout - run: COMPOSER=composer.circleci.json composer install - run: COMPOSER=composer.circleci.json composer test + build_php5.4: + docker: + - image: lavoweb/php-5.4 + steps: + - run: + name: PHP version check + command: php --version + - run: + name: Install system packages + command: apt-get update && apt-get -y install git + - checkout + - run: + name: Install composer + command: | + php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" + 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;" + php composer-setup.php + php -r "unlink('composer-setup.php');" + - run: + name: Install dependencies + command: COMPOSER=composer.circleci.json php composer.phar install + - run: + name: Run tests + command: COMPOSER=composer.circleci.json php composer.phar test workflows: version: 2 build_php_versions: jobs: + - build_php5.4 - build_php5.6 - build_php7.3 - build_php7.4 From d44b925c19ad1e65287073ae5c098af14ad69fe4 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sat, 11 Jul 2020 17:51:37 -0400 Subject: [PATCH 2/6] Downgrade required php version to 5.4 --- composer.circleci.json | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.circleci.json b/composer.circleci.json index dce6a631..df834908 100644 --- a/composer.circleci.json +++ b/composer.circleci.json @@ -37,7 +37,7 @@ "test": "./vendor/bin/phpunit --configuration phpunit.circleci.xml" }, "require" : { - "php" : ">=5.6.0", + "php" : ">=5.4.0", "squizlabs/php_codesniffer": "^3.1", "phpcsstandards/phpcsutils": "^1.0" }, diff --git a/composer.json b/composer.json index 64f53c1a..a0224240 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "phpstan": "./vendor/bin/phpstan analyse" }, "require" : { - "php" : ">=5.6.0", + "php" : ">=5.4.0", "squizlabs/php_codesniffer": "^3.5", "phpcsstandards/phpcsutils": "^1.0" }, From 5375c7c1abc52408a1e8d2813baaecbb39fdb04f Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sat, 11 Jul 2020 18:48:42 -0400 Subject: [PATCH 3/6] Allow phpunit 4 for testing --- composer.circleci.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.circleci.json b/composer.circleci.json index df834908..066a5546 100644 --- a/composer.circleci.json +++ b/composer.circleci.json @@ -42,6 +42,6 @@ "phpcsstandards/phpcsutils": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^5.0 || ^6.5 || ^7.0 || ^8.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.5 || ^7.0 || ^8.0" } } From 25c67744d867af59ef134804c75dcb11b9889a6b Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sat, 11 Jul 2020 18:53:26 -0400 Subject: [PATCH 4/6] Remove constant expression from BaseTestCase --- Tests/BaseTestCase.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Tests/BaseTestCase.php b/Tests/BaseTestCase.php index 5f4c9200..5f75523e 100644 --- a/Tests/BaseTestCase.php +++ b/Tests/BaseTestCase.php @@ -8,15 +8,16 @@ class BaseTestCase extends TestCase { const STANDARD_NAME = 'VariableAnalysis'; - const SNIFF_FILE = __DIR__ . '/../VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php'; public function prepareLocalFileForSniffs($fixtureFile) { + $sniffFile = __DIR__ . '/../VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php'; + $config = new Config(); $config->cache = false; $config->standards = [self::STANDARD_NAME]; $config->ignored = []; - $sniffFiles = [realpath(self::SNIFF_FILE)]; + $sniffFiles = [realpath($sniffFile)]; $ruleset = new Ruleset($config); $ruleset->registerSniffs($sniffFiles, [], []); $ruleset->populateTokenListeners(); From d6ac366f064dcfe285c8b9f5b28aef6b53b88a21 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sat, 11 Jul 2020 18:55:33 -0400 Subject: [PATCH 5/6] Use func_get_args instead of ellipses --- VariableAnalysis/Lib/Helpers.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/VariableAnalysis/Lib/Helpers.php b/VariableAnalysis/Lib/Helpers.php index e50bf040..684b230d 100644 --- a/VariableAnalysis/Lib/Helpers.php +++ b/VariableAnalysis/Lib/Helpers.php @@ -487,7 +487,8 @@ public static function getVariablesDefinedByArrowFunction(File $phpcsFile, $stac /** * @return void */ - public static function debug(...$messages) { + public static function debug() { + $messages = func_get_args(); if (! defined('PHP_CODESNIFFER_VERBOSITY')) { return; } From 90af293e3feed550c8ae46d613e71e9c33e0757e Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sat, 11 Jul 2020 18:59:36 -0400 Subject: [PATCH 6/6] Downgrade PHP requirement in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6b84793d..b62770a7 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Plugin for PHP_CodeSniffer static analysis tool that adds analysis of problemati ### Requirements -VariableAnalysis requires PHP 5.6 or higher and [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) version 3.5.0 or higher. +VariableAnalysis requires PHP 5.4 or higher and [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) version 3.5.0 or higher. 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). @@ -97,7 +97,7 @@ This was forked from the excellent work in https://github.com/illusori/PHP_Codes Please open issues or PRs on this repository. -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. +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. To run tests, make sure composer is installed, then run: