PHPackages                             wozinski/php-static-analysis-hook - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wozinski/php-static-analysis-hook

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wozinski/php-static-analysis-hook
=================================

A script that enables

41.2k[2 issues](https://github.com/wozinski/php-static-analysis-hook/issues)Shell

Since Mar 11Pushed 10y ago3 watchersCompare

[ Source](https://github.com/wozinski/php-static-analysis-hook)[ Packagist](https://packagist.org/packages/wozinski/php-static-analysis-hook)[ RSS](/packages/wozinski-php-static-analysis-hook/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

PHP Static Analysis hook
========================

[](#php-static-analysis-hook)

PHP Static Analysis Hook configures a GIT pre-commit hook to run a few static analysis tools and block the commit if any of the tools detects code issues. Static analysis tools included in the current version of the hook:

- internal PHP linter (`php -l`)
- [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)
- [PHP Mess Detector](https://github.com/phpmd/phpmd)

Additionally, the tool symlinks hook to Composer's `bin-dir`, so that it's code can be versioned in the repository.

Credits
-------

[](#credits)

The tool is an extended version of [this gist](https://gist.github.com/cjsaylor/10503398#file-pre-commit) by [cjsaylor](https://github.com/cjsaylor). Git hook versioning is inspired by this StackOverflow answer:

Requirements
------------

[](#requirements)

- an initialized git repository in the project's directory
- the repository needs to have at least one commit for the script to work correctly. Yes, it is a bug - I didn't have time to cover that yet (but please go ahead and fix it).

Usage
-----

[](#usage)

1. Add the package to require-dev section of your composer.json file and run `composer update`. Example:

```
{
    "require-dev": {
        "cdwv/php-static-analysis-hook": "dev-master"
    }
}

```

2. In your CLI, run `bin/symlink-git-hooks-to-hub` command. It will automatically back up your existing git hooks and will redirect all the hooks to a git-hook-hub, which in turn redirects the hooks' calls to the hooks in Composer's `bin-dir` (currently only pre-commit hook is in use).

The script doesn't need any additional action - it runs whenever you run a `git commit` command.

Ignore-errors mode
------------------

[](#ignore-errors-mode)

Sometimes it might be useful to commit the code even though it contains some issues. You can do that by setting an environment variable `STATIC_ANALYSIS_IGNORE_ERRORS` prior to running `git commit` command.

Please note that you should remember to unset the variable after the commit. Otherwise, all your future commits will not be blocked in case there are errors in your code. The following command sets the variable before the commit and unsets it afterwards, feel free to use it or adjust it to your own needs:

`export STATIC_ANALYSIS_IGNORE_ERRORS="t" && git commit -a; unset STATIC_ANALYSIS_IGNORE_ERRORS`

Disclaimer
----------

[](#disclaimer)

The script in it's current version is only a proof of concept and should be used with extreme care. Use it at your own risk.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed1d8a8890125e9e51db463b8db7c7a7703710cf53b9dc0a01aa9b0d6d2e2b83?d=identicon)[wozinski](/maintainers/wozinski)

---

Top Contributors

[![ekiwok](https://avatars.githubusercontent.com/u/5066380?v=4)](https://github.com/ekiwok "ekiwok (4 commits)")[![grzegorz-daszuta](https://avatars.githubusercontent.com/u/268889264?v=4)](https://github.com/grzegorz-daszuta "grzegorz-daszuta (1 commits)")

### Embed Badge

![Health badge](/badges/wozinski-php-static-analysis-hook/health.svg)

```
[![Health](https://phpackages.com/badges/wozinski-php-static-analysis-hook/health.svg)](https://phpackages.com/packages/wozinski-php-static-analysis-hook)
```

###  Alternatives

[pedroborges/meta-tags

HTML meta tags generator for PHP.

4628.6k1](/packages/pedroborges-meta-tags)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
