1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class Kint_Parser_Iterator extends Kint_Parser_Plugin |
|
|
|
|
4
|
|
|
{ |
5
|
|
|
/** |
6
|
|
|
* List of classes and interfaces to blacklist. |
7
|
|
|
* |
8
|
|
|
* Certain classes (Such as PDOStatement) irreversibly lose information |
9
|
|
|
* when traversed. Others are just huge. Either way, put them in here |
10
|
|
|
* and you won't have to worry about them being parsed. |
11
|
|
|
* |
12
|
|
|
* @var array |
13
|
|
|
*/ |
14
|
|
|
public static $blacklist = array( |
15
|
|
|
'PDOStatement', |
16
|
|
|
'DOMNodeList', |
17
|
|
|
'DOMNamedNodeMap', |
18
|
|
|
); |
19
|
|
|
|
20
|
|
|
public function getTypes() |
21
|
|
|
{ |
22
|
|
|
return array('object'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function getTriggers() |
|
|
|
|
26
|
|
|
{ |
27
|
|
|
return Kint_Parser::TRIGGER_SUCCESS; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function parse(&$var, Kint_Object &$o, $trigger) |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
if (!$var instanceof Traversable) { |
33
|
|
|
return; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
foreach (self::$blacklist as $class) { |
37
|
|
|
if ($var instanceof $class) { |
38
|
|
|
$b = new Kint_Object(); |
39
|
|
|
$b->name = $class.' Iterator Contents'; |
40
|
|
|
$b->access_path = 'iterator_to_array('.$o->access_path.', true)'; |
41
|
|
|
$b->depth = $o->depth + 1; |
42
|
|
|
$b->hints[] = 'blacklist'; |
43
|
|
|
|
44
|
|
|
$r = new Kint_Object_Representation('Iterator'); |
45
|
|
|
$r->contents = array($b); |
46
|
|
|
|
47
|
|
|
$o->addRepresentation($r); |
48
|
|
|
|
49
|
|
|
return; |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$data = iterator_to_array($var); |
54
|
|
|
|
55
|
|
|
if ($data === false) { |
56
|
|
|
return; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
$base_obj = new Kint_Object(); |
|
|
|
|
60
|
|
|
$base_obj->depth = $o->depth; |
|
|
|
|
61
|
|
|
|
62
|
|
|
if ($o->access_path) { |
|
|
|
|
63
|
|
|
$base_obj->access_path = 'iterator_to_array('.$o->access_path.')'; |
|
|
|
|
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
$r = new Kint_Object_Representation('Iterator'); |
67
|
|
|
$r->contents = $this->parser->parse($data, $base_obj); |
|
|
|
|
68
|
|
|
$r->contents = $r->contents->value->contents; |
69
|
|
|
|
70
|
|
|
$primary = reset($o->representations); |
71
|
|
|
if ($primary && $primary === $o->value && $primary->contents === array()) { |
72
|
|
|
$o->addRepresentation($r, 0); |
73
|
|
|
} else { |
74
|
|
|
$o->addRepresentation($r); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
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.