From d6815f610bc9509d162edac4374e12e60432eb0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Machulda?= Date: Fri, 6 Mar 2020 17:46:56 +0100 Subject: [PATCH 01/51] Normalize composer.json --- composer.json | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 3c90b69..bddf01c 100644 --- a/composer.json +++ b/composer.json @@ -3,10 +3,20 @@ "description": "This tool check syntax of PHP files about 20x faster than serial check.", "homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint", "license": "BSD-2-Clause", + "authors": [ + { + "name": "Jakub Onderka", + "email": "ahoj@jakubonderka.cz" + } + ], "require": { "php": ">=5.4.0", "ext-json": "*" }, + "replace": { + "grogy/php-parallel-lint": "*", + "jakub-onderka/php-parallel-lint": "*" + }, "require-dev": { "nette/tester": "^1.3 || ^2.0", "php-parallel-lint/php-console-highlighter": "~0.3", @@ -15,20 +25,15 @@ "suggest": { "php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet" }, - "authors": [ - { - "name": "Jakub Onderka", - "email": "ahoj@jakubonderka.cz" - } - ], + "config": { + "sort-packages": true + }, "autoload": { "classmap": [ "./" ] }, - "bin": ["parallel-lint"], - "replace": { - "jakub-onderka/php-parallel-lint": "*", - "grogy/php-parallel-lint": "*" - } + "bin": [ + "parallel-lint" + ] } From b47ec5c9a8b76eeb0a2fe6709537e9a705fcb38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Thu, 9 Apr 2020 18:08:58 +0200 Subject: [PATCH 02/51] Added normalized composer.json to changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e544f1b..e987f7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Internal + +- Normalized composer.json from [@OndraM](https://github.com/OndraM) + ## [1.2.0] - 2020-04-04 ### Added From 6a61304275b48023ae474820ff72943b2316a10e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 18 Aug 2019 17:21:26 +0200 Subject: [PATCH 03/51] Composer: update the PHPCS dependency The current version is `3.5.4` released end of January 2020 and - aside from lots of bug fixes -, it includes compatibility with PHP 7.4. See: https://github.com/squizlabs/php_codesniffer/releases --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bddf01c..0a0cb67 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "require-dev": { "nette/tester": "^1.3 || ^2.0", "php-parallel-lint/php-console-highlighter": "~0.3", - "squizlabs/php_codesniffer": "~3.0" + "squizlabs/php_codesniffer": "^3.5" }, "suggest": { "php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet" From 6d18571f446e68d93d30698d5931a2145b1fef60 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 18 Aug 2019 17:23:04 +0200 Subject: [PATCH 04/51] Travis: only run PHPCS once The results of PHPCS run will be no different across PHP versions as all sniffs are unit tested against all supported PHP versions, so it is unnecessary to run it against every PHP version, just run it once per build. I've chosen to run it against PHP 7.4 as that's the fastest PHP version. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8b13987..3fad9df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ matrix: - php: 7.2 - php: 7.3 - php: 7.4 + env: SNIFF=1 - php: "nightly" fast_finish: true @@ -27,4 +28,4 @@ script: - ./vendor/bin/tester -p php tests - ./parallel-lint --exclude vendor --exclude tests/examples --no-colors . - ./parallel-lint --exclude vendor --exclude tests/examples . - - ./vendor/bin/phpcs --standard=phpcs-ruleset.xml -s src + - if [[ "$SNIFF" == "1" ]]; then ./vendor/bin/phpcs --standard=phpcs-ruleset.xml -s src;fi From cde635b760ba4914391133873e3cfdcc08f137dc Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 18 Aug 2019 17:27:18 +0200 Subject: [PATCH 05/51] PHPCS: tweak ruleset * Rename the ruleset to one which PHPCS will recognize automatically. This means you no longer need to pass the `--standard` on the command-line. * Use the `dist` extension to allow for devs to overload the ruleset file locally and gitignore the typical overload file names which are recognized by PHPCS by default. * Ruleset/Travis: move command-line arguments to the project ruleset. ... and scan all PHP files, not just the files in `src`. * Ruleset: also scan the `phpt` test files. * Ruleset: enable parallel scanning. * Ruleset: set the basepath for a cleaner output report. * Ruleset: add the PHPCS XML scheme. * Ruleset: selectively exclude the `skip-linting.php` file for the `Generic.PHP.NoSilencedErrors` rule. --- .gitattributes | 1 - .gitignore | 2 ++ .travis.yml | 2 +- phpcs-ruleset.xml => phpcs.xml.dist | 37 +++++++++++++++++++++++++++-- 4 files changed, 38 insertions(+), 4 deletions(-) rename phpcs-ruleset.xml => phpcs.xml.dist (66%) diff --git a/.gitattributes b/.gitattributes index 61c19cd..64d88f3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12,7 +12,6 @@ /box.json export-ignore /doc export-ignore /phpcs.xml.dist export-ignore -/phpcs-ruleset.xml export-ignore /tests export-ignore # diff --git a/.gitignore b/.gitignore index 8b7ef35..0822554 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /vendor composer.lock +.phpcs.xml +phpcs.xml diff --git a/.travis.yml b/.travis.yml index 3fad9df..9eafe4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,4 +28,4 @@ script: - ./vendor/bin/tester -p php tests - ./parallel-lint --exclude vendor --exclude tests/examples --no-colors . - ./parallel-lint --exclude vendor --exclude tests/examples . - - if [[ "$SNIFF" == "1" ]]; then ./vendor/bin/phpcs --standard=phpcs-ruleset.xml -s src;fi + - if [[ "$SNIFF" == "1" ]]; then ./vendor/bin/phpcs;fi diff --git a/phpcs-ruleset.xml b/phpcs.xml.dist similarity index 66% rename from phpcs-ruleset.xml rename to phpcs.xml.dist index 8d730a6..e84650a 100644 --- a/phpcs-ruleset.xml +++ b/phpcs.xml.dist @@ -1,7 +1,38 @@ - + PHP Parallel Lint coding standard. + + + . + + + */tests/examples/* + */vendor/* + + + + + + + + + + + + + + + @@ -20,7 +51,9 @@ - + + /bin/skip-linting\.php$ + From 9c39813c9ebdb084d67cb60bb53a6c906dc5b59c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 18 Aug 2019 17:31:10 +0200 Subject: [PATCH 06/51] CS: minor clean up --- tests/Manager.run.phpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Manager.run.phpt b/tests/Manager.run.phpt index 169608c..33179e5 100644 --- a/tests/Manager.run.phpt +++ b/tests/Manager.run.phpt @@ -19,7 +19,7 @@ class ManagerRunTest extends Tester\TestCase $settings = $this->prepareSettings(); $settings->paths = array('path/for-not-found/'); $manager = $this->getManager($settings); - Assert::exception(function() use ($manager, $settings) { + Assert::exception(function () use ($manager, $settings) { $manager->run($settings); }, 'JakubOnderka\PhpParallelLint\NotExistsPathException'); } @@ -29,7 +29,7 @@ class ManagerRunTest extends Tester\TestCase $settings = $this->prepareSettings(); $settings->paths = array('examples/example-01/'); $manager = $this->getManager($settings); - Assert::exception(function() use ($manager, $settings) { + Assert::exception(function () use ($manager, $settings) { $manager->run($settings); }, 'JakubOnderka\PhpParallelLint\Exception', 'No file found to check.'); } From 1028c0d109185d866aac1b05be505ea3c755f0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Thu, 9 Apr 2020 18:18:13 +0200 Subject: [PATCH 07/51] Added cleaning in code style to changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e987f7b..df9d565 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Internal -- Normalized composer.json from [@OndraM](https://github.com/OndraM) +- Normalized composer.json from [@OndraM](https://github.com/OndraM). +- Updated PHPCS dependency from [@jrfnl](https://github.com/jrfnl). +- Cleaned coding style from [@jrfnl](https://github.com/jrfnl). ## [1.2.0] - 2020-04-04 From b9375e51b445de8f2cfe93f239e5ce26b2a78939 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 18 Aug 2019 21:10:44 +0200 Subject: [PATCH 08/51] Allow for multi-part file extensions to be passed using -e Implementation of feature request 115. The user can now pass longer, multi-part extensions on the command-line and they will be respected. Example: `-e php,php.dist` Fixes 115 --- src/Manager.php | 9 +++++---- tests/Settings.parseArguments.phpt | 12 ++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Manager.php b/src/Manager.php index abb6024..0e5df45 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -134,7 +134,8 @@ protected function gitBlame(Result $result, Settings $settings) */ protected function getFilesFromPaths(array $paths, array $extensions, array $excluded = array()) { - $extensions = array_flip($extensions); + $extensions = array_map('preg_quote', $extensions, array_fill(0, count($extensions), '`')); + $regex = '`\.(?:' . implode('|', $extensions) . ')$`iD'; $files = array(); foreach ($paths as $path) { @@ -151,11 +152,11 @@ protected function getFilesFromPaths(array $paths, array $extensions, array $exc \RecursiveIteratorIterator::CATCH_GET_CHILD ); + $iterator = new \RegexIterator($iterator, $regex); + /** @var \SplFileInfo[] $iterator */ foreach ($iterator as $directoryFile) { - if (isset($extensions[pathinfo($directoryFile->getFilename(), PATHINFO_EXTENSION)])) { - $files[] = (string) $directoryFile; - } + $files[] = (string) $directoryFile; } } else { throw new NotExistsPathException($path); diff --git a/tests/Settings.parseArguments.phpt b/tests/Settings.parseArguments.phpt index 60aa7c6..76c19e8 100644 --- a/tests/Settings.parseArguments.phpt +++ b/tests/Settings.parseArguments.phpt @@ -108,6 +108,18 @@ class SettingsParseArgumentsTest extends Tester\TestCase $settings = Settings::parseArguments($argv); Assert::equal(Settings::FORMAT_CHECKSTYLE, $settings->format); } + + public function testExtensions() + { + $commandLine = './parallel-lint -e php,php.dist,phpt .'; + $argv = explode(" ", $commandLine); + $settings = Settings::parseArguments($argv); + + $expectedSettings = new Settings(); + $expectedSettings->extensions = array('php', 'php.dist', 'phpt'); + + Assert::equal($expectedSettings->extensions, $settings->extensions); + } } $testCase = new SettingsParseArgumentsTest; From 5a3ff75945cb308cc8e335006dee7eb2333e2349 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 14 Apr 2020 15:58:48 +0200 Subject: [PATCH 09/51] Multi-part extensions: add extra unit test --- tests/Manager.run.phpt | 17 +++++++++++++++++ tests/examples/example-06/example.php | 4 ++++ tests/examples/example-06/example.php-dist | 4 ++++ tests/examples/example-06/example.php.dist | 4 ++++ 4 files changed, 29 insertions(+) create mode 100644 tests/examples/example-06/example.php create mode 100644 tests/examples/example-06/example.php-dist create mode 100644 tests/examples/example-06/example.php.dist diff --git a/tests/Manager.run.phpt b/tests/Manager.run.phpt index 33179e5..65789dd 100644 --- a/tests/Manager.run.phpt +++ b/tests/Manager.run.phpt @@ -88,6 +88,23 @@ class ManagerRunTest extends Tester\TestCase Assert::false($result->hasError()); } + /** + * Note: the `example.php-dist` file contains a parse error. + * With multi-part extensions being escaped before being used in the RegexIterator, + * this file will not be included in the scan and the test will pass. + */ + public function testMultiPartExtensions() + { + $settings = $this->prepareSettings(); + $settings->paths = array('examples/example-06/'); + + $settings->extensions = array('php', 'php.dist'); + + $manager = $this->getManager($settings); + $result = $manager->run($settings); + Assert::false($result->hasError()); + } + /** * @param Settings $settings * @return Manager diff --git a/tests/examples/example-06/example.php b/tests/examples/example-06/example.php new file mode 100644 index 0000000..2186cb4 --- /dev/null +++ b/tests/examples/example-06/example.php @@ -0,0 +1,4 @@ + Date: Thu, 16 Apr 2020 16:36:06 +0200 Subject: [PATCH 10/51] Added new feature to changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index df9d565..ed700e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Added + +- Allow for multi-part file extensions to be passed using -e (like `-e php,php.dist`) from [@jrfnl](https://github.com/jrfnl). + ### Internal - Normalized composer.json from [@OndraM](https://github.com/OndraM). From 5263bbbdacda90de2c5a257779969dabccd2ff96 Mon Sep 17 00:00:00 2001 From: Markus Podar Date: Sat, 4 Jul 2020 07:03:40 +0200 Subject: [PATCH 11/51] Provide one true way to run the test suite --- .travis.yml | 2 +- appveyor.yml | 2 +- composer.json | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9eafe4f..fb01fdd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ install: - composer install --no-interaction --prefer-source script: - - ./vendor/bin/tester -p php tests + - composer test - ./parallel-lint --exclude vendor --exclude tests/examples --no-colors . - ./parallel-lint --exclude vendor --exclude tests/examples . - if [[ "$SNIFF" == "1" ]]; then ./vendor/bin/phpcs;fi diff --git a/appveyor.yml b/appveyor.yml index 08bdae4..15ae250 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,6 +25,6 @@ install: - php composer.phar install --prefer-source --no-interaction test_script: - - vendor\bin\tester tests -p php + - php composer.phar test - php parallel-lint --exclude vendor --exclude tests\examples --no-colors . - php parallel-lint --exclude vendor --exclude tests\examples . diff --git a/composer.json b/composer.json index 0a0cb67..ae978fd 100644 --- a/composer.json +++ b/composer.json @@ -35,5 +35,11 @@ }, "bin": [ "parallel-lint" - ] + ], + "scripts": { + "test": "@php vendor/bin/tester -p php tests" + }, + "scripts-descriptions": { + "test": "Run all tests!" + } } From ec7e2531323042e9c8cd059d5cd07b232109de9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Thu, 20 Aug 2020 22:01:46 +0200 Subject: [PATCH 12/51] Added composer changes to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed700e9..9692ca9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Normalized composer.json from [@OndraM](https://github.com/OndraM). - Updated PHPCS dependency from [@jrfnl](https://github.com/jrfnl). - Cleaned coding style from [@jrfnl](https://github.com/jrfnl). +- Provide one true way to run the test suite [#37](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/37) from [@mfn](https://github.com/mfn). ## [1.2.0] - 2020-04-04 From 1cef4e1fbca220d015fe3c64216f4eb771bb9efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Kut=C3=A1=C4=8D?= Date: Mon, 20 Apr 2020 18:56:07 +0200 Subject: [PATCH 13/51] Add first shot for Fail Callback --- src/Application.php | 39 ++++++++++++++------------- src/Contracts/SyntaxErrorCallback.php | 13 +++++++++ src/Manager.php | 29 ++++++++++++++++++++ src/ParallelLint.php | 28 +++++++++++++++++-- src/Settings.php | 10 +++++++ src/exceptions.php | 39 +++++++++++++++++++++++++++ tests/Settings.parseArguments.phpt | 14 ++++++++++ 7 files changed, 151 insertions(+), 21 deletions(-) create mode 100644 src/Contracts/SyntaxErrorCallback.php diff --git a/src/Application.php b/src/Application.php index 4517083..7317dfd 100644 --- a/src/Application.php +++ b/src/Application.php @@ -75,25 +75,26 @@ private function showOptions() { echo << Specify PHP-CGI executable to run (default: 'php'). - -s, --short Set short_open_tag to On (default: Off). - -a, -asp Set asp_tags to On (default: Off). - -e Check only files with selected extensions separated by comma. - (default: php,php3,php4,php5,phtml,phpt) - --exclude Exclude a file or directory. If you want exclude multiple items, - use multiple exclude parameters. - -j Run jobs in parallel (default: 10). - --colors Enable colors in console output. (disables auto detection of color support) - --no-colors Disable colors in console output. - --no-progress Disable progress in console output. - --json Output results as JSON string. - --checkstyle Output results as Checkstyle XML. - --blame Try to show git blame for row with error. - --git Path to Git executable to show blame message (default: 'git'). - --stdin Load files and folder to test from standard input. - --ignore-fails Ignore failed tests. - -h, --help Print this help. - -V, --version Display this application version + -p Specify PHP-CGI executable to run (default: 'php'). + -s, --short Set short_open_tag to On (default: Off). + -a, -asp Set asp_tags to On (default: Off). + -e Check only files with selected extensions separated by comma. + (default: php,php3,php4,php5,phtml,phpt) + --exclude Exclude a file or directory. If you want exclude multiple items, + use multiple exclude parameters. + -j Run jobs in parallel (default: 10). + --colors Enable colors in console output. (disables auto detection of color support) + --no-colors Disable colors in console output. + --no-progress Disable progress in console output. + --json Output results as JSON string. + --checkstyle Output results as Checkstyle XML. + --blame Try to show git blame for row with error. + --git Path to Git executable to show blame message (default: 'git'). + --stdin Load files and folder to test from standard input. + --ignore-fails Ignore failed tests. + --syntax-error-callback File with syntax error callback for modifying error + -h, --help Print this help. + -V, --version Display this application version HELP; } diff --git a/src/Contracts/SyntaxErrorCallback.php b/src/Contracts/SyntaxErrorCallback.php new file mode 100644 index 0000000..0db055f --- /dev/null +++ b/src/Contracts/SyntaxErrorCallback.php @@ -0,0 +1,13 @@ +setAspTagsEnabled($settings->aspTags); $parallelLint->setShortTagEnabled($settings->shortTag); $parallelLint->setShowDeprecated($settings->showDeprecated); + $parallelLint->setSyntaxErrorCallback($this->createSyntaxErrorCallback($settings)); $parallelLint->setProcessCallback(function ($status, $file) use ($output) { if ($status === ParallelLint::STATUS_OK) { @@ -167,6 +169,33 @@ protected function getFilesFromPaths(array $paths, array $extensions, array $exc return $files; } + + protected function createSyntaxErrorCallback(Settings $settings) + { + if ($settings->syntaxErrorCallbackFile === null) { + return null; + } + + $fullFilePath = realpath($settings->syntaxErrorCallbackFile); + if ($fullFilePath === false) { + throw new NotExistsPathException($settings->syntaxErrorCallbackFile); + } + + require_once $fullFilePath; + + $expectedClassName = basename($fullFilePath, '.php'); + if (!class_exists($expectedClassName)) { + throw new NotExistsClassException($expectedClassName, $settings->syntaxErrorCallbackFile); + } + + $callbackInstance = new $expectedClassName; + + if (!($callbackInstance instanceof SyntaxErrorCallback)) { + throw new NotImplementCallbackException($expectedClassName); + } + + return $callbackInstance; + } } class RecursiveDirectoryFilterIterator extends \RecursiveFilterIterator diff --git a/src/ParallelLint.php b/src/ParallelLint.php index 8c12a73..8137020 100644 --- a/src/ParallelLint.php +++ b/src/ParallelLint.php @@ -1,6 +1,7 @@ phpExecutable = $phpExecutable; @@ -92,7 +96,7 @@ public function lint(array $files) } else if ($process->containsError()) { $checkedFiles[] = $file; - $errors[] = new SyntaxError($file, $process->getSyntaxError()); + $errors[] = $this->triggerSyntaxErrorCallback(new SyntaxError($file, $process->getSyntaxError())); $processCallback(self::STATUS_ERROR, $file); } else if ($process->isSuccess()) { @@ -131,7 +135,7 @@ public function lint(array $files) } else if ($process->containsError()) { $checkedFiles[] = $file; - $errors[] = new SyntaxError($file, $process->getSyntaxError()); + $errors[] = $this->triggerSyntaxErrorCallback(new SyntaxError($file, $process->getSyntaxError())); $processCallback(self::STATUS_ERROR, $file); } else { @@ -259,4 +263,24 @@ public function setShowDeprecated($showDeprecated) return $this; } + + public function triggerSyntaxErrorCallback($syntaxError) + { + if ($this->syntaxErrorCallback === null) { + return $syntaxError; + } + + return $this->syntaxErrorCallback->errorFound($syntaxError); + } + + /** + * @param SyntaxErrorCallback|null $syntaxErrorCallback + * @return ParallelLint + */ + public function setSyntaxErrorCallback($syntaxErrorCallback) + { + $this->syntaxErrorCallback = $syntaxErrorCallback; + + return $this; + } } diff --git a/src/Settings.php b/src/Settings.php index 24071af..3e03a71 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -103,6 +103,12 @@ class Settings */ public $showDeprecated = false; + /** + * Path to a file with syntax error callback + * @var string|null + */ + public $syntaxErrorCallbackFile = null; + /** * @param array $paths */ @@ -197,6 +203,10 @@ public static function parseArguments(array $arguments) $settings->showDeprecated = true; break; + case '--syntax-error-callback': + $settings->syntaxErrorCallbackFile = $arguments->getNext(); + break; + default: throw new InvalidArgumentException($argument); } diff --git a/src/exceptions.php b/src/exceptions.php index fd47ddc..3893b83 100644 --- a/src/exceptions.php +++ b/src/exceptions.php @@ -49,3 +49,42 @@ public function getPath() return $this->path; } } + +class NotExistsClassException extends Exception +{ + protected $className; + protected $fileName; + + public function __construct($className, $fileName) + { + $this->className = $className; + $this->fileName = $fileName; + $this->message = "Class with name '$className' does not exists in file '$fileName'"; + } + + public function getClassName() + { + return $this->className; + } + + public function getFileName() + { + return $this->fileName; + } +} + +class NotImplementCallbackException extends Exception +{ + protected $className; + + public function __construct($className) + { + $this->className = $className; + $this->message = "Class '$className' does not implement SyntaxErrorCallback interface."; + } + + public function getClassName() + { + return $this->className; + } +} diff --git a/tests/Settings.parseArguments.phpt b/tests/Settings.parseArguments.phpt index 76c19e8..0a83673 100644 --- a/tests/Settings.parseArguments.phpt +++ b/tests/Settings.parseArguments.phpt @@ -27,6 +27,7 @@ class SettingsParseArgumentsTest extends Tester\TestCase $expectedSettings->colors = Settings::AUTODETECT; $expectedSettings->showProgress = true; $expectedSettings->format = Settings::FORMAT_TEXT; + $expectedSettings->syntaxErrorCallbackFile = null; Assert::equal($expectedSettings->shortTag, $settings->shortTag); Assert::equal($expectedSettings->aspTags, $settings->aspTags); @@ -37,6 +38,7 @@ class SettingsParseArgumentsTest extends Tester\TestCase Assert::equal($expectedSettings->colors, $settings->colors); Assert::equal($expectedSettings->showProgress, $settings->showProgress); Assert::equal($expectedSettings->format, $settings->format); + Assert::equal($expectedSettings->syntaxErrorCallbackFile, $settings->syntaxErrorCallbackFile); } public function testMoreArguments() @@ -120,6 +122,18 @@ class SettingsParseArgumentsTest extends Tester\TestCase Assert::equal($expectedSettings->extensions, $settings->extensions); } + + public function testFailCallaback() + { + $commandLine = "./parallel-lint --syntax-error-callback ./path/to/my_custom_callback_file.php ."; + $argv = explode(" ", $commandLine); + $settings = Settings::parseArguments($argv); + + $expectedSettings = new Settings(); + $expectedSettings->syntaxErrorCallbackFile = "./path/to/my_custom_callback_file.php"; + + Assert::equal($expectedSettings->syntaxErrorCallbackFile, $settings->syntaxErrorCallbackFile); + } } $testCase = new SettingsParseArgumentsTest; From 4838574038ea7273d11ddbd64893e92db9528844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Kut=C3=A1=C4=8D?= Date: Sun, 30 Aug 2020 11:22:16 +0200 Subject: [PATCH 14/51] Add doc --- README.md | 35 ++++++++++++++++++----------------- doc/syntax-error-callback.md | 31 +++++++++++++++++++++++++++++++ src/Application.php | 2 +- 3 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 doc/syntax-error-callback.md diff --git a/README.md b/README.md index 446428d..615b41e 100644 --- a/README.md +++ b/README.md @@ -48,23 +48,24 @@ This is a fork of [original project](https://github.com/JakubOnderka/PHP-Paralle ## Options for run -- `-p ` Specify PHP-CGI executable to run (default: 'php'). -- `-s, --short` Set short_open_tag to On (default: Off). -- `-a, --asp` Set asp_tags to On (default: Off). -- `-e ` Check only files with selected extensions separated by comma. (default: php,php3,php4,php5,phtml,phpt) -- `--exclude` Exclude a file or directory. If you want exclude multiple items, use multiple exclude parameters. -- `-j ` Run jobs in parallel (default: 10). -- `--colors` Force enable colors in console output. -- `--no-colors` Disable colors in console output. -- `--no-progress` Disable progress in console output. -- `--checkstyle` Output results as Checkstyle XML. -- `--json` Output results as JSON string (require PHP 5.4). -- `--blame` Try to show git blame for row with error. -- `--git ` Path to Git executable to show blame message (default: 'git'). -- `--stdin` Load files and folder to test from standard input. -- `--ignore-fails` Ignore failed tests. -- `-h, --help` Print this help. -- `-V, --version` Display this application version. +- `-p ` Specify PHP-CGI executable to run (default: 'php'). +- `-s, --short` Set short_open_tag to On (default: Off). +- `-a, --asp` Set asp_tags to On (default: Off). +- `-e ` Check only files with selected extensions separated by comma. (default: php,php3,php4,php5,phtml,phpt) +- `--exclude` Exclude a file or directory. If you want exclude multiple items, use multiple exclude parameters. +- `-j ` Run jobs in parallel (default: 10). +- `--colors` Force enable colors in console output. +- `--no-colors` Disable colors in console output. +- `--no-progress` Disable progress in console output. +- `--checkstyle` Output results as Checkstyle XML. +- `--json` Output results as JSON string (require PHP 5.4). +- `--blame` Try to show git blame for row with error. +- `--git ` Path to Git executable to show blame message (default: 'git'). +- `--stdin` Load files and folder to test from standard input. +- `--ignore-fails` Ignore failed tests. +- `--syntax-error-callback` File with syntax error callback for ability to modify error, see more in [example](doc/syntax-error-callback.md) +- `-h, --help` Print this help. +- `-V, --version` Display this application version. ## Recommended setting for usage with Symfony framework diff --git a/doc/syntax-error-callback.md b/doc/syntax-error-callback.md new file mode 100644 index 0000000..f35466e --- /dev/null +++ b/doc/syntax-error-callback.md @@ -0,0 +1,31 @@ +# Syntax Error Callback + +1. Set a path to a file with custom error callback to `--syntax-error-callback` option. +1. Create a class implementing `JakubOnderka\PhpParallelLint\Contracts\SyntaxErrorCallback` interface. File with the class must have the same name as the class inside. +1. Modify error before it is printed to the output. + +## Configuration + +File `MyCustomErrorHandler.php` will be passed as an argument like `./parallel-lint --syntax-error-callback ./path/to/MyCustomErrorHandler.php .`. +The content should look like: + +```php + +use JakubOnderka\PhpParallelLint\Contracts\SyntaxErrorCallback; +use JakubOnderka\PhpParallelLint\SyntaxError; + +class MyCustomErrorHandler implements SyntaxErrorCallback { + /** + * @param SyntaxError $error + * @return SyntaxError + */ + public function errorFound(SyntaxError $error){ + // Return new SyntaxError with custom modification to FilePath or Message + // Or return completely new SyntaxError extending the original one... + return new SyntaxError( + $error->getFilePath(), + $error->getMessage() + ); + } +} +``` diff --git a/src/Application.php b/src/Application.php index 7317dfd..f4002e0 100644 --- a/src/Application.php +++ b/src/Application.php @@ -92,7 +92,7 @@ private function showOptions() --git Path to Git executable to show blame message (default: 'git'). --stdin Load files and folder to test from standard input. --ignore-fails Ignore failed tests. - --syntax-error-callback File with syntax error callback for modifying error + --syntax-error-callback File with syntax error callback for ability to modify error -h, --help Print this help. -V, --version Display this application version From 9f07b8b3d7ab8ef1d4e9864e94d0f5911f2b8014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Kut=C3=A1=C4=8D?= Date: Sun, 30 Aug 2020 11:24:05 +0200 Subject: [PATCH 15/51] Fix doc --- doc/syntax-error-callback.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/syntax-error-callback.md b/doc/syntax-error-callback.md index f35466e..955f5ef 100644 --- a/doc/syntax-error-callback.md +++ b/doc/syntax-error-callback.md @@ -4,9 +4,9 @@ 1. Create a class implementing `JakubOnderka\PhpParallelLint\Contracts\SyntaxErrorCallback` interface. File with the class must have the same name as the class inside. 1. Modify error before it is printed to the output. -## Configuration +## Example configuration -File `MyCustomErrorHandler.php` will be passed as an argument like `./parallel-lint --syntax-error-callback ./path/to/MyCustomErrorHandler.php .`. +File `MyCustomErrorHandler.php` will be passed as an argument like `./parallel-lint --syntax-error-callback ./path/to/MyCustomErrorHandler.php .`.
The content should look like: ```php @@ -21,7 +21,7 @@ class MyCustomErrorHandler implements SyntaxErrorCallback { */ public function errorFound(SyntaxError $error){ // Return new SyntaxError with custom modification to FilePath or Message - // Or return completely new SyntaxError extending the original one... + // Or return custom implementation of SyntaxError extending the original one... return new SyntaxError( $error->getFilePath(), $error->getMessage() From 7e913af556dd17b5b89955437769603d567495a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Tue, 1 Sep 2020 22:11:20 +0200 Subject: [PATCH 16/51] Updated changelog - syntax error callback --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9692ca9..4002d20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added -- Allow for multi-part file extensions to be passed using -e (like `-e php,php.dist`) from [@jrfnl](https://github.com/jrfnl). +- Allow for multi-part file extensions to be passed using -e (like `-e php,php.dist`) from [@jrfnl](https://github.com/jrfnl). +- Added syntax error callback [#30](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/30) from [@arxeiss](https://github.com/arxeiss). ### Internal From 4d9bb4a9488c7e730a477c27c8c057b60789790c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 23 May 2020 03:06:06 +0200 Subject: [PATCH 17/51] Ignore PHP startup errors This should fix issue 33, by ignoring PHP startup errors completely for any PHP processes started from within the application. --- src/Process/PhpProcess.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Process/PhpProcess.php b/src/Process/PhpProcess.php index de9eee1..0df293a 100644 --- a/src/Process/PhpProcess.php +++ b/src/Process/PhpProcess.php @@ -23,8 +23,11 @@ public function __construct(PhpExecutable $phpExecutable, array $parameters = ar */ private function constructParameters(array $parameters, $isHhvm) { + // Always ignore PHP startup errors ("Unable to load library...") in sub-processes. + array_unshift($parameters, '-d display_startup_errors=0'); + if ($isHhvm) { - $parameters = array_merge(array('-php'), $parameters); + array_unshift($parameters, '-php'); } return $parameters; From 738aa4fc278c912b775ebba81266e219c90f2249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Tue, 1 Sep 2020 22:31:01 +0200 Subject: [PATCH 18/51] Updated changelog - ignore PHP startup errors --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4002d20..8082ffc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Allow for multi-part file extensions to be passed using -e (like `-e php,php.dist`) from [@jrfnl](https://github.com/jrfnl). - Added syntax error callback [#30](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/30) from [@arxeiss](https://github.com/arxeiss). +- Ignore PHP startup errors [#34](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/34) from [@jrfnl](https://github.com/jrfnl). ### Internal From 45ea3b44195dd9d2912afa5eaa1d9ed82f520833 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 4 Dec 2020 05:51:29 +0100 Subject: [PATCH 19/51] Travis: add build against PHP 8.0 PHP 8.0 has been branched off two months ago, so `nightly` is now PHP 8.1 and in the mean time PHP 8.0 was released last week. As of today, there is a PHP 8.0 image available on Travis. This PR adds a new build against PHP 8.0 to the matrix and, as PHP 8.0 has been released, that build is not allowed to fail. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index fb01fdd..af54d4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ matrix: - php: 7.3 - php: 7.4 env: SNIFF=1 + - php: 8.0 - php: "nightly" fast_finish: true From c247a48cfd5c3af3545f185a04e6d2d7db474fdf Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 4 Dec 2020 06:15:59 +0100 Subject: [PATCH 20/51] ParallelLintLintTest::testDeprecated(): fix the test This test is expected to throw a deprecation warning for the PHP4-style class constructor (method named the same as the class). In PHP 8, the deprecation warning is no longer thrown and PHP4-style constructor method are now treated as _normal_ methods. This fixes the test to have the correct expectations. --- tests/ParallelLint.lint.phpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ParallelLint.lint.phpt b/tests/ParallelLint.lint.phpt index b42a044..4ed584c 100644 --- a/tests/ParallelLint.lint.phpt +++ b/tests/ParallelLint.lint.phpt @@ -101,8 +101,8 @@ class ParallelLintLintTest extends Tester\TestCase Assert::false($result->hasSyntaxError()); Assert::equal(0, count($result->getErrors())); - if (PHP_VERSION_ID < 70000) { - Tester\Environment::skip('test for php version > 7.0'); + if (PHP_VERSION_ID < 70000 || PHP_VERSION_ID >= 80000 ) { + Tester\Environment::skip('test for php version 7.0-7.4'); } $parallelLint = new ParallelLint($this->getPhpExecutable()); From f2262ae043eb665d39233ae61aca71bcc5cd378c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Sun, 27 Dec 2020 10:53:53 +0100 Subject: [PATCH 21/51] Changelod - Travis build agains PHP 8.0 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8082ffc..00affda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Updated PHPCS dependency from [@jrfnl](https://github.com/jrfnl). - Cleaned coding style from [@jrfnl](https://github.com/jrfnl). - Provide one true way to run the test suite [#37](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/37) from [@mfn](https://github.com/mfn). +- Travis: add build against PHP 8.0 and fix failing test [#41(https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/41) from [@jrfnl](https://github.com/jrfnl). ## [1.2.0] - 2020-04-04 From 3b0278ffdfe17ef42cb8d17ad7ca7e28209d2b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kon=C3=A1=C5=A1?= Date: Fri, 5 Feb 2021 11:19:29 +0100 Subject: [PATCH 22/51] Determine skip lint process failure by status code instead of stderr content --- src/ParallelLint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ParallelLint.php b/src/ParallelLint.php index 8137020..b1825f3 100644 --- a/src/ParallelLint.php +++ b/src/ParallelLint.php @@ -115,7 +115,7 @@ public function lint(array $files) if (!empty($waiting)) { $skipLintProcess->waitForFinish(); - if ($skipLintProcess->getErrorOutput()) { + if ($skipLintProcess->isFail()) { $message = "Error in skip-linting.php process\nError output: {$skipLintProcess->getErrorOutput()}"; throw new \Exception($message); } From 287d0b4ff738f00002e293209631d083f583667f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Sun, 14 Feb 2021 07:38:27 +0100 Subject: [PATCH 23/51] Added fix to changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00affda..b7784e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Added syntax error callback [#30](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/30) from [@arxeiss](https://github.com/arxeiss). - Ignore PHP startup errors [#34](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/34) from [@jrfnl](https://github.com/jrfnl). +### Fixed + +- Determine skip lint process failure by status code instead of stderr content [#48](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/48) from [@jankonas](https://github.com/jankonas). + ### Internal - Normalized composer.json from [@OndraM](https://github.com/OndraM). From 60236387e22a2d9bd487206240b6448c050445a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 14 Mar 2021 10:55:20 +0200 Subject: [PATCH 24/51] Improve wording in the readme - Update Fork section to be neutral and include current fork relation - Improve wording in the rest of the readme - Add git blame as well into readme --- README.md | 58 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 615b41e..33d234f 100644 --- a/README.md +++ b/README.md @@ -4,33 +4,36 @@ [![Build Status](https://travis-ci.org/php-parallel-lint/PHP-Parallel-Lint.svg?branch=master)](https://travis-ci.org/php-parallel-lint/PHP-Parallel-Lint) [![License](https://poser.pugx.org/php-parallel-lint/php-parallel-lint/license.svg)](https://packagist.org/packages/php-parallel-lint/php-parallel-lint) -This tool checks syntax of PHP files faster than serial check with a fancier output. +This application checks syntax of PHP files in parallel. +It can output in plain text, colored text, json and checksyntax formats. +Additionally `blame` can be used to show commits that introduced the breakage. + Running parallel jobs in PHP is inspired by Nette framework tests. -This works from PHP 5.4 to 7.4 +The application is officially supported for use with PHP 5.4 to 8.0. ## Table of contents 1. [Installation](#installation) 2. [Example output](#example-output) -3. [Fork](#fork) -4. [Options for run](#options-for-run) -5. [Options for Symfony](#recommended-setting-for-usage-with-symfony-framework) +3. [History](#history) +4. [Command line options](#command-line-options) +5. [Recommended excludes for Symfony framework](#recommended-excludes-for-symfony-framework) 6. [Create Phar package](#create-phar-package) -7. [How upgrade](#how-upgrade) +7. [How to upgrade](#how-to-upgrade) ## Installation -Just run the following command to install it: +Install with `composer` as development dependency: composer require --dev php-parallel-lint/php-parallel-lint -When you cannot use tool as dependency then you can install as project. Command for it: +Alternatively you can install as a standalone `composer` project: composer create-project php-parallel-lint/php-parallel-lint /path/to/folder/php-parallel-lint /path/to/folder/php-parallel-lint/parallel-lint # running tool -For colored output also install the suggested package `php-parallel-lint/php-console-highlighter`: +For colored output, install the suggested package `php-parallel-lint/php-console-highlighter`: composer require --dev php-parallel-lint/php-console-highlighter @@ -39,14 +42,27 @@ For colored output also install the suggested package `php-parallel-lint/php-con ![Example use of tool with error](/tests/examples/example-images/use-error.png?raw=true "Example use of tool with error") -## Fork -This is a fork of [original project](https://github.com/JakubOnderka/PHP-Parallel-Lint). Why I forked it and why I am the right man? +## History + +This project was originally created by [@JakubOnderka] and released as +[jakub-onderka/php-parallel-lint]. + +Since then, Jakub has moved on to other interests and as of January 2020, the +second most active maintainer [@grogy] has taken over maintenance of the project +and given the project - and related dependencies - a new home in the PHP +Parallel Lint organisation. + +It is strongly recommended for existing users of the (unmaintained) +[jakub-onderka/php-parallel-lint] package to switch their dependency to +[php-parallel-lint/php-parallel-lint]. -- Project is used in many and projects. -- I am [second most active](https://github.com/JakubOnderka/PHP-Parallel-Lint/graphs/contributors) contributor in original project. -- Author does [not responds to issues and PRs](https://github.com/JakubOnderka/PHP-Parallel-Lint/pulls) and my mail messages. +[php-parallel-lint/php-parallel-lint]: https://github.com/php-parallel-lint/PHP-Parallel-Lint +[grogy/php-parallel-lint]: https://github.com/grogy/PHP-Parallel-Lint +[jakub-onderka/php-parallel-lint]: https://github.com/JakubOnderka/PHP-Parallel-Lint +[@JakubOnderka]: https://github.com/JakubOnderka +[@grogy]: https://github.com/grogy -## Options for run +## Command line options - `-p ` Specify PHP-CGI executable to run (default: 'php'). - `-s, --short` Set short_open_tag to On (default: Off). @@ -58,7 +74,7 @@ This is a fork of [original project](https://github.com/JakubOnderka/PHP-Paralle - `--no-colors` Disable colors in console output. - `--no-progress` Disable progress in console output. - `--checkstyle` Output results as Checkstyle XML. -- `--json` Output results as JSON string (require PHP 5.4). +- `--json` Output results as JSON string (requires PHP 5.4). - `--blame` Try to show git blame for row with error. - `--git ` Path to Git executable to show blame message (default: 'git'). - `--stdin` Load files and folder to test from standard input. @@ -68,9 +84,9 @@ This is a fork of [original project](https://github.com/JakubOnderka/PHP-Paralle - `-V, --version` Display this application version. -## Recommended setting for usage with Symfony framework +## Recommended excludes for Symfony framework -For run from command line: +To run from the command line: vendor/bin/parallel-lint --exclude app --exclude vendor . @@ -82,14 +98,14 @@ PHP Parallel Lint supports [Box app](https://box-project.github.io/box2/) for cr curl -LSs https://box-project.github.io/box2/installer.php | php -and then run this command in parallel lint folder, which creates `parallel-lint.phar` file. +then run the build command in parallel lint folder, which creates `parallel-lint.phar` file. box build -## How upgrade +## How to upgrade -Are you using original package? You can easy use this fork. Steps for upgrade are: +Are you using `jakub-onderka/php-parallel-lint` package? You can switch to `php-parallel-lint/php-parallel-lint` using: composer remove --dev jakub-onderka/php-parallel-lint composer require --dev php-parallel-lint/php-parallel-lint From d539e6ce1df7046405b0028d5942b06928d4ccf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 15 Mar 2021 11:58:58 +0200 Subject: [PATCH 25/51] Add info how to switch project --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 33d234f..68c99c1 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Parallel Lint organisation. It is strongly recommended for existing users of the (unmaintained) [jakub-onderka/php-parallel-lint] package to switch their dependency to -[php-parallel-lint/php-parallel-lint]. +[php-parallel-lint/php-parallel-lint], see [How to upgrade](#how-to-upgrade) below. [php-parallel-lint/php-parallel-lint]: https://github.com/php-parallel-lint/PHP-Parallel-Lint [grogy/php-parallel-lint]: https://github.com/grogy/PHP-Parallel-Lint From e7dc3a79bf8dd0e06ef4ffb9f425bab0a8c01488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Sat, 20 Mar 2021 17:58:56 +0100 Subject: [PATCH 26/51] Changelog - Improve wording in the readme --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7784e8..6c46c0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Determine skip lint process failure by status code instead of stderr content [#48](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/48) from [@jankonas](https://github.com/jankonas). +### Changed + +- Improve wording in the readme [#52](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/52) from [@glensc](https://github.com/glensc). + ### Internal - Normalized composer.json from [@OndraM](https://github.com/OndraM). From 496c25c96bf9deb91ce195fb5caa5452be1c7876 Mon Sep 17 00:00:00 2001 From: Roelof Roos Date: Sun, 21 Mar 2021 22:02:31 +0100 Subject: [PATCH 27/51] Fixed phar creation using the wrong file --- box.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/box.json b/box.json index 951802d..8c6fc81 100644 --- a/box.json +++ b/box.json @@ -5,7 +5,7 @@ "Herrera\\Box\\Compactor\\Php" ], "extract": false, - "main": "parallel-lint.php", + "main": "parallel-lint", "files": [ "LICENSE" ], From b4a028947de3aab16aaccff151e59c2d05a96f66 Mon Sep 17 00:00:00 2001 From: Roelof Roos Date: Sun, 21 Mar 2021 22:02:51 +0100 Subject: [PATCH 28/51] Added GitHub Actions for release and testing --- .github/workflows/release.yml | 115 ++++++++++++++++++++++++++++++ .github/workflows/test.yml | 128 ++++++++++++++++++++++++++++++++++ 2 files changed, 243 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9fbb685 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,115 @@ +name: Build and test phar + +on: + push: + tags: + - 'v*' + +jobs: + bundle: + name: Bundle binary + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 5.4 + extensions: exif, phar, openssl + coverage: false + ini-values: phar.readonly=Off + + - name: Install Box from GitHub + run: | + curl -LSs https://box-project.github.io/box2/installer.php | php + test -f ./box.phar + test -d ~/bin || mkdir ~/bin + mv ./box.phar ~/bin/box + ~/bin/box -V + echo "$HOME/bin" >> $GITHUB_PATH + + - name: Install Composer dependencies + uses: ramsey/composer-install@v1 + + - name: Building binary... + run: box build -v + + - uses: actions/upload-artifact@v2 + with: + name: parallel-lint-phar + path: ./parallel-lint.phar + + verify: + name: Validate binary on PHP ${{ matrix.php }} + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.experimental == true }} + needs: + - bundle + + strategy: + matrix: + php: + - '5.4' + - '5.5' + - '5.6' + - '7.0' + - '7.1' + - '7.2' + - '7.3' + - '7.4' + - '8.0' + - '8.1' + + include: + - php: '8.1' + experimental: true + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - uses: actions/download-artifact@v2 + with: + name: parallel-lint-phar + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: false + + - name: Run linter against codebase + run: php ./parallel-lint.phar src/ + + publish: + name: Add binary to release + runs-on: ubuntu-latest + needs: + - bundle + - verify + + steps: + - uses: actions/download-artifact@v2 + with: + name: parallel-lint-phar + + - name: Draft Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: true + prerelease: false + + - name: Upload Phar as Release Asset + id: upload-release-asset + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: parallel-lint.phar diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1491a1c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,128 @@ +name: Run unit and style tests + +on: + pull_request: + push: + branches: + - develop + - master + +jobs: + lint: + name: Run style linter + runs-on: ubuntu-latest + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + extensions: json + coverage: none + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install Composer dependencies + uses: ramsey/composer-install@v1 + + - name: Run code sniffer + run: vendor/bin/phpcs + + test: + name: Run unit tests + runs-on: ubuntu-latest + + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + extensions: json + coverage: none + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install Composer dependencies + uses: ramsey/composer-install@v1 + + - name: Run tests + run: composer test + + bundle: + name: Bundle binary + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 5.4 + extensions: exif, phar, openssl + coverage: false + ini-values: phar.readonly=Off + + - name: Install Box from GitHub + run: | + curl -LSs https://box-project.github.io/box2/installer.php | php + test -f ./box.phar + test -d ~/bin || mkdir ~/bin + mv ./box.phar ~/bin/box + ~/bin/box -V + echo "$HOME/bin" >> $GITHUB_PATH + + - name: Install Composer dependencies + uses: ramsey/composer-install@v1 + + - name: Building binary... + run: box build -v + + - uses: actions/upload-artifact@v2 + with: + name: parallel-lint-phar + path: ./parallel-lint.phar + + verify-bundle: + name: Validate binary on PHP ${{ matrix.php }} + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.experimental == true }} + needs: + - bundle + + strategy: + matrix: + php: + - '5.4' + - '5.5' + - '5.6' + - '7.0' + - '7.1' + - '7.2' + - '7.3' + - '7.4' + - '8.0' + - '8.1' + + include: + - php: '8.1' + experimental: true + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - uses: actions/download-artifact@v2 + with: + name: parallel-lint-phar + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: false + + - name: Run linter against codebase + run: php ./parallel-lint.phar src/ From 44061921fe42539b296cd3df1813eaf01c241c72 Mon Sep 17 00:00:00 2001 From: Roelof Roos Date: Mon, 22 Mar 2021 00:23:44 +0100 Subject: [PATCH 29/51] Added tokenizer to setup-php on tests --- .github/workflows/test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1491a1c..d948369 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,9 +36,8 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' - extensions: json - coverage: none + php-version: 5.4 + extensions: json, tokenizer - name: Checkout code uses: actions/checkout@v2 From 11a5bdd86465a51ac0eab93286a2120d55e37d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Sat, 27 Mar 2021 15:44:36 +0100 Subject: [PATCH 30/51] Added Github Actions to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c46c0a..13d9c09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Cleaned coding style from [@jrfnl](https://github.com/jrfnl). - Provide one true way to run the test suite [#37](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/37) from [@mfn](https://github.com/mfn). - Travis: add build against PHP 8.0 and fix failing test [#41(https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/41) from [@jrfnl](https://github.com/jrfnl). +- GitHub Actions for testing, and automatic phar creation [#46](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/46) from [@roelofr](https://github.com/roelofr). ## [1.2.0] - 2020-04-04 From 6c4a1a42133e89694b5ff6724124d7c7de2f6eff Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sun, 28 Mar 2021 00:06:07 +0000 Subject: [PATCH 31/51] Add .github folder to .gitattributes export-ignore --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 64d88f3..5794cff 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,6 +6,7 @@ # https://blog.madewithlove.be/post/gitattributes/ # /.gitattributes export-ignore +/.github export-ignore /.gitignore export-ignore /.travis.yml export-ignore /appveyor.yml export-ignore From cfa65f65956f3b85ee80397a9080590abdb910ec Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sat, 27 Mar 2021 23:40:18 +0000 Subject: [PATCH 32/51] Suggest to curl composer install via HTTPS --- parallel-lint | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parallel-lint b/parallel-lint index 0d77fdb..54d6887 100755 --- a/parallel-lint +++ b/parallel-lint @@ -55,7 +55,7 @@ foreach ($autoloadLocations as $autoload) { if (!$loaded) { fwrite(STDERR, 'You must set up the project dependencies, run the following commands:' . PHP_EOL . - 'curl -s http://getcomposer.org/installer | php' . PHP_EOL . + 'curl -s https://getcomposer.org/installer | php' . PHP_EOL . 'php composer.phar install' . PHP_EOL ); exit(254); From 326ff12ac6fb77a6b91fb9d50370c5dbea77b5d5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Mar 2021 03:07:00 +0200 Subject: [PATCH 33/51] GH Actions workflows: fix PHP set up step To disable code coverage, the `coverage` key should be set to `none`. `false` is not a valid (or supported) value, so the behaviour may be unpredictable. Ref: https://github.com/shivammathur/setup-php#disable-coverage --- .github/workflows/release.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9fbb685..a172935 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: with: php-version: 5.4 extensions: exif, phar, openssl - coverage: false + coverage: none ini-values: phar.readonly=Off - name: Install Box from GitHub @@ -79,7 +79,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - coverage: false + coverage: none - name: Run linter against codebase run: php ./parallel-lint.phar src/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d948369..badc207 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,7 +61,7 @@ jobs: with: php-version: 5.4 extensions: exif, phar, openssl - coverage: false + coverage: none ini-values: phar.readonly=Off - name: Install Box from GitHub @@ -121,7 +121,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - coverage: false + coverage: none - name: Run linter against codebase run: php ./parallel-lint.phar src/ From 1c6b0598f5932b35e7213c7bc8690244a951f81f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Mar 2021 03:19:02 +0200 Subject: [PATCH 34/51] GH Actions: run the tests against all supported PHP versions The original Travis script ran the following commands against *all* supported PHP versions, but didn't test the phar: ```yaml - composer test - ./parallel-lint --exclude vendor --exclude tests/examples --no-colors . - ./parallel-lint --exclude vendor --exclude tests/examples . ``` The current `test` job only ran the unit tests against PHP 5.4. It did not run the integration test (running Parallel Lint against its own code) via a direct call to the script anymore at all. The integration test was basically now _only_ being run for the phar and only in one flavour, though it did do that on all supported PHP versions. This commit: * Removes the job which only ran the unit tests against PHP 5.4. * Adds the running of the above three commands (unit tests and two versions of integrations tests runs via a direct call to the script), to the job which also runs the integration tests via the phar file. * Updates the command line parameters used for the phar run to be the same as those used for the direct script call integration tests. --- .github/workflows/test.yml | 48 ++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index badc207..8e84d04 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,26 +28,6 @@ jobs: - name: Run code sniffer run: vendor/bin/phpcs - test: - name: Run unit tests - runs-on: ubuntu-latest - - steps: - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 5.4 - extensions: json, tokenizer - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install Composer dependencies - uses: ramsey/composer-install@v1 - - - name: Run tests - run: composer test - bundle: name: Bundle binary runs-on: ubuntu-latest @@ -84,8 +64,8 @@ jobs: name: parallel-lint-phar path: ./parallel-lint.phar - verify-bundle: - name: Validate binary on PHP ${{ matrix.php }} + test: + name: Run tests on PHP ${{ matrix.php }} runs-on: ubuntu-latest continue-on-error: ${{ matrix.experimental == true }} needs: @@ -113,15 +93,27 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 - with: - name: parallel-lint-phar - - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} coverage: none - - name: Run linter against codebase - run: php ./parallel-lint.phar src/ + - name: Install Composer dependencies + uses: ramsey/composer-install@v1 + + - name: Run unit tests + run: composer test + + - name: 'Integration test 1 - linting own code, no colors' + run: ./parallel-lint --exclude vendor --exclude tests/examples --no-colors . + + - name: 'Integration test 2 - linting own code' + run: ./parallel-lint --exclude vendor --exclude tests/examples . + + - uses: actions/download-artifact@v2 + with: + name: parallel-lint-phar + + - name: Run linter against codebase using the phar + run: php ./parallel-lint.phar --exclude vendor --exclude tests/examples . From 6d82e66424694800b5bb7d6f9b5f857c15d659c5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Mar 2021 04:42:27 +0200 Subject: [PATCH 35/51] GH Actions: actually get the tests running on all PHP versions This fixes the problem originally identified by roelofr with the `Fatal error: Interface 'JsonSerializable' not found` error. The problem had nothing to do with the PHP setup, but everything with some inane setting of the Nette testing framework as can be seen in the transcript of older, failing trial runs done by roelofr while setting up the GH Actions workflows: ``` Run composer test > @php vendor/bin/tester -p php tests _____ ___ ___ _____ ___ ___ |_ _/ __)( __/_ _/ __)| _ ) |_| \___ /___) |_| \___ |_|_\ v2.3.5 Note: No php.ini is used. ``` The key here is the `Note: No php.ini is used.`. As the system `php.ini` was not being used, no extensions were loaded, which was causing the errors. This is a change which was introduced in Nette Tester 2.0.0. As of that version, you need to always tell the Nette testing framework explicitly which `php.ini` file to use, `-C` tells it to use the system-wide `php.ini`, with `-c` you can specify a path to a `php.ini` file and by default **_no `php.ini` is used_**. (_honestly, why did anyone ever think making that the default was a good idea ?!!?_) As the tests will be running on different versions of the Nette Framework, Nette 1.x for PHP 5.4 and 5.5 and Nette 2.x for PHP 5.6+ and Nette 1.x, does not yet support the `-C` option and breaks when it is used, I've added a second test script to the `composer.json` file with the correct command line options to run Nette on PHP 5.4/5.5 and added conditions to the GH Actions workflow to use the correct script depending on the PHP/Nette test framework version being used. Refs: * https://tester.nette.org/en/running-tests#toc-c-path * https://tester.nette.org/en/guide#toc-supported-php-versions * https://github.com/nette/tester/releases/tag/v2.0.0 --- .github/workflows/test.yml | 7 ++++++- composer.json | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e84d04..fd7cac0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -102,7 +102,12 @@ jobs: - name: Install Composer dependencies uses: ramsey/composer-install@v1 - - name: Run unit tests + - name: 'Run unit tests PHP 5.4, 5.5' + if: ${{ matrix.php < 5.6 }} + run: composer testphp5 + + - name: 'Run unit tests PHP >= 5.6' + if: ${{ matrix.php >= 5.6 }} run: composer test - name: 'Integration test 1 - linting own code, no colors' diff --git a/composer.json b/composer.json index ae978fd..9916ca7 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,8 @@ "parallel-lint" ], "scripts": { - "test": "@php vendor/bin/tester -p php tests" + "test": "@php vendor/bin/tester -C -p php tests", + "testphp5": "@php vendor/bin/tester -p php tests" }, "scripts-descriptions": { "test": "Run all tests!" From 0f9f0ace58cb996548dd88d3a3d478022e0cce7e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Mar 2021 03:19:33 +0200 Subject: [PATCH 36/51] GH Actions: allow for manually triggering a workflow Triggering a workflow for a branch manually is not supported by default in GH Actions, but has to be explicitly allowed. This is useful if, for instance, an external action script or composer dependency has broken. Once a fix is available, failing builds for open PRs can be retriggered manually instead of having to be re-pushed to retrigger the workflow. Ref: https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/ --- .github/workflows/release.yml | 2 ++ .github/workflows/test.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a172935..634d9d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,8 @@ on: push: tags: - 'v*' + # Allow manually triggering the workflow. + workflow_dispatch: jobs: bundle: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fd7cac0..fa1bc27 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,8 @@ on: branches: - develop - master + # Allow manually triggering the workflow. + workflow_dispatch: jobs: lint: From 27697af0e57bfaecd3cb824101f601456ef92f24 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Mar 2021 03:21:26 +0200 Subject: [PATCH 37/51] GH Actions: report CS violations in the PR The cs2pr tool will allow to display the results from an action run in checkstyle format in-line in the PR code view, which should improve usability of the workflow results. This implements this for the style check command. Includes switching the PHP version to PHP 7.4, as PHP 8.0 is not fully supported yet in PHP_CodeSniffer (full support expected in PHPCS 3.6.0). Ref: https://github.com/staabm/annotate-pull-request-from-checkstyle --- .github/workflows/test.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa1bc27..03a9ffc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,9 +17,9 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' - extensions: json + php-version: '7.4' coverage: none + tools: cs2pr - name: Checkout code uses: actions/checkout@v2 @@ -28,7 +28,11 @@ jobs: uses: ramsey/composer-install@v1 - name: Run code sniffer - run: vendor/bin/phpcs + continue-on-error: true + run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml + + - name: Show PHPCS results in PR + run: cs2pr ./phpcs-report.xml bundle: name: Bundle binary From 44db920a2bcaaf451fb371cc82cc3ee4c2a5615f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Mar 2021 03:26:25 +0200 Subject: [PATCH 38/51] GH Actions: clean up * Remove the now redundant Travis script. * Remove the reference to the Travis script from `.gitattributes` and add the new `.github` folder. * Update the "Build status" badge in the README to show the result of the GH Actions run instead of Travis. Supersedes 54 Co-authored-by: Sam Reed --- .gitattributes | 2 +- .travis.yml | 32 -------------------------------- README.md | 2 +- 3 files changed, 2 insertions(+), 34 deletions(-) delete mode 100644 .travis.yml diff --git a/.gitattributes b/.gitattributes index 5794cff..319afb0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,7 +8,7 @@ /.gitattributes export-ignore /.github export-ignore /.gitignore export-ignore -/.travis.yml export-ignore +/.github/ export-ignore /appveyor.yml export-ignore /box.json export-ignore /doc export-ignore diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index af54d4e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -language: php - -matrix: - include: - - php: 5.4 - dist: trusty - - php: 5.5 - dist: trusty - - php: 5.6 - - php: 7.0 - - php: 7.1 - - php: 7.2 - - php: 7.3 - - php: 7.4 - env: SNIFF=1 - - php: 8.0 - - php: "nightly" - - fast_finish: true - - allow_failures: - # Allow failures for unstable builds. - - php: "nightly" - -install: - - composer install --no-interaction --prefer-source - -script: - - composer test - - ./parallel-lint --exclude vendor --exclude tests/examples --no-colors . - - ./parallel-lint --exclude vendor --exclude tests/examples . - - if [[ "$SNIFF" == "1" ]]; then ./vendor/bin/phpcs;fi diff --git a/README.md b/README.md index 68c99c1..0ba4f11 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # PHP Parallel Lint [![Downloads this Month](https://img.shields.io/packagist/dm/php-parallel-lint/php-parallel-lint.svg)](https://packagist.org/packages/php-parallel-lint/php-parallel-lint) -[![Build Status](https://travis-ci.org/php-parallel-lint/PHP-Parallel-Lint.svg?branch=master)](https://travis-ci.org/php-parallel-lint/PHP-Parallel-Lint) +[![Build Status](https://github.com/php-parallel-lint/PHP-Parallel-Lint/actions/workflows/test.yml/badge.svg)](https://github.com/php-parallel-lint/PHP-Parallel-Lint/actions/workflows/test.yml) [![License](https://poser.pugx.org/php-parallel-lint/php-parallel-lint/license.svg)](https://packagist.org/packages/php-parallel-lint/php-parallel-lint) This application checks syntax of PHP files in parallel. From 8310f4837d3d7b5f436c833df3230c6c1af2b159 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Mar 2021 14:10:58 +0200 Subject: [PATCH 39/51] GH Actions: allow for testing on PHP 5.3 In anticipation of PR 51 being merged, I'm already adding an extra step to the `test` job. PHP_CodeSniffer has a minimum PHP requirement of PHP 5.4, which would block the `composer install` on PHP 5.3. By removing that `dev` dependency ahead of the `composer install`, the test workflow can also run on PHP 5.3. --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 03a9ffc..7c2ee2f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -105,6 +105,11 @@ jobs: php-version: ${{ matrix.php }} coverage: none + # Remove PHPCS as it has a minimum PHP requirements of PHP 5.4 and would block install on PHP 5.3. + - name: 'Composer: remove PHPCS' + if: ${{ matrix.php < 5.4 }} + run: composer remove --dev squizlabs/php_codesniffer --no-update + - name: Install Composer dependencies uses: ramsey/composer-install@v1 From b770fe32868b4e0c0b8772e6c0f84f5c6a8ed311 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Mar 2021 14:21:21 +0200 Subject: [PATCH 40/51] GH Actions: fix phar creation The `phar` file should only contain the files of PHP Parallel Lint and any non-dev requirements. It should not include the `dev` requirements of this package. As things were, it did. Fixed now, by doing the `composer install` with the `--no-dev` option, both for the Test workflow as well as for the Release workflow. --- .github/workflows/release.yml | 2 ++ .github/workflows/test.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 634d9d6..e1e1cd8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,6 +35,8 @@ jobs: - name: Install Composer dependencies uses: ramsey/composer-install@v1 + with: + composer-options: "--no-dev" - name: Building binary... run: box build -v diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7c2ee2f..b92c455 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,6 +61,8 @@ jobs: - name: Install Composer dependencies uses: ramsey/composer-install@v1 + with: + composer-options: "--no-dev" - name: Building binary... run: box build -v From c8b6db9dcd54cf78caad4220970d4c939e611fd1 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Mar 2021 15:14:45 +0200 Subject: [PATCH 41/51] GH Actions: switch execution order of unit vs integration tests ... and add `continue-on-error` to the first of the integration tests. If/when any of the tests fail, execution of the `Test` job will stop. Now, if there is a parse error in the code of any of the Parallel Lint files, with the test execution order as it was, that means the job would already fail on the running of the unit tests and stop there. However to identify the parse error, the integration tests are more useful, so with that in mind, those will now be run first. Secondly, if there is a parse error, the first integration test would fail and the second (with colours) would never get executed, while especially in the case of a parse error in the Parallel Lint code itself, it is useful to see the output of both these integration tests. So, with that in mind, I've set the first of the two to `continue-on-error`. As the second integration test would fail anyway, this will never negatively impact the workflow success/failure marking in the end, while it does allow us to see the output of both integration test steps. --- .github/workflows/test.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b92c455..99633a0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -115,6 +115,13 @@ jobs: - name: Install Composer dependencies uses: ramsey/composer-install@v1 + - name: 'Integration test 1 - linting own code, no colors' + continue-on-error: true + run: ./parallel-lint --exclude vendor --exclude tests/examples --no-colors . + + - name: 'Integration test 2 - linting own code' + run: ./parallel-lint --exclude vendor --exclude tests/examples . + - name: 'Run unit tests PHP 5.4, 5.5' if: ${{ matrix.php < 5.6 }} run: composer testphp5 @@ -123,12 +130,6 @@ jobs: if: ${{ matrix.php >= 5.6 }} run: composer test - - name: 'Integration test 1 - linting own code, no colors' - run: ./parallel-lint --exclude vendor --exclude tests/examples --no-colors . - - - name: 'Integration test 2 - linting own code' - run: ./parallel-lint --exclude vendor --exclude tests/examples . - - uses: actions/download-artifact@v2 with: name: parallel-lint-phar From b3d58c64cff5472c7d54888fdfec4f5d35caf4f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 14 Mar 2021 10:34:13 +0200 Subject: [PATCH 42/51] Add polyfill for \JsonSerializable --- composer.json | 1 + src/polyfill.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/polyfill.php diff --git a/composer.json b/composer.json index 9916ca7..d45d9d6 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,7 @@ "sort-packages": true }, "autoload": { + "files": [ "src/polyfill.php" ], "classmap": [ "./" ] diff --git a/src/polyfill.php b/src/polyfill.php new file mode 100644 index 0000000..79b3049 --- /dev/null +++ b/src/polyfill.php @@ -0,0 +1,15 @@ + Date: Sun, 14 Mar 2021 10:34:18 +0200 Subject: [PATCH 43/51] Use traditional array syntax --- parallel-lint | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parallel-lint b/parallel-lint index 54d6887..6de4764 100755 --- a/parallel-lint +++ b/parallel-lint @@ -35,14 +35,14 @@ if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50400) { exit(254); } -$autoloadLocations = [ +$autoloadLocations = array( getcwd() . '/vendor/autoload.php', getcwd() . '/../../autoload.php', __DIR__ . '/vendor/autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php', __DIR__ . '/../../autoload.php', -]; +); $loaded = false; foreach ($autoloadLocations as $autoload) { From 82a9ba44d3f708e55883ad8a1acc980e86ccddd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 14 Mar 2021 10:34:24 +0200 Subject: [PATCH 44/51] Allow loading script with php 5.3 --- parallel-lint | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parallel-lint b/parallel-lint index 6de4764..b226da1 100755 --- a/parallel-lint +++ b/parallel-lint @@ -30,8 +30,8 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50400) { - fwrite(STDERR, "PHP Parallel Lint require PHP 5.4.0 or newer." . PHP_EOL); +if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) { + fwrite(STDERR, "PHP Parallel Lint requires PHP 5.3.0 or newer." . PHP_EOL); exit(254); } From 2d36938473ecaf369b8bee3aaae9e98591e33211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 14 Mar 2021 10:34:21 +0200 Subject: [PATCH 45/51] Allow php 5.3 in composer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d45d9d6..2fe44f5 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "php": ">=5.4.0", + "php": ">=5.3.0", "ext-json": "*" }, "replace": { From c28c152cfa22dd24d36b9ac1e9d23af96f72cbcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sat, 27 Mar 2021 21:05:55 +0200 Subject: [PATCH 46/51] Add php 5.3 to CI and listed as supported --- .github/workflows/test.yml | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 99633a0..8791eab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -82,6 +82,7 @@ jobs: strategy: matrix: php: + - '5.3' - '5.4' - '5.5' - '5.6' diff --git a/README.md b/README.md index 0ba4f11..e5c762f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Additionally `blame` can be used to show commits that introduced the breakage. Running parallel jobs in PHP is inspired by Nette framework tests. -The application is officially supported for use with PHP 5.4 to 8.0. +The application is officially supported for use with PHP 5.3 to 8.0. ## Table of contents From b2643dc5a7f7b4a0a33ddd47287d3837f6e81538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 28 Mar 2021 13:54:14 +0300 Subject: [PATCH 47/51] Load polyfill from application, not from composer' This way the polyfill won't be executed when php-parallel-lint is loaded as composer dependency but in application only. --- composer.json | 1 - parallel-lint | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2fe44f5..ce7ed04 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,6 @@ "sort-packages": true }, "autoload": { - "files": [ "src/polyfill.php" ], "classmap": [ "./" ] diff --git a/parallel-lint b/parallel-lint index b226da1..f44e110 100755 --- a/parallel-lint +++ b/parallel-lint @@ -61,5 +61,7 @@ if (!$loaded) { exit(254); } +require_once __DIR__ . '/src/polyfill.php'; + $app = new JakubOnderka\PhpParallelLint\Application(); exit($app->run()); From a1f199abcbceddaa17a3f53f54b630760f1a1a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Tue, 30 Mar 2021 23:27:53 +0200 Subject: [PATCH 48/51] Updated changelog - Github Action, PHP 5.3 support --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13d9c09..0e7c191 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Allow for multi-part file extensions to be passed using -e (like `-e php,php.dist`) from [@jrfnl](https://github.com/jrfnl). - Added syntax error callback [#30](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/30) from [@arxeiss](https://github.com/arxeiss). - Ignore PHP startup errors [#34](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/34) from [@jrfnl](https://github.com/jrfnl). +- Restore php 5.3 support [#51](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/51) from [@glensc](https://github.com/glensc). ### Fixed @@ -26,8 +27,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Updated PHPCS dependency from [@jrfnl](https://github.com/jrfnl). - Cleaned coding style from [@jrfnl](https://github.com/jrfnl). - Provide one true way to run the test suite [#37](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/37) from [@mfn](https://github.com/mfn). -- Travis: add build against PHP 8.0 and fix failing test [#41(https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/41) from [@jrfnl](https://github.com/jrfnl). +- Travis: add build against PHP 8.0 and fix failing test [#41](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/41) from [@jrfnl](https://github.com/jrfnl). - GitHub Actions for testing, and automatic phar creation [#46](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/46) from [@roelofr](https://github.com/roelofr). +- Add .github folder to .gitattributes export-ignore [#54](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/54) from [@glensc](https://github.com/glensc). +- Suggest to curl composer install via HTTPS [#53](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/53) from [@reedy](https://github.com/reedy). +- GH Actions: allow for manually triggering a workflow [#55](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/55) from [@jrfnl](https://github.com/jrfnl). +- GH Actions: fix phar creation [#55](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/55) from [@jrfnl](https://github.com/jrfnl). +- GH Actions: run the tests against all supported PHP versions [#55](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/55) from [@jrfnl](https://github.com/jrfnl). +- GH Actions: report CS violations in the PR [#55](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/55) from [@jrfnl](https://github.com/jrfnl). ## [1.2.0] - 2020-04-04 From f3954ba11db28cff260be6741edceb75edd7359c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Tue, 30 Mar 2021 23:31:59 +0200 Subject: [PATCH 49/51] Typo in Github workflow --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8791eab..7d54101 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -123,7 +123,7 @@ jobs: - name: 'Integration test 2 - linting own code' run: ./parallel-lint --exclude vendor --exclude tests/examples . - - name: 'Run unit tests PHP 5.4, 5.5' + - name: 'Run unit tests PHP <= 5.5' if: ${{ matrix.php < 5.6 }} run: composer testphp5 From 2aee0adb9fe0b4eecc6b89608f32ba2753628060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 31 Mar 2021 11:04:59 +0300 Subject: [PATCH 50/51] Add missing reflinks to changelog See the guide: https://keepachangelog.com/en/1.0.0/ --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e7c191..6d9e5e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - GH Actions: run the tests against all supported PHP versions [#55](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/55) from [@jrfnl](https://github.com/jrfnl). - GH Actions: report CS violations in the PR [#55](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/55) from [@jrfnl](https://github.com/jrfnl). +[Unreleased]: https://github.com/php-parallel-lint/PHP-Parallel-Lint/compare/v1.2.0...HEAD + ## [1.2.0] - 2020-04-04 ### Added @@ -56,3 +58,5 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Added info about installing like not a dependency. - Cleaned readme - new organization from previous package. - Added checklist for new version from [@szepeviktor](https://github.com/szepeviktor). + +[1.2.0]: https://github.com/php-parallel-lint/PHP-Parallel-Lint/compare/v1.1.0...v1.2.0 From 772a954e5f119f6f5871d015b23eabed8cbdadfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Wed, 7 Apr 2021 16:42:48 +0200 Subject: [PATCH 51/51] New version - 1.3.0 --- CHANGELOG.md | 6 +++++- src/Application.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d9e5e8..16c15e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +[Unreleased]: https://github.com/php-parallel-lint/PHP-Parallel-Lint/compare/v1.3.0...HEAD + +## [1.3.0] - 2021-04-07 + ### Added - Allow for multi-part file extensions to be passed using -e (like `-e php,php.dist`) from [@jrfnl](https://github.com/jrfnl). @@ -36,7 +40,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - GH Actions: run the tests against all supported PHP versions [#55](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/55) from [@jrfnl](https://github.com/jrfnl). - GH Actions: report CS violations in the PR [#55](https://github.com/php-parallel-lint/PHP-Parallel-Lint/pull/55) from [@jrfnl](https://github.com/jrfnl). -[Unreleased]: https://github.com/php-parallel-lint/PHP-Parallel-Lint/compare/v1.2.0...HEAD +[1.3.0]: https://github.com/php-parallel-lint/PHP-Parallel-Lint/compare/v1.2.0...v1.3.0 ## [1.2.0] - 2020-04-04 diff --git a/src/Application.php b/src/Application.php index f4002e0..d38e42d 100644 --- a/src/Application.php +++ b/src/Application.php @@ -4,7 +4,7 @@ class Application { - const VERSION = '1.2.0'; + const VERSION = '1.3.0'; // Return codes const SUCCESS = 0,