1 | <?php |
||
10 | class CodeBlock |
||
11 | { |
||
12 | /** |
||
13 | * @var string The contained code |
||
14 | */ |
||
15 | private $code; |
||
16 | |||
17 | public function __construct(string $code) |
||
21 | |||
22 | /** |
||
23 | * Prepend this code block with the contents of $codeBlock |
||
24 | */ |
||
25 | public function prepend(CodeBlock $codeBlock) |
||
35 | |||
36 | /** |
||
37 | * Grab contained code |
||
38 | */ |
||
39 | public function getCode(): string |
||
43 | |||
44 | /** |
||
45 | * Execute code block |
||
46 | * |
||
47 | * @return Result The result of the executed code |
||
48 | */ |
||
49 | public function execute(): Result |
||
64 | } |
||
65 |
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.