This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Doctrine\DBAL\Tools; |
||
4 | |||
5 | use ArrayIterator; |
||
6 | use ArrayObject; |
||
7 | use DateTimeInterface; |
||
8 | use Doctrine\Common\Collections\Collection; |
||
9 | use Doctrine\Common\Persistence\Proxy; |
||
10 | use stdClass; |
||
11 | use function array_keys; |
||
12 | use function class_exists; |
||
13 | use function count; |
||
14 | use function end; |
||
15 | use function explode; |
||
16 | use function extension_loaded; |
||
17 | use function get_class; |
||
18 | use function html_entity_decode; |
||
19 | use function ini_get; |
||
20 | use function ini_set; |
||
21 | use function is_array; |
||
22 | use function is_object; |
||
23 | use function ob_get_clean; |
||
24 | use function ob_start; |
||
25 | use function strip_tags; |
||
26 | use function strrpos; |
||
27 | use function substr; |
||
28 | use function var_dump; |
||
29 | |||
30 | /** |
||
31 | * Static class used to dump the variable to be used on output. |
||
32 | * Simplified port of Util\Debug from doctrine/common. |
||
33 | * |
||
34 | * @internal |
||
35 | */ |
||
36 | final class Dumper |
||
37 | { |
||
38 | /** |
||
39 | * Private constructor (prevents instantiation). |
||
40 | */ |
||
41 | private function __construct() |
||
42 | { |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Returns a dump of the public, protected and private properties of $var. |
||
47 | * |
||
48 | * @link https://xdebug.org/ |
||
49 | * |
||
50 | * @param mixed $var The variable to dump. |
||
51 | * @param int $maxDepth The maximum nesting level for object properties. |
||
52 | */ |
||
53 | public static function dump($var, int $maxDepth = 2) : string |
||
54 | { |
||
55 | $html = ini_get('html_errors'); |
||
56 | |||
57 | if ($html !== true) { |
||
58 | ini_set('html_errors', true); |
||
59 | } |
||
60 | |||
61 | if (extension_loaded('xdebug')) { |
||
62 | ini_set('xdebug.var_display_max_depth', $maxDepth); |
||
63 | } |
||
64 | |||
65 | $var = self::export($var, $maxDepth); |
||
66 | |||
67 | ob_start(); |
||
68 | var_dump($var); |
||
0 ignored issues
–
show
Security
Debugging Code
introduced
by
![]() |
|||
69 | |||
70 | try { |
||
71 | return strip_tags(html_entity_decode(ob_get_clean())); |
||
72 | } finally { |
||
73 | ini_set('html_errors', $html); |
||
74 | } |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @param mixed $var |
||
79 | * |
||
80 | * @return mixed |
||
0 ignored issues
–
show
|
|||
81 | */ |
||
82 | public static function export($var, int $maxDepth) |
||
83 | { |
||
84 | $return = null; |
||
0 ignored issues
–
show
$return is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
85 | $isObj = is_object($var); |
||
86 | |||
87 | if ($var instanceof Collection) { |
||
0 ignored issues
–
show
The class
Doctrine\Common\Collections\Collection does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
88 | $var = $var->toArray(); |
||
89 | } |
||
90 | |||
91 | if ($maxDepth === 0) { |
||
92 | return is_object($var) ? get_class($var) |
||
93 | : (is_array($var) ? 'Array(' . count($var) . ')' : $var); |
||
94 | } |
||
95 | |||
96 | if (is_array($var)) { |
||
97 | $return = []; |
||
98 | |||
99 | foreach ($var as $k => $v) { |
||
100 | $return[$k] = self::export($v, $maxDepth - 1); |
||
101 | } |
||
102 | |||
103 | return $return; |
||
104 | } |
||
105 | |||
106 | if (! $isObj) { |
||
107 | return $var; |
||
108 | } |
||
109 | |||
110 | $return = new stdClass(); |
||
111 | if ($var instanceof DateTimeInterface) { |
||
112 | $return->__CLASS__ = get_class($var); |
||
113 | $return->date = $var->format('c'); |
||
114 | $return->timezone = $var->getTimezone()->getName(); |
||
115 | |||
116 | return $return; |
||
117 | } |
||
118 | |||
119 | $return->__CLASS__ = self::getClass($var); |
||
120 | |||
121 | if ($var instanceof Proxy) { |
||
0 ignored issues
–
show
The class
Doctrine\Common\Persistence\Proxy does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
122 | $return->__IS_PROXY__ = true; |
||
123 | $return->__PROXY_INITIALIZED__ = $var->__isInitialized(); |
||
124 | } |
||
125 | |||
126 | if ($var instanceof ArrayObject || $var instanceof ArrayIterator) { |
||
127 | $return->__STORAGE__ = self::export($var->getArrayCopy(), $maxDepth - 1); |
||
128 | } |
||
129 | |||
130 | return self::fillReturnWithClassAttributes($var, $return, $maxDepth); |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * Fill the $return variable with class attributes |
||
135 | * Based on obj2array function from {@see https://secure.php.net/manual/en/function.get-object-vars.php#47075} |
||
136 | * |
||
137 | * @param object $var |
||
138 | * |
||
139 | * @return mixed |
||
0 ignored issues
–
show
|
|||
140 | */ |
||
141 | private static function fillReturnWithClassAttributes($var, stdClass $return, int $maxDepth) |
||
142 | { |
||
143 | $clone = (array) $var; |
||
144 | |||
145 | foreach (array_keys($clone) as $key) { |
||
146 | $aux = explode("\0", $key); |
||
147 | $name = end($aux); |
||
148 | if ($aux[0] === '') { |
||
149 | $name .= ':' . ($aux[1] === '*' ? 'protected' : $aux[1] . ':private'); |
||
150 | } |
||
151 | $return->$name = self::export($clone[$key], $maxDepth - 1); |
||
152 | } |
||
153 | |||
154 | return $return; |
||
155 | } |
||
156 | |||
157 | /** |
||
158 | * @param object $object |
||
159 | */ |
||
160 | private static function getClass($object) : string |
||
161 | { |
||
162 | $class = get_class($object); |
||
163 | |||
164 | if (! class_exists(Proxy::class)) { |
||
165 | return $class; |
||
166 | } |
||
167 | |||
168 | $pos = strrpos($class, '\\' . Proxy::MARKER . '\\'); |
||
169 | |||
170 | if ($pos === false) { |
||
171 | return $class; |
||
172 | } |
||
173 | |||
174 | return substr($class, $pos + Proxy::MARKER_LENGTH + 2); |
||
175 | } |
||
176 | } |
||
177 |