Completed
Push — master ( 2b7f2d...31c8a2 )
by stéphane
03:00
created

Node::parse()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 13
nc 5
nop 1
dl 0
loc 17
rs 9.5222
c 0
b 0
f 0
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Dallgoot\Yaml;
4
5
use Dallgoot\Yaml\Yaml as Y;
6
use Dallgoot\Yaml\Regex as R;
7
8
/**
9
 * TODO
10
 * @category tag in class comment
0 ignored issues
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
Coding Style introduced by
Category name "tag in class comment" is not valid; consider "Tag_In_Class_Comment" instead
Loading history...
11
 * @package tag in class comment
1 ignored issue
show
Coding Style introduced by
Package name "tag in class comment" is not valid; consider "Tag_In_Class_Comment" instead
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
12
 * @author tag in class comment
1 ignored issue
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 3 spaces but found 1
Loading history...
13
 * @license tag in class comment
1 ignored issue
show
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
14
 */
0 ignored issues
show
Coding Style introduced by
Missing @link tag in class comment
Loading history...
15
final class Node
16
{
17
    /** @var int */
2 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
18
    public $indent = -1;
19
    /** @var int */
2 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
20
    public $line;
21
    /** @var int */
2 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
22
    public $type;
23
    /** @var null|string|boolean */
2 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
24
    public $identifier;
25
    /** @var Node|NodeList|null|string */
2 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
26
    public $value;
27
28
    /** @var null|Node */
2 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
29
    private $parent;
0 ignored issues
show
Coding Style introduced by
Private member variable "parent" must be prefixed with an underscore
Loading history...
30
31
    public function __construct($nodeString = null, $line = null)
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
32
    {
33
        $this->line = $line;
34
        if (is_null($nodeString)) {
35
            $this->type = Y::ROOT;
36
        } else {
37
            $this->parse($nodeString);
38
        }
39
    }
40
41
    /**
42
     * Sets the parent of the current Node
43
     * @param      Node       $node   The node
3 ignored issues
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 7 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 3 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 6
Loading history...
44
     *
45
     * @return     Node|self  The currentNode
1 ignored issue
show
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 5
Loading history...
46
     */
47
    public function setParent(Node $node):Node
48
    {
49
        $this->parent = $node;
50
        return $this;
51
    }
52
53
    /**
54
     * Gets the ancestor with specified $indent or the direct $parent OR the current Node itself
55
     *
56
     * @param int|null    $indent        The indent
2 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 4 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 8 found
Loading history...
57
     *
58
     * @return Node|self        The parent.
59
     */
60
    public function getParent(int $indent = null):Node
61
    {
62
        if (!is_int($indent)) return $this->parent ?? $this;
63
        $cursor = $this;
64
        while ($cursor instanceof Node && $cursor->indent >= $indent) {
65
            $cursor = $cursor->parent;
66
        }
67
        return $cursor;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $cursor could return the type null which is incompatible with the type-hinted return Dallgoot\Yaml\Node. Consider adding an additional type-check to rule them out.
Loading history...
68
    }
69
70
    /**
71
     * Set the value for the current Node :
72
     * - if value is null , then value = $child (Node)
73
     * - if value is Node, then value is a NodeList with (previous value AND $child)
74
     * - if value is a NodeList, simply push $child into
75
     *
76
     * @param      Node  $child  The child
3 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 6
Loading history...
77
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
78
    public function add(Node $child):void
79
    {
80
        $child->setParent($this);
81
        $current = $this->value;
82
        if (is_null($current)) {
83
            $this->value = $child;
84
        } else {
85
            if ($current instanceof Node) {
86
                $this->value = new NodeList();
87
                $this->value->push($current);
88
            }
89
            $this->value->push($child);
0 ignored issues
show
Bug introduced by
The method push() does not exist on Dallgoot\Yaml\Node. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

89
            $this->value->/** @scrutinizer ignore-call */ 
90
                          push($child);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method push() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

89
            $this->value->/** @scrutinizer ignore-call */ 
90
                          push($child);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
90
            //modify type according to child
91
            if ($child->type & (Y::COMMENT | Y::KEY)) $this->value->type = Y::MAPPING;
92
            if ($child->type & Y::ITEM)               $this->value->type = Y::SEQUENCE;
93
            if ($this->type & Y::LITTERALS)  $this->value->type = $this->type;
94
        }
95
    }
96
97
    public function getDeepestNode():Node
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
98
    {
99
        $cursor = $this;
100
        while ($cursor->value instanceof Node) {
101
            $cursor = $cursor->value;
102
        }
103
        return $cursor;
104
    }
105
106
    /**
107
     * Parses the string (assumed to be a line from a valid YAML)
108
     *
109
     * @param      string     $nodeString  The node string
3 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 5 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 6
Loading history...
110
     *
111
     * @return     Node|self  ( description_of_the_return_value )
1 ignored issue
show
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 5
Loading history...
112
     */
113
    public function parse(string $nodeString):Node
114
    {
115
        $nodeValue = preg_replace("/^\t+/m", " ", $nodeString); //permissive to tabs but replacement
116
        $this->indent = strspn($nodeValue, ' ');
117
        $nodeValue = ltrim($nodeValue);
118
        if ($nodeValue === '') {
119
            $this->type = Y::BLANK;
120
            // $this->indent = 0; // remove if no bugs
121
        } elseif (substr($nodeValue, 0, 3) === '...') {//TODO: can have something on same line ?
122
            $this->type = Y::DOC_END;
123
        } elseif (preg_match(R::KEY, $nodeValue, $matches)) {
124
            $this->onKey($matches);
125
        } else {//NOTE: can be of another type according to parent
126
            list($this->type, $value) = $this->define($nodeValue);
127
            is_object($value) ? $this->add($value) : $this->value = $value;
128
        }
129
        return $this;
130
    }
131
132
    /**
133
     *  Set the type and value according to first character
134
     *
135
     * @param      string  $nodeValue  The node value
3 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 6
Loading history...
136
     * @return     array   contains [node->type, node->value]
1 ignored issue
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 5
Loading history...
137
     */
138
    private function define($nodeValue):array
0 ignored issues
show
Coding Style introduced by
Private method name "Node::define" must be prefixed with an underscore
Loading history...
139
    {
140
        $v = substr($nodeValue, 1);
141
        $first = $nodeValue[0];
142
        if (in_array($first, ['"', "'"])) {
143
            $type = R::isProperlyQuoted($nodeValue) ? Y::QUOTED : Y::PARTIAL;
144
            return [$type, $nodeValue];
145
        }
146
        if (in_array($first, ['{', '[']))      return $this->onObject($nodeValue);
147
        if (in_array($first, ['!', '&', '*'])) return $this->onNodeAction($nodeValue);
148
        // Note : php don't like '?' as an array key -_-
149
        if($first === '?') return [Y::SET_KEY, empty($v) ? null : new Node(ltrim($v), $this->line)];
150
        $characters = [ '#' =>  [Y::COMMENT, ltrim($v)],
151
                        "-" =>  $this->onHyphen($nodeValue),
152
                        '%' =>  [Y::DIRECTIVE, ltrim($v)],
153
                        ':' =>  [Y::SET_VALUE, empty($v) ? null : new Node(ltrim($v), $this->line)],
154
                        '>' =>  [Y::LITT_FOLDED, null],
155
                        '|' =>  [Y::LITT, null]
156
        ];
157
        if (array_key_exists($first, $characters)) {
158
            return $characters[$first];
159
        }
160
        return [Y::SCALAR, $nodeValue];
161
    }
162
163
    /**
164
     * Process when a "key: value" syntax is found in the parsed string
165
     * Note : key is match 1, value is match 2 as per regex from R::KEY
166
     * @param      array  $matches  The matches provided by 'preg_match' function
3 ignored issues
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 6
Loading history...
167
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
168
    private function onKey(array $matches):void
0 ignored issues
show
Coding Style introduced by
Private method name "Node::onKey" must be prefixed with an underscore
Loading history...
169
    {
170
        $this->type = Y::KEY;
171
        $this->identifier = trim($matches[1]);
172
        $value = isset($matches[2]) ? trim($matches[2]) : null;
173
        if (!empty($value)) {
174
            $n = new Node($value, $this->line);
175
            $hasComment = strpos($value, ' #');
176
            if (!is_bool($hasComment)) {
0 ignored issues
show
introduced by
The condition is_bool($hasComment) is always false.
Loading history...
177
                $tmpNode = new Node(trim(substr($value, 0, $hasComment)), $this->line);
178
                if ($tmpNode->type !== Y::PARTIAL) {
179
                    $comment = new Node(trim(substr($value, $hasComment + 1)), $this->line);
180
                    $comment->identifier = true; //to specify it is NOT a fullline comment
181
                    $this->add($comment);
182
                    $n = $tmpNode;
183
                }
184
            }
185
            $n->indent = $this->indent + strlen($this->identifier);
186
            $this->add($n);
187
        }
188
    }
189
190
    /**
191
     * Determines the correct type and value when a short object/array syntax is found
192
     *
193
     * @param      string  $value  The value assumed to start with { or ( or characters
3 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 6
Loading history...
194
     *
195
     * @return     array   array with the type and $value (unchanged for now)
1 ignored issue
show
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 5
Loading history...
196
     * @see self:define
1 ignored issue
show
Coding Style introduced by
Tag value indented incorrectly; expected 4 spaces but found 1
Loading history...
197
     */
198
    private function onObject($value):array
1 ignored issue
show
Coding Style introduced by
Private method name "Node::onObject" must be prefixed with an underscore
Loading history...
199
    {
200
        json_decode($value, false, 512, JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_UNESCAPED_SLASHES);
201
        if (json_last_error() === JSON_ERROR_NONE)  return [Y::JSON, $value];
202
        if (preg_match(R::MAPPING, $value))         return [Y::COMPACT_MAPPING, $value];
203
        if (preg_match(R::SEQUENCE, $value))        return [Y::COMPACT_SEQUENCE, $value];
204
        return [Y::PARTIAL, $value];
205
    }
206
207
    /**
208
     * Determines type and value when an hyphen "-" is found
209
     *
210
     * @param      string $nodeValue  The node value
2 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 6
Loading history...
211
     *
212
     * @return     array   array with the type and $value
1 ignored issue
show
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 5
Loading history...
213
     */
214
    private function onHyphen($nodeValue):array
0 ignored issues
show
Coding Style introduced by
Private method name "Node::onHyphen" must be prefixed with an underscore
Loading history...
215
    {
216
        if (substr($nodeValue, 0, 3) === '---') {
217
            $rest = trim(substr($nodeValue, 3));
218
            if (empty($rest)) return [Y::DOC_START, null];
219
            $n = new Node($rest, $this->line);
220
            $n->indent = $this->indent + 4;
221
            return [Y::DOC_START, $n->setParent($this)];
222
        }
223
        if (preg_match(R::ITEM, $nodeValue, $matches)) {
224
            if (isset($matches[1]) && !empty(trim($matches[1]))) {
225
                $n = new Node(trim($matches[1]), $this->line);
226
                return [Y::ITEM, $n->setParent($this)];
227
            }
228
            return [Y::ITEM, null];
229
        }
230
        return [Y::SCALAR, $nodeValue];
231
    }
232
233
    /**
234
     * Determines the type and value according to $nodeValue when one of these characters is found : !,&,*
235
     *
236
     * @param      string  $nodeValue  The node value
3 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 6
Loading history...
237
     *
238
     * @return     array   array with the type and $value
1 ignored issue
show
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 5
Loading history...
239
     * @see self::define
1 ignored issue
show
Coding Style introduced by
Tag value indented incorrectly; expected 4 spaces but found 1
Loading history...
240
     */
241
    private function onNodeAction($nodeValue):array
0 ignored issues
show
Coding Style introduced by
Private method name "Node::onNodeAction" must be prefixed with an underscore
Loading history...
242
    {
243
        // TODO: handle tags like  <tag:clarkevans.com,2002:invoice>
244
        $v = substr($nodeValue, 1);
245
        $type = ['!' => Y::TAG, '&' => Y::REF_DEF, '*' => Y::REF_CALL][$nodeValue[0]];
246
        $pos = strpos($v, ' ');
247
        $this->identifier = is_bool($pos) ? $v : strstr($v, ' ', true);
0 ignored issues
show
introduced by
The condition is_bool($pos) is always false.
Loading history...
248
        $n = is_bool($pos) ? null : (new Node(trim(substr($nodeValue, $pos + 1)), $this->line))->setParent($this);
0 ignored issues
show
introduced by
The condition is_bool($pos) is always false.
Loading history...
249
        return [$type, $n];
250
    }
251
252
    /**
253
     * Returns the correct PHP datatype for the value of the current Node
254
     *
255
     * @return mixed  The value as PHP type : scalar, array or Compact, DateTime
256
     */
257
    public function getPhpValue()
258
    {
259
        $v = &$this->value;
260
        if (is_null($v)) return null;
261
        if ($this->type & (Y::REF_CALL | Y::SCALAR)) return self::getScalar($v);
0 ignored issues
show
Bug introduced by
It seems like $v can also be of type Dallgoot\Yaml\NodeList and Dallgoot\Yaml\Node; however, parameter $v of Dallgoot\Yaml\Node::getScalar() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

261
        if ($this->type & (Y::REF_CALL | Y::SCALAR)) return self::getScalar(/** @scrutinizer ignore-type */ $v);
Loading history...
262
        if ($this->type & (Y::COMPACT_MAPPING | Y::COMPACT_SEQUENCE)) return self::getCompact(substr($v, 1, -1), $this->type);
0 ignored issues
show
Bug introduced by
It seems like $v can also be of type Dallgoot\Yaml\NodeList and Dallgoot\Yaml\Node; however, parameter $string of substr() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

262
        if ($this->type & (Y::COMPACT_MAPPING | Y::COMPACT_SEQUENCE)) return self::getCompact(substr(/** @scrutinizer ignore-type */ $v, 1, -1), $this->type);
Loading history...
263
        $expected = [Y::JSON   => json_decode($v, false, 512, JSON_PARTIAL_OUTPUT_ON_ERROR),
0 ignored issues
show
Bug introduced by
It seems like $v can also be of type Dallgoot\Yaml\NodeList and Dallgoot\Yaml\Node; however, parameter $json of json_decode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

263
        $expected = [Y::JSON   => json_decode(/** @scrutinizer ignore-type */ $v, false, 512, JSON_PARTIAL_OUTPUT_ON_ERROR),
Loading history...
264
                     Y::QUOTED => substr($v, 1, -1),
265
                     Y::RAW    => strval($v)];
266
        if (isset($expected[$this->type])) {
267
            return $expected[$this->type];
268
        }
269
        trigger_error("Error can not get PHP type for ".Y::getName($this->type), E_USER_WARNING);
270
        return null;
271
    }
272
273
    /**
274
     * Returns the correct PHP type according to the string value
275
     *
276
     * @param      string  $v      a string value
3 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 6 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 6
Loading history...
277
     *
278
     * @return     mixed   The value with appropriate PHP type
1 ignored issue
show
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 5
Loading history...
279
     */
280
    private static function getScalar(string $v)
0 ignored issues
show
Coding Style introduced by
Private method name "Node::getScalar" must be prefixed with an underscore
Loading history...
281
    {
282
        $types = ['yes'   => true,
283
                    'no'    => false,
284
                    'true'  => true,
285
                    'false' => false,
286
                    'null'  => null,
287
                    '.inf'  => INF,
288
                    '-.inf' => -INF,
289
                    '.nan'  => NAN
290
        ];
291
        if (isset($types[strtolower($v)])) return $types[strtolower($v)];
292
        if (R::isDate($v))   return date_create($v);
293
        if (R::isNumber($v)) return self::getNumber($v);
294
        return strval($v);
295
    }
296
297
    /**
298
     * Returns the correct PHP type according to the string value
299
     *
300
     * @param      string  $v      a string value
3 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 6 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 6
Loading history...
301
     *
302
     * @return     int|float   The scalar value with appropriate PHP type
1 ignored issue
show
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 5
Loading history...
303
     */
304
    private static function getNumber(string $v)
0 ignored issues
show
Coding Style introduced by
Private method name "Node::getNumber" must be prefixed with an underscore
Loading history...
305
    {
306
        if (preg_match("/^(0o\d+)$/i", $v))      return intval(base_convert($v, 8, 10));
307
        if (preg_match("/^(0x[\da-f]+)$/i", $v)) return intval(base_convert($v, 16, 10));
308
        return is_bool(strpos($v, '.')) ? intval($v) : floatval($v);
0 ignored issues
show
introduced by
The condition is_bool(strpos($v, '.')) is always false.
Loading history...
309
    }
310
311
    private static function getCompact(string $mappingOrSeqString, int $type):object
0 ignored issues
show
Coding Style introduced by
Private method name "Node::getCompact" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
312
    {
313
        $out = new Compact();
314
        if ($type === Y::COMPACT_SEQUENCE) {
315
            $f = function ($e) { return self::getScalar(trim($e));};
0 ignored issues
show
Coding Style introduced by
Opening brace must be the last content on the line
Loading history...
Coding Style introduced by
Closing brace must be on a line by itself
Loading history...
316
            //TODO : that's not robust enough, improve it
317
            foreach (array_map($f, explode(",", $mappingOrSeqString)) as $key => $value) {
318
                $out[$key] = $value;
319
            }
320
        }
321
        if ($type === Y::COMPACT_MAPPING) {
322
            //TODO : that's not robust enough, improve it
323
            foreach (explode(',', $mappingOrSeqString) as $value) {
324
                list($keyName, $keyValue) = explode(':', $value);
325
                $out->{trim($keyName)} = self::getScalar(trim($keyValue));
326
            }
327
        }
328
        return $out;
329
    }
330
331
    /**
332
     * PHP internal function for debugging purpose : simplify output provided by 'var_dump'
333
     *
334
     * @return     array  the Node properties and respective values displayed by 'var_dump'
1 ignored issue
show
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 5
Loading history...
335
     */
336
    public function __debugInfo():array
337
    {
338
        return ['line'  => $this->line,
339
                'indent'=> $this->indent,
340
                'type'  => Y::getName($this->type).($this->identifier ? "($this->identifier)" : ''),
341
                'value' => $this->value];
342
    }
343
}
344