for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace xiaodi;
use think\App;
use Lcobucci\JWT\Token;
/**
* 黑名单
*
*/
class Blacklist
{
private $app;
private $store;
protected $cacheName = 'blacklist';
public function __construct(App $app)
$this->app = $app;
$this->store = $this->getStore();
$this->store
$this->getStore()
xiaodi\Blacklist::getStore()
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
class A { function getObject() { return null; } } $a = new A(); $object = $a->getObject();
The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
}
* 获取 缓存驱动
* @return void
public function getStore()
return $this->app->cache;
return $this->app->cache
think\Cache
void
* 加入黑名单
* @param Token $token
public function push(Token $token)
if (false === $this->has($token)) {
$claims = $token->getClaims();
$exp = $claims['exp']->getValue() - time();
$this->store->push($this->cacheName, (string)$token, $exp);
* 是否存在黑名单
* @return boolean
public function has(Token $token)
$blacklist = $this->getAll();
return in_array((string)$token, $blacklist);
* 获取所有黑名单
* @return array
public function getAll()
return $this->store->get($this->cacheName, []);
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.