|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Kint\Object; |
|
4
|
|
|
|
|
5
|
|
|
use Kint\Object\Representation\Representation; |
|
6
|
|
|
use Kint\Object\Representation\SourceRepresentation; |
|
7
|
|
|
use ReflectionFunction; |
|
8
|
|
|
use ReflectionMethod; |
|
9
|
|
|
|
|
10
|
|
|
class TraceFrameObject extends BasicObject |
|
11
|
|
|
{ |
|
12
|
|
|
public $trace; |
|
13
|
|
|
public $hints = array('trace_frame'); |
|
14
|
|
|
|
|
15
|
|
|
public function assignFrame(array &$frame) |
|
16
|
|
|
{ |
|
17
|
|
|
$this->trace = array( |
|
18
|
|
|
'function' => isset($frame['function']) ? $frame['function'] : null, |
|
19
|
|
|
'line' => isset($frame['line']) ? $frame['line'] : null, |
|
20
|
|
|
'file' => isset($frame['file']) ? $frame['file'] : null, |
|
21
|
|
|
'class' => isset($frame['class']) ? $frame['class'] : null, |
|
22
|
|
|
'type' => isset($frame['type']) ? $frame['type'] : null, |
|
23
|
|
|
'object' => null, |
|
24
|
|
|
'args' => null, |
|
25
|
|
|
); |
|
26
|
|
|
|
|
27
|
|
|
if ($this->trace['class'] && method_exists($this->trace['class'], $this->trace['function'])) { |
|
28
|
|
|
$func = new ReflectionMethod($this->trace['class'], $this->trace['function']); |
|
29
|
|
|
$this->trace['function'] = new MethodObject($func); |
|
30
|
|
|
} elseif (!$this->trace['class'] && function_exists($this->trace['function'])) { |
|
31
|
|
|
$func = new ReflectionFunction($this->trace['function']); |
|
32
|
|
|
$this->trace['function'] = new MethodObject($func); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
foreach ($this->value->contents as $frame_prop) { |
|
|
|
|
|
|
36
|
|
|
if ($frame_prop->name === 'object') { |
|
|
|
|
|
|
37
|
|
|
$this->trace['object'] = $frame_prop; |
|
|
|
|
|
|
38
|
|
|
$this->trace['object']->name = null; |
|
39
|
|
|
$this->trace['object']->operator = BasicObject::OPERATOR_NONE; |
|
40
|
|
|
} |
|
41
|
|
|
if ($frame_prop->name === 'args') { |
|
|
|
|
|
|
42
|
|
|
$this->trace['args'] = $frame_prop->value->contents; |
|
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
if ($this->trace['function'] instanceof MethodObject) { |
|
45
|
|
|
foreach (array_values($this->trace['function']->parameters) as $param) { |
|
46
|
|
|
if (isset($this->trace['args'][$param->position])) { |
|
47
|
|
|
$this->trace['args'][$param->position]->name = $param->getName(); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$this->clearRepresentations(); |
|
55
|
|
|
|
|
56
|
|
|
if (isset($this->trace['file'], $this->trace['line']) && is_readable($this->trace['file'])) { |
|
57
|
|
|
$this->addRepresentation(new SourceRepresentation($this->trace['file'], $this->trace['line'])); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
if ($this->trace['args']) { |
|
61
|
|
|
$args = new Representation('Arguments'); |
|
62
|
|
|
$args->contents = $this->trace['args']; |
|
63
|
|
|
$this->addRepresentation($args); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
if ($this->trace['object']) { |
|
67
|
|
|
$callee = new Representation('object'); |
|
68
|
|
|
$callee->label = 'Callee object ['.$this->trace['object']->classname.']'; |
|
69
|
|
|
$callee->contents[] = $this->trace['object']; |
|
70
|
|
|
$this->addRepresentation($callee); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.