Posted by Anonymous Wed 21st Mar 2007 11:52 - Syntax is PHP - 14 viewsRun this post in the PHP shell
Download | New Post | Modify | Hide line numbers
PHP parser reported no syntax errors in this post!
  1. $calls_stack = array();
  2.  
  3. function call_thief()
  4. {
  5.     global $calls_stack;
  6.     $trace = debug_backtrace();
  7.     $call = '/* ';
  8.     $stack = array();
  9.     for ($i=1; $i($trace); ++$i)
  10.         $stack[] = $trace[$i]['function'];
  11.  
  12.     $stack = array_reverse($stack);
  13.  
  14.     $call .= implode(' -> ', $stack) . " */\n";
  15.     $call .= $trace[1]['function'] . '(';
  16.     $arg = array();
  17.     foreach ($trace[1]['args'] as $keh => $val)
  18.         $arg[] = var_export($val, true);
  19.     $call .= implode(', ', $arg) . ')';
  20.     $calls_stack[] = $call;
  21. }
  22.  
  23. function return_thief($ret)
  24. {
  25.     global $calls_stack;
  26.     $data = "assert_true(\n/* " . count($calls_stack) . " */\n" .
  27.         array_pop($calls_stack) . ' == ' . var_export($ret, true) . ");\n\n\n";
  28.     file_put_contents('call_log.log', $data, FILE_APPEND);
  29.     return $ret;
  30. }
  31.  

PermaLink to this entry https://pastebin.co.uk/12114
Posted by Anonymous Wed 21st Mar 2007 11:52 - Syntax is PHP - 14 viewsRun this post in the PHP shell
Download | New Post | Modify | Hide line numbers

 

Comments: 0