PHP code example of realodix / cs-config

1. Go to this page and download the library: Download realodix/cs-config library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

realodix / cs-config example snippets




use Realodix\CsConfig\Config;
use Realodix\CsConfig\Finder;
use Realodix\CsConfig\Rules\Realodix;

return Config::create(new Realodix);



use Realodix\CsConfig\Config;
use Realodix\CsConfig\Finder;
use Realodix\CsConfig\Rules\Realodix;

$localRules = [
    // Adding a rule
    'array_syntax' => true,
    // Adding a rule or override predefined rules
    'binary_operator_spaces' => [
        'operators' => ['=>' => 'align_single_space_minimal']
    ],
    // Override predefined rules
    'ternary_operator_spaces' => false,
    // Adding custom rules
    'CustomFixer/rule_1' => true,
    'CustomFixer/rule_2' => true,
];

return Config::create(new Realodix($localRules))
    ->registerCustomFixers(new PhpCsFixerCustomFixers\CustomFixer());



use Realodix\CsConfig\Rules\AbstractRules;

final class MyRules extends AbstractRules
{
    // public string $name = 'Personal CS';

    protected function rules(): array
    {
        //
    }
}



use Realodix\CsConfig\Config;
use Realodix\CsConfig\Finder;
use YourVendorName\YourPackageName\MyRules;

$finder = Finder::base(__DIR__);

return Config::create(new MyRules)
    ->setFinder($finder);