| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | namespace Kint\Parser; |
| 27: | |
| 28: | use Kint\Object\BasicObject; |
| 29: | use Kint\Object\TraceFrameObject; |
| 30: | use Kint\Object\TraceObject; |
| 31: | use Kint\Utils; |
| 32: | |
| 33: | class TracePlugin extends Plugin |
| 34: | { |
| 35: | public static $blacklist = array('spl_autoload_call'); |
| 36: | |
| 37: | public function getTypes() |
| 38: | { |
| 39: | return array('array'); |
| 40: | } |
| 41: | |
| 42: | public function getTriggers() |
| 43: | { |
| 44: | return Parser::TRIGGER_SUCCESS; |
| 45: | } |
| 46: | |
| 47: | public function parse(&$var, BasicObject &$o, $trigger) |
| 48: | { |
| 49: | if (!$o->value) { |
| 50: | return; |
| 51: | } |
| 52: | |
| 53: | $trace = $this->parser->getCleanArray($var); |
| 54: | |
| 55: | if (\count($trace) !== \count($o->value->contents) || !Utils::isTrace($trace)) { |
| 56: | return; |
| 57: | } |
| 58: | |
| 59: | $traceobj = new TraceObject(); |
| 60: | $traceobj->transplant($o); |
| 61: | $rep = $traceobj->value; |
| 62: | |
| 63: | $old_trace = $rep->contents; |
| 64: | |
| 65: | Utils::normalizeAliases(self::$blacklist); |
| 66: | |
| 67: | $rep->contents = array(); |
| 68: | |
| 69: | foreach ($old_trace as $frame) { |
| 70: | $index = $frame->name; |
| 71: | |
| 72: | if (!isset($trace[$index]['function'])) { |
| 73: | |
| 74: | continue; |
| 75: | } |
| 76: | |
| 77: | if (Utils::traceFrameIsListed($trace[$index], self::$blacklist)) { |
| 78: | continue; |
| 79: | } |
| 80: | |
| 81: | $rep->contents[$index] = new TraceFrameObject($frame, $trace[$index]); |
| 82: | } |
| 83: | |
| 84: | \ksort($rep->contents); |
| 85: | $rep->contents = \array_values($rep->contents); |
| 86: | |
| 87: | $traceobj->clearRepresentations(); |
| 88: | $traceobj->addRepresentation($rep); |
| 89: | $traceobj->size = \count($rep->contents); |
| 90: | $o = $traceobj; |
| 91: | } |
| 92: | } |
| 93: | |