1 | <?php |
||
8 | class CodeBlock |
||
9 | { |
||
10 | /** |
||
11 | * @var string The contained code |
||
12 | */ |
||
13 | private $code; |
||
14 | |||
15 | /** |
||
16 | * @param string $code |
||
17 | */ |
||
18 | public function __construct($code) |
||
22 | |||
23 | /** |
||
24 | * Grab contained code |
||
25 | * |
||
26 | * @return string |
||
27 | */ |
||
28 | public function getCode() |
||
32 | |||
33 | /** |
||
34 | * Execute code block |
||
35 | * |
||
36 | * @return Result The result of the executed code |
||
37 | */ |
||
38 | public function execute() |
||
53 | } |
||
54 |
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.