當我重新安裝我的XAMPP和運行我laravel項目,我得到這個錯誤 FatalErrorExceptionFatalErrorException語法錯誤,意外的':',期待';'或「{」在PermissionRegistrar.php
語法錯誤,意想不到的「:」,希望「;」或 '{' 在 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;
}
}
哪裏是你的代碼?錯誤很明顯。你爲什麼不修復它? – Hassaan
@saranya:1)請檢查您的循環是否正確關閉。 2)請驗證是否缺少任何半色調 – Abhijit
分享'PermissionRegistrar.php(第33行)'和上面一行? – C2486