davahome/php-cs-fixer-ruleset

There is no license information available for the latest version (1.2.1) of this package.

The default ruleset of php-cs-fixer for all davahome projects

1.2.1 2020-09-13 16:24 UTC

This package is auto-updated.

Last update: 2024-03-29 00:01:49 UTC


README

DavaHome Ruleset for php-cs-fixer

Installation

php composer.phar require --dev davahome/php-cs-fixer-ruleset

Usage

php_cs.php

<?php

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

return \DavaHome\PhpCsFixer::createFromDir(__DIR__)->getRuleSet();

php-cs-fixer.phar

php php-cs-fixer.phar fix --config=php_cs.php
php php-cs-fixer.phar fix --dry-run --diff --config=php_cs.php

Examples

php_cs.php

<?php

use DavaHome\PhpCsFixer;
use PhpCsFixer\Finder;

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

$finder = Finder::create()
    ->in(__DIR__)
    ->notPath('/^data/');
    
return (new PhpCsFixer($finder))
    ->getRuleSet()
    ->setCacheFile(__DIR__ . '/data/cache/.php_cs.cache');

php_cs.php

<?php

use DavaHome\PhpCsFixer;
use PhpCsFixer\Finder;

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

$finder = Finder::create()
    ->in(__DIR__)
    ->notPath('/exclude/');

return (new PhpCsFixer($finder))
    ->getRuleSet()
    ->setLineEnding("\r\n")
    ->setCacheFile('/tmp/.php_cs.cache')
    ->setIndent("\t")
    ->setRiskyAllowed(false)
    ->setUsingCache(true);

composer.json

{
    "scripts": {
        "phpcs": [
            "bash bin/php-cs-fixer.sh",
            "php php-cs-fixer.phar fix --config=php_cs.php"
        ]
    }
}