1 | <?php declare(strict_types=1); |
||
13 | class I18nHandler |
||
14 | { |
||
15 | const REGEX_LOCALE = '#^/(?P<locale>[a-z]{2}[-_][a-zA-Z]{2})(?:/|$)#'; |
||
16 | |||
17 | /** @var Translator$translator */ |
||
18 | private $translator; |
||
19 | |||
20 | /** @var array $supportedLocales */ |
||
21 | private $supportedLocales; |
||
22 | |||
23 | /** @var string $defaultLocale */ |
||
24 | private $defaultLocale; |
||
25 | |||
26 | /** |
||
27 | * InternationalisationMiddleware constructor. |
||
28 | * @param $helper |
||
29 | * @param string|null $defaultLocale |
||
30 | */ |
||
31 | 12 | public function __construct(Translator $translator, array $supportedLocales, string $defaultLocale) |
|
37 | |||
38 | /** |
||
39 | * @param ServerRequestInterface $request |
||
40 | * @return ServerRequestInterface |
||
41 | * @throws NotFoundException |
||
42 | */ |
||
43 | 10 | public function handleI18n(ServerRequestInterface $request): ServerRequestInterface |
|
68 | |||
69 | /** |
||
70 | * @param ServerRequestInterface $request |
||
71 | * @return ServerRequestInterface |
||
72 | */ |
||
73 | 2 | public function removeI18n(ServerRequestInterface $request): ServerRequestInterface |
|
89 | } |
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.