Skip to content

Commit

Permalink
Bootstrap - If there's a PHP parse error, point out potential issues …
Browse files Browse the repository at this point in the history
…with PHP version
  • Loading branch information
totten committed Aug 20, 2019
1 parent 1cd07fd commit 14fe9da
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
*/
class Bootstrap {

const PHP_RECOMMENDED_MIN = '7.0.0';

protected static $singleton = NULL;

protected $options = array();
Expand Down Expand Up @@ -150,7 +152,13 @@ public function boot($options = array()) {
case E_ERROR:
case E_PARSE:
case E_COMPILE_ERROR:
$errMsg = sprintf("\nPHP Error: %s\nat line %s in %s", $last_error['message'], $last_error['line'], $last_error['file']);
$errMsg = sprintf("PHP Error: %s\nat line %s in %s", $last_error['message'], $last_error['line'], $last_error['file']);
// We only warn about PHP version if there's actually a fatal; for older versions of civicrm-core, it would be incorrect for
// cv to start outputting PHP version errors.
if (!version_compare(PHP_VERSION, self::PHP_RECOMMENDED_MIN, '>=')) {
$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);
}

if ($this->output && is_callable([$this->output, 'getErrorOutput'])) {
$this->output->getErrorOutput()->writeln("<error>$errMsg</error>");
}
Expand Down

0 comments on commit 14fe9da

Please sign in to comment.