当我重新安装我的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;
}
}
答案 0 :(得分:0)
Return type declaration support is added to php 7。因此,从
中删除: bool
(正如您目前使用的是PHP 5.6.31)
public function registerPermissions(): bool
到
public function registerPermissions()