Completed
Push — master ( f1462e...556a60 )
by Nikola
09:28 queued 07:57
created

FileMetadata::getTraits()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/*
3
 * This file is part of the Abstract builder package, an RunOpenCode project.
4
 *
5
 * (c) 2017 RunOpenCode
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace RunOpenCode\AbstractBuilder\Ast\Metadata;
11
12
/**
13
 * Class FileMetadata
14
 *
15
 * @package RunOpenCode\AbstractBuilder\Ast\Metadata
16
 */
17
class FileMetadata
18
{
19
    /**
20
     * @var string
21
     */
22
    private $filename;
23
24
    /**
25
     * @var array
26
     */
27
    private $uses;
28
29
    /**
30
     * @var ClassMetadata[]
31
     */
32
    private $classes;
33
34
    /**
35
     * @var TraitMetadata[]
36
     */
37
    private $traits;
38
39
    /**
40
     * @var array
41
     */
42
    private $ast;
43
44
    /**
45
     * FileMetadata constructor.
46
     *
47
     * @param string $filename
48
     * @param array $classes
49
     * @param array $traits
50
     * @param array $ast
51
     */
52
    public function __construct($filename, array $uses = [], array $classes = [], array $traits = [], array $ast = null)
53
    {
54
        $this->filename = $filename;
55
        $this->uses = $uses;
56
        $this->classes = $classes;
57
        $this->traits = $traits;
58
        $this->ast = $ast;
0 ignored issues
show
Documentation Bug introduced by
It seems like $ast can be null. However, the property $ast 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...
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function getFilename()
65
    {
66
        return $this->filename;
67
    }
68
69
    /**
70
     * @return array
71
     */
72
    public function getUses()
73
    {
74
        return $this->uses;
75
    }
76
77
    /**
78
     * @return ClassMetadata[]
79
     */
80
    public function getClasses()
81
    {
82
        return $this->classes;
83
    }
84
85
    /**
86
     * @return TraitMetadata[]
87
     */
88
    public function getTraits()
89
    {
90
        return $this->traits;
91
    }
92
93
    /**
94
     * @return array
95
     */
96
    public function getAst()
97
    {
98
        return $this->ast;
99
    }
100
}
101