valantic/php-cs-fixer-config

Provides a standard php-cs-fixer configuration used in projects built by Valantic.

v2.0.0 2025-07-10 06:10 UTC

This package is auto-updated.

Last update: 2025-07-14 12:08:15 UTC


README

Latest Version on Packagist PHPUnit Rector PHP-CS-Fixer PHPStan Total Downloads

This package provides standard PHP-CS-Fixer configurations used in projects built by Valantic.

Installation

composer require --dev valantic/php-cs-fixer-config friendsofphp/php-cs-fixer

Note: This package requires PHP 8.1 or higher.

Note: friendsofphp/php-cs-fixer is not a dependency as to allow the use of e.g. the Composer bin plugin.

Usage

Create a .php-cs-fixer.php or .php-cs-fixer.dist.php file in your project root with one of the following configurations:

Basic Configuration

<?php

require_once __DIR__ . '/vendor/autoload.php';

use Valantic\PhpCsFixerConfig\ConfigFactory;

return ConfigFactory::createValanticConfig([
        // Add your custom rules here
        'declare_strict_types' => false,
    ])
    ->setFinder(
        PhpCsFixer\Finder::create()
            ->in(__DIR__ . '/src')
            ->in(__DIR__ . '/tests')
    )
    // Enable risky rules (recommended as the ruleset includes risky rules)
    ->setRiskyAllowed(true)
    // Enable parallel execution
    ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
;

Development

This package provides several Composer scripts to help with development:

# Run PHP-CS-Fixer in dry-run mode with diff output
composer cs-check

# Run PHP-CS-Fixer to fix code style issues
composer cs-fix

# Run PHPStan for static analysis
composer phpstan

# Run Rector in dry-run mode
composer rector-dry-run

# Run Rector and apply changes
composer rector

# Run PHPUnit tests
composer test

# Run all checks (cs-check, phpstan, rector-dry-run, test)
composer check