From 4241cb61b6a011c6803b5558cc0946abce8fdbeb Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 20 Feb 2022 19:21:09 +0100 Subject: [PATCH 1/2] Allow version check in application entry file to work By putting the class name, which contains PHP 5.3 namespace separator tokens, as a variable and then dynamically calling the class, the parse error on PHP < 5.3 is prevented and the version check at the top of the file can work as expected. Fixes 62 --- parallel-lint | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/parallel-lint b/parallel-lint index b6bb513..184df83 100755 --- a/parallel-lint +++ b/parallel-lint @@ -70,5 +70,7 @@ if (!$loaded) { require_once __DIR__ . '/src/polyfill.php'; -$app = new PHP_Parallel_Lint\PhpParallelLint\Application(); +// Prevent parse error on PHP < 5.3 so the version check above can work. +$className = 'PHP_Parallel_Lint\PhpParallelLint\Application'; +$app = new $className(); exit($app->run()); From f92206034185e0bf0df9ab6e255b39cb0eac993f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 8 Jun 2021 06:28:15 +0200 Subject: [PATCH 2/2] Make the version check more informative Previously, the PHP version check run at the start of the script would display `PHP Parallel Lint requires PHP 5.3.0 or newer.` if the PHP version was too low. The message has been updated to include the currently detected PHP version and the path to the PHP binary. Note: both constants used are available in PHP cross-version. --- parallel-lint | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/parallel-lint b/parallel-lint index 184df83..3a806d5 100755 --- a/parallel-lint +++ b/parallel-lint @@ -31,7 +31,15 @@ either expressed or implied, of the FreeBSD Project. */ if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) { - fwrite(STDERR, "PHP Parallel Lint requires PHP 5.3.0 or newer." . PHP_EOL); + fwrite( + STDERR, + sprintf( + 'PHP Parallel Lint requires PHP 5.3.0 or newer.' . PHP_EOL + . 'You are using PHP %s (%s).' . PHP_EOL, + PHP_VERSION, + PHP_BINDIR + ) + ); exit(254); }