FatalErrorException语法错误,意外':',期待&#39 ;;'或者' {'在PermissionRegistrar.php中

时间:2017-10-11 05:49:21

标签: php laravel

当我重新安装我的xampp并运行我的laravel项目时,我收到此错误 FatalErrorException

  

语法错误,意外':',期待';'或者' {'在   PermissionRegistrar.php(第33行)   我的代码是

public function __construct(Gate $gate, Repository $cache, Log $logger)
{
    $this->gate = $gate;
    $this->cache = $cache;
    $this->logger = $logger;
}
public function registerPermissions(): bool
{
    try {
        $this->getPermissions()->map(function (Permission $permission) {
    $this->gate->define($permission->name, function ($user) use($permission) 
{
                return $user->hasPermissionTo($permission);
            });
        });
        return true;
    } catch (Exception $exception) {
        if ($this->shouldLogException()) {
            $this->logger->alert(
 "Could not register permissions because {$exceptiongetMessage()}".PHP_EOL.
                $exception->getTraceAsString()
            );
        }
        return false;
    }
}

1 个答案:

答案 0 :(得分:0)

Return type declaration support is added to php 7。因此,从

中删除: bool(正如您目前使用的是PHP 5.6.31)
public function registerPermissions(): bool

public function registerPermissions()