1 | <?php |
||
18 | trait AssertThrows |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * Asserts that callback throws an exception |
||
23 | * |
||
24 | * @param $throws |
||
25 | * @param callable $fn |
||
26 | * |
||
27 | * @throws \Exception |
||
28 | */ |
||
29 | public function assertThrows($throws, callable $fn) |
||
33 | |||
34 | /** |
||
35 | * Asserts that callback throws an exception with a message |
||
36 | * |
||
37 | * @param $throws |
||
38 | * @param $message |
||
39 | * @param callable $fn |
||
40 | * |
||
41 | * @throws Exception |
||
42 | */ |
||
43 | public function assertThrowsWithMessage($throws, $message, callable $fn) |
||
80 | |||
81 | /** |
||
82 | * @param Exception $exception |
||
83 | * @param string $expectedMsg |
||
84 | * |
||
85 | * @return bool |
||
86 | */ |
||
87 | private function exceptionMessageDoesNotMatchExpected(Exception $exception, string $expectedMsg) : bool |
||
91 | |||
92 | /** |
||
93 | * @param $throws |
||
94 | * @param $message |
||
95 | */ |
||
96 | private function parseThrows(&$throws, &$message) |
||
105 | } |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.