This is the ZooRoyal coding standard.

Installs: 16 613

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 33

Forks: 2

Open Issues: 8


3.15.6 2022-11-28 12:57 UTC


Build Status Packagist Release License

ZooRoyal Coding Standard

This repository holds the necessary data to use the ZooRoyal coding standard. It incorporates

In addition, there is a PHP script in src/bin to be used by a continuous integration tool of your choice. It searches your source code to find files to check with its static code analysis tools. Information about its usage can be found by calling it with -h option.


To install this package just run

composer require --dev "zooroyal/coding-standard"

Eslint and StyleLint

In case you want to use eslint and stylelint checks you have to install the packages from the package.json in the root folder of your project.

Local Installation

You may install the packages locally in your project. For this to happen you need to follow the following steps:

  1. composer require --dev zooroyal/coding-standard
  2. npm install --save-dev vendor/zooroyal/coding-standard

Global Installation

You may have installed eslint and stylelint globally in your system. If you want coding-standard to try to use them just make sure coding-standard is installed properly.

composer require --dev zooroyal/coding-standard


To update this package just run

composer update "zooroyal/coding-standard"

Usage coding-standard

Please keep in mind, that coding-standard can only run from inside a git repository.

Run the command to get usage instructions.

php vendor/bin/coding-standard
Available commands:
  find-files                Finds files for code style checks.
  help                      Displays help for a command
  list                      Lists commands
  checks:forbidden-changes  Checks for unwanted code changes.
  sca:all                   Run all static code analysis tools.
  sca:copy-paste-detect     Run PHP-CPD on PHP files.
  sca:eslint                Run ESLint on JS files.
  sca:mess-detect           Run PHP-MD on PHP files.
  sca:parallel-lint         Run Parallel-Lint on PHP files.
  sca:sniff                 Run PHP-CS on PHP files.
  sca:stylelint             Run StyleLint on Less files.
  sca:stan                  Run PHPStan on PHP files.

Example sca:all

vendor/bin/coding-standard sca:all -h
  sca:all [options]

  -t, --target=TARGET      Finds Files which have changed since the current branch parted from the target
                           branch only. The Value has to be a commit-ish. [default: false]
  -a, --auto-target        Finds Files which have changed since the current branch parted from the parent
                           branch only. It tries to find the parent branch by automagic.
  -f, --fix                Runs tool to try to fix violations automagically.
  -p, --process-isolation  Runs all checks in separate processes. Slow but not as resource hungry.
  -h, --help               Display this help message
  -q, --quiet              Do not output any message
  -V, --version            Display this application version
      --ansi               Force ANSI output
      --no-ansi            Disable ANSI output
  -n, --no-interaction     Do not ask any interactive question
  -v|vv|vvv, --verbose     Increase the verbosity of messages: 1 for normal output, 2 for more verbose output
                           and 3 for debug

  This tool executes all static code analysis tools on files of this project. It ignores files which are in
  directories with a .dont<toolshortcut> file. Subdirectories are ignored too.

The all command forwards all applicable parameters to all implemented static code analysis tools.

vendor/bin/coding-standard sca:all -a -f

This command for example tries to find the parent branch by automagic (-a) and tells all static code analysis tools to fix found violations if they are able to.

vendor/bin/coding-standard sca:all -t origin/master

This command computes the diff to the branch origin/master and searches for all violations in this files.

For examples just have a look an the .travis.yml

Extend the Coding Standard

If you want to extend the Coding-Standard with your own tools there are two tutorials available: