Example #1
0
 /**
  * Ajoute un message à la pile.
  *
  * @param array $aParams
  * @return void
  */
 public function addMessage($aParams)
 {
     if (empty($aParams['style'])) {
         $aParams['style'] = 'info';
     }
     $aCompleteBacktrace = debug_backtrace();
     if (!empty($aCompleteBacktrace)) {
         $aParams['backtrace'] = $this->get_debug_print_backtrace(3);
     }
     if (OKT_XDEBUG) {
         if (empty($aParams['file'])) {
             $aParams['file'] = xdebug_call_file();
         }
         if (empty($aParams['line'])) {
             $aParams['line'] = xdebug_call_line();
         }
         $aParams['class'] = xdebug_call_class();
         $aParams['function'] = xdebug_call_function();
     } else {
         $aTrace = next($aCompleteBacktrace);
         if (empty($aParams['file'])) {
             $aParams['file'] = isset($aTrace['file']) ? $aTrace['file'] : '';
         }
         if (empty($aParams['line'])) {
             $aParams['line'] = isset($aTrace['line']) ? $aTrace['line'] : '';
         }
         $aParams['class'] = isset($aTrace['class']) ? $aTrace['class'] : '';
         $aParams['function'] = isset($aTrace['function']) ? $aTrace['function'] : '';
     }
     $this->aStack[] = $aParams;
 }
Example #2
0
 public function myCallee()
 {
     printf("%s", xdebug_call_class());
     printf("::%s", xdebug_call_function());
     printf(" in %s", xdebug_call_file());
     printf(":%s\n", xdebug_call_line());
 }
 function foo($a)
 {
     echo '<br>Class Name : ' . xdebug_call_class() . '<br>';
     //To Display the Class name.
     echo 'Function Name : ' . xdebug_call_function() . '<br>';
     //To Display the Function name.
     echo 'Line : ' . xdebug_call_line() . '<br>';
     //To Display the Function name.
     return $a + 1;
 }
Example #4
0
 protected function runInShell($command, $bail = true)
 {
     putenv('PHPUNIT_TEST_ID=' . xdebug_call_class() . '::' . xdebug_call_function());
     $proc = proc_open('php -c build/config/php_coverage.ini ' . $command, [self::STDOUT => ["pipe", "w"], self::STDERR => ["pipe", "w"]], $pipes);
     if (!is_resource($proc)) {
         $this->fail('Unable to start process.');
     }
     $stdout = stream_get_contents($pipes[self::STDOUT]);
     fclose($pipes[self::STDOUT]);
     $stderr = stream_get_contents($pipes[self::STDERR]);
     fclose($pipes[self::STDERR]);
     $return = proc_close($proc);
     if ($bail && $return != 0) {
         $this->fail("{$stderr}\nCommand exited with a non-zero value ({$return}).");
     }
     return ['return' => $return, 'stdout' => $stdout, 'stderr' => $stderr];
 }
 /**
  * Add log message (time, memory, message, call, file_line) to _log.
  * Use Profile::traceLast() for $bt.
  *
  * @param string $msg (default = '')
  */
 public function log($msg = '')
 {
     $ts = microtime(true);
     $mem = memory_get_usage();
     if ($mem > $this->_xlog['maxmem']) {
         $this->_xlog['maxmem'] = $mem;
     }
     if ($mem < $this->_xlog['minmem']) {
         $this->_xlog['minmem'] = $mem;
     }
     $log = array('call' => '', 'file_line' => '');
     $log['time'] = $ts - $this->_xlog['time'];
     $log['memory'] = $mem - $this->_xlog['memory'];
     $log['message'] = $msg;
     if ($this->_xdebug_on) {
         $class = xdebug_call_class();
         $func = xdebug_call_function();
         $log['call'] = $class ? $class . '::' . $func : $func;
         $log['file_line'] = basename(xdebug_call_file()) . ':' . xdebug_call_line();
     }
     array_push($this->_log, $log);
     $this->_xlog['time'] = $ts;
     $this->_xlog['memory'] = $mem;
 }
Example #6
0
File: XDebug.php Project: ksst/kf
 public static function showCallStack()
 {
     echo 'CallStack - File: ' . xdebug_call_file();
     echo '<br />Class: ' . xdebug_call_class();
     echo '<br />Function: ' . xdebug_call_function();
     echo '<br />Line: ' . xdebug_call_line();
     echo '<br />Depth of Stacks: ' . xdebug_get_stack_depth();
     echo '<br />Content of Stack: ' . xdebug_var_dump(xdebug_get_function_stack());
 }
Example #7
0
 public static function b($var)
 {
     echo $var, ': ', xdebug_call_class(), '>', xdebug_call_function(), ' @ ', xdebug_call_file(), ':', xdebug_call_line(), "\n";
     c($var + 1);
 }
Example #8
0
 /**
  * This function returns the name of the class from which the current function/method was called from.
  * @return string
  */
 public function callClass()
 {
     return xdebug_call_class();
 }
Example #9
0
 /**
  * Outputs a block containing the data into the document.
  *
  * @param  mixed    $data       The debugging data to output.
  * @param  boolean  $highlight  Whether the data should be highlighted.
  * @param  boolean  $collapsed  Should the debug block be collapsed initially
  *
  * @todo  Tidy this up.
  * @todo  Formatting and highlighting without xdebug.
  */
 public static function out($data, $highlight = true, $collapsed = false)
 {
     if (!self::$enabled) {
         return;
     }
     static $count = 0;
     $id = '__debug' . $count;
     echo PHP_EOL;
     echo '<div id="' . $id . '" style="background: #fed; border: solid 2px #edc; font-size: 12px; margin: 1em; padding: 0.3em; width: auto;">';
     echo '<div style="background: #edc; overflow: hidden; padding: 0.3em;">';
     echo '<span style="font-weight: bold;">Debug</span>';
     echo '<div style="float: right; font-size: 10px;">( ';
     $style = 'cursor: pointer; text-decoration: underline;';
     if (!$highlight) {
         echo '<span style="' . $style . '" onclick="document.getElementById(\'' . $id . '_data\').select();">Select All</span> | ';
     }
     echo '<span style="' . $style . '" onclick="var e = document.getElementById(\'' . $id . '_data\'); if (e.style.display == \'none\') { e.style.display = \'block\'; this.innerHTML = \'Collapse\'; } else { e.style.display = \'none\'; this.innerHTML = \'Expand\'; }">' . ($collapsed ? 'Expand' : 'Collapse') . '</span> | ';
     echo '<span style="' . $style . '" onclick="var e = document.getElementById(\'' . $id . '\'); e.parentNode.removeChild(e);">Remove</span>';
     echo ' )</div>';
     if (extension_loaded('xdebug')) {
         printf('<span style="display: block; margin-top: 0.3em; white-space: nowrap;">%s:%s in %s::%s()</span>', str_replace($_SERVER['DOCUMENT_ROOT'] . '/', '', xdebug_call_file()), xdebug_call_line(), xdebug_call_class(), xdebug_call_function());
     } else {
         # TODO: Formatting and highlighting without xdebug.
     }
     echo '</div>';
     echo '<pre style="background: none; border: none; margin: none; padding: none;">';
     $style = 'background: none; border: none; margin-top: 0.3em; max-height: 150px; width: 100%;';
     if ($collapsed) {
         $style .= ' display: none;';
     }
     if ($highlight) {
         echo '<div id="' . $id . '_data" style="' . $style . ' font-family: monospace; max-height: 150px; overflow: auto; white-space: pre;">';
         # TODO: Need to escape data without clobbering highlight/xdebug modifications.
         var_dump($data);
         echo '</div>';
     } else {
         echo '<textarea cols="80" rows="8" id="' . $id . '_data" style="' . $style . '">';
         ob_start();
         var_dump($data);
         $data = ob_get_clean();
         echo strip_tags($data);
         echo '</textarea>';
     }
     echo '</pre>';
     echo '</div>';
     echo PHP_EOL, PHP_EOL;
     $count++;
 }