Minimum Version: 7.2

For PHP, we use a foundation of PSR-1 and PSR-2 and then customize from there. These customizations are highlighted below:

Linting Code

We use a custom standard for the phpcs tool, available at Submitty/submitty-php-codesniffer. You can run this against your code by running it (assuming in the site/ directory):

vendor/bin/phpcs --standard=Submitty path/to/dir/or/file.php

Classes, Methods

class Test {
    public function foo() {
        // code
    }

    public function method(
        $long_arg_name_1,
        $another_long_name,
        $third_long_name
    ) {
        // code
    }
}

Control Structures

if ($foo) {
    // code
}
elseif ($bar) {
    // code
}
else {
    // code
}
do {
    // code
} while ($foo);

Naming Conventions