JRG
JRG

Reputation: 2135

Strange PHPCS error message

I have the following snippet in a php class:

$returnArray = array();
while($row = mysql_fetch_assoc($rhandle)) {
    $returnArray[] = $row;
}

phpcs complains about the 'while' line:

 161 | ERROR   | Expected "while (...) {\n"; found "while(...){\n"

Upvotes: 0

Views: 196

Answers (1)

marcelog
marcelog

Reputation: 7180

the problem is that cs (in this case) expects a space after the while. so you need to write your code like this:

while ($row = mysql_fetch_assoc($rhandle)) {
}

EDIT: also, see that CS is reporting that you are missing the space between ) and { when closing the while, i think you fixed it when posting the question :)

Upvotes: 2

Related Questions