ILIAS uses PHPStan
as an optional tool for developers
to find errors in the ILIAS code base without actually running it.
To provide a common configuration a shared config file is located in
./CI/PHPStan/phpstan.neon
.
PHPStan
provides the possibility to analyse the code based on specfic
rule levels.
The level used in ILIAS is level 6, which includes the reporting of missing typehints.
To prevent False Positives
beingt reported related to global constants, developers can extend the constant collection
defined in the constants.php
To run PHPStan
you just need to execute the bash script:
./CI/PHPStan/run_check.sh
To run PHPStan
in the context of a specific component, pass the respective folder name as argument:
./CI/PHPStan/run_check.sh Services/Mail
You can overwrite the rule level by passing a --level
argument:
./CI/PHPStan/run_check.sh Services/Mail --level 3
A custom configuration file could be provided by adding a file named phpstan.local.neon
to the ILIAS root directory.
The filename is ignored by the .gitignore
file and ILIAS \RootFolderTest
, which ensures no new files are added
to the root level of ILIAS.
Example:
includes:
- CI/PHPStan/phpstan.neon
parameters:
level: 9
In this example the shared PHPStan
configuration is extended by the local configuration, where we defined stricter
rule level.
A baseline file can be generated by using the --generate-baseline
option.
/CI/PHPStan/run_check.sh -c phpstan.local.neon Services/Mail --generate-baseline
The generated baseline file phpstan-baseline.neon
will be stored in the ILIAS root folder and must be included in the
local phpstan.local.neon
configuration.
includes:
- CI/PHPStan/phpstan.neon
- phpstan-baseline.neon
parameters:
level: 9
If you analyse different components/folders with PHPStan
, you will need to generate a new baseline file.
See: https://www.jetbrains.com/help/phpstorm/using-phpstan.html