This is the coding style for the ILIAS project.
The ILIAS coding standard is aligned to the widely used and established PSR-2 standard of the PHP Interop Group (PHP-FIG), extended by the following additions:
Operators MUST have a space before and after the operator.
Mathematical Operators:
$result = 1 + $value;
Comparsion Operators:
if ($size > 0) {
// ...
}
Concatenation Operator:
$test = 'hello ' . $name . '!';
Spaces MUST be added after a type cast.
$foo = (int) '12345';
Spaces MUST be added around a colon in return type declaration.
function () : void {}
The ILIAS code style can be checked/applied with/by different tools.
When working with the PhpStorm
IDE developers can import the
PhpStorm Code Style example.
Furthermore multiple Git Hooks are provided to check or fix the code style of changed files in a Git commit.
Developers can additionally use the PHP Coding Standards Fixer to check or fix one or multiple files.
libs/composer/vendor/bin/php-cs-fixer fix --dry-run --stop-on-violation --using-cache=no --diff --config=./CI/PHP-CS-Fixer/code-format.php_cs [FILE]
libs/composer/vendor/bin/php-cs-fixer fix --stop-on-violation --using-cache=no --diff --config=./CI/PHP-CS-Fixer/code-format.php_cs [FILE]