Skip to content

Commit 14fe9da

Browse files
committed
Bootstrap - If there's a PHP parse error, point out potential issues with PHP version
1 parent 1cd07fd commit 14fe9da

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Bootstrap.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
*/
7979
class Bootstrap {
8080

81+
const PHP_RECOMMENDED_MIN = '7.0.0';
82+
8183
protected static $singleton = NULL;
8284

8385
protected $options = array();
@@ -150,7 +152,13 @@ public function boot($options = array()) {
150152
case E_ERROR:
151153
case E_PARSE:
152154
case E_COMPILE_ERROR:
153-
$errMsg = sprintf("\nPHP Error: %s\nat line %s in %s", $last_error['message'], $last_error['line'], $last_error['file']);
155+
$errMsg = sprintf("PHP Error: %s\nat line %s in %s", $last_error['message'], $last_error['line'], $last_error['file']);
156+
// We only warn about PHP version if there's actually a fatal; for older versions of civicrm-core, it would be incorrect for
157+
// cv to start outputting PHP version errors.
158+
if (!version_compare(PHP_VERSION, self::PHP_RECOMMENDED_MIN, '>=')) {
159+
$errMsg .= sprintf("\n\nWARNING: cv recommends PHP %s+ for use with current CiviCRM versions. This command is running PHP %s.", self::PHP_RECOMMENDED_MIN, PHP_VERSION);
160+
}
161+
154162
if ($this->output && is_callable([$this->output, 'getErrorOutput'])) {
155163
$this->output->getErrorOutput()->writeln("<error>$errMsg</error>");
156164
}

0 commit comments

Comments
 (0)