|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Patsura Dmitry https://github.com/ovr <[email protected]> |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace PHPSA; |
|
7
|
|
|
|
|
8
|
|
|
class Issue |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @todo Description |
|
12
|
|
|
* |
|
13
|
|
|
* @var string |
|
14
|
|
|
*/ |
|
15
|
|
|
const CATEGORY_BUG_RISK = 'Bug Risk'; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @todo Description |
|
19
|
|
|
* |
|
20
|
|
|
* @var string |
|
21
|
|
|
*/ |
|
22
|
|
|
const CATEGORY_CLARITY = 'Clarity'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @todo Description |
|
26
|
|
|
* |
|
27
|
|
|
* @var string |
|
28
|
|
|
*/ |
|
29
|
|
|
const CATEGORY_COMPATIBILITY = 'Compatibility'; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @todo Description |
|
33
|
|
|
* |
|
34
|
|
|
* @var string |
|
35
|
|
|
*/ |
|
36
|
|
|
const CATEGORY_COMPLEXITY = 'Complexity'; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @todo Description |
|
40
|
|
|
* |
|
41
|
|
|
* @var string |
|
42
|
|
|
*/ |
|
43
|
|
|
const CATEGORY_DUPLICATION = 'Duplication'; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @todo Description |
|
47
|
|
|
* |
|
48
|
|
|
* @var string |
|
49
|
|
|
*/ |
|
50
|
|
|
const CATEGORY_PERFORMANCE = 'Performance'; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @todo Description |
|
54
|
|
|
* |
|
55
|
|
|
* @var string |
|
56
|
|
|
*/ |
|
57
|
|
|
const CATEGORY_SECURITY = 'Security'; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @todo Description |
|
61
|
|
|
* |
|
62
|
|
|
* @var string |
|
63
|
|
|
*/ |
|
64
|
|
|
const CATEGORY_STYLE = 'Style'; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Required. Must always be "issue". |
|
68
|
|
|
* |
|
69
|
|
|
* @var string |
|
70
|
|
|
*/ |
|
71
|
|
|
protected $type = 'issue'; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Required. A unique name representing the static analysis check that emitted this issue. |
|
75
|
|
|
* |
|
76
|
|
|
* @var string |
|
77
|
|
|
*/ |
|
78
|
|
|
protected $checkName; |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Required. A string explaining the issue that was detected. |
|
82
|
|
|
* |
|
83
|
|
|
* @var string |
|
84
|
|
|
*/ |
|
85
|
|
|
protected $description; |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Optional. A markdown snippet describing the issue, including deeper explanations and links to other resources. |
|
89
|
|
|
* |
|
90
|
|
|
* @var string |
|
91
|
|
|
*/ |
|
92
|
|
|
protected $content; |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Required. At least one category indicating the nature of the issue being reported. |
|
96
|
|
|
* |
|
97
|
|
|
* @var string |
|
98
|
|
|
*/ |
|
99
|
|
|
protected $categories; |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Required. A Location object representing the place in the source code where the issue was discovered. |
|
103
|
|
|
* |
|
104
|
|
|
* @var IssueLocation |
|
105
|
|
|
*/ |
|
106
|
|
|
protected $location; |
|
107
|
|
|
|
|
108
|
|
|
protected $blame; |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @param string $checkName |
|
112
|
|
|
* @param string $description |
|
113
|
|
|
* @param IssueLocation $location |
|
114
|
|
|
* @param array $categories |
|
115
|
|
|
*/ |
|
116
|
41 |
|
public function __construct($checkName, $description, IssueLocation $location, array $categories = [self::CATEGORY_BUG_RISK]) |
|
117
|
|
|
{ |
|
118
|
41 |
|
$this->checkName = $checkName; |
|
119
|
41 |
|
$this->description = $description; |
|
120
|
41 |
|
$this->location = $location; |
|
121
|
41 |
|
$this->categories = $categories; |
|
|
|
|
|
|
122
|
41 |
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @return array |
|
126
|
|
|
*/ |
|
127
|
|
|
public function toArray() |
|
128
|
|
|
{ |
|
129
|
|
|
return [ |
|
130
|
|
|
'type' => $this->type, |
|
131
|
|
|
'check_name' => $this->checkName, |
|
132
|
|
|
'description' => $this->description, |
|
133
|
|
|
'location' => $this->location->toArray(), |
|
134
|
|
|
'categories' => $this->categories, |
|
135
|
|
|
'blame' => $this->blame, |
|
136
|
|
|
]; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @return IssueLocation |
|
141
|
|
|
*/ |
|
142
|
41 |
|
public function getLocation() |
|
143
|
|
|
{ |
|
144
|
41 |
|
return $this->location; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* @return string |
|
149
|
|
|
*/ |
|
150
|
|
|
public function getType() |
|
151
|
|
|
{ |
|
152
|
|
|
return $this->type; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @return string |
|
157
|
|
|
*/ |
|
158
|
41 |
|
public function getCheckName() |
|
159
|
|
|
{ |
|
160
|
41 |
|
return $this->checkName; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* @return string |
|
165
|
|
|
*/ |
|
166
|
41 |
|
public function getDescription() |
|
167
|
|
|
{ |
|
168
|
41 |
|
return $this->description; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* @return string |
|
173
|
|
|
*/ |
|
174
|
|
|
public function getBlame() |
|
175
|
|
|
{ |
|
176
|
|
|
return $this->blame; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* @param string $blame |
|
181
|
|
|
*/ |
|
182
|
|
|
public function setBlame($blame) |
|
183
|
|
|
{ |
|
184
|
|
|
$this->blame = $blame; |
|
185
|
|
|
} |
|
186
|
|
|
} |
|
187
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..