|
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 string |
|
105
|
|
|
*/ |
|
106
|
|
|
protected $location; |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @param string $checkName |
|
110
|
|
|
* @param string $description |
|
111
|
|
|
* @param array $location |
|
112
|
|
|
* @param array $categories |
|
113
|
|
|
*/ |
|
114
|
|
|
public function __construct($checkName, $description, array $location, array $categories = [self::CATEGORY_BUG_RISK]) |
|
115
|
|
|
{ |
|
116
|
|
|
$this->checkName = $checkName; |
|
117
|
|
|
$this->description = $description; |
|
118
|
|
|
$this->location = $location; |
|
|
|
|
|
|
119
|
|
|
$this->categories = $categories; |
|
|
|
|
|
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
public function toArray() |
|
123
|
|
|
{ |
|
124
|
|
|
return [ |
|
125
|
|
|
'type' => $this->type, |
|
126
|
|
|
'description' => $this->description, |
|
127
|
|
|
'location' => $this->location, |
|
128
|
|
|
'categories' => $this->categories, |
|
129
|
|
|
]; |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|