1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class Kint_Parser_Closure extends Kint_Parser_Plugin |
|
|
|
|
4
|
|
|
{ |
5
|
|
|
public function getTypes() |
6
|
|
|
{ |
7
|
|
|
if (KINT_PHP53) { |
8
|
|
|
return array('object'); |
9
|
|
|
} else { |
10
|
|
|
return array(); |
11
|
|
|
} |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
public function getTriggers() |
|
|
|
|
15
|
|
|
{ |
16
|
|
|
if (KINT_PHP53) { |
17
|
|
|
return Kint_Parser::TRIGGER_SUCCESS; |
18
|
|
|
} else { |
19
|
|
|
return Kint_Parser::TRIGGER_NONE; |
20
|
|
|
} |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function parse(&$var, Kint_Object &$o, $trigger) |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
if (!$var instanceof Closure) { |
26
|
|
|
return; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
$o = $o->transplant(new Kint_Object_Closure()); |
30
|
|
|
$o->removeRepresentation('properties'); |
31
|
|
|
|
32
|
|
|
$closure = new ReflectionFunction($var); |
33
|
|
|
|
34
|
|
|
$o->filename = $closure->getFileName(); |
|
|
|
|
35
|
|
|
$o->startline = $closure->getStartLine(); |
|
|
|
|
36
|
|
|
|
37
|
|
|
foreach ($closure->getParameters() as $param) { |
38
|
|
|
$o->parameters[] = new Kint_Object_Parameter($param); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
$p = new Kint_Object_Representation('Parameters'); |
|
|
|
|
42
|
|
|
$p->contents = &$o->parameters; |
43
|
|
|
$o->addRepresentation($p, 0); |
44
|
|
|
|
45
|
|
|
$statics = array(); |
46
|
|
|
|
47
|
|
|
if (method_exists($closure, 'getClosureThis') && $v = $closure->getClosureThis()) { |
|
|
|
|
48
|
|
|
$statics = array('this' => $v); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
if (count($statics = $statics + $closure->getStaticVariables())) { |
52
|
|
|
$statics_parsed = array(); |
|
|
|
|
53
|
|
|
|
54
|
|
|
foreach ($statics as $name => &$static) { |
55
|
|
|
$obj = Kint_Object::blank('$'.$name); |
56
|
|
|
$obj->depth = $o->depth + 1; |
57
|
|
|
$statics_parsed[$name] = $this->parser->parse($static, $obj); |
|
|
|
|
58
|
|
|
if ($statics_parsed[$name]->value === null) { |
|
|
|
|
59
|
|
|
$statics_parsed[$name]->access_path = null; |
|
|
|
|
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$r = new Kint_Object_Representation('Uses'); |
|
|
|
|
64
|
|
|
$r->contents = $statics_parsed; |
|
|
|
|
65
|
|
|
$o->addRepresentation($r, 0); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
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.