PHP code example of ergebnis / php-cs-fixer-config
1. Go to this page and download the library: Download ergebnis/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/ */
ergebnis / php-cs-fixer-config example snippets
declare(strict_types=1);
use Ergebnis\PhpCsFixer\Config;
$ruleSet = Config\RuleSet\Php83::create();
$config = Config\Factory::fromRuleSet($ruleSet);
$config->getFinder()->in(__DIR__);
$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');
return $config;
diff
declare(strict_types=1);
use Ergebnis\PhpCsFixer\Config;
+$header = <<<EOF
+Copyright (c) 2023 Andreas Möller
+
+For the full copyright and license information, please view
+the LICENSE file that was distributed with this source code.
+
+@see https://github.com/ergebnis/php-cs-fixer-config
+EOF;
-$ruleSet = Config\RuleSet\Php83::create();
+$ruleSet = Config\RuleSet\Php83::create()->withHeader($header);
$config = Config\Factory::fromRuleSet($ruleSet);
$config->getFinder()->in(__DIR__);
$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');
return $config;
diff
declare(strict_types=1);
use Ergebnis\PhpCsFixer\Config;
-$ruleSet = Config\RuleSet\Php83::create();
+$ruleSet = Config\RuleSet\Php83::create()->withRules(Config\Rules::fromArray([
+ 'mb_str_functions' => false,
+ 'strict_comparison' => false,
+]));
$config = Config\Factory::fromRuleSet($ruleSet);
$config->getFinder()->in(__DIR__);
$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');
return $config;
diff
declare(strict_types=1);
use Ergebnis\PhpCsFixer\Config;
use FooBar\Fixer;
-$ruleSet = Config\RuleSet\Php83::create();
+$ruleSet = Config\RuleSet\Php83::create()
+ ->withCustomFixers(Config\Fixers::fromFixers(
+ new Fixer\BarBazFixer(),
+ new Fixer\QuzFixer(),
+ ))
+ ->withRules(Config\Rules::fromArray([
+ 'FooBar/bar_baz' => true,
+ 'FooBar/quz' => [
+ 'qux => false,
+ ],
+ ]))
+]);
$config = Config\Factory::fromRuleSet($ruleSet);
$config->getFinder()->in(__DIR__);
$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');
return $config;
diff
+.PHONY: coding-standards
+coding-standards: vendor
+ mkdir -p .build/php-cs-fixer
+ vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --show-progress=dots --verbose
vendor: composer.json composer.lock
composer validate
composer install