PHPackages                             marac19901990/php-quality-pack - 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. marac19901990/php-quality-pack

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

marac19901990/php-quality-pack
==============================

Zero-config PHP code quality standards with GrumPHP, PHPStan, and PHP-CS-Fixer

v1.1.0(3mo ago)50MITPHPPHP ^8.2CI passing

Since Jan 28Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/marac19901990/php-quality-pack)[ Packagist](https://packagist.org/packages/marac19901990/php-quality-pack)[ Docs](https://github.com/marac19901990/php-quality-pack)[ RSS](/packages/marac19901990-php-quality-pack/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (3)Used By (0)

PHP Quality Pack
================

[](#php-quality-pack)

[![CI](https://github.com/marac19901990/php-quality-pack/actions/workflows/ci.yml/badge.svg)](https://github.com/marac19901990/php-quality-pack/actions/workflows/ci.yml)[![Packagist Version](https://camo.githubusercontent.com/1dce5f417c47c8ea54255cf5beeeed93c1c2c8b498304e61e9d1c619284a43c4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6172616331393930313939302f7068702d7175616c6974792d7061636b)](https://packagist.org/packages/marac19901990/php-quality-pack)[![PHP Version](https://camo.githubusercontent.com/5f658e5c812415ba6eca2f09770b65d9a95f2d49207440bc231fb4b0ec3b2fbe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6172616331393930313939302f7068702d7175616c6974792d7061636b)](https://packagist.org/packages/marac19901990/php-quality-pack)[![License](https://camo.githubusercontent.com/f2d54c34486f1f6dec88ab5f3846209c796f307235bc8b0bfe79135ce4bc1962/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6172616331393930313939302f7068702d7175616c6974792d7061636b)](https://packagist.org/packages/marac19901990/php-quality-pack)

Zero-config PHP code quality standards with GrumPHP, PHPStan, and PHP-CS-Fixer. Installs pre-commit hooks that automatically run static analysis and code style fixes on every commit.

What It Does
------------

[](#what-it-does)

- **Installs GrumPHP pre-commit hooks** automatically on `composer install`
- **Runs PHPStan** (level 5, strict rules, deprecation warnings) on every commit
- **Runs PHP-CS-Fixer** (PSR-12 + sensible rules) on every commit
- **Zero-config** - works out of the box with sensible defaults
- **Only checks changed files** for fast pre-commit validation

Default Standards
-----------------

[](#default-standards)

ToolConfigurationPHPStanLevel 5, strict rules, deprecation warnings, bleeding edgePHP-CS-FixerPER-CS, PHP 8.2 migration, sorted imports, trailing commas, single quotesPHP Version8.2+ requiredRequirements
------------

[](#requirements)

This package intentionally requires modern versions:

- **PHP 8.2+** - Modern PHP only
- **PHPStan 2.x** - Latest major version
- **PHP-CS-Fixer 3.x** - Latest stable

Legacy projects requiring older versions should not use this pack.

> **Note**: All dependencies use stable releases. If your project has `"minimum-stability": "stable"` (the default), installation will work without issues.

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

[](#installation)

```
composer require --dev marac19901990/php-quality-pack
```

Setup
-----

[](#setup)

### 1. Update composer.json

[](#1-update-composerjson)

Add the following to your project's `composer.json`:

```
{
    "extra": {
        "grumphp": {
            "config-default-path": "vendor/marac19901990/php-quality-pack/rules/grumphp.yml"
        }
    },
    "config": {
        "allow-plugins": {
            "phpro/grumphp": true,
            "phpstan/extension-installer": true
        }
    }
}
```

### 2. Create a PHPStan baseline file

[](#2-create-a-phpstan-baseline-file)

> **IMPORTANT**: This file is required. PHPStan will fail without it.

Create an empty `phpstan-baseline.neon` in your project root:

```
echo "parameters:" > phpstan-baseline.neon
```

Or generate one with current errors (recommended for existing codebases):

```
vendor/bin/phpstan analyse src/ -c vendor/marac19901990/php-quality-pack/rules/phpstan.neon --generate-baseline
```

### 3. Run composer install

[](#3-run-composer-install)

```
composer install
```

**That's it!** GrumPHP hooks are automatically installed.

Usage
-----

[](#usage)

### Just commit

[](#just-commit)

```
git add .
git commit -m "Your commit message"
```

PHPStan and PHP-CS-Fixer run automatically on changed files. If there are issues, the commit is blocked until you fix them.

### Manual checks

[](#manual-checks)

```
# Run all checks on changed files
vendor/bin/grumphp run

# Run PHPStan on entire codebase (specify your source directory)
vendor/bin/phpstan analyse src/ -c vendor/marac19901990/php-quality-pack/rules/phpstan.neon

# Run PHP-CS-Fixer on entire codebase (dry-run)
vendor/bin/php-cs-fixer fix --config=vendor/marac19901990/php-quality-pack/rules/php-cs-fixer.php --dry-run --diff

# Auto-fix code style issues
vendor/bin/php-cs-fixer fix --config=vendor/marac19901990/php-quality-pack/rules/php-cs-fixer.php
```

### Regenerate baseline

[](#regenerate-baseline)

When you've fixed PHPStan errors or want to capture existing ones:

```
vendor/bin/phpstan analyse src/ -c vendor/marac19901990/php-quality-pack/rules/phpstan.neon --generate-baseline
```

Customization
-------------

[](#customization)

For most projects, the default configuration works out of the box. Only customize if you have specific needs.

### Override GrumPHP tasks

[](#override-grumphp-tasks)

Create a local `grumphp.yml` in your project root:

```
imports:
    - { resource: vendor/marac19901990/php-quality-pack/rules/grumphp.yml }

grumphp:
    tasks:
        phpcsfixer:
            diff: false  # Example: disable diff output
```

Then update `config-default-path` in `composer.json`:

```
"grumphp": {
    "config-default-path": "grumphp.yml"
}
```

### Add additional PHPStan paths or ignores

[](#add-additional-phpstan-paths-or-ignores)

Create a local `phpstan.neon`:

```
includes:
    - vendor/marac19901990/php-quality-pack/rules/phpstan.neon
    - phpstan-baseline.neon

parameters:
    paths:
        - src
        - lib  # Additional paths

    ignoreErrors:
        - message: "#^Project-specific error to ignore$#"
```

Then create a `grumphp.yml` that points to your local config.

### Adding framework-specific extensions

[](#adding-framework-specific-extensions)

This package includes only base PHPStan extensions. Add framework-specific extensions to your project:

```
# For Symfony projects
composer require --dev phpstan/phpstan-symfony

# For PHPUnit
composer require --dev phpstan/phpstan-phpunit

# For Doctrine
composer require --dev phpstan/phpstan-doctrine
```

The `phpstan/extension-installer` automatically registers these extensions.

Two Usage Models
----------------

[](#two-usage-models)

### 1. Direct Use (Generic Defaults)

[](#1-direct-use-generic-defaults)

Use directly via `composer require` if you're happy with:

- PSR-12 coding standards
- PHPStan level 5 with strict rules
- Deprecation warnings enabled

Good for: personal projects, new projects, teams aligned with these standards.

### 2. Fork and Customize

[](#2-fork-and-customize)

Fork this repo to create your organization's version:

1. Fork to `your-org/php-quality-pack`
2. Modify `rules/` files to your standards:
    - Change PHPStan level in `rules/phpstan.neon`
    - Adjust PHP-CS-Fixer rules in `rules/php-cs-fixer.php`
    - Add/remove GrumPHP tasks in `rules/grumphp.yml`
3. Update paths in `rules/grumphp.yml` to your vendor name
4. Publish to Packagist as your org's package

Good for: organizations with specific coding standards.

Default Configuration Details
-----------------------------

[](#default-configuration-details)

### PHPStan (`rules/phpstan.neon`)

[](#phpstan-rulesphpstanneon)

- Level 5 (balanced)
- Strict rules enabled
- Deprecation warnings enabled
- Bleeding edge rules enabled
- Includes project's `phpstan-baseline.neon`
- No hardcoded paths - GrumPHP passes changed files, manual runs specify paths

### PHP-CS-Fixer (`rules/php-cs-fixer.php`)

[](#php-cs-fixer-rulesphp-cs-fixerphp)

- **Base rulesets**: PER-CS (modern successor to PSR-12) + PHP 8.2 migration rules
- **Array rules**: Short syntax, consistent indentation, trimmed spaces, trailing commas
- **Import rules**: Unused imports removed, sorted alphabetically (classes, functions, constants), no leading slash
- **Spacing**: Blank lines before return/throw/try, no extra blank lines, clean whitespace
- **Code cleanup**: No empty statements, no unneeded braces or control parentheses
- **Types**: Short scalar casts (`(bool)` not `(boolean)`), native function casing
- **Class structure**: Ordered elements (traits, constants, properties, constructor, methods by visibility)
- **Style**: Single quotes, no Yoda conditions, PHPDoc formatting
- **PHPUnit**: Snake\_case test method names allowed

All rules are non-risky (safe transformations that don't change code behavior).

### GrumPHP (`rules/grumphp.yml`)

[](#grumphp-rulesgrumphpyml)

- **Only analyzes changed files** for fast pre-commit checks:
    - `use_grumphp_paths: true` for PHPStan - only files GrumPHP detects as changed
    - `config_contains_finder: false` for PHP-CS-Fixer - GrumPHP passes the file list
- Stops on first failure
- Local git hooks

Migration from Local Configs
----------------------------

[](#migration-from-local-configs)

If your project has local `phpstan.neon`, `grumphp.yml`, or `.php-cs-fixer.dist.php`:

1. **Regenerate baseline**: Run `vendor/bin/phpstan analyse src/ -c vendor/marac19901990/php-quality-pack/rules/phpstan.neon --generate-baseline`
2. **Delete local configs**: Remove `phpstan.neon`, `grumphp.yml`, `.php-cs-fixer.dist.php`
3. **Update composer.json**: Set `config-default-path` to `vendor/marac19901990/php-quality-pack/rules/grumphp.yml`
4. **Run composer install**: Reinstalls GrumPHP hooks with new config

Makefile Updates
----------------

[](#makefile-updates)

If your project uses Makefile targets, update them to use the vendor config paths:

```
stan: ## Run PHPStan
	vendor/bin/phpstan analyse src/ -c vendor/marac19901990/php-quality-pack/rules/phpstan.neon

stan-baseline: ## Generate PHPStan baseline
	vendor/bin/phpstan analyse src/ -c vendor/marac19901990/php-quality-pack/rules/phpstan.neon --generate-baseline

cs-fix: ## Run PHP-CS-Fixer
	vendor/bin/php-cs-fixer fix --config vendor/marac19901990/php-quality-pack/rules/php-cs-fixer.php

cs-check: ## Check code style (dry-run)
	vendor/bin/php-cs-fixer fix --config vendor/marac19901990/php-quality-pack/rules/php-cs-fixer.php --dry-run --diff
```

Recommended .gitignore
----------------------

[](#recommended-gitignore)

Add these entries to your project's `.gitignore`:

```
.php-cs-fixer.cache
```

GitHub Actions
--------------

[](#github-actions)

Example workflow for CI:

```
name: Code Quality

on: [push, pull_request]

jobs:
  quality:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.2'

      - name: Install dependencies
        run: composer install --prefer-dist --no-progress

      - name: Create PHPStan baseline if missing
        run: test -f phpstan-baseline.neon || echo "parameters:" > phpstan-baseline.neon

      - name: Run PHPStan
        run: vendor/bin/phpstan analyse src/ -c vendor/marac19901990/php-quality-pack/rules/phpstan.neon

      - name: Run PHP-CS-Fixer
        run: vendor/bin/php-cs-fixer fix --config=vendor/marac19901990/php-quality-pack/rules/php-cs-fixer.php --dry-run --diff
```

Known Issues
------------

[](#known-issues)

### Deprecation warning during commits

[](#deprecation-warning-during-commits)

You may see this warning during commits:

```
PHP Deprecated: Using Diff::parse without raw information is deprecated.

```

This comes from `gitonomy/gitlib` (a GrumPHP dependency) and doesn't affect functionality. It will be resolved when GrumPHP updates the dependency.

License
-------

[](#license)

MIT License - see [LICENSE](LICENSE) for details.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance81

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

101d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3f89b6d8bbe24fb36a80af0b38ff36f50022d7eec5832c3dac2f79522e6baf07?d=identicon)[marac990](/maintainers/marac990)

---

Top Contributors

[![markopetrovic990](https://avatars.githubusercontent.com/u/270894953?v=4)](https://github.com/markopetrovic990 "markopetrovic990 (7 commits)")

---

Tags

code-qualitygrumphpphp-cs-fixerphpstanpre-commit-hooksstatic-analysisPHPStanstatic analysiscode qualitycoding-standardspre-commitphp-cs-fixergrumphpgit-hooks

### Embed Badge

![Health badge](/badges/marac19901990-php-quality-pack/health.svg)

```
[![Health](https://phpackages.com/badges/marac19901990-php-quality-pack/health.svg)](https://phpackages.com/packages/marac19901990-php-quality-pack)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[ekino/phpstan-banned-code

Detected banned code using PHPStan

2925.6M92](/packages/ekino-phpstan-banned-code)[staabm/phpstan-dba

2912.3M2](/packages/staabm-phpstan-dba)[wp-cli/wp-cli-tests

WP-CLI testing framework

422.7M87](/packages/wp-cli-wp-cli-tests)[shipmonk/dead-code-detector

Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.

3462.2M52](/packages/shipmonk-dead-code-detector)[sci3ma/symfony-grumphp

Configured GrumPHP with bunch of tools for static code analysis Symfony Framework

196.7k](/packages/sci3ma-symfony-grumphp)

PHPackages © 2026

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