Skip to content

Commit 3c49968

Browse files
committed
initial commit
1 parent 1306d2b commit 3c49968

24 files changed

+2561
-0
lines changed

config.default.php

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<?php
2+
isset( $GLOBALS['_kint_settings'] ) or $GLOBALS['_kint_settings'] = array();
3+
$_kintSettings = &$GLOBALS['_kint_settings'];
4+
5+
6+
/** @var bool if set to false, kint will become silent, same as Kint::enabled(false) */
7+
$_kintSettings['enabled'] = true;
8+
9+
10+
/**
11+
* @var array custom added data dumpers
12+
*
13+
* format:
14+
* array(
15+
* "datatypes class name" => < mixed options >
16+
* )
17+
*/
18+
$_kintSettings['customDataTypes'] = array(
19+
/**
20+
* @var string one of three values: 'off', 'non-scalar', 'on'. When a passed array is detected to contain tabular data,
21+
* it can be displayed as a table instead of vertically. Note, the detection algorithms are quite naive as they check
22+
* only the first couple of rows for the tabular data pattern. However it will never stop any piece of data from showing
23+
* up even if the array is not tabular after all. In the worst case scenario, it will look a little weird.
24+
*
25+
* - off: will never use the tabular display
26+
* - non-scalar: will display in tabular view only if the table contains strings and numeric values (no arrays, objects)
27+
* - on: will display all detected tabular data in a table
28+
*/
29+
'tabularArray' => 'non-scalar',
30+
'splFileInfo' => null,
31+
'json' => null,
32+
);
33+
34+
35+
/**
36+
* @var bool whether to display where kint was called from
37+
*/
38+
$_kintSettings['displayCalledFrom'] = true;
39+
40+
/**
41+
* @var callback filter/skip display of trace entries
42+
*
43+
* @param string $file filename where the function was called
44+
* @param int $line [OPTIONAL] the line number in the file (not applicable when used in resource dumps)
45+
*
46+
* @return string html - escaped string
47+
*
48+
* [!] EXAMPLE:
49+
*
50+
* $_kintSettings['pathDisplayCallback'] = function( $file, $line = NULL ) {
51+
* $shortenedName = strpos( $file, $_SERVER['DOCUMENT_ROOT'] ) === 0
52+
* ? 'DOCUMENT_ROOT' . DIRECTORY_SEPARATOR . substr( $file, strlen( $_SERVER['DOCUMENT_ROOT'] ) )
53+
* : $file;
54+
*
55+
* if ( !$line ) { // means this is called from resource type dump
56+
* return $shortenedName;
57+
* }
58+
*
59+
* return "<u><a class=\"kint-ide-link\" href=\"http://localhost:8091/?message={$file}:{$line}\">"
60+
* . $shortenedName
61+
* . "</a></u> line <i>{$line}</i>";
62+
* };
63+
*/
64+
$_kintSettings['pathDisplayCallback'] = null;
65+
66+
67+
/**
68+
* @var callback|null
69+
*
70+
* @param array $step each step of the backtrace is passed to this callback to clean it up or skip it entirely
71+
*
72+
* @return array|null you can return null if you want to bypass outputting this step
73+
*
74+
* [!] EXAMPLE:
75+
*
76+
* $_kintSettings['traceCleanupCallback'] = function( $traceStep ) {
77+
* if ( isset( $traceStep['class'] ) && strtolower( $traceStep['class'] ) === 'errorHandler' ) {
78+
* return null;
79+
* }
80+
*
81+
* if ( isset( $traceStep['function'] ) && strtolower( $traceStep['function'] ) === '__tostring' ) {
82+
* $traceStep['function'] = "[object converted to string]";
83+
* }
84+
*
85+
* return $traceStep;
86+
* };
87+
*/
88+
$_kintSettings['traceCleanupCallback'] = null;
89+
90+
91+
/** @var int max length of string before it is truncated and displayed separately in full */
92+
$_kintSettings['maxStrLength'] = 60;
93+
94+
95+
/** @var bool whether to add a right colored gutter based on the location of the call to the dump */
96+
$_kintSettings['colorCodeLoops'] = true;
97+
98+
99+
/** @var int max array/object levels to go deep, if zero no limits are applied */
100+
$_kintSettings['maxLevels'] = 5;
101+
102+
103+
/** @var bool whether dumped indexed arrays that are in ideal sequence are displayed */
104+
$_kintSettings['hideSequentialKeys'] = true;
105+
106+
107+
/** @var string|null if set, prepends a <head> tag with appropriate meta charset value */
108+
$_kintSettings['charset'] = null;
109+
110+
111+
/**
112+
* @var callback filters array/object keys before outputting; return false if you do not wish to see it in the output
113+
*
114+
* @param string $key the key being output
115+
* @param mixed $val the contents of the dumped element in case you need it
116+
*
117+
* @return bool return false to skip displaying
118+
*
119+
* [!] EXAMPLE:
120+
*
121+
* $_kintSettings['keyFilterCallback'] = function( $key, $val ) {
122+
* if ( preg_match( '#_mt$#', $key ) ) {
123+
* return false;
124+
* }
125+
*
126+
* if ( $val === '--testing--' ) {
127+
* return false;
128+
* }
129+
*
130+
* // no need to return true to continue output
131+
* };
132+
*
133+
*/
134+
$_kintSettings['keyFilterCallback'] = null;
135+
136+
137+
/** @var bool only set to true if you want to develop kint and know what you're doing */
138+
$_kintSettings['devel'] = true;
139+
140+
unset( $_kintSettings );

config.php

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?php
2+
isset( $GLOBALS['_kint_settings'] ) or $GLOBALS['_kint_settings'] = array();
3+
$_kintSettings = &$GLOBALS['_kint_settings'];
4+
5+
6+
/** @var bool if set to false, kint will become silent, same as Kint::enabled(false) */
7+
$_kintSettings['enabled'] = true;
8+
9+
10+
/**
11+
* @var bool whether to display where kint was called from
12+
*/
13+
$_kintSettings['displayCalledFrom'] = true;
14+
15+
16+
17+
/**
18+
* @var callback filter/skip display of trace entries
19+
*
20+
* @param string $file filename where the function was called
21+
* @param int $line [OPTIONAL] the line number in the file (not applicable when used in resource dumps)
22+
*
23+
* @return string html - escaped string
24+
*
25+
* [!] EXAMPLE:
26+
*
27+
* $_kintSettings['pathDisplayCallback'] = function( $file, $line = NULL ) {
28+
* $shortenedName = strpos( $file, $_SERVER['DOCUMENT_ROOT'] ) === 0
29+
* ? 'DOCUMENT_ROOT' . DIRECTORY_SEPARATOR . substr( $file, strlen( $_SERVER['DOCUMENT_ROOT'] ) )
30+
* : $file;
31+
*
32+
* if ( !$line ) { // means this is called from resource type dump
33+
* return $shortenedName;
34+
* }
35+
*
36+
* return "<u><a class=\"kint-ide-link\" href=\"http://localhost:8091/?message={$file}:{$line}\">"
37+
* . $shortenedName
38+
* . "</a></u> line <i>{$line}</i>";
39+
* };
40+
*/
41+
$_kintSettings['pathDisplayCallback'] = "_kintLine";
42+
43+
44+
/**
45+
* @var callback|null
46+
*
47+
* @param array $step each step of the backtrace is passed to this callback to clean it up or skip it entirely
48+
*
49+
* @return array|null you can return null if you want to bypass outputting this step
50+
*
51+
* [!] EXAMPLE:
52+
*
53+
* $_kintSettings['traceCleanupCallback'] = function( $traceStep ) {
54+
* if ( isset( $traceStep['class'] ) && strtolower( $traceStep['class'] ) === 'errorHandler' ) {
55+
* return null;
56+
* }
57+
*
58+
* if ( isset( $traceStep['function'] ) && strtolower( $traceStep['function'] ) === '__tostring' ) {
59+
* $traceStep['function'] = "[object converted to string]";
60+
* }
61+
*
62+
* return $traceStep;
63+
* };
64+
*/
65+
$_kintSettings['traceCleanupCallback'] = null;
66+
67+
68+
/** @var int max length of string before it is truncated and displayed separately in full */
69+
$_kintSettings['maxStrLength'] = 60;
70+
71+
72+
/** @var bool whether to add a right colored gutter based on the location of the call to the dump */
73+
$_kintSettings['colorCodeLoops'] = true;
74+
75+
76+
/** @var int max array/object levels to go deep, if zero no limits are applied */
77+
$_kintSettings['maxLevels'] = 5;
78+
79+
80+
/** @var bool whether dumped indexed arrays that are in ideal sequence are displayed */
81+
$_kintSettings['hideSequentialKeys'] = true;
82+
83+
84+
/** @var string|null if set, prepends a <head> tag with appropriate meta charset value */
85+
$_kintSettings['charset'] = null;
86+
87+
88+
/**
89+
* @var callback filters array/object keys before outputting; return false if you do not wish to see it in the output.
90+
* NOTE, object member keys will be passed here too. The object is first cast to array so read this:
91+
* http://www.php.net/manual/en/language.types.array.php#language.types.array.casting
92+
*
93+
* @param string $key the key being output
94+
* @param mixed $val the contents of the dumped element in case you need it
95+
*
96+
* @return bool return false to skip displaying
97+
*
98+
* [!] EXAMPLE:
99+
*
100+
* $_kintSettings['keyFilterCallback'] = function( $key, $val ) {
101+
* if ( preg_match( '#_mt$#', $key ) ) {
102+
* return false;
103+
* }
104+
*
105+
* if ( $val === '--testing--' ) {
106+
* return false;
107+
* }
108+
*
109+
* // no need to return true to continue output
110+
* };
111+
*
112+
*/
113+
$_kintSettings['keyFilterCallback'] = null;
114+
115+
116+
/** @var bool only set to true if you want to develop kint and know what you're doing */
117+
$_kintSettings['devel'] = true;
118+
119+
unset( $_kintSettings );
120+
121+
122+
/**
123+
* This is used with PHPstorm and its remotecall plugin to click file links in browser that will open the IDE in the
124+
* appropriate place in code.
125+
*
126+
* @param string $file
127+
* @param int $line
128+
*
129+
* @return string
130+
*/
131+
function _kintLine( $file, $line = NULL )
132+
{
133+
$shortenedName = error::debug_path( $file );
134+
135+
if ( !$line ) { // means this is called from resource type dump
136+
return $shortenedName;
137+
}
138+
139+
140+
return "<u><a class=\"kint-ide-link\" href=\"http://localhost:8091/?message={$file}:{$line}\">"
141+
. $shortenedName
142+
. "</a></u> line <i>{$line}</i>";
143+
}

decorators/concise.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
class kintConciseDecorator extends Kint
3+
{
4+
/**
5+
* output:
6+
*
7+
* [value]
8+
*
9+
* value [title="[access] [name] [operator *] [subtype] [size] "]
10+
* OR
11+
* type [title="[access] [name] type [operator *] [subtype] [size] "]
12+
* <ul>extendedValue
13+
*
14+
* @param kintParser $kintVar
15+
*
16+
* @return string
17+
*/
18+
public static function decorate( kintParser $kintVar )
19+
{
20+
if ( is_array( $kintVar->value ) || $kintVar->extendedValue !== null ) {
21+
return self::$_richDecorator->decorate( $kintVar );
22+
}
23+
24+
$output = '<span title="';
25+
26+
if ( $kintVar->access !== null ) {
27+
$output .= $kintVar->access . " ";
28+
}
29+
30+
if ( $kintVar->name !== null ) {
31+
$output .= $kintVar->name . " ";
32+
}
33+
34+
if ( $kintVar->type !== null ) {
35+
$output .= $kintVar->type;
36+
if ( $kintVar->subtype !== null ) {
37+
$output .= " " . $kintVar->subtype;
38+
}
39+
$output .= " ";
40+
}
41+
42+
if ( $kintVar->operator !== null ) {
43+
$output .= $kintVar->operator . "";
44+
}
45+
46+
if ( $kintVar->size !== null ) {
47+
$output .= "(" . $kintVar->size . ") ";
48+
}
49+
50+
$output .= '">' . $kintVar->value . '</span>';
51+
52+
return $output;
53+
}
54+
}

decorators/plain.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
class kintPlainDecorator extends Kint
3+
{
4+
/**
5+
* output:
6+
*
7+
* [access *] [name] type [operator *] [subtype] [size] [value]
8+
*
9+
* @param kintParser $kintVar
10+
*
11+
* @return string
12+
*/
13+
protected static function decorate( $kintVar )
14+
{
15+
}
16+
17+
18+
/**
19+
* produces css and js required for display. May be called multiple times, will only produce output once per
20+
* pageload or until `-` or `@` modifier is used
21+
*
22+
* @return string
23+
*/
24+
protected static function _css()
25+
{
26+
}
27+
28+
29+
30+
/**
31+
* called for each dump, opens the html tag
32+
*
33+
* @param array $callee caller information taken from debug backtrace
34+
*
35+
* @return string
36+
*/
37+
protected static function _wrapStart( $callee )
38+
{
39+
}
40+
41+
42+
/**
43+
* closes Kint::_wrapStart() started html tags and displays callee information
44+
*
45+
* @param array $callee caller information taken from debug backtrace
46+
* @param array $prevCaller previous caller information taken from debug backtrace
47+
*
48+
* @return string
49+
*/
50+
private static function _wrapEnd( $callee, $prevCaller )
51+
{
52+
}
53+
54+
}

0 commit comments

Comments
 (0)