This is the coding style for the ILIAS project.
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:
Names of properties and variables MUST be written in underscore-case:
$foo_bar = 3;
$this->foo_bar = 3;
Spaces MUST be added after a type cast.
$foo = (int) '12345';
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.
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]