1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kint\Renderer; |
4
|
|
|
|
5
|
|
|
use Kint\Object\BasicObject; |
6
|
|
|
use Kint\Object\InstanceObject; |
7
|
|
|
|
8
|
|
|
abstract class Renderer |
|
|
|
|
9
|
|
|
{ |
10
|
|
|
const SORT_NONE = 0; |
11
|
|
|
const SORT_VISIBILITY = 1; |
12
|
|
|
const SORT_FULL = 2; |
13
|
|
|
|
14
|
|
|
protected $parameters; |
15
|
|
|
|
16
|
|
|
abstract public function render(BasicObject $o); |
|
|
|
|
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* It's a constructor. It constructs. |
20
|
|
|
* |
21
|
|
|
* @param array $parameters Array with initial kint state information |
22
|
|
|
*/ |
23
|
|
|
public function __construct(array $parameters) |
24
|
|
|
{ |
25
|
|
|
$this->parameters = $parameters; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Returns the first compatible plugin available. |
30
|
|
|
* |
31
|
|
|
* @param array $plugins Array of hints to class strings |
32
|
|
|
* @param array $hints Array of object hints |
33
|
|
|
* |
34
|
|
|
* @return array Array of hints to class strings filtered and sorted by object hints |
35
|
|
|
*/ |
36
|
|
|
public function matchPlugins(array $plugins, array $hints) |
37
|
|
|
{ |
38
|
|
|
$out = array(); |
39
|
|
|
|
40
|
|
|
foreach ($hints as $key) { |
41
|
|
|
if (isset($plugins[$key])) { |
42
|
|
|
$out[$key] = $plugins[$key]; |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
return $out; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function parserPlugins(array $plugins) |
50
|
|
|
{ |
51
|
|
|
return $plugins; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function preRender() |
55
|
|
|
{ |
56
|
|
|
return ''; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function postRender() |
60
|
|
|
{ |
61
|
|
|
return ''; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public static function sortPropertiesFull(BasicObject $a, BasicObject $b) |
|
|
|
|
65
|
|
|
{ |
66
|
|
|
$sort = BasicObject::sortByAccess($a, $b); |
67
|
|
|
if ($sort) { |
68
|
|
|
return $sort; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
$sort = BasicObject::sortByName($a, $b); |
72
|
|
|
if ($sort) { |
73
|
|
|
return $sort; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
return InstanceObject::sortByHierarchy($a->owner_class, $b->owner_class); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Sorts an array of BasicObject. |
81
|
|
|
* |
82
|
|
|
* @param BasicObject[] $contents Object properties to sort |
83
|
|
|
* @param int $sort |
84
|
|
|
* |
85
|
|
|
* @return BasicObject[] |
86
|
|
|
*/ |
87
|
|
|
public static function sortProperties(array $contents, $sort) |
88
|
|
|
{ |
89
|
|
|
switch ($sort) { |
90
|
|
|
case self::SORT_VISIBILITY: |
91
|
|
|
$containers = array( |
92
|
|
|
BasicObject::ACCESS_PUBLIC => array(), |
93
|
|
|
BasicObject::ACCESS_PROTECTED => array(), |
94
|
|
|
BasicObject::ACCESS_PRIVATE => array(), |
95
|
|
|
BasicObject::ACCESS_NONE => array(), |
96
|
|
|
); |
97
|
|
|
|
98
|
|
|
foreach ($contents as $item) { |
99
|
|
|
$containers[$item->access][] = $item; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
return call_user_func_array('array_merge', $containers); |
103
|
|
|
case self::SORT_FULL: |
104
|
|
|
usort($contents, array('Kint\\Renderer\\Renderer', 'sortPropertiesFull')); |
105
|
|
|
// fall through |
106
|
|
|
default: |
107
|
|
|
return $contents; |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|
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.