From 6099e85160a0715ea6fe52223bb3eee130dd14b8 Mon Sep 17 00:00:00 2001 From: Jurmarcus Allen Date: Tue, 6 May 2014 01:18:37 -0500 Subject: [PATCH] HHVM compatibility Fixes for Yii 2 Console Application --- framework/console/Controller.php | 6 +++--- framework/console/ErrorHandler.php | 2 +- framework/helpers/BaseConsole.php | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/framework/console/Controller.php b/framework/console/Controller.php index cf39ed1881..a927692aad 100644 --- a/framework/console/Controller.php +++ b/framework/console/Controller.php @@ -49,7 +49,7 @@ class Controller extends \yii\base\Controller * @param resource $stream the stream to check. * @return boolean Whether to enable ANSI style in output. */ - public function isColorEnabled($stream = STDOUT) + public function isColorEnabled($stream = \STDOUT) { return $this->color === null ? Console::streamSupportsAnsiColors($stream) : $this->color; } @@ -192,13 +192,13 @@ class Controller extends \yii\base\Controller */ public function stderr($string) { - if ($this->isColorEnabled(STDERR)) { + if ($this->isColorEnabled(\STDERR)) { $args = func_get_args(); array_shift($args); $string = Console::ansiFormat($string, $args); } - return fwrite(STDERR, $string); + return fwrite(\STDERR, $string); } /** diff --git a/framework/console/ErrorHandler.php b/framework/console/ErrorHandler.php index f9cf74cb94..3b4761accf 100644 --- a/framework/console/ErrorHandler.php +++ b/framework/console/ErrorHandler.php @@ -64,7 +64,7 @@ class ErrorHandler extends \yii\base\ErrorHandler */ protected function formatMessage($message, $format = [Console::FG_RED, Console::BOLD]) { - $stream = (PHP_SAPI === 'cli') ? STDERR : STDOUT; + $stream = (PHP_SAPI === 'cli') ? \STDERR : \STDOUT; // try controller first to allow check for --color switch if (Yii::$app->controller instanceof \yii\console\Controller && Yii::$app->controller->isColorEnabled($stream) || Yii::$app instanceof \yii\console\Application && Console::streamSupportsAnsiColors($stream)) { diff --git a/framework/helpers/BaseConsole.php b/framework/helpers/BaseConsole.php index 178bbcd2be..aafeeff21b 100644 --- a/framework/helpers/BaseConsole.php +++ b/framework/helpers/BaseConsole.php @@ -628,7 +628,7 @@ class BaseConsole */ public static function stdin($raw = false) { - return $raw ? fgets(STDIN) : rtrim(fgets(STDIN), PHP_EOL); + return $raw ? fgets(\STDIN) : rtrim(fgets(\STDIN), PHP_EOL); } /** @@ -639,7 +639,7 @@ class BaseConsole */ public static function stdout($string) { - return fwrite(STDOUT, $string); + return fwrite(\STDOUT, $string); } /** @@ -650,7 +650,7 @@ class BaseConsole */ public static function stderr($string) { - return fwrite(STDERR, $string); + return fwrite(\STDERR, $string); } /**