2017-10-11 7 views
2

に、私はこのエラー FatalErrorExceptionFatalErrorException構文エラー、予期しない ':'、予期している ';' 「:」私はXAMPPを再インストールして、私のlaravelプロジェクトを実行する場合や「{」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; 
    } 
} 
+0

public function registerPermissions(): bool 

から: boolを削除しますか?エラーはクリアです。なぜそれを修正しないのですか? – Hassaan

+0

@サランヤ:1)ループが正しく閉じているかどうかを確認してください。 2)セミクロンが不足していることを確認してください。 – Abhijit

+0

PermissionRegistrar.php(行33)を共有し、1行上にあることを確認してください。 – C2486

答えて

0

Return type declaration support is added to php 7あります。 (あなたはPHP 5.6.31で現在のように)だからあなたのコードはどこにあるの

public function registerPermissions() 
+0

これはPHPバージョンの問題だと思いますか? – usertest

+0

はい、そのPHP版の問題です。私はあなたに現在のバージョンを尋ねました。あなたが使用している構文はPHP 7でサポートされています –

+0

はい、私はversion.itの作品を変更しました。ありがとうございます – usertest

関連する問題