sudo apt install python3-pip gawk &&\
pip3 install pre-commit
DIR=~/.git-template
git config --global init.templateDir ${DIR}
pre-commit init-templatedir -t pre-commit ${DIR}
Step into the repository you want to have the pre-commit hooks installed and run:
git init
cat <<EOF > .pre-commit-config.yaml
repos:
- repo: git://github.com/kumadee/pre-commit-php
rev: <VERSION> # Get the latest from: https://github.com/kumadee/pre-commit-php/releases
hooks:
- id: docker-phpda-0
EOF
After pre-commit hook has been installed you can run it manually on all files in the repository
pre-commit run -a
There are several pre-commit hooks to keep PHP source code in a good shape:
Hook name | Description |
---|---|
docker-phpda-0 |
Checks for possible dependency cycles and hierarchy violations in classes. |
docker-phpda-1 |
Checks for possible dependency cycles and hierarchy violations in 'Internal'. |
docker-phpda-2 |
Checks for possible dependency cycles and hierarchy violations in 'Domain/Framework'. |
docker-phpda-3 |
Checks for possible dependency cycles and hierarchy violations in 'Framework/Module'. |
container-factory-check |
Check if 'ContainerFactory' class is used in PHP source code. |
Check the source file to know arguments used for each hook.