madpilot78/php-cs-fixer-config

Personal coding standards for the php cs fixer

1.1.0 2024-05-03 16:10 UTC

This package is auto-updated.

Last update: 2024-05-03 16:14:20 UTC


README

Madpilot78 coding standards for PHP CS Fixer.

Based on Nexcloud Coding Standard.

Installation

Add the package to your dev dependencies

composer require --dev madpilot78/php-cs-fixer-config

and create a .php-cs-fixer.dist.php like

<?php

declare(strict_types=1);

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

use madpilot78\PhpCsFixerConfig\Config;

$config = new Config();
$config
$config
    ->setRules([ // Added to default ones
        '@PHP82Migration' => true,
    ])
    ->getFinder()
    ->ignoreVCSIgnored(true)
    ->notPath('vendor')
    ->in(__DIR__);

return $config;

To run the fixer you first have to install it. Then you can run php-cs-fixer fix to apply all automated fixes.

For convenience you may add it to the scripts section of your composer.json:

{
    "scripts": {
        "cs:check": "php-cs-fixer fix --dry-run --diff",
        "cs:fix": "php-cs-fixer fix"
    }
}

Note: Don't forget to exclude .php-cs-fixer.dist.php and .php-cs-fixer.cache in your build scripts.