diff options
author | Stefan Giehl <stefan@matomo.org> | 2021-01-15 10:53:48 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-15 10:53:48 +0300 |
commit | b38578b468d694534db5fabe356db5ffdc58bd6e (patch) | |
tree | f9d0307513b614d966075d946ac5e68bed1c660a /phpcs.xml | |
parent | 6f957d15b4db3b0d8d54f046de33207044f87681 (diff) |
Introduce PHP CS to improve code quality (#16755)
* Adds PHP CS with a basic config
* automatically check coding style for pull requests
* Disallow usage of eval & create_function and force using Common::safe_unserialize instead of unserialize
* Forbid inline control structures
* fix test
Diffstat (limited to 'phpcs.xml')
-rw-r--r-- | phpcs.xml | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000000..65da90b5b5 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<ruleset name="matomo"> + + <description>Matomo Coding Standard</description> + + <arg name="extensions" value="php" /> + + <file>core</file> + <file>plugins</file> + <file>tests/PHPUnit</file> + + <exclude-pattern>tests/PHPUnit/proxy/*</exclude-pattern> + <exclude-pattern>*/vendor/*</exclude-pattern> + <exclude-pattern>*/libs/*</exclude-pattern> + + <!-- Forbid other line endings than \n --> + <rule ref="Generic.Files.LineEndings"> + <properties> + <property name="eolChar" value="\n" /> + </properties> + </rule> + + <!-- Forbid short open tags --> + <rule ref="Generic.PHP.DisallowShortOpenTag.Found" /> + + <!-- Forbid inline control structures --> + <rule ref="Generic.ControlStructures.InlineControlStructure" /> + + <!-- Forbid some functions that should not be used (directly) --> + <rule ref="Generic.PHP.ForbiddenFunctions"> + <properties> + <property name="forbiddenFunctions" type="array"> + <element key="eval" value="null"/> + <element key="create_function" value="null"/> + <element key="unserialize" value="\Piwik\Common::safe_unserialize"/> + </property> + </properties> + <!-- still allow those functions in tests --> + <exclude-pattern>*/tests/*</exclude-pattern> + </rule> +</ruleset>
\ No newline at end of file |