Test Failed
Push — master ( 44c6e4...f07b2d )
by stéphane
03:54 queued 11s
created

Builder   F

Complexity

Total Complexity 77

Size/Duplication

Total Lines 341
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
wmc 77
lcom 1
cbo 7
dl 0
loc 341
rs 2.24
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
C buildContent() 0 29 10
A build() 0 5 2
B buildNodeList() 0 33 9
B buildNode() 0 28 8
B buildKey() 0 35 11
B buildItem() 0 24 10
C buildLitteral() 0 29 12
A buildSetKey() 0 8 5
A buildSetValue() 0 11 2
B buildTag() 0 26 7
A buildDirective() 0 4 1

How to fix   Complexity   

Complex Class

Complex classes like Builder often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Builder, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace Dallgoot\Yaml;
4
5
use Dallgoot\Yaml\{Yaml as Y, Regex as R};
6
7
/**
8
 * Constructs the result (YamlObject or array) according to every Node and respecting value
9
 *
10
 * @author  Stéphane Rebai <[email protected]>
11
 * @license Apache 2.0
12
 * @link    TODO : url to specific online doc
13
 */
14
final class Builder
15
{
16
    private static $_root;
0 ignored issues
show
Coding Style introduced by
$_root 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...
17
    private static $_debug;
0 ignored issues
show
Coding Style introduced by
$_debug 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...
18
19
    const ERROR_NO_KEYNAME = self::class.": key has NO IDENTIFIER on line %d";
20
    const INVALID_DOCUMENT = self::class.": DOCUMENT %d can NOT be a mapping AND a sequence";
21
22
    /**
23
     * Builds a file.  check multiple documents & split if more than one documents
24
     *
25
     * @param   Node   $_root      The root node : Node with Node->type === YAML::ROOT
26
     * @param   int   $_debug      the level of debugging requested
27
     *
28
     * @return array|YamlObject      list of documents or just one.
29
     * @todo  implement splitting on YAML::DOC_END also
30
     */
31
    public static function buildContent(Node $_root, int $_debug)
0 ignored issues
show
Coding Style introduced by
$_root 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...
32
    {
33
        self::$_debug = $_debug;
0 ignored issues
show
Coding Style introduced by
$_debug 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...
34
        $totalDocStart = 0;
35
        $documents = [];
36
        if ($_root->value instanceof Node) {
0 ignored issues
show
Coding Style introduced by
$_root 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...
37
            $q = new NodeList;
38
            $q->push($_root->value);
0 ignored issues
show
Coding Style introduced by
$_root 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...
39
            $_root->value = $q;
0 ignored issues
show
Coding Style introduced by
$_root 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...
40
        }
41
        $_root->value instanceof NodeList && $_root->value->setIteratorMode(NodeList::IT_MODE_DELETE);
0 ignored issues
show
Coding Style introduced by
$_root 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...
42
        foreach ($_root->value as $child) {
0 ignored issues
show
Coding Style introduced by
$_root 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...
Bug introduced by
The expression $_root->value of type object<Dallgoot\Yaml\NodeList>|null|string is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
43
            if ($child->type & Y::DOC_START) $totalDocStart++;
44
            //if 0 or 1 DOC_START = we are still in first document
45
            $currentDoc = $totalDocStart > 1 ? $totalDocStart - 1 : 0;
46
            if (!isset($documents[$currentDoc])) $documents[$currentDoc] = new NodeList();
47
            $documents[$currentDoc]->push($child);
48
        }
49
        $content = [];
50
        foreach ($documents as $num => $list) {
51
            self::$_root = new YamlObject;
52
            try {
53
                $content[] = self::buildNodeList($list, self::$_root);
54
            } catch (\Exception $e) {
55
                throw new \ParseError(sprintf(self::INVALID_DOCUMENT, $num));
0 ignored issues
show
Unused Code introduced by
The call to ParseError::__construct() has too many arguments starting with sprintf(self::INVALID_DOCUMENT, $num).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
56
            }
57
        }
58
        return count($content) === 1 ? $content[0] : $content;
59
    }
60
61
    /**
62
     * Generic function to distinguish between Node and NodeList
63
     *
64
     * @param Node|NodeList $node   The node.
0 ignored issues
show
Documentation introduced by
Should the type for parameter $node not be object?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
65
     * @param mixed         $parent The parent
66
     *
67
     * @return mixed  ( description_of_the_return_value )
68
     */
69
    private static function build(object $node, &$parent = null)
70
    {
71
        if ($node instanceof NodeList) return self::buildNodeList($node, $parent);
72
        return self::buildNode($node, $parent);
73
    }
74
75
    /**
76
     * Builds a node list.
77
     *
78
     * @param NodeList $node   The node
79
     * @param mixed    $parent The parent
80
     *
81
     * @return mixed    The parent (object|array) or a string representing the NodeList.
82
     */
83
    private static function buildNodeList(NodeList $node, &$parent=null)
84
    {
85
        $node->forceType();
86
        if ($node->type & (Y::RAW | Y::LITTERALS)) {
87
            return self::buildLitteral($node, (int) $node->type);
88
        }
89
        $action = function ($child, &$parent, &$out) {
90
            self::build($child, $out);
91
        };
92
        if ($node->type & (Y::COMPACT_MAPPING|Y::MAPPING|Y::SET)) {
93
            $out = $parent ?? new \StdClass;
94
        } elseif ($node->type & (Y::COMPACT_SEQUENCE|Y::SEQUENCE)) {
95
            $out = $parent ?? [];
96
        } else {
97
            $out = '';
98
            $action = function ($child, &$parent, &$out) {
99
                if ($child->type & (Y::SCALAR|Y::QUOTED)) {
100
                    if ($parent) {
101
                        $parent->setText(self::build($child));
102
                    } else {
103
                        $out .= self::build($child);
104
                    }
105
                }
106
            };
107
        }
108
        foreach ($node as $child) {
109
            $action($child, $parent, $out);
110
        }
111
        if ($node->type & (Y::COMPACT_SEQUENCE|Y::COMPACT_MAPPING)) {
112
            $out = new Compact($out);
113
        }
114
        return is_null($out) ? $parent : $out;
115
    }
116
117
    /**
118
     * Builds a node.
119
     *
120
     * @param Node    $node    The node of any Node->type
121
     * @param mixed  $parent  The parent
122
     *
123
     * @return mixed  The node value as scalar, array or object or null to otherwise.
124
     */
125
    private static function buildNode(Node $node, &$parent)
126
    {
127
        extract((array) $node, EXTR_REFS);
0 ignored issues
show
Bug introduced by
(array) $node cannot be passed to extract() as the parameter $var_array expects a reference.
Loading history...
128
        if ($type & (Y::REF_DEF | Y::REF_CALL)) {
129
            if (is_object($value)) {
130
                $tmp = self::build($value, $parent) ?? $parent;
131
            } else {
132
                $tmp = Node2PHP::get($node);
133
            }
134
            if ($type === Y::REF_DEF) self::$_root->addReference($identifier, $tmp);
135
            return self::$_root->getReference($identifier);
136
        }
137
        if ($type & (Y::COMPACT_MAPPING|Y::COMPACT_SEQUENCE)) {
138
            return self::buildNodeList($node->value, $parent);
0 ignored issues
show
Bug introduced by
It seems like $node->value can also be of type null or object<Dallgoot\Yaml\Node> or string; however, Dallgoot\Yaml\Builder::buildNodeList() does only seem to accept object<Dallgoot\Yaml\NodeList>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
139
        }
140
        if ($type & Y::COMMENT) self::$_root->addComment($node->line, $node->value);
141
        $typesActions = [Y::DIRECTIVE => 'buildDirective',
142
                         Y::ITEM      => 'buildItem',
143
                         Y::KEY       => 'buildKey',
144
                         Y::SET_KEY   => 'buildSetKey',
145
                         Y::SET_VALUE => 'buildSetValue',
146
                         Y::TAG       => 'buildTag',
147
        ];
148
        if (isset($typesActions[$type])) {
149
            return self::{$typesActions[$type]}($node, $parent);
150
        }
151
        return is_object($value) ? self::build($value, $parent) : Node2PHP::get($node);
152
    }
153
154
    /**
155
     * Builds a key and set the property + value to the given parent
156
     *
157
     * @param Node $node       The node with type YAML::KEY
158
     * @param object|array $parent       The parent
0 ignored issues
show
Documentation introduced by
Should the type for parameter $parent not be object|array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
159
     *
160
     * @throws \ParseError if Key has no name(identifier) Note: empty string is allowed
161
     * @return null
162
     */
163
    private static function buildKey(Node $node, &$parent=null)
164
    {
165
        extract((array) $node, EXTR_REFS);
0 ignored issues
show
Bug introduced by
(array) $node cannot be passed to extract() as the parameter $var_array expects a reference.
Loading history...
166
        if (is_null($identifier)) {
167
            throw new \ParseError(sprintf(self::ERROR_NO_KEYNAME, $line));
0 ignored issues
show
Unused Code introduced by
The call to ParseError::__construct() has too many arguments starting with sprintf(self::ERROR_NO_KEYNAME, $line).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
168
        } else {
169
            if ($value instanceof Node) {
170
                if ($value->type & (Y::ITEM|Y::KEY)) {
171
                    $list = new NodeList();
172
                    $list->push($value);
173
                    $list->type = $value->type & Y::ITEM ? Y::SEQUENCE : Y::MAPPING;
174
                    $value = $list;
175
                } else {
176
                    $result = self::build($value);
177
                }
178
            }
179
            if ($value instanceof NodeList) {
180
                $childTypes = $value->getTypes();
181
                if (is_null($value->type) && $childTypes & Y::SCALAR && !($childTypes & Y::COMMENT)) {
182
                    $result = self::buildLitteral($value, Y::LITT_FOLDED);
183
                } else {
184
                    $result = self::buildNodeList($value);
185
                }
186
            }
187
            if (is_null($parent)) {
188
                return $result;
189
            } else {
190
                if (is_array($parent)) {
191
                    $parent[$identifier] = $result;
192
                } else {
193
                    $parent->{$identifier} = $result;
194
                }
195
            }
196
        }
197
    }
198
199
    /**
200
     * Builds an item. Adds the item value to the parent array|Iterator
201
     *
202
     * @param      Node        $node    The node with type YAML::ITEM
203
     * @param      array|\Iterator      $parent  The parent
204
     *
205
     * @throws     \Exception  if parent is another type than array or object Iterator
206
     * @return null
207
     */
208
    private static function buildItem(Node $node, &$parent)
209
    {
210
        extract((array) $node, EXTR_REFS);
0 ignored issues
show
Bug introduced by
(array) $node cannot be passed to extract() as the parameter $var_array expects a reference.
Loading history...
211
        if (!is_array($parent) && !($parent instanceof \ArrayIterator)) {
212
            throw new \Exception("parent must be an Iterable not ".(is_object($parent) ? get_class($parent) : gettype($parent)), 1);
213
        }
214
        $ref = $parent instanceof \ArrayIterator ? $parent->getArrayCopy() : $parent;
215
        $numKeys = array_filter(array_keys($ref), 'is_int');
216
        $key = count($numKeys) > 0 ? max($numKeys) + 1 : 0;
217
        if ($value instanceof Node) {
218
            if($value->type & Y::KEY) {
219
                self::buildKey($node->value, $parent);
0 ignored issues
show
Bug introduced by
It seems like $node->value can also be of type null or object<Dallgoot\Yaml\NodeList> or string; however, Dallgoot\Yaml\Builder::buildKey() does only seem to accept object<Dallgoot\Yaml\Node>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
220
                return;
221
            } elseif ($value->type & Y::ITEM) {
222
                $a = [];
223
                $result = self::buildItem($value, $a);
224
            } else {
225
                $result = self::build($value);
226
            }
227
        } elseif ($value instanceof NodeList) {
228
            $result = self::buildNodeList($value);
229
        }
230
        $parent[$key] = $result;
231
    }
232
233
234
    /**
235
     * Builds a litteral (folded or not) or any NodeList that has YAML::RAW type (like a multiline value)
236
     *
237
     * @param      NodeList  $children  The children
0 ignored issues
show
Bug introduced by
There is no parameter named $children. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
238
     * @param      integer   $type      The type
239
     *
240
     * @return     string    The litteral.
241
     * @todo : Example 6.1. Indentation Spaces  spaces must be considered as content
242
     */
243
    private static function buildLitteral(NodeList $list, int $type):string
244
    {
245
        $list->rewind();
246
        $refIndent = $list->current()->indent;
247
        //remove trailing blank
248
        while ($list->top()->type & Y::BLANK) {
249
            $list->pop();
250
        }
251
        $result = '';
252
        $separator = '';
253
        if ($type & Y::LITT)         $separator = "\n";
254
        if ($type & Y::LITT_FOLDED)  $separator = ' ';
255
        foreach ($list as $child) {
256
            if ($child->value instanceof NodeList) {
257
                $result .= self::buildLitteral($child->value, $type).$separator;
258
            } else {
259
                $val = $child->type & (Y::SCALAR|Y::BLANK) ? $child->value : substr($child->raw, $refIndent);
260
                if ($type & Y::LITT_FOLDED && ($child->indent > $refIndent || ($child->type & Y::BLANK))) {
261
                    if ($result[-1] === $separator)
262
                        $result[-1] = "\n";
263
                    if ($result[-1] === "\n")
264
                        $result .= $val;
265
                    continue;
266
                }
267
                $result .= $val.$separator;
268
            }
269
        }
270
        return rtrim($result);
271
    }
272
273
    /**
274
     * Builds a set key.
275
     *
276
     * @param      Node        $node    The node of type YAML::SET_KEY.
277
     * @param      object      $parent  The parent
278
     *
279
     * @throws     \Exception  if a problem occurs during serialisation (json format) of the key
280
     */
281
    private function buildSetKey(Node $node, &$parent)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
282
    {
283
        $built = is_object($node->value) ? self::build($node->value) : null;
0 ignored issues
show
Documentation introduced by
$node->value is of type object<Dallgoot\Yaml\Nod...Dallgoot\Yaml\NodeList>, but the function expects a object<Dallgoot\Yaml\object>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
284
        $stringKey = is_string($built) && Regex::isProperlyQuoted($built) ? trim($built, '\'" '): $built;
285
        $key = json_encode($stringKey, JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_UNESCAPED_SLASHES);
286
        if (empty($key)) throw new \Exception("Cant serialize complex key: ".var_export($node->value, true), 1);
287
        $parent->{trim($key, '\'" ')} = null;
288
    }
289
290
    /**
291
     * Builds a set value.
292
     *
293
     * @param      Node    $node    The node of type YAML::SET_VALUE
294
     * @param      object  $parent  The parent (the document object or any previous object created through a mapping key)
295
     */
296
    private function buildSetValue(Node $node, &$parent)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
297
    {
298
        $prop = array_keys(get_object_vars($parent));
299
        $key = end($prop);
300
        if ($node->value->type & (Y::ITEM|Y::KEY )) {
301
            $nl = new NodeList;
302
            $nl->push($node->value);
303
            $node->value = $nl;
304
        }
305
        $parent->{$key} = self::build($node->value);
0 ignored issues
show
Documentation introduced by
$node->value is of type object<Dallgoot\Yaml\Nod...t\Yaml\NodeList>|string, but the function expects a object<Dallgoot\Yaml\object>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
306
    }
307
308
    /**
309
     * Builds a tag and its value (also built) and encapsulates them in a Tag object.
310
     *
311
     * @param      Node    $node    The node of type YAML::TAG
312
     * @param      mixed  $parent  The parent
313
     *
314
     * @return     Tag|null     The tag object of class Dallgoot\Yaml\Tag.
315
     */
316
    private static function buildTag(Node $node, &$parent)
317
    {
318
        $name = (string) $node->identifier;
319
        if ($parent === self::$_root && empty($node->value)) {
320
            $parent->addTag($name);
321
        } else {
322
            $target = $node->value;
323
            if ($node->value instanceof Node) {
324
                if ($node->value->type & (Y::KEY|Y::ITEM)) {
325
                    if (is_null($parent)) {
326
                        $target = new NodeList;
327
                        $target->push($node->value);
328
                        // $target->type = $node->value->type & Y::KEY ? Y::MAPPING : Y::SEQUENCE;
329
                    } else {
330
                        self::build($node->value, $parent);
0 ignored issues
show
Documentation introduced by
$node->value is of type object<Dallgoot\Yaml\Node>, but the function expects a object<Dallgoot\Yaml\object>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
331
                        // $node->value->type & Y::KEY ? self::buildKey($node->value, $parent) : self::buildItem($node->value, $parent);
332
                    }
333
                }
334
            }
335
            //TODO: have somewhere a list of common tags and their treatment
336
            // if (in_array($node->identifier, ['!binary', '!str'])) {
337
            //     $target->type = Y::RAW;
338
            // }
339
            return new Tag($name, is_object($target) ? self::build($target) : null);
0 ignored issues
show
Documentation introduced by
$target is of type object<Dallgoot\Yaml\Nod...Dallgoot\Yaml\NodeList>, but the function expects a object<Dallgoot\Yaml\object>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
340
        }
341
    }
342
343
    /**
344
     * Builds a directive. NOT IMPLEMENTED YET
345
     *
346
     * @param      Node  $node    The node
347
     * @param      mixed  $parent  The parent
348
     * @todo implement if requested
349
     */
350
    private function buildDirective(Node $node, $parent)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
Unused Code introduced by
The parameter $node 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...
Unused Code introduced by
The parameter $parent 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...
351
    {
352
        // TODO : implement
353
    }
354
}
355