PHPackages                             fernleafsystems/qa - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. fernleafsystems/qa

ActiveLibrary[Testing &amp; Quality](/categories/testing)

fernleafsystems/qa
==================

Shared PHP code quality configuration for FernleafSystems projects

1.0.2(3mo ago)0391[1 PRs](https://github.com/FernleafSystems/qa/pulls)1MITPHPPHP ^8.3CI passing

Since Jan 26Pushed 3mo agoCompare

[ Source](https://github.com/FernleafSystems/qa)[ Packagist](https://packagist.org/packages/fernleafsystems/qa)[ RSS](/packages/fernleafsystems-qa/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (11)Versions (5)Used By (1)

FernleafSystems QA
==================

[](#fernleafsystems-qa)

Shared PHP code quality configuration for all FernleafSystems projects. One package gives you consistent code style, static analysis, and pre-commit hooks across all your repositories.

Installation
------------

[](#installation)

```
composer require --dev fernleafsystems/qa
```

Quick Start
-----------

[](#quick-start)

**Step 1:** Run the setup wizard to generate configuration files:

```
vendor/bin/qa-setup
```

**Step 2:** Install the git hooks:

```
composer install
```

Both steps are required. The wizard generates config files including `captainhook.json`. The `composer install` reads that file and installs the actual git hooks.

The wizard will ask you:

- PHP version (detected from your `composer.json`)
- Source directory (defaults to `src`, `lib`, `app` if found)
- Whether to include your `tests` directory
- PHPStan strictness level (3 = conservative, 6 = strict)

What Gets Generated
-------------------

[](#what-gets-generated)

FilePurpose`.php-cs-fixer.php`Code style rules (non-WordPress projects)`.phpcs.xml.dist`WordPress Coding Standards (WordPress projects)`rector.php`Automated refactoring rules`phpstan.neon`Static analysis configuration`captainhook.json`Pre-commit hook configuration`.gitattributes`Line endings, diff settings, export-ignore rulesRunning the Tools
-----------------

[](#running-the-tools)

After setup, run the tools directly via `vendor/bin/`:

```
# Code Style (PHP CS Fixer)
vendor/bin/php-cs-fixer fix --allow-risky=yes
vendor/bin/php-cs-fixer fix --dry-run --diff --allow-risky=yes  # CI check

# Rector (Automated Refactoring)
vendor/bin/rector process
vendor/bin/rector process --dry-run  # CI check

# PHPStan (Static Analysis)
vendor/bin/phpstan analyse
vendor/bin/phpstan analyse --generate-baseline  # Generate baseline

# WordPress Projects Only
vendor/bin/phpcs
vendor/bin/phpcbf  # Auto-fix
```

### Optional: Add Composer Scripts

[](#optional-add-composer-scripts)

For convenience, add these to your project's `composer.json`:

```
{
    "scripts": {
        "cs": "php-cs-fixer fix --allow-risky=yes",
        "cs-check": "php-cs-fixer fix --dry-run --diff --allow-risky=yes",
        "rector": "rector process",
        "rector-check": "rector process --dry-run",
        "phpstan": "phpstan analyse"
    }
}
```

Then run: `composer cs`, `composer rector`, etc.

Pre-Commit Hooks
----------------

[](#pre-commit-hooks)

**Important:** Git hooks require TWO steps to install:

1. Run `vendor/bin/qa-setup` - this generates `captainhook.json`
2. Run `composer install` - this triggers CaptainHook to install the git hooks

Without both steps, hooks will NOT be installed.

Once installed, on every commit:

1. Rector runs on staged PHP files (with parallel mode disabled)
2. PHP CS Fixer runs on staged PHP files
3. If files were modified, the commit is blocked with a message to re-stage

This ensures all committed code meets quality standards.

Manual Usage (Without Setup Wizard)
-----------------------------------

[](#manual-usage-without-setup-wizard)

If you prefer to create configs manually, here's a minimal `.php-cs-fixer.php`:

```
