Issues (1165)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Renderer/Rich.php (68 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
class Kint_Renderer_Rich extends Kint_Renderer
0 ignored issues
show
Kint_Renderer_Rich does not seem to conform to the naming convention (^[A-Z][a-zA-Z0-9]*$).

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.

Loading history...
The property $object_renderers is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
The property $tab_renderers is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
The property $pre_render_sources is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
The property $access_paths is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
The property $strlen_max is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
The property $escape_types is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
The property $been_run is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
The property $plugin_objs is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
The property $mod_return is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
The property $mini_trace is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
The property $previous_caller is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
The property $file_link_format is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
The property $show_minitrace is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
The property $auto_expand is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
4
{
5
    public static $object_renderers = array(
0 ignored issues
show
$object_renderers does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
6
        'blacklist' => 'Kint_Renderer_Rich_Blacklist',
7
        'callable' => 'Kint_Renderer_Rich_Callable',
8
        'closure' => 'Kint_Renderer_Rich_Closure',
9
        'color' => 'Kint_Renderer_Rich_Color',
10
        'depth_limit' => 'Kint_Renderer_Rich_DepthLimit',
11
        'nothing' => 'Kint_Renderer_Rich_Nothing',
12
        'recursion' => 'Kint_Renderer_Rich_Recursion',
13
        'simplexml_element' => 'Kint_Renderer_Rich_SimpleXMLElement',
14
        'trace_frame' => 'Kint_Renderer_Rich_TraceFrame',
15
    );
16
    public static $tab_renderers = array(
0 ignored issues
show
$tab_renderers does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
17
        'binary' => 'Kint_Renderer_Rich_Binary',
18
        'color' => 'Kint_Renderer_Rich_ColorDetails',
19
        'docstring' => 'Kint_Renderer_Rich_Docstring',
20
        'microtime' => 'Kint_Renderer_Rich_Microtime',
21
        'source' => 'Kint_Renderer_Rich_Source',
22
        'table' => 'Kint_Renderer_Rich_Table',
23
        'timestamp' => 'Kint_Renderer_Rich_Timestamp',
24
    );
25
    public static $pre_render_sources = array(
0 ignored issues
show
$pre_render_sources does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
26
        'script' => array(
27
            array('Kint_Renderer_Rich', 'renderJs'),
28
            array('Kint_Renderer_Rich_Microtime', 'renderJs'),
29
        ),
30
        'style' => array(
31
            array('Kint_Renderer_Rich', 'renderCss'),
32
        ),
33
        'raw' => array(),
34
    );
35
36
    /**
37
     * Whether or not to render access paths.
38
     *
39
     * Access paths can become incredibly heavy with very deep and wide
40
     * structures. Given mostly public variables it will typically make
41
     * up one quarter of the output HTML size.
42
     *
43
     * If this is an unacceptably large amount and your browser is groaning
44
     * under the weight of the access paths - your first order of buisiness
45
     * should be to get a new browser. Failing that, use this to turn them off.
46
     *
47
     * @var bool
48
     */
49
    public static $access_paths = true;
0 ignored issues
show
$access_paths does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
50
51
    /**
52
     * The maximum length of a string before it is truncated.
53
     *
54
     * Falsey to disable
55
     *
56
     * @var int
57
     */
58
    public static $strlen_max = 80;
0 ignored issues
show
$strlen_max does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
59
60
    /**
61
     * Path to the CSS file to load by default.
62
     *
63
     * @var string
64
     */
65
    public static $theme = 'original.css';
66
67
    /**
68
     * Assume types and sizes don't need to be escaped.
69
     *
70
     * Turn this off if you use anything but ascii in your class names,
71
     * but it'll cause a slowdown of around 10%
72
     *
73
     * @var bool
74
     */
75
    public static $escape_types = false;
0 ignored issues
show
$escape_types does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
76
77
    protected static $been_run = false;
0 ignored issues
show
$been_run does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
78
79
    protected $plugin_objs = array();
0 ignored issues
show
$plugin_objs does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
80
    protected $mod_return = false;
0 ignored issues
show
$mod_return does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
81
    protected $callee;
82
    protected $mini_trace;
0 ignored issues
show
$mini_trace does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
83
    protected $previous_caller;
0 ignored issues
show
$previous_caller does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
84
    protected $file_link_format = false;
0 ignored issues
show
$file_link_format does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
85
    protected $show_minitrace = true;
0 ignored issues
show
$show_minitrace does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
86
    protected $auto_expand = false;
0 ignored issues
show
$auto_expand does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
87
88
    public function __construct(array $params = array())
89
    {
90
        parent::__construct($params);
91
92
        $params += array(
93
            'modifiers' => array(),
94
            'minitrace' => array(),
95
            'callee' => null,
96
            'caller' => null,
97
        );
98
99
        $this->callee = $params['callee'];
100
        $this->mini_trace = $params['minitrace'];
101
        $this->previous_caller = $params['caller'];
102
103
        if (isset($params['settings']['return'])) {
104
            $this->mod_return = $params['settings']['return'];
105
        }
106
107
        if (isset($params['settings']['file_link_format'])) {
108
            $this->file_link_format = $params['settings']['file_link_format'];
109
        }
110
111
        if (empty($params['settings']['display_called_from'])) {
112
            $this->show_minitrace = false;
113
        }
114
115
        if (!empty($params['settings']['expanded'])) {
116
            $this->auto_expand = true;
117
        }
118
    }
119
120
    public function render(Kint_Object $o)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
Comprehensibility introduced by
Avoid variables with short names like $o. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
121
    {
122 View Code Duplication
        if ($plugin = $this->getPlugin(self::$object_renderers, $o->hints)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
123
            if (strlen($output = $plugin->render($o))) {
124
                return $output;
125
            }
126
        }
127
128
        $children = $this->renderChildren($o);
129
        $header = $this->renderHeaderWrapper($o, (bool) strlen($children), $this->renderHeader($o));
130
131
        return '<dl>'.$header.$children.'</dl>';
132
    }
133
134
    public function renderHeaderWrapper(Kint_Object $o, $has_children, $contents)
0 ignored issues
show
$has_children does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
Comprehensibility introduced by
Avoid variables with short names like $o. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
Coding Style Naming introduced by
The parameter $has_children is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
135
    {
136
        $out = '<dt';
137
138
        if ($has_children) {
0 ignored issues
show
$has_children does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
139
            $out .= ' class="kint-parent';
140
141
            if ($this->auto_expand) {
142
                $out .= ' kint-show';
143
            }
144
145
            $out .= '"';
146
        }
147
148
        $out .= '>';
149
150 View Code Duplication
        if (self::$access_paths && $o->depth > 0 && $ap = $o->getAccessPath()) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Comprehensibility introduced by
Avoid variables with short names like $ap. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
151
            $out .= '<span class="kint-access-path-trigger" title="Show access path">&rlarr;</span>';
152
        }
153
154
        if ($has_children) {
0 ignored issues
show
$has_children does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
155
            $out .= '<span class="kint-popup-trigger" title="Open in new window">&rarr;</span><nav></nav>';
156
        }
157
158
        $out .= $contents;
159
160
        if (!empty($ap)) {
161
            $out .= '<div class="access-path">'.$this->escape($ap).'</div>';
162
        }
163
164
        return $out.'</dt>';
165
    }
166
167
    public function renderHeader(Kint_Object $o)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
168
    {
169
        $output = '';
170
171
        if (($s = $o->getModifiers()) !== null) {
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $s. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
172
            $output .= '<var>'.$s.'</var> ';
173
        }
174
175
        if (($s = $o->getName()) !== null) {
176
            $output .= '<dfn>'.$this->escape($s).'</dfn> ';
177
178
            if ($s = $o->getOperator()) {
179
                $output .= $this->escape($s, 'ASCII').' ';
0 ignored issues
show
'ASCII' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
180
            }
181
        }
182
183
        if (($s = $o->getType()) !== null) {
184
            if (self::$escape_types) {
185
                $s = $this->escape($s);
186
            }
187
188
            if ($o->reference) {
189
                $s = '&amp;'.$s;
190
            }
191
192
            $output .= '<var>'.$s.'</var> ';
193
        }
194
195
        if (($s = $o->getSize()) !== null) {
196
            if (self::$escape_types) {
197
                $s = $this->escape($s);
198
            }
199
            $output .= '('.$s.') ';
200
        }
201
202
        if (($s = $o->getValueShort()) !== null) {
203
            $s = preg_replace('/\s+/', ' ', $s);
204
205
            if (self::$strlen_max && Kint_Object_Blob::strlen($s) > self::$strlen_max) {
206
                $s = substr($s, 0, self::$strlen_max).'...';
207
            }
208
            $output .= $this->escape($s);
209
        }
210
211
        return trim($output);
212
    }
213
214
    public function renderChildren(Kint_Object $o)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
215
    {
216
        $contents = array();
217
        $tabs = array();
218
219
        foreach ($o->getRepresentations() as $rep) {
220
            $result = $this->renderTab($o, $rep);
221
            if (strlen($result)) {
222
                $contents[] = $result;
223
                $tabs[] = $rep;
224
            }
225
        }
226
227
        if (empty($tabs)) {
228
            return '';
229
        }
230
231
        $output = '<dd>';
232
233
        if (count($tabs) === 1 && $tabs[0]->labelIsImplicit()) {
234
            $output .= reset($contents);
235
        } else {
236
            $output .= '<ul class="kint-tabs">';
237
238
            foreach ($tabs as $i => $tab) {
239
                if ($i === 0) {
240
                    $output .= '<li class="kint-active-tab">';
241
                } else {
242
                    $output .= '<li>';
243
                }
244
245
                $output .= $this->escape($tab->getLabel()).'</li>';
246
            }
247
248
            $output .= '</ul><ul>';
249
250
            foreach ($contents as $tab) {
251
                $output .= '<li>'.$tab.'</li>';
252
            }
253
254
            $output .= '</ul>';
255
        }
256
257
        return $output.'</dd>';
258
    }
259
260
    protected function renderTab(Kint_Object $o, Kint_Object_Representation $rep)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
Comprehensibility introduced by
Avoid variables with short names like $o. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
261
    {
262 View Code Duplication
        if ($plugin = $this->getPlugin(self::$tab_renderers, $rep->hints)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
263
            if (strlen($output = $plugin->render($rep))) {
264
                return $output;
265
            }
266
        }
267
268
        if (is_array($rep->contents)) {
269
            $output = '';
270
            foreach ($rep->contents as $obj) {
271
                $output .= $this->render($obj);
272
            }
273
274
            return $output;
275
        } elseif (is_string($rep->contents)) {
276
            $show_contents = false;
0 ignored issues
show
$show_contents does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
277
278
            // If it is the value representation of a string and its whitespace
279
            // was truncated in the header, always display the full string
280
            if ($o->type !== 'string' || $o->value !== $rep) {
281
                $show_contents = true;
0 ignored issues
show
$show_contents does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
282
            } elseif (preg_match('/(:?[\r\n\t\f\v]| {2})/', $rep->contents)) {
283
                $show_contents = true;
0 ignored issues
show
$show_contents does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
284
            } elseif (self::$strlen_max && Kint_Object_Blob::strlen($rep->contents) > self::$strlen_max) {
285
                $show_contents = true;
0 ignored issues
show
$show_contents does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
286
            }
287
288
            if ($o->type === 'string' && $o->value === $rep && $o->encoding === false) {
0 ignored issues
show
The property encoding does not seem to exist in Kint_Object.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
289
                $show_contents = false;
0 ignored issues
show
$show_contents does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
290
            }
291
292
            if ($show_contents) {
0 ignored issues
show
$show_contents does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
293
                return '<pre>'.$this->escape($rep->contents)."\n</pre>";
294
            }
295
        } elseif ($rep->contents instanceof Kint_Object) {
296
            return $this->render($rep->contents);
297
        }
298
299
        return;
300
    }
301
302
    protected static function renderJs()
303
    {
304
        return file_get_contents(KINT_DIR.'/resources/compiled/rich.js');
305
    }
306
307 View Code Duplication
    protected static function renderCss()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
308
    {
309
        if (file_exists(KINT_DIR.'/resources/compiled/'.self::$theme)) {
310
            return file_get_contents(KINT_DIR.'/resources/compiled/'.self::$theme);
311
        } else {
312
            return file_get_contents(self::$theme);
313
        }
314
    }
315
316 View Code Duplication
    public function preRender()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
317
    {
318
        $output = '';
319
320
        if (!self::$been_run || $this->mod_return) {
321
            foreach (self::$pre_render_sources as $type => $values) {
322
                $contents = '';
323
                foreach ($values as $v) {
324
                    if (is_callable($v)) {
325
                        $contents .= call_user_func($v, $this);
326
                    } elseif (is_string($v)) {
327
                        $contents .= $v;
328
                    }
329
                }
330
331
                if (!strlen($contents)) {
332
                    continue;
333
                }
334
335
                switch ($type) {
336
                    case 'script':
337
                        $output .= '<script class="kint-script">'.$contents.'</script>';
338
                        break;
339
                    case 'style':
340
                        $output .= '<style class="kint-style">'.$contents.'</style>';
341
                        break;
342
                    default:
343
                        $output .= $contents;
344
                }
345
            }
346
347
            if (!$this->mod_return) {
348
                self::$been_run = true;
349
            }
350
        }
351
352
        return $output.'<div class="kint-rich">';
353
    }
354
355
    public function postRender()
356
    {
357
        if (!$this->show_minitrace) {
358
            return '</div>';
359
        }
360
361
        $output = '<footer>';
362
        $output .= '<span class="kint-popup-trigger" title="Open in new window">&rarr;</span> ';
363
364
        if (isset($this->callee['file'])) {
365
            if (!empty($this->mini_trace)) {
366
                $output .= '<nav></nav>';
367
            }
368
369
            $output .= 'Called from '.$this->ideLink($this->callee['file'], $this->callee['line']);
370
        }
371
372
        $caller = '';
373
374
        if (isset($this->previous_caller['class'])) {
375
            $caller .= $this->previous_caller['class'];
376
        }
377
        if (isset($this->previous_caller['type'])) {
378
            $caller .= $this->previous_caller['type'];
379
        }
380 View Code Duplication
        if (isset($this->previous_caller['function'])
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
381
            && !in_array($this->previous_caller['function'], array('include', 'include_once', 'require', 'require_once'))
382
        ) {
383
            $caller .= $this->previous_caller['function'].'()';
384
        }
385
386
        if ($caller) {
387
            $output .= ' ['.$caller.']';
388
        }
389
390
        if (!empty($this->mini_trace)) {
391
            $output .= '<ol>';
392
            foreach ($this->mini_trace as $step) {
393
                $output .= '<li>'.$this->ideLink($step['file'], $step['line']); // closing tag not required
394
                if (isset($step['function'])
395
                    && !in_array($step['function'], array('include', 'include_once', 'require', 'require_once'))
396
                ) {
397
                    $output .= ' [';
398
                    if (isset($step['class'])) {
399
                        $output .= $step['class'];
400
                    }
401
                    if (isset($step['type'])) {
402
                        $output .= $step['type'];
403
                    }
404
                    $output .= $step['function'].'()]';
405
                }
406
            }
407
            $output .= '</ol>';
408
        }
409
410
        $output .= '</footer></div>';
411
412
        return $output;
413
    }
414
415 View Code Duplication
    public function escape($string, $encoding = false)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
416
    {
417
        if ($encoding === false) {
418
            $encoding = Kint_Object_Blob::detectEncoding($string);
0 ignored issues
show
Consider using a different name than the parameter $encoding. This often makes code more readable.
Loading history...
419
        }
420
421
        $original_encoding = $encoding;
0 ignored issues
show
$original_encoding does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
422
423
        if ($encoding === false || $encoding === 'ASCII') {
424
            $encoding = 'UTF-8';
0 ignored issues
show
Consider using a different name than the parameter $encoding. This often makes code more readable.
Loading history...
425
        }
426
427
        $string = htmlspecialchars($string, ENT_NOQUOTES, $encoding);
0 ignored issues
show
Consider using a different name than the parameter $string. This often makes code more readable.
Loading history...
428
429
        // this call converts all non-ASCII characters into numeirc htmlentities
430
        if (extension_loaded('mbstring') && $original_encoding !== 'ASCII') {
0 ignored issues
show
$original_encoding does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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.

Loading history...
431
            $string = mb_encode_numericentity($string, array(0x80, 0xffff, 0, 0xffff), $encoding);
0 ignored issues
show
Consider using a different name than the parameter $string. This often makes code more readable.
Loading history...
432
        }
433
434
        return $string;
435
    }
436
437 View Code Duplication
    protected function getPlugin(array $plugins, array $hints)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
438
    {
439
        if ($plugins = $this->matchPlugins($plugins, $hints)) {
0 ignored issues
show
Consider using a different name than the parameter $plugins. This often makes code more readable.
Loading history...
440
            $plugin = end($plugins);
441
442
            if (!isset($this->plugin_objs[$plugin])) {
443
                $this->plugin_objs[$plugin] = new $plugin($this);
444
            }
445
446
            return $this->plugin_objs[$plugin];
447
        }
448
    }
449
450 View Code Duplication
    protected function ideLink($file, $line)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
451
    {
452
        $shortenedPath = $this->escape(Kint::shortenPath($file));
453
        if (!$this->file_link_format) {
454
            return $shortenedPath.':'.$line;
455
        }
456
457
        $ideLink = Kint::getIdeLink($file, $line);
458
        $class = (strpos($ideLink, 'http://') === 0) ? 'class="kint-ide-link" ' : '';
459
460
        return "<a {$class}href=\"{$ideLink}\">{$shortenedPath}:{$line}</a>";
461
    }
462
}
463