Skip to content

Latest commit

 

History

History
73 lines (48 loc) · 1.72 KB

coding-style.md

File metadata and controls

73 lines (48 loc) · 1.72 KB

ILIAS Coding Style

This is the coding style for the ILIAS project.

PSR-2 and additions

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

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 . '!';

Type cast

Spaces MUST be added after a type cast.

$foo = (int) '12345';

Return Type Declaration

Spaces MUST be added around a colon in return type declaration.

function () : void {}

Code Style Checks and Fixes

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.

Checking Code Style

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]

Fixing Code Style

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]