Esempio n. 1
0
 /**
  * @param array $traceData
  *
  * @return string
  */
 public static function decorateTrace(array $traceData = array())
 {
     $output = self::_title('TRACE');
     $lastStep = count($traceData);
     foreach ($traceData as $stepNo => $step) {
         $title = str_pad(++$stepNo . ': ', 4, ' ');
         $title .= self::_colorize(isset($step['file']) ? self::_buildCalleeString($step) : 'PHP internal call', 'title');
         if (!empty($step['function'])) {
             $title .= '    ' . $step['function'];
             if (isset($step['args'])) {
                 $title .= '(';
                 if (empty($step['args'])) {
                     $title .= ')';
                 }
                 $title .= PHP_EOL;
             }
         }
         $output .= $title;
         if (!empty($step['args'])) {
             $appendDollar = $step['function'] === '{closure}' ? '' : '$';
             $i = 0;
             foreach ($step['args'] as $name => $argument) {
                 $argument = KintParser::factory($argument, $name ? $appendDollar . $name : '#' . ++$i);
                 $argument->operator = $name ? ' =' : ':';
                 $maxLevels = Kint::$maxLevels;
                 if ($maxLevels) {
                     Kint::$maxLevels = $maxLevels + 2;
                 }
                 $output .= self::decorate($argument, 2);
                 if ($maxLevels) {
                     Kint::$maxLevels = $maxLevels;
                 }
             }
             $output .= '    )' . PHP_EOL;
         }
         if (!empty($step['object'])) {
             $output .= self::_colorize('    ' . self::_char('─', 27) . ' Callee object ' . self::_char('─', 34), 'title');
             $maxLevels = Kint::$maxLevels;
             if ($maxLevels) {
                 # in cli the terminal window is filled too quickly to display huge objects
                 Kint::$maxLevels = Kint::enabled() === Kint::MODE_CLI ? 1 : $maxLevels + 1;
             }
             $output .= self::decorate(KintParser::factory($step['object']), 1);
             if ($maxLevels) {
                 Kint::$maxLevels = $maxLevels;
             }
         }
         if ($stepNo !== $lastStep) {
             $output .= self::_colorize(self::_char('─', self::$_consoleRow), 'title');
         }
     }
     return $output;
 }