PHPエラーチェックで出たエラーの意味と解決方法

PHPのコーディング規約をよくわかってない初心者が
チェッカーかけたら山ほどエラーが出たのでメモ。



Expected 1 space after closing parenthesis; found 0

  • 意味:括弧のあとスペースないやん
  • 現状: }elseif(){
  • 解決: } elseif () {



Whitespace found at end of line

  • 意味:空白行インデントするな
  • 解決: 空白行のインデント削除



Expected "if (...) {\n"; found "if(...){"

  • 意味:if文1行にまとめんのやめろ
  • 現状: if (...) { 処理 }
  • 解決: if (...) {



Variable "pre_id" is not in valid camel caps format

  • 意味:変数スネークやめてキャメル型にして
  • 現状: $sample_name
  • 解決: $sampleName



Missing space after comma

  • 意味:コンマの後スペースないやんけ
  • 現状: array(aaa,bbb)
  • 解決: array(aaa, bbb)



Missing space after ';'

  • 意味:セミコロンの後スペースないやんけ
  • 現状: if ($i = 0;$i <= 10;$i++) {
  • 解決: if ($i = 0; $i <= 10; $i++) {



Expected 1 blank line before member var; 0 found

  • 意味:改行いれたほうがええぞ
  • 解決: 改行いれる



Closing brace must be on a line by itself

  • 意味:1行にまとめよ
  • 解決: まとめる



Each PHP statement must be on a line by itself

  • 意味:1行にまとめるな
  • 解決: 改行



Code after EXIT statement cannot be executed

  • 意味:EXIT文の後実行できないよ
  • 解決: return文の後にあった例外処理を前に回した?(ちょっと記憶が曖昧)



Line indented incorrectly; expected at least 5 spaces, found 4

  • 意味:インデントおかC
  • 解決: インデント追加



The use of count() inside a loop condition is not allowed;
assign the return value to a variable and use the variable in
the loop condition instead

  • 意味:for文の中でカウント使うのやめーや
  • 現状: if ($i = 0; $i <= count($aaa); $i++) {
  • 解決: $cnt = count($aaa);  if ($i = 0; $i <= $aaa; $i++) {