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
|
|
|
/** |
25
|
|
|
* @var ResponseInterface |
26
|
|
|
*/ |
27
|
|
|
private $response; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Result constructor. |
31
|
|
|
* |
32
|
|
|
* @param $status |
33
|
|
|
* @param $value |
34
|
|
|
* @param $message |
35
|
|
|
*/ |
36
|
|
|
public function __construct($status, $message = '', $value = null, $url = null) |
37
|
|
|
{ |
38
|
|
|
$this->status = $status; |
39
|
|
|
$this->value = $value; |
40
|
|
|
$this->message = $message; |
41
|
|
|
$this->url = $url; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return Attribute[] |
46
|
|
|
*/ |
47
|
|
|
public function getAttributes() |
48
|
|
|
{ |
49
|
|
|
return $this->attributes; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param array $attributes |
|
|
|
|
54
|
|
|
*/ |
55
|
|
|
public function addAttribute(Attribute $attribute) |
56
|
|
|
{ |
57
|
|
|
$this->attributes[] = $attribute; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function setHint($message) |
61
|
|
|
{ |
62
|
|
|
$this->addAttribute(new Attribute(self::HINT_KEY, $message, false)); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return mixed |
67
|
|
|
*/ |
68
|
|
|
public function getStatus() |
69
|
|
|
{ |
70
|
|
|
return $this->status; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return mixed |
75
|
|
|
*/ |
76
|
|
|
public function getValue() |
77
|
|
|
{ |
78
|
|
|
return $this->value; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
|
|
public function getMessage() |
85
|
|
|
{ |
86
|
|
|
return $this->message; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param string $message |
91
|
|
|
*/ |
92
|
|
|
public function setMessage($message) |
93
|
|
|
{ |
94
|
|
|
$this->message = $message; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return UriAwareResponse |
99
|
|
|
*/ |
100
|
|
|
public function getResponse() |
101
|
|
|
{ |
102
|
|
|
return $this->response; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @param ResponseInterface $response |
107
|
|
|
*/ |
108
|
|
|
public function setResponse(ResponseInterface $response) |
109
|
|
|
{ |
110
|
|
|
$this->response = $response; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return mixed |
115
|
|
|
*/ |
116
|
|
|
public function getRuleName() |
117
|
|
|
{ |
118
|
|
|
return $this->ruleName; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param mixed $ruleName |
123
|
|
|
*/ |
124
|
|
|
public function setRuleName($ruleName) |
125
|
|
|
{ |
126
|
|
|
$this->ruleName = $ruleName; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return string |
131
|
|
|
*/ |
132
|
|
|
public function getUrl() |
133
|
|
|
{ |
134
|
|
|
return $this->url; |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|
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.