Question

Could anyone help me with these errors? I am getting them from the code checker plugin.,

if·($this->content·!==·null){

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

#38: ········if(isloggedin()·and·!has_capability('moodle/site:config',·get_context_instance(CONTEXT_SYSTEM)))·{

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

#44: ············if($courseid·>·1)·{

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

#49: ················foreach($criteriamods·as·$ctmds)·{

Expected "foreach (...) {\n"; found "foreach(...) {\n"
Was it helpful?

Solution

Good news: these are not PHP errors. Bad news: they are violations of standard Moodle coding style.

Which means that fixing these "errors" will not have any effect on the way the code runs, but should (hopefully) lead to code which is easier for most Moodle developers to read and understand.

In all of the "errors" you have listed, the complaint looks to be related to spacing around the parentheses. For example, in the first one you need to put some space between the closing parenthesis ) and the opening brace {.

It's a similar story for the others. Once you have identified the appropriate lines of code, make sure there are spaces before the opening parentheses and after the closing parentheses.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top