These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php declare(strict_types=1); |
||
2 | |||
3 | namespace WyriHaximus\FileDescriptors; |
||
4 | |||
5 | final class Factory |
||
6 | { |
||
7 | private const LISTERS = [ |
||
8 | ProcSelfFd::class, |
||
9 | ]; |
||
10 | |||
11 | 1 | public static function create(): ListerInterface |
|
12 | { |
||
13 | 1 | $lister = null; |
|
0 ignored issues
–
show
|
|||
14 | 1 | foreach (self::LISTERS as $listerClass) { |
|
15 | /** @var ListerInterface $lister */ |
||
16 | 1 | $lister = new $listerClass(); |
|
17 | 1 | if ($lister->isSupported() === true) { |
|
18 | 1 | return $lister; |
|
19 | } |
||
20 | unset($lister); |
||
21 | } |
||
22 | |||
23 | throw new \Exception('No suitable lister found'); |
||
24 | } |
||
25 | } |
||
26 |
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.