Declare_   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 1
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubNodeNames() 0 3 1
A __construct() 0 5 1
1
<?php
2
3
namespace PhpParser\Node\Stmt;
4
5
use PhpParser\Node;
6
class Declare_ extends Node\Stmt
7
{
8
    /** @var DeclareDeclare[] List of declares */
9
    public $declares;
10
    /** @var Node[] Statements */
11
    public $stmts;
12
13
    /**
14
     * Constructs a declare node.
15
     *
16
     * @param DeclareDeclare[] $declares   List of declares
17
     * @param Node[]|null      $stmts      Statements
18
     * @param array            $attributes Additional attributes
19
     */
20
    public function __construct(array $declares, array $stmts = null, array $attributes = array()) {
21
        parent::__construct($attributes);
22
        $this->declares = $declares;
23
        $this->stmts = $stmts;
0 ignored issues
show
Documentation Bug introduced by
It seems like $stmts can be null. However, the property $stmts is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
24
    }
25
26
    public function getSubNodeNames() {
27
        return array('declares', 'stmts');
28
    }
29
}
30