2017 © Pedro PelĂĄez
 

library php-code-quality-tools

PHP Code Quality Tools used in Bitban projects.

image

bitban/php-code-quality-tools

PHP Code Quality Tools used in Bitban projects.

  • Tuesday, December 19, 2017
  • by bitban
  • Repository
  • 4 Watchers
  • 2 Stars
  • 4,875 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 4 Open issues
  • 18 Versions
  • 13 % Grown

The README.md

PHP Code Quality Tools

Latest Stable Version License Build Status Coverage Status, (*1)

These tools may be used to detect and fix some common errors before committing them to the code repository., (*2)

Check command reference section for more detailed information., (*3)

Installation

If you have not done this yet, add bin directory to composer.json:, (*4)

composer config bin-dir bin/, (*5)

It will add something like this to your composer.json file:, (*6)

"config": {
    "bin-dir": "bin/"
}

For a better experience, we also suggest to configure post-install and post-update script:, (*7)

"scripts": {
    "post-install-cmd": [
        "Bitban\\PhpCodeQualityTools\\Composer\\ScriptHandler::checkHooks"
    ],
    "post-update-cmd": [
        "Bitban\\PhpCodeQualityTools\\Composer\\ScriptHandler::checkHooks"
    ]
}

Then, require new dev dependency:, (*8)

composer require --dev "bitban/php-code-quality-tools:dev-master", (*9)

After that, a new command is available from project's root path:, (*10)

bin/php-cqtools, (*11)

Command reference

Check Git Hooks

Checks if Git hooks are installed for current project. If not, it gives a hint to install them, but does not take any action automatically., (*12)

bin/php-cqtools hooks:check, (*13)

Install Git Hooks

Installs Git hooks into .git/hooks/. If destination files already exist, the are backed up., (*14)

bin/php-cqtools hooks:install, (*15)

Git hooks managed are:, (*16)

  • pre-commit
  • post-checkout
  • post-merge

pre-commit hook

It calls code:validate command., (*17)

bin/php-cqtools code:validate --only-commited-files, (*18)

post-checkout hook

It checks whether composer.lock has changed or not. If so, launches composer install command., (*19)

bin/php-cqtools hooks:post-checkout <prevCommit> <postCommit> [<projectPath>], (*20)

projectPath argument sets path to be processed. Default value is current project base path., (*21)

post-merge hook

It has the same behaviour than post-checkout hook., (*22)

bin/php-cqtools hooks:post-merge [<projectPath>], (*23)

Uninstall Git Hooks

Removes Git hooks from destination path. If backup files exist, they are restored., (*24)

bin/php-cqtools hooks:uninstall, (*25)

Fix Code Style

Fixes code style of files according to defined code style., (*26)

It may fix all project files or only files to be commited. This second option is very convinient to fix errors detected in pre-commit hook., (*27)

bin/php-cqtools code:fix-codestyle [--dry-run] [--excluded-paths=EXCLUDED_PATHS] [--only-commited-files] [--custom-ruleset=CUSTOM_RULESET] [<projectPath>], (*28)

projectPath argument sets path to be processed. Default value is current project base path., (*29)

--dry-run option shows diffs without applying any changes to files. --excluded-paths option sets some paths not to be processed. --only-commited-files option processes only files scheduled to be commited. --custom-ruleset option sets phpcs custom ruleset to be used instead of default one, (*30)

Validate Code

It performs several tasks:, (*31)

  • PHP files:
    • Check for syntax errors
    • Check that forbidden functions (i.e., var_dump(), empty()) are not commited
    • Check whether multibyte string functions are being used
    • Check that code complies defined code style recommendations (errors cannot be commited, warnings may be)
    • Check that variable usage is right (i.e., use undefined variables, parameters not used, etc.)
  • JSON files:
    • Check for syntax errors
  • Composer related files:
    • Check that composer.json is not commited without composer.lock (checked only with --only-commited-files modifier)

bin/php-cqtools code:validate [--excluded-paths=EXCLUDED_PATHS] [--only-commited-files] [--custom-ruleset=CUSTOM_RULESET] [<projectPath>], (*32)

projectPath argument sets path to be processed. Default value is current project base path., (*33)

--excluded-paths option sets some paths not to be processed. --only-commited-files option processes only files scheduled to be commited. --custom-ruleset option sets phpcs custom ruleset to be used instead of default one, (*34)

Show debug information

Shows debug information about:, (*35)

  • Validation/fix tools installed, such as phpcs, jsonlint, phpcbf
  • Project basepath
  • Git hooks path
  • Git hooks source path
  • Commited files
  • Excluded paths
  • Project files

bin/php-cqtools debug:show [--show-full-paths] [<projectPath], (*36)

projectPath argument sets path to be processed. Default value is current project base path., (*37)

--show-full-paths option enables full path file listing instead of relative path, (*38)

This command, may be unavailable in any future versions of these tools, as it has been added for debug purposes., (*39)

Run Bitban Lightweight tests

Runs Bitban's framework lightweight tests. It assumes that Bitban's Development VM is up and running, and it has test launcher script run_light_tests.sh installed., (*40)

bin/php-cqtools test:run --vmHost[=VMHOST] [<projectPath], (*41)

projectPath argument sets path to be processed. Default value is current project base path., (*42)

--vmHost=VMHOST option sets Development VM hostname, (*43)

This command has no use for projects not integrating Bitban's framework., (*44)

References

Here are several interesting links with information (and inspiration) about this subject., (*45)

  • https://carlosbuenosvinos.com/write-your-git-hooks-in-php-and-keep-them-under-git-control/
  • https://www.sitepoint.com/writing-php-git-hooks-with-static-review/
  • https://github.com/sdieunidou/php-git-hooks
  • http://tech.zumba.com/2014/04/14/control-code-quality/
  • https://www.sitepoint.com/8-must-have-php-quality-assurance-tools/
  • http://phpqatools.org/
  • https://github.com/illusori/PHP_Codesniffer-VariableAnalysis/

The Versions

19/12 2017

dev-master

9999999-dev

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

02/12 2016

v0.9.15

0.9.15.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

16/11 2016

v0.9.14

0.9.14.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

08/11 2016

v0.9.13

0.9.13.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

21/10 2016

v0.9.12

0.9.12.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

20/09 2016

v0.9.11

0.9.11.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

31/08 2016

dev-feature-localConfig

dev-feature-localConfig

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

31/08 2016

v0.9.10

0.9.10.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

01/08 2016

v0.9.9

0.9.9.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

29/07 2016

v0.9.8

0.9.8.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

28/07 2016

v0.9.7

0.9.7.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

26/07 2016

v0.9.6

0.9.6.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

22/07 2016

v0.9.5

0.9.5.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

15/07 2016

v0.9.4

0.9.4.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

15/07 2016

v0.9.3

0.9.3.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

14/07 2016

v0.9.2

0.9.2.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fede Álvarez

hook git quality

08/07 2016

v0.9.1

0.9.1.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

by Fede Álvarez

hook git quality

07/07 2016

v0.9.0

0.9.0.0

PHP Code Quality Tools used in Bitban projects.

  Sources   Download

MIT

The Requires

 

by Fede Álvarez

hook git quality