今回出てたLaravelの開発で出たエラー。結構ハマったのでメモ。
結論:フォルダ名も予約語使わないこと。
PHP Parse error: Syntax error, unexpected T_INTERFACE, expecting T_STRING or '{' on line 1
初めは全体通して動かしてたけど問題の切り分けのために、tinkerで直指定してファイル呼び出し。
php artisan tinker
>>> use App\Infrastructure\Repositories\Interface\IGreetdictionarysRepository;
PHP Parse error: Syntax error, unexpected T_INTERFACE, expecting T_STRING or '{' on line 1
ファイルの中身を全部消してもエラー出るので、フォルダ名を変えた。
Interfaceって名前が予約語なのでIRepositoriesに変えた。
use App\Infrastructure\Repositories\IRepositories;
use App\Infrastructure\Repositories\IRepositories\IGreetdictionarysRepository;
これで通った。
他の言語でも同じように注意
Pythonの予約語に注意
Pythonの変数名で避けた方がいい名前は?
https://qiita.com/matsui2019/items/98165df7bee980ae6a18
MySqlの予約語に注意
MySqlで予約語を使うと、syntax errorが出る
https://qiita.com/ma_me/items/a98842d1cb65bfcd20cf