Search code examples
moodleparenthesesrequire-once

How to prevent phpfmt from removing parentheses from "require_once" statements


I use phpfmt to format the php files according to PSR1 standard. Every time I use the Format Document function (Shift + Alt + F) in Visual Studio Code, the parentheses have been removed from the require_once lines.

require_once($CFG->dirroot.'/lib/filelib.php');

-> require_once $CFG->dirroot.'/lib/filelib.php';

This is what I do not want. Because when uploading these files to Moodle, Moodle will throw errors:

(#30) "require_once" must be immediately followed by an open parenthesis

Problem: How to use the quick format under PSR1 without removing the parentheses of require_once?


Solution

  • Put this in settings.json: "phpfmt.exclude": ["RemoveIncludeParentheses"],

    But its still put a space after require_once.