1 | <?php |
||
15 | class Cache |
||
16 | { |
||
17 | /** |
||
18 | * @var CacheItemPoolInterface The cache implementation used |
||
19 | */ |
||
20 | private $cache; |
||
21 | |||
22 | /** |
||
23 | * @var CacheUtil |
||
24 | */ |
||
25 | private $cacheUtil; |
||
26 | |||
27 | /** |
||
28 | * @var CacheControl |
||
29 | */ |
||
30 | private $cacheControl; |
||
31 | |||
32 | /** |
||
33 | * Set the psr-6 cache pool. |
||
34 | * |
||
35 | * @param CacheItemPoolInterface $cache |
||
36 | */ |
||
37 | public function __construct(CacheItemPoolInterface $cache) |
||
42 | |||
43 | /** |
||
44 | * Set a cache-control header to all responses. |
||
45 | * |
||
46 | * @param string|CacheControl $cacheControl |
||
47 | * |
||
48 | * @return self |
||
49 | */ |
||
50 | public function cacheControl($cacheControl) |
||
60 | |||
61 | /** |
||
62 | * Execute the middleware. |
||
63 | * |
||
64 | * @param RequestInterface $request |
||
65 | * @param ResponseInterface $response |
||
66 | * @param callable $next |
||
67 | * |
||
68 | * @return ResponseInterface |
||
69 | */ |
||
70 | public function __invoke(RequestInterface $request, ResponseInterface $response, callable $next) |
||
120 | |||
121 | /** |
||
122 | * Returns the id used to cache a request. |
||
123 | * |
||
124 | * @param RequestInterface $request |
||
125 | * |
||
126 | * @return string |
||
127 | */ |
||
128 | private function getCacheKey(RequestInterface $request) |
||
132 | } |
||
133 |
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.