1: <?php
2:
3: /*
4: * The MIT License (MIT)
5: *
6: * Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
7: *
8: * Permission is hereby granted, free of charge, to any person obtaining a copy of
9: * this software and associated documentation files (the "Software"), to deal in
10: * the Software without restriction, including without limitation the rights to
11: * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12: * the Software, and to permit persons to whom the Software is furnished to do so,
13: * subject to the following conditions:
14: *
15: * The above copyright notice and this permission notice shall be included in all
16: * copies or substantial portions of the Software.
17: *
18: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20: * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21: * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22: * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23: * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24: */
25:
26: namespace Kint\Renderer\Rich;
27:
28: use Kint\Object\BasicObject;
29: use Kint\Object\TraceFrameObject;
30:
31: class TraceFramePlugin extends Plugin implements ObjectPluginInterface
32: {
33: public function renderObject(BasicObject $o)
34: {
35: if (!$o instanceof TraceFrameObject) {
36: return;
37: }
38:
39: if (!empty($o->trace['file']) && !empty($o->trace['line'])) {
40: $header = '<var>'.$this->renderer->ideLink($o->trace['file'], (int) $o->trace['line']).'</var> ';
41: } else {
42: $header = '<var>PHP internal call</var> ';
43: }
44:
45: if ($o->trace['class']) {
46: $header .= $this->renderer->escape($o->trace['class'].$o->trace['type']);
47: }
48:
49: if (\is_string($o->trace['function'])) {
50: $function = $this->renderer->escape($o->trace['function'].'()');
51: } else {
52: $function = $this->renderer->escape(
53: $o->trace['function']->getName().'('.$o->trace['function']->getParams().')'
54: );
55:
56: if (null !== ($url = $o->trace['function']->getPhpDocUrl())) {
57: $function = '<a href="'.$url.'" target=_blank>'.$function.'</a>';
58: }
59: }
60:
61: $header .= '<dfn>'.$function.'</dfn>';
62:
63: $children = $this->renderer->renderChildren($o);
64: $header = $this->renderer->renderHeaderWrapper($o, (bool) \strlen($children), $header);
65:
66: return '<dl>'.$header.$children.'</dl>';
67: }
68: }
69: