It seems like $dir defined by $this->getConfig()->get('cache_dir') on line 29 can also be of type boolean; however, CybozuHttp\CacheClient::attachCacheSubscriber() does only seem to accept string, maybe add an additional type check?
If a method or function can return multiple different values and unless you are
sure that you only can receive a single value in this context, we recommend
to add an additional type check:
/** * @return array|string */functionreturnsDifferentValues($x){if($x){return'foo';}returnarray();}$x=returnsDifferentValues($y);if(is_array($x)){// $x is an array.}
If this a common case that PHP Analyzer should handle natively, please let us
know by opening an issue.
Loading history...
32
}
33
34
/**
35
* @param string $dir
36
* @param int $ttl
37
*/
38
private function attachCacheSubscriber($dir, $ttl = 0)
39
{
40
$storage = new CacheStorage(new FilesystemCache($dir), $ttl);
41
CacheSubscriber::attach($this, $storage);
42
$this->storage = $storage;
43
}
44
45
/**
46
* Clear all cache
47
*/
48
public function cacheClear()
49
{
50
$dir = $this->getConfig()->get('cache_dir');
51
array_map('unlink', glob($dir . "/*/*"));
52
foreach (glob($dir . '/*') as $d) {
53
rmdir($d);
54
}
55
}
56
57
/**
58
* Delete cache by request
59
* @param RequestInterface $request
60
*/
61
public function deleteCache(RequestInterface $request)
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.