Test Setup Failed
Push — test ( 528f91...abcbcc )
by Jonathan
03:20
created

DOMDocumentPlugin::parseNode()   F

Complexity

Conditions 21
Paths 400

Size

Total Lines 104
Code Lines 62

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 21
eloc 62
nc 400
nop 3
dl 0
loc 104
rs 3.6155
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Kint\Parser;
4
5
use DOMNamedNodeMap;
6
use DOMNode;
7
use DOMNodeList;
8
use Kint\Object\BasicObject;
9
use Kint\Object\InstanceObject;
10
use Kint\Object\Representation\Representation;
11
12
/**
13
 * The DOMDocument parser plugin is particularly useful as it is both the only
14
 * way to see inside the DOMNode without print_r, and the only way to see mixed
15
 * text and node inside XML (SimpleXMLElement will strip out the text).
16
 */
17
class DOMDocumentPlugin extends Plugin
18
{
19
    /**
20
     * List of properties to skip parsing.
21
     *
22
     * The properties of a DOMNode can do a *lot* of damage to debuggers. The
23
     * DOMNode contains not one, not two, not three, not four, not 5, not 6,
24
     * not 7 but 8 different ways to recurse into itself:
25
     * * firstChild
26
     * * lastChild
27
     * * previousSibling
28
     * * nextSibling
29
     * * ownerDocument
30
     * * parentNode
31
     * * childNodes
32
     * * attributes
33
     *
34
     * All of this combined: the tiny SVGs used as the caret in Kint are already
35
     * enough to make parsing and rendering take over a second, and send memory
36
     * usage over 128 megs. So we blacklist every field we don't strictly need
37
     * and hope that that's good enough.
38
     *
39
     * In retrospect - this is probably why print_r does the same
40
     *
41
     * @var array
42
     */
43
    public static $blacklist = array(
44
        'parentNode' => 'DOMNode',
45
        'firstChild' => 'DOMNode',
46
        'lastChild' => 'DOMNode',
47
        'previousSibling' => 'DOMNode',
48
        'nextSibling' => 'DOMNode',
49
        'ownerDocument' => 'DOMDocument',
50
    );
51
52
    /**
53
     * Show all properties and methods.
54
     *
55
     * @var bool
56
     */
57
    public static $verbose = false;
58
59
    public function getTypes()
60
    {
61
        return array('object');
62
    }
63
64
    public function getTriggers()
0 ignored issues
show
Documentation introduced by
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...
65
    {
66
        return Parser::TRIGGER_SUCCESS;
67
    }
68
69
    public function parse(&$var, BasicObject &$o, $trigger)
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...
70
    {
71
        if (!$o instanceof InstanceObject) {
72
            return;
73
        } elseif ($var instanceof DOMNamedNodeMap || $var instanceof DOMNodeList) {
74
            return $this->parseList($var, $o, $trigger);
75
        } elseif ($var instanceof DOMNode) {
76
            return $this->parseNode($var, $o, $trigger);
77
        }
78
    }
79
80
    protected function parseList(&$var, InstanceObject &$o, $trigger)
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...
81
    {
82
        // Recursion should never happen, should always be stopped at the parent
83
        // DOMNode.  Depth limit on the other hand we're going to skip since
84
        // that would show an empty iterator and rather useless. Let the depth
85
        // limit hit the children (DOMNodeList only has DOMNode as children)
86
        if ($trigger & Parser::TRIGGER_RECURSION) {
87
            return;
88
        }
89
90
        $o->size = $var->length;
91
        if ($o->size === 0) {
92
            $o->replaceRepresentation(new Representation('Iterator'));
93
            $o->size = null;
94
95
            return;
96
        }
97
98
        // Depth limit
99
        // Make empty iterator representation since we need it in DOMNode to point out depth limits
100
        if ($this->parser->getDepthLimit() && $o->depth + 1 >= $this->parser->getDepthLimit()) {
101
            $b = new BasicObject();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $b. 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...
102
            $b->name = $o->classname.' Iterator Contents';
103
            $b->access_path = 'iterator_to_array('.$o->access_path.')';
104
            $b->depth = $o->depth + 1;
105
            $b->hints[] = 'depth_limit';
106
107
            $r = new Representation('Iterator');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $r. 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...
108
            $r->contents = array($b);
109
            $o->replaceRepresentation($r, 0);
110
111
            return;
112
        }
113
114
        $data = iterator_to_array($var);
115
116
        $r = new Representation('Iterator');
117
        $o->replaceRepresentation($r, 0);
118
119
        foreach ($data as $key => $item) {
120
            $base_obj = new BasicObject();
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
121
            $base_obj->depth = $o->depth + 1;
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
122
            $base_obj->name = $item->nodeName;
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
123
124
            if ($o->access_path) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $o->access_path of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
125
                if ($var instanceof DOMNamedNodeMap) {
126
                    $base_obj->access_path = $o->access_path.'->getNamedItem('.var_export($key, true).')';
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
127
                } elseif ($var instanceof DOMNodeList) {
128
                    $base_obj->access_path = $o->access_path.'->item('.var_export($key, true).')';
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
129
                } else {
130
                    $base_obj->access_path = 'iterator_to_array('.$o->access_path.')';
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
131
                }
132
            }
133
134
            $r->contents[] = $this->parser->parse($item, $base_obj);
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
135
        }
136
    }
137
138
    protected function parseNode(&$var, InstanceObject &$o, $trigger)
0 ignored issues
show
Unused Code introduced by
The parameter $trigger is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

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...
139
    {
140
        // Fill the properties
141
        // They can't be enumerated through reflection or casting,
142
        // so we have to trust the docs and try them one at a time
143
        $known_properties = array(
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
144
            'nodeValue',
145
            'childNodes',
146
            'attributes',
147
        );
148
149
        if (self::$verbose) {
150
            $known_properties = array(
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
151
                'nodeName',
152
                'nodeValue',
153
                'nodeType',
154
                'parentNode',
155
                'childNodes',
156
                'firstChild',
157
                'lastChild',
158
                'previousSibling',
159
                'nextSibling',
160
                'attributes',
161
                'ownerDocument',
162
                'namespaceURI',
163
                'prefix',
164
                'localName',
165
                'baseURI',
166
                'textContent',
167
            );
168
        }
169
170
        $childNodes = array();
171
        $attributes = array();
172
173
        $rep = $o->value;
174
175
        foreach ($known_properties as $prop) {
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
176
            $prop_obj = $this->parseProperty($o, $prop, $var);
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
177
            $rep->contents[] = $prop_obj;
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
178
179
            if ($prop === 'childNodes') {
180
                $childNodes = $prop_obj->getRepresentation('iterator');
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
181
            } elseif ($prop === 'attributes') {
182
                $attributes = $prop_obj->getRepresentation('iterator');
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
183
            }
184
        }
185
186
        if (!self::$verbose) {
187
            $o->removeRepresentation('methods');
188
            $o->removeRepresentation('properties');
189
        }
190
191
        // Attributes and comments and text nodes don't
192
        // need children or attributes of their own
193
        if (in_array($o->classname, array('DOMAttr', 'DOMText', 'DOMComment'))) {
194
            return;
195
        }
196
197
        // Set the attributes
198
        if ($attributes) {
199
            $a = new Representation('Attributes');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $a. 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...
200
            foreach ($attributes->contents as $attribute) {
201
                $a->contents[] = self::textualNodeToString($attribute);
202
            }
203
            $o->addRepresentation($a, 0);
204
        }
205
206
        // Set the children
207
        if ($childNodes) {
208
            $c = new Representation('Children');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $c. 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...
209
210
            if (count($childNodes->contents) === 1 && ($node = reset($childNodes->contents)) && in_array('depth_limit', $node->hints)) {
211
                $node = $node->transplant(new InstanceObject());
212
                $node->name = 'childNodes';
213
                $node->classname = 'DOMNodeList';
214
                $c->contents = array($node);
215
            } else {
216
                foreach ($childNodes->contents as $index => $node) {
217
                    // Shortcircuit text nodes to plain strings
218
                    if ($node->classname === 'DOMText' || $node->classname === 'DOMComment') {
219
                        $node = self::textualNodeToString($node);
220
221
                        // And remove them if they're empty
222
                        if (ctype_space($node->value->contents) || $node->value->contents === '') {
223
                            continue;
224
                        }
225
                    }
226
227
                    $c->contents[] = $node;
228
                }
229
            }
230
231
            $o->addRepresentation($c, 0);
232
        }
233
234
        if (isset($c) && count($c->contents)) {
235
            $o->size = count($c->contents);
236
        }
237
238
        if (!$o->size) {
0 ignored issues
show
Bug Best Practice introduced by
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 ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

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
Loading history...
239
            $o->size = null;
240
        }
241
    }
242
243
    protected function parseProperty(InstanceObject $o, $prop, &$var)
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...
244
    {
245
        // Duplicating (And slightly optimizing) the Parser::parseObject() code here
246
        $base_obj = new BasicObject();
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
247
        $base_obj->depth = $o->depth + 1;
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
248
        $base_obj->owner_class = $o->classname;
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
249
        $base_obj->name = $prop;
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
250
        $base_obj->operator = BasicObject::OPERATOR_OBJECT;
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
251
        $base_obj->access = BasicObject::ACCESS_PUBLIC;
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
252
253
        if ($o->access_path !== null) {
254
            $base_obj->access_path = $o->access_path;
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
255
256
            if (preg_match('/^[A-Za-z0-9_]+$/', $base_obj->name)) {
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
257
                $base_obj->access_path .= '->'.$base_obj->name;
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
258
            } else {
259
                $base_obj->access_path .= '->{'.var_export($base_obj->name, true).'}';
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
260
            }
261
        }
262
263
        if (!isset($var->$prop)) {
264
            $base_obj->type = 'null';
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
265
        } elseif (isset(self::$blacklist[$prop])) {
266
            $base_obj = $base_obj->transplant(new InstanceObject());
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
267
            $base_obj->hints[] = 'blacklist';
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
268
            $base_obj->classname = self::$blacklist[$prop];
0 ignored issues
show
Bug introduced by
The property classname does not seem to exist in Kint\Object\BasicObject.

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...
Coding Style introduced by
$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.

Loading history...
269
        } elseif ($prop === 'attributes') {
270
            $base_obj = $this->parser->parseDeep($var->$prop, $base_obj);
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
271
        } else {
272
            $base_obj = $this->parser->parse($var->$prop, $base_obj);
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
273
        }
274
275
        return $base_obj;
0 ignored issues
show
Coding Style introduced by
$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.

Loading history...
276
    }
277
278
    protected static function textualNodeToString(InstanceObject $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...
279
    {
280
        if (empty($o->value) || empty($o->value->contents) || empty($o->classname)) {
281
            return;
282
        }
283
284
        if (!in_array($o->classname, array('DOMText', 'DOMAttr', 'DOMComment'))) {
285
            return;
286
        }
287
288
        foreach ($o->value->contents as $property) {
289
            if ($property->name === 'nodeValue') {
290
                $ret = clone $property;
291
                $ret->name = $o->name;
292
293
                return $ret;
294
            }
295
        }
296
    }
297
}
298