1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace whm\Smoke\Rules; |
4
|
|
|
|
5
|
|
|
use phm\HttpWebdriverClient\Http\Response\UriAwareResponse; |
6
|
|
|
use Psr\Http\Message\ResponseInterface; |
7
|
|
|
|
8
|
|
|
class CheckResult |
9
|
|
|
{ |
10
|
|
|
const STATUS_SUCCESS = 'success'; |
11
|
|
|
const STATUS_FAILURE = 'failure'; |
12
|
|
|
const STATUS_SKIPPED = 'skipped'; |
13
|
|
|
const STATUS_NONE = 'none'; |
14
|
|
|
|
15
|
|
|
const HINT_KEY = '__hint'; |
16
|
|
|
|
17
|
|
|
private $status; |
18
|
|
|
private $value; |
19
|
|
|
private $message; |
20
|
|
|
private $attributes = array(); |
21
|
|
|
private $ruleName; |
22
|
|
|
private $url; |
23
|
|
|
|
24
|
|
|
private $tool; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var UriAwareResponse |
28
|
|
|
*/ |
29
|
|
|
private $response; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Result constructor. |
33
|
|
|
* |
34
|
|
|
* @param $status |
35
|
|
|
* @param $value |
36
|
|
|
* @param $message |
37
|
|
|
*/ |
38
|
|
|
public function __construct($status, $message = '', $value = null, $url = null) |
39
|
|
|
{ |
40
|
|
|
$this->status = $status; |
41
|
|
|
$this->value = $value; |
42
|
|
|
$this->message = $message; |
43
|
|
|
$this->url = $url; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return Attribute[] |
48
|
|
|
*/ |
49
|
|
|
public function getAttributes() |
50
|
|
|
{ |
51
|
|
|
return $this->attributes; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param array $attributes |
|
|
|
|
56
|
|
|
*/ |
57
|
|
|
public function addAttribute(Attribute $attribute) |
58
|
|
|
{ |
59
|
|
|
$this->attributes[] = $attribute; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function setHint($message) |
63
|
|
|
{ |
64
|
|
|
$this->addAttribute(new Attribute(self::HINT_KEY, $message, false)); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return mixed |
69
|
|
|
*/ |
70
|
|
|
public function getStatus() |
71
|
|
|
{ |
72
|
|
|
return $this->status; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return mixed |
77
|
|
|
*/ |
78
|
|
|
public function getValue() |
79
|
|
|
{ |
80
|
|
|
return $this->value; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return string |
85
|
|
|
*/ |
86
|
|
|
public function getTool() |
87
|
|
|
{ |
88
|
|
|
return $this->tool; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @param string $tool |
93
|
|
|
*/ |
94
|
|
|
public function setTool($tool) |
95
|
|
|
{ |
96
|
|
|
$this->tool = $tool; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return string |
101
|
|
|
*/ |
102
|
|
|
public function getMessage() |
103
|
|
|
{ |
104
|
|
|
return $this->message; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @param string $message |
109
|
|
|
*/ |
110
|
|
|
public function setMessage($message) |
111
|
|
|
{ |
112
|
|
|
$this->message = $message; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return UriAwareResponse |
117
|
|
|
*/ |
118
|
|
|
public function getResponse() |
119
|
|
|
{ |
120
|
|
|
return $this->response; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @param ResponseInterface $response |
125
|
|
|
*/ |
126
|
|
|
public function setResponse(ResponseInterface $response) |
127
|
|
|
{ |
128
|
|
|
$this->response = $response; |
|
|
|
|
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @return mixed |
133
|
|
|
*/ |
134
|
|
|
public function getRuleName() |
135
|
|
|
{ |
136
|
|
|
return $this->ruleName; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param mixed $ruleName |
141
|
|
|
*/ |
142
|
|
|
public function setRuleName($ruleName) |
143
|
|
|
{ |
144
|
|
|
$this->ruleName = $ruleName; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @return string |
149
|
|
|
*/ |
150
|
|
|
public function getUrl() |
151
|
|
|
{ |
152
|
|
|
return $this->url; |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.