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/Text.php (41 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_Text extends Kint_Renderer
0 ignored issues
show
Kint_Renderer_Text 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 $parser_plugin_whitelist 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 $default_width 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 $default_indent 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 $header_width 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 $indent_width 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 $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 $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...
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_Text_Blacklist',
7
        'depth_limit' => 'Kint_Renderer_Text_DepthLimit',
8
        'nothing' => 'Kint_Renderer_Text_Nothing',
9
        'recursion' => 'Kint_Renderer_Text_Recursion',
10
        'trace' => 'Kint_Renderer_Text_Trace',
11
    );
12
13
    /**
14
     * Parser plugins must be instanceof one of these or
15
     * it will be removed for performance reasons.
16
     */
17
    public static $parser_plugin_whitelist = array(
0 ignored issues
show
$parser_plugin_whitelist 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 Naming introduced by
The variable name $parser_plugin_whitelist exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
18
        'Kint_Parser_Blacklist',
19
        'Kint_Parser_Stream',
20
        'Kint_Parser_Trace',
21
    );
22
23
    /**
24
     * The maximum length of a string before it is truncated.
25
     *
26
     * Falsey to disable
27
     *
28
     * @var int
29
     */
30
    public static $strlen_max = 0;
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...
31
32
    /**
33
     * The default width of the terminal for headers.
34
     *
35
     * @var int
36
     */
37
    public static $default_width = 80;
0 ignored issues
show
$default_width 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...
38
39
    /**
40
     * Indentation width.
41
     *
42
     * @var int
43
     */
44
    public static $default_indent = 4;
0 ignored issues
show
$default_indent 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...
45
46
    /**
47
     * Decorate the header and footer.
48
     *
49
     * @var bool
50
     */
51
    public static $decorations = true;
52
53
    public $header_width = 80;
0 ignored issues
show
$header_width 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...
54
    public $indent_width = 4;
0 ignored issues
show
$indent_width 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...
55
56
    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...
57
    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...
58
    protected $callee;
59
    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...
60
61
    public function __construct(array $params = array())
62
    {
63
        parent::__construct($params);
64
65
        $params += array(
66
            'callee' => null,
67
            'caller' => null,
68
        );
69
70
        $this->callee = $params['callee'];
71
        $this->previous_caller = $params['caller'];
72
        $this->show_minitrace = !empty($params['settings']['display_called_from']);
73
        $this->header_width = self::$default_width;
74
        $this->indent_width = self::$default_indent;
75
    }
76
77
    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...
78
    {
79 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...
80
            if (strlen($output = $plugin->render($o))) {
81
                return $output;
82
            }
83
        }
84
85
        $out = '';
86
87
        if ($o->depth == 0) {
88
            $out .= $this->colorTitle($this->renderTitle($o)).PHP_EOL;
89
        }
90
91
        $out .= $this->renderHeader($o);
92
        $out .= $this->renderChildren($o).PHP_EOL;
93
94
        return $out;
95
    }
96
97
    public function boxText($text, $width)
98
    {
99
        if (Kint_Object_Blob::strlen($text) > $width - 4) {
100
            $text = Kint_Object_Blob::substr($text, 0, $width - 7).'...';
0 ignored issues
show
Consider using a different name than the parameter $text. This often makes code more readable.
Loading history...
101
        }
102
103
        $text .= str_repeat(' ', $width - 4 - Kint_Object_Blob::strlen($text));
104
105
        $out = '┌'.str_repeat('─', $width - 2).'┐'.PHP_EOL;
106
        $out .= '│ '.$this->escape($text).' │'.PHP_EOL;
107
        $out .= '└'.str_repeat('─', $width - 2).'┘';
108
109
        return $out;
110
    }
111
112
    public function renderTitle(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...
113
    {
114
        if (($name = $o->getName()) === null) {
115
            $name = 'literal';
116
        }
117
118
        if (self::$decorations) {
119
            return $this->boxText($name, $this->header_width);
120
        } elseif (Kint_Object_Blob::strlen($name) > $this->header_width) {
121
            return Kint_Object_Blob::substr($name, 0, $this->header_width - 3).'...';
122
        } else {
123
            return $name;
124
        }
125
    }
126
127
    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...
128
    {
129
        $output = array();
130
131
        if ($o->depth) {
132
            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...
133
                $output[] = $s;
134
            }
135
136
            if ($o->name !== null) {
137
                $output[] = $this->escape(var_export($o->name, true));
138
139
                if (($s = $o->getOperator()) !== null) {
140
                    $output[] = $this->escape($s);
141
                }
142
            }
143
        }
144
145
        if (($s = $o->getType()) !== null) {
146
            if ($o->reference) {
147
                $s = '&'.$s;
148
            }
149
150
            $output[] = $this->colorType($this->escape($s));
151
        }
152
153 View Code Duplication
        if (($s = $o->getSize()) !== null) {
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...
154
            $output[] = '('.$this->escape($s).')';
155
        }
156
157 View Code Duplication
        if (($s = $o->getValueShort()) !== null) {
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...
158
            if (self::$strlen_max && Kint_Object_Blob::strlen($s) > self::$strlen_max) {
159
                $s = substr($s, 0, self::$strlen_max).'...';
160
            }
161
            $output[] = $this->colorValue($this->escape($s));
162
        }
163
164
        return str_repeat(' ', $o->depth * $this->indent_width).implode(' ', $output);
165
    }
166
167
    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...
168
    {
169
        if ($o->type === 'array') {
170
            $output = ' [';
171
        } elseif ($o->type === 'object') {
172
            $output = ' (';
173
        } else {
174
            return '';
175
        }
176
177
        $children = '';
178
179
        if ($o->value && is_array($o->value->contents)) {
180
            foreach ($o->value->contents as $child) {
181
                $children .= $this->render($child);
182
            }
183
        }
184
185
        if ($children) {
186
            $output .= PHP_EOL.$children;
187
            $output .= str_repeat(' ', $o->depth * $this->indent_width);
188
        }
189
190
        if ($o->type === 'array') {
191
            $output .= ']';
192
        } elseif ($o->type === 'object') {
193
            $output .= ')';
194
        }
195
196
        return $output;
197
    }
198
199
    public function colorValue($string)
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...
200
    {
201
        return $string;
202
    }
203
204
    public function colorType($string)
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...
205
    {
206
        return $string;
207
    }
208
209
    public function colorTitle($string)
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...
210
    {
211
        return $string;
212
    }
213
214
    public function postRender()
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...
215
    {
216
        if (self::$decorations) {
217
            $output = str_repeat('═', $this->header_width);
218
        } else {
219
            $output = '';
220
        }
221
222
        if (!$this->show_minitrace) {
223
            return $this->colorTitle($output);
224
        } else {
225
            if ($output) {
226
                $output .= PHP_EOL;
227
            }
228
229
            return $this->colorTitle($output.$this->calledFrom().PHP_EOL);
230
        }
231
    }
232
233
    public function parserPlugins(array $plugins)
234
    {
235
        $return = array();
236
237
        foreach ($plugins as $index => $plugin) {
238
            foreach (self::$parser_plugin_whitelist as $whitelist) {
239
                if ($plugin instanceof $whitelist) {
240
                    $return[] = $plugin;
241
                    continue 2;
242
                }
243
            }
244
        }
245
246
        return $return;
247
    }
248
249
    protected function calledFrom()
250
    {
251
        $output = '';
252
253
        if (isset($this->callee['file'])) {
254
            $output .= 'Called from '.$this->ideLink($this->callee['file'], $this->callee['line']);
255
        }
256
257
        $caller = '';
258
259
        if (isset($this->previous_caller['class'])) {
260
            $caller .= $this->previous_caller['class'];
261
        }
262
        if (isset($this->previous_caller['type'])) {
263
            $caller .= $this->previous_caller['type'];
264
        }
265 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...
266
            && !in_array($this->previous_caller['function'], array('include', 'include_once', 'require', 'require_once'))
267
        ) {
268
            $caller .= $this->previous_caller['function'].'()';
269
        }
270
271
        if ($caller) {
272
            $output .= ' ['.$caller.']';
273
        }
274
275
        return $output;
276
    }
277
278
    public function ideLink($file, $line)
279
    {
280
        return $this->escape(Kint::shortenPath($file)).':'.$line;
281
    }
282
283 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...
284
    {
285
        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...
286
            $plugin = end($plugins);
287
288
            if (!isset($this->plugin_objs[$plugin])) {
289
                $this->plugin_objs[$plugin] = new $plugin($this);
290
            }
291
292
            return $this->plugin_objs[$plugin];
293
        }
294
    }
295
296
    public function escape($string, $encoding = false)
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...
297
    {
298
        return $string;
299
    }
300
}
301