Skip to content

Contributing

Wtyd edited this page Jun 6, 2024 · 6 revisions

If you detect an error and want to contribute by fixing it or want to add a new feature, you are free to do so. Please, read this document carefully.

1. Php Minimum Compatibility

At this moment the php minimum compatibility is with php 7.1. Please, the modified/added code must run in this version.

2. Create a Feature Branch

Create a feature branch from master to make your changes.

3. Check Static Code

3.1. PSR-12 Coding Standard

GitHooks follow PSR12 guidelines. This standad is implemented by Php Code Sniffer (which is a dev dependency) and the complete ruleset is qa/psr12-ruleset.xml. For check if your changes are folling too PSR12, you can to launch GitHooks in this way:

php githooks tool:phpcs

This fixes all autofixable errors and show you the non fixable.

3.2. Php Mess Detector

In the same way of Phpcs, GitHooks applies some rules from Phpmd (phpmd-ruleset.xml).

Only the src code will be checked with Phpmd:

php githooks tool:phpmd

3.3. Php Stan

GitHooks pass 8 levels from phpstan. To check the code you can execute:

php githooks tool:phpstan

3.4. Launch All Code Analyzers

You can launch all code analyzers (phpcs, phpmd, phpstan) with the project configuration just with one command:

php githooks tool all

4. Add tests

Add or modify any test that you think that is needed to test your changes. For run the complete test suite you can execute vendor/bin/phpunit. Please, don't make a pull request without the corresponding tests.

5. CI Pipelines

GitHooks has setted GitHub Actions flows. This flows check static code and run the tests suite.

When you request for merge your feature branch with master you must ensure that your ci pipeline pass.

6. Resume

  • Create feature branches.
  • Check the code. You can run php githooks tool all.
  • Add tests! Your patch won't be accepted if it doesn't have tests. You can run vendor/bin/phpunit.
  • CI flows must pass.