Skip to content

Latest commit

 

History

History
57 lines (38 loc) · 1.82 KB

coding-style.md

File metadata and controls

57 lines (38 loc) · 1.82 KB

ILIAS Coding Style

This is the coding style for the ILIAS project.

PSR-12 and additions

The ILIAS coding standard is aligned to the widely used and established PSR-12 standard of the PHP Interop Group (PHP-FIG), extended by the following additions:

Property and Variable Names

Names of properties and variables MUST be written in underscore-case:

$foo_bar = 3;
$this->foo_bar = 3;

Type cast

Spaces MUST be added after a type cast.

$foo = (int) '12345';

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.

Furthermore multiple Git Hooks are provided to check or fix the code style of changed files in a Git commit.

Another possibility to apply the code style checks is to import and run the PhpStorm PHP Code Inspection Profile. This does not only check the ILIAS Coding Style but applies other inspection rules to the PHP code base (or parts of it) as well.

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]