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 | /** |
||
4 | * The DOMNode parser plugin is particularly useful as it is both the only way |
||
5 | * to see inside the DOMNode without print_r, and the only way to see mixed |
||
6 | * text and node inside XML (SimpleXMLElement will strip out the text). |
||
7 | */ |
||
8 | class Kint_Parser_DOMNode extends Kint_Parser_Plugin |
||
0 ignored issues
–
show
|
|||
9 | { |
||
10 | /** |
||
11 | * List of properties to skip parsing. |
||
12 | * |
||
13 | * The properties of a DOMNode can do a *lot* of damage to debuggers. The |
||
14 | * DOMNode contains not one, not two, not three, not four, not 5, not 6, |
||
15 | * not 7 but 8 different ways to recurse into itself: |
||
16 | * * firstChild |
||
17 | * * lastChild |
||
18 | * * previousSibling |
||
19 | * * nextSibling |
||
20 | * * ownerDocument |
||
21 | * * parentNode |
||
22 | * * childNodes |
||
23 | * * attributes |
||
24 | * |
||
25 | * All of this combined: the tiny SVGs used as the caret in Kint are already |
||
26 | * enough to make parsing and rendering take over a second, and send memory |
||
27 | * usage over 128 megs. So we blacklist every field we don't strictly need |
||
28 | * and hope that that's good enough. |
||
29 | * |
||
30 | * In retrospect - this is probably why print_r does the same |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | public static $blacklist = array( |
||
35 | 'parentNode' => 'DOMNode', |
||
36 | 'firstChild' => 'DOMNode', |
||
37 | 'lastChild' => 'DOMNode', |
||
38 | 'previousSibling' => 'DOMNode', |
||
39 | 'nextSibling' => 'DOMNode', |
||
40 | 'ownerDocument' => 'DOMDocument', |
||
41 | ); |
||
42 | |||
43 | /** |
||
44 | * Show all properties and methods. |
||
45 | * |
||
46 | * @var bool |
||
47 | */ |
||
48 | public static $verbose = false; |
||
49 | |||
50 | public function getTypes() |
||
51 | { |
||
52 | return array('object'); |
||
53 | } |
||
54 | |||
55 | public function getTriggers() |
||
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 ![]() |
|||
56 | { |
||
57 | return Kint_Parser::TRIGGER_SUCCESS; |
||
58 | } |
||
59 | |||
60 | public function parse(&$var, Kint_Object &$o, $trigger) |
||
0 ignored issues
–
show
|
|||
61 | { |
||
62 | if (!$var instanceof DOMNode) { |
||
63 | return; |
||
64 | } |
||
65 | |||
66 | // Fill the properties |
||
67 | // They can't be enumerated through reflection or casting, |
||
68 | // so we have to trust the docs and try them one at a time |
||
69 | $known_properties = array( |
||
0 ignored issues
–
show
$known_properties 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. ![]() |
|||
70 | 'nodeValue', |
||
71 | 'childNodes', |
||
72 | 'attributes', |
||
73 | ); |
||
74 | |||
75 | if (self::$verbose) { |
||
76 | $known_properties = array( |
||
0 ignored issues
–
show
$known_properties 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. ![]() |
|||
77 | 'nodeName', |
||
78 | 'nodeValue', |
||
79 | 'nodeType', |
||
80 | 'parentNode', |
||
81 | 'childNodes', |
||
82 | 'firstChild', |
||
83 | 'lastChild', |
||
84 | 'previousSibling', |
||
85 | 'nextSibling', |
||
86 | 'attributes', |
||
87 | 'ownerDocument', |
||
88 | 'namespaceURI', |
||
89 | 'prefix', |
||
90 | 'localName', |
||
91 | 'baseURI', |
||
92 | 'textContent', |
||
93 | ); |
||
94 | } |
||
95 | |||
96 | $childNodes = array(); |
||
97 | $attributes = array(); |
||
98 | |||
99 | $rep = $o->value; |
||
100 | |||
101 | foreach ($known_properties as $prop) { |
||
0 ignored issues
–
show
$known_properties 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. ![]() |
|||
102 | $prop_obj = $this->parseProperty($o, $prop, $var); |
||
0 ignored issues
–
show
$prop_obj 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. ![]() |
|||
103 | $rep->contents[] = $prop_obj; |
||
0 ignored issues
–
show
$prop_obj 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. ![]() |
|||
104 | |||
105 | if ($prop === 'childNodes') { |
||
106 | $childNodes = $prop_obj->getRepresentation('iterator'); |
||
0 ignored issues
–
show
$prop_obj 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. ![]() |
|||
107 | } elseif ($prop === 'attributes') { |
||
108 | $attributes = $prop_obj->getRepresentation('iterator'); |
||
0 ignored issues
–
show
$prop_obj 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. ![]() |
|||
109 | } |
||
110 | } |
||
111 | |||
112 | if (!self::$verbose) { |
||
113 | $o->removeRepresentation('methods'); |
||
114 | $o->removeRepresentation('properties'); |
||
115 | } |
||
116 | |||
117 | // Attributes and comments and text nodes don't |
||
118 | // need children or attributes of their own |
||
119 | if (in_array($o->classname, array('DOMAttr', 'DOMText', 'DOMComment'))) { |
||
0 ignored issues
–
show
The property
classname 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. ![]() |
|||
120 | return; |
||
121 | } |
||
122 | |||
123 | // Set the attributes |
||
124 | if ($attributes) { |
||
125 | $a = new Kint_Object_Representation('Attributes'); |
||
0 ignored issues
–
show
|
|||
126 | foreach ($attributes->contents as $attribute) { |
||
127 | $a->contents[] = self::textualNodeToString($attribute); |
||
128 | } |
||
129 | $o->addRepresentation($a, 0); |
||
130 | } |
||
131 | |||
132 | // Set the children |
||
133 | if ($childNodes) { |
||
134 | $c = new Kint_Object_Representation('Children'); |
||
0 ignored issues
–
show
|
|||
135 | |||
136 | if (count($childNodes->contents) === 1 && ($node = reset($childNodes->contents)) && in_array('depth_limit', $node->hints)) { |
||
137 | $node = $node->transplant(new Kint_Object_Instance()); |
||
138 | $node->name = 'childNodes'; |
||
139 | $node->classname = 'DOMNodeList'; |
||
140 | $c->contents = array($node); |
||
141 | } else { |
||
142 | foreach ($childNodes->contents as $index => $node) { |
||
143 | // Shortcircuit text nodes to plain strings |
||
144 | if ($node->classname === 'DOMText' || $node->classname === 'DOMComment') { |
||
145 | $node = self::textualNodeToString($node); |
||
146 | |||
147 | // And remove them if they're empty |
||
148 | if (ctype_space($node->value->contents) || $node->value->contents === '') { |
||
149 | continue; |
||
150 | } |
||
151 | } |
||
152 | |||
153 | $c->contents[] = $node; |
||
154 | } |
||
155 | } |
||
156 | |||
157 | $o->addRepresentation($c, 0); |
||
158 | } |
||
159 | |||
160 | if (isset($c) && count($c->contents)) { |
||
161 | $o->size = count($c->contents); |
||
162 | } |
||
163 | |||
164 | if (!$o->size) { |
||
0 ignored issues
–
show
The expression
$o->size of type integer|null is loosely compared to false ; this is ambiguous if the integer can be zero. You might want to explicitly use === null instead.
In PHP, under loose comparison (like For 0 == false // true
0 == null // true
123 == false // false
123 == null // false
// It is often better to use strict comparison
0 === false // false
0 === null // false
![]() |
|||
165 | $o->size = null; |
||
166 | } |
||
167 | } |
||
168 | |||
169 | protected function parseProperty(Kint_Object $o, $prop, &$var) |
||
0 ignored issues
–
show
|
|||
170 | { |
||
171 | // Duplicating (And slightly optimizing) the Kint_Parser::parseObject() code here |
||
172 | $base_obj = new Kint_Object(); |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
173 | $base_obj->depth = $o->depth + 1; |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
174 | $base_obj->owner_class = $o->classname; |
||
0 ignored issues
–
show
$base_obj 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. ![]() The property
classname 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. ![]() |
|||
175 | $base_obj->name = $prop; |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
176 | $base_obj->operator = Kint_Object::OPERATOR_OBJECT; |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
177 | $base_obj->access = Kint_Object::ACCESS_PUBLIC; |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
178 | |||
179 | if ($o->access_path !== null) { |
||
180 | $base_obj->access_path = $o->access_path; |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
181 | |||
182 | if (preg_match('/^[A-Za-z0-9_]+$/', $base_obj->name)) { |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
183 | $base_obj->access_path .= '->'.$base_obj->name; |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
184 | } else { |
||
185 | $base_obj->access_path .= '->{'.var_export($base_obj->name, true).'}'; |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
186 | } |
||
187 | } |
||
188 | |||
189 | if (!isset($var->$prop)) { |
||
190 | $base_obj->type = 'null'; |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
191 | } elseif (isset(self::$blacklist[$prop])) { |
||
192 | $base_obj = $base_obj->transplant(new Kint_Object_Instance()); |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
193 | $base_obj->hints[] = 'blacklist'; |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
194 | $base_obj->classname = self::$blacklist[$prop]; |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
195 | } elseif ($prop === 'attributes') { |
||
196 | $depth_stash = $this->parser->max_depth; |
||
0 ignored issues
–
show
$depth_stash 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. ![]() |
|||
197 | $this->parser->max_depth = 0; |
||
198 | $base_obj = $this->parser->parse($var->$prop, $base_obj); |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
199 | $this->parser->max_depth = $depth_stash; |
||
0 ignored issues
–
show
$depth_stash 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. ![]() |
|||
200 | } else { |
||
201 | $base_obj = $this->parser->parse($var->$prop, $base_obj); |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
202 | } |
||
203 | |||
204 | return $base_obj; |
||
0 ignored issues
–
show
$base_obj 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. ![]() |
|||
205 | } |
||
206 | |||
207 | protected static function textualNodeToString(Kint_Object_Instance $o) |
||
0 ignored issues
–
show
|
|||
208 | { |
||
209 | if (empty($o->value) || empty($o->value->contents) || empty($o->classname)) { |
||
210 | return; |
||
211 | } |
||
212 | |||
213 | if (!in_array($o->classname, array('DOMText', 'DOMAttr', 'DOMComment'))) { |
||
214 | return; |
||
215 | } |
||
216 | |||
217 | foreach ($o->value->contents as $property) { |
||
218 | if ($property->name === 'nodeValue') { |
||
219 | $ret = clone $property; |
||
220 | $ret->name = $o->name; |
||
221 | |||
222 | return $ret; |
||
223 | } |
||
224 | } |
||
225 | } |
||
226 | } |
||
227 |
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.