isTTY() public static method

public static isTTY ( )
 static function colorize($text = '', $parameters = array(), $stream = STDOUT)
 {
     // disable colors if not supported (windows or non tty console)
     if (!pakeApp::isTTY()) {
         return $text;
     }
     static $options = array('bold' => 1, 'underscore' => 4, 'blink' => 5, 'reverse' => 7, 'conceal' => 8);
     static $foreground = array('black' => 30, 'red' => 31, 'green' => 32, 'yellow' => 33, 'blue' => 34, 'magenta' => 35, 'cyan' => 36, 'white' => 37);
     static $background = array('black' => 40, 'red' => 41, 'green' => 42, 'yellow' => 43, 'blue' => 44, 'magenta' => 45, 'cyan' => 46, 'white' => 47);
     if (!is_array($parameters) && isset(self::$styles[$parameters])) {
         $parameters = self::$styles[$parameters];
     }
     $codes = array();
     if (isset($parameters['fg'])) {
         $codes[] = $foreground[$parameters['fg']];
     }
     if (isset($parameters['bg'])) {
         $codes[] = $background[$parameters['bg']];
     }
     foreach ($options as $option => $value) {
         if (isset($parameters[$option]) && $parameters[$option]) {
             $codes[] = $value;
         }
     }
     return "[" . implode(';', $codes) . 'm' . $text . "";
 }
 public static function render($e)
 {
     $isatty = pakeApp::isTTY();
     $title = '  [' . get_class($e) . ']  ';
     $len = self::strlen($title);
     $lines = array();
     foreach (explode("\n", $e->getMessage()) as $line) {
         if ($isatty) {
             $pieces = explode("\n", wordwrap($line, pakeApp::screenWidth() - 4, "\n", true));
         } else {
             $pieces = array($line);
         }
         foreach ($pieces as $piece) {
             $lines[] = '  ' . $piece . '  ';
             $len = max(self::strlen($piece) + 4, $len);
         }
     }
     if ($isatty) {
         $messages = array(str_repeat(' ', $len), $title . str_repeat(' ', $len - self::strlen($title)));
     } else {
         $messages = array('', $title);
     }
     foreach ($lines as $line) {
         if ($isatty) {
             $messages[] = $line . str_repeat(' ', $len - self::strlen($line));
         } else {
             $messages[] = $line;
         }
     }
     if ($isatty) {
         $messages[] = str_repeat(' ', $len);
     } else {
         $messages[] = '';
     }
     fwrite(STDERR, "\n");
     foreach ($messages as $message) {
         fwrite(STDERR, pakeColor::colorize($message, 'ERROR', STDERR) . "\n");
     }
     fwrite(STDERR, "\n");
     $pake = pakeApp::get_instance();
     if ($pake->get_trace()) {
         fwrite(STDERR, "exception trace:\n");
         $trace = self::trace($e);
         for ($i = 0, $count = count($trace); $i < $count; $i++) {
             $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
             $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
             $function = $trace[$i]['function'];
             $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
             $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
             fwrite(STDERR, pake_sprintf(" %s%s%s at %s:%s\n", $class, $type, $function, pakeColor::colorize($file, 'INFO', STDERR), pakeColor::colorize($line, 'INFO', STDERR)));
         }
     }
     fwrite(STDERR, "\n");
 }
 protected function initAndRunTaskInSubprocess($command)
 {
     if (function_exists('pcntl_fork')) {
         // UNIX
         $argv = explode(' ', $command);
         list($task_name, $args, $options) = self::parseTaskAndParameters($argv);
         $task_name = pakeTask::get_full_task_name($task_name);
         $pid = pcntl_fork();
         if ($pid == -1) {
             die('could not fork');
         }
         if ($pid) {
             // we are the parent
             pcntl_wait($status);
             $status = pcntl_wexitstatus($status);
             if ($status == self::QUIT_INTERACTIVE) {
                 exit(0);
             }
         } else {
             try {
                 $status = $this->initAndRunTask($task_name, $args, $options);
                 if (true === $status) {
                     exit(0);
                 }
                 exit($status);
             } catch (pakeException $e) {
                 pakeException::render($e);
                 exit(1);
             }
         }
     } else {
         // WINDOWS or missing PCNTL functions
         $php_exec = escapeshellarg((isset($_SERVER['_']) and substr($_SERVER['_'], -4) != 'pake') ? $_SERVER['_'] : 'php');
         $force_tty = '';
         if (pakeApp::isTTY()) {
             $force_tty = ' --force-tty';
         }
         $pake_php = escapeshellarg($_SERVER['SCRIPT_NAME']);
         $import_flag = ' --import=interactive';
         system($php_exec . ' ' . $pake_php . $force_tty . $import_flag . ' ' . $command, $status);
         if ($status == self::QUIT_INTERACTIVE) {
             exit(0);
         }
     }
 }