1 | <?php |
||
17 | final class Product implements CreatableFromArray |
||
18 | { |
||
19 | /** |
||
20 | * @var int |
||
21 | */ |
||
22 | private $id = 0; |
||
23 | |||
24 | /** |
||
25 | * @var null|string |
||
26 | */ |
||
27 | private $name; |
||
28 | |||
29 | /** |
||
30 | * @var null|string |
||
31 | */ |
||
32 | private $code = ''; |
||
33 | |||
34 | /** |
||
35 | * @var string[] |
||
36 | */ |
||
37 | private $channels = []; |
||
38 | |||
39 | /** |
||
40 | * @var string[][] |
||
41 | */ |
||
42 | private $translations = []; |
||
43 | |||
44 | /** |
||
45 | * @var Image[] |
||
46 | */ |
||
47 | private $images = []; |
||
48 | |||
49 | private function __construct() |
||
52 | |||
53 | /** |
||
54 | * @return Product |
||
55 | */ |
||
56 | public static function createFromArray(array $data): self |
||
87 | |||
88 | public function getId(): int |
||
92 | |||
93 | public function getCode(): string |
||
97 | |||
98 | /** |
||
99 | * @return string[] |
||
100 | */ |
||
101 | public function getChannels(): array |
||
105 | |||
106 | /** |
||
107 | * @return \string[][] |
||
108 | */ |
||
109 | public function getTranslations(): array |
||
113 | |||
114 | /** |
||
115 | * @return Image[] |
||
116 | */ |
||
117 | public function getImages(): array |
||
121 | |||
122 | public function getName(): ?string |
||
126 | } |
||
127 |
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.