我用审查器来分析我的代码。几乎所有的事情都已经解决了,但我似乎无法解决这个问题。
Accessing id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?我看到了这个问题,因为它是一个不存在属性的接口,但是我的代码工作得很好。那么,当我分析我的代码时,如何才能让这些代码传递呢?
谢谢
编辑
得到这些行上的错误(以及其他一些文件几乎相同)
$this->tracert->log(
'users',
$this->auth->user()->id,
$this->auth->user()->id,
'Login'
);该类的构造函数
/**
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \jorenvanhocht\Tracert\Tracert $tracert
*/
public function __construct(Guard $auth, Tracert $tracert)
{
parent::__construct($auth);
$this->tracert = $tracert;
}基本控制器的构造函数:
public function __construct(Guard $auth)
{
$this->auth = $auth;
$this->config = objectify(config('blogify'));
$this->auth_user = $this->auth->check() ? $this->auth->user() : false;
}旧合同https://github.com/illuminate/contracts/blob/master/Auth/Guard.php
发布于 2015-06-11 07:20:22
要解决经过身份验证的用户的id问题,您应该使用:
$this->auth->user()->getAuthIdentifier()Interface由方法组成。您正在直接访问属性。例如$foo->id而不是$foo->getId()。当然,你必须给界面添加新的方法。
解决办法是对检查器说,$object是所需类的实例。
if ($object instanceof MyClass) {
//
}https://stackoverflow.com/questions/30774076
复制相似问题