PHP code example of eliashaeussler / php-cs-fixer-config

1. Go to this page and download the library: Download eliashaeussler/php-cs-fixer-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/ */

    

eliashaeussler / php-cs-fixer-config example snippets


use EliasHaeussler\PhpCsFixerConfig;
use Symfony\Component\Finder;

// Create header rule
$header = PhpCsFixerConfig\Rules\Header::create(
    'eliashaeussler/package-name',
    PhpCsFixerConfig\Package\Type::ComposerPackage,
    PhpCsFixerConfig\Package\Author::create('Elias Häußler', '[email protected]'),
    PhpCsFixerConfig\Package\CopyrightRange::from(2021),
    PhpCsFixerConfig\Package\License::GPL3OrLater,
);

// Create custom rule set
$ruleSet = PhpCsFixerConfig\Rules\RuleSet::fromArray([
    'modernize_types_casting' => true,
    'php_unit_test_case_static_method_calls' => [
        'call_type' => 'self',
    ],
]);

return PhpCsFixerConfig\Config::create()
    ->withRule($header)
    ->withRule($ruleSet)
    // You can also overwrite all rules
    ->withRule($ruleSet, false)
    ->withFinder(static fn (Finder\Finder $finder) => $finder->in(__DIR__))
    // You can also inject your own Finder instance
    ->withFinder($finder)
;