1 | <?php |
||
20 | class Assert |
||
21 | { |
||
22 | use TypeAssertTrait; |
||
23 | use ObjectAssertTrait; |
||
24 | use CollectionAssertTrait; |
||
25 | |||
26 | /** |
||
27 | * An array of operators mapping to assertions. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | public static $operators = [ |
||
32 | '==' => 'loosely->equal', |
||
33 | '===' => 'equal', |
||
34 | '>' => 'above', |
||
35 | '>=' => 'least', |
||
36 | '<' => 'below', |
||
37 | '<=' => 'most', |
||
38 | '!=' => 'not->loosely->equal', |
||
39 | '!==' => 'not->equal' |
||
40 | ]; |
||
41 | |||
42 | /** |
||
43 | * @var Assertion |
||
44 | */ |
||
45 | protected $assertion; |
||
46 | |||
47 | /** |
||
48 | * @param ResponderInterface $responder |
||
|
|||
49 | */ |
||
50 | public function __construct(Assertion $assertion = null) |
||
57 | |||
58 | /** |
||
59 | * Perform an a loose equality assertion. |
||
60 | * |
||
61 | * @param mixed $actual |
||
62 | * @param mixed $expected |
||
63 | * @param string $message |
||
64 | */ |
||
65 | public function equal($actual, $expected, $message = "") |
||
70 | |||
71 | /** |
||
72 | * Perform a negated loose equality assertion. |
||
73 | * |
||
74 | * @param mixed $actual |
||
75 | * @param mixed $expected |
||
76 | * @param string $message |
||
77 | */ |
||
78 | public function notEqual($actual, $expected, $message = "") |
||
83 | |||
84 | /** |
||
85 | * Performs a throw assertion. |
||
86 | * |
||
87 | * @param callable $fn |
||
88 | * @param $exceptionType |
||
89 | * @param string $exceptionMessage |
||
90 | * @param string $message |
||
91 | */ |
||
92 | public function throws(callable $fn, $exceptionType, $exceptionMessage = "", $message = "") |
||
97 | |||
98 | /** |
||
99 | * Performs a negated throw assertion. |
||
100 | * |
||
101 | * @param callable $fn |
||
102 | * @param $exceptionType |
||
103 | * @param string $exceptionMessage |
||
104 | * @param string $message |
||
105 | */ |
||
106 | public function doesNotThrow(callable $fn, $exceptionType, $exceptionMessage = "", $message = "") |
||
111 | |||
112 | /** |
||
113 | * Perform an ok assertion. |
||
114 | * |
||
115 | * @param mixed $object |
||
116 | * @param string $message |
||
117 | */ |
||
118 | public function ok($object, $message = "") |
||
123 | |||
124 | /** |
||
125 | * Perform a negated assertion. |
||
126 | * |
||
127 | * @param mixed $object |
||
128 | * @param string $message |
||
129 | */ |
||
130 | public function notOk($object, $message = "") |
||
135 | |||
136 | /** |
||
137 | * Perform a strict equality assertion. |
||
138 | * |
||
139 | * @param mixed $actual |
||
140 | * @param mixed $expected |
||
141 | * @param string $message |
||
142 | */ |
||
143 | public function strictEqual($actual, $expected, $message = "") |
||
148 | |||
149 | /** |
||
150 | * Perform a negated strict equality assertion. |
||
151 | * |
||
152 | * @param mixed $actual |
||
153 | * @param mixed $expected |
||
154 | * @param string $message |
||
155 | */ |
||
156 | public function notStrictEqual($actual, $expected, $message = "") |
||
161 | |||
162 | /** |
||
163 | * Perform a pattern assertion. |
||
164 | * |
||
165 | * @param string $value |
||
166 | * @param string $pattern |
||
167 | * @param string $message |
||
168 | */ |
||
169 | public function match($value, $pattern, $message = "") |
||
174 | |||
175 | /** |
||
176 | * Perform a negated pattern assertion. |
||
177 | * |
||
178 | * @param string $value |
||
179 | * @param string $pattern |
||
180 | * @param string $message |
||
181 | */ |
||
182 | public function notMatch($value, $pattern, $message = "") |
||
187 | |||
188 | /** |
||
189 | * Compare two values using the given operator. |
||
190 | * |
||
191 | * @param mixed $left |
||
192 | * @param string $operator |
||
193 | * @param mixed $right |
||
194 | * @param string $message |
||
195 | */ |
||
196 | public function operator($left, $operator, $right, $message = "") |
||
204 | |||
205 | /** |
||
206 | * Defined to allow use of reserved words for methods. |
||
207 | * |
||
208 | * @param $method |
||
209 | * @param $args |
||
210 | */ |
||
211 | public function __call($method, $args) |
||
222 | } |
||
223 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.