authManager.php laravel 6中的错误异常(E_警告)非法偏移量类型

authManager.php laravel 6中的错误异常(E_警告)非法偏移量类型,php,laravel-6.2,Php,Laravel 6.2,我正在尝试为我的Laravel应用程序创建一个登录功能,其中register工作正常,数据被添加到MySQL表中。但当我使用凭据登录时,它会显示 ErrorException(E_警告)返回的偏移量类型非法 $this->guards[$name]$this->guards[$name]=$this->resolve($name) 请帮我做这件事 public function guard($name = null) { $name = $name ?: $this->getDef

我正在尝试为我的Laravel应用程序创建一个登录功能,其中register工作正常,数据被添加到MySQL表中。但当我使用凭据登录时,它会显示

ErrorException(E_警告)返回的偏移量类型非法 $this->guards[$name]$this->guards[$name]=$this->resolve($name)

请帮我做这件事

public function guard($name = null)
{
    $name = $name ?: $this->getDefaultDriver();

    return $this->guards[$name] ?? $this->guards[$name] = $this->resolve($name);
}
我还添加了新的函数代码

public function guard($name = null)
{
    if (empty($name)) {
        $name = $this->getDefaultDriver();
    }
    echo 'Argument type: '. gettype($name);
    var_dump($name); 
    if (key_exists($name, $this->guards)) {
        $result = $this->guards[$name];
    } else {
        $result = $this->resolve($name);
    }
    return $result;
}

它显示在key_exists()中,第一个参数应该是整数或字符串,然后我添加了var_dump()方法来了解$name的类型。

这对您有用吗

public function guard($name = null)
{
    if (empty($name)) {
        $name = $this->getDefaultDriver();
    }

    if (key_exists($name, $this->guards)) {
        $result = $this->guards[$name];
    } else {
        $result = $this->resolve($name);
    }
    return $result;
}

现在它给了我一个新的错误ErrorException(E_WARNING)key_exists():如果(key_exists($name,$this->guards)){$result=$this->guards[$name];@shubhanshu放在
if(key_exists…
此行:
echo'参数类型:”。gettype($name);
并写回类型。您也可以使用
var\u dump($name)
获取有关var
$name
的信息时,您遇到了问题。它只是给了我一大堆信息而没有解决问题。@shubhanshu垃圾根本不是垃圾。它是解决问题的关键信息。编辑您的问题并添加有关导致问题的
$name
类型的信息。我已经编辑了我的问题并添加了您想要的信息,请帮助我完成。