PHP code example of permafrost-dev / phpcsfixer-preset
1. Go to this page and download the library: Download permafrost-dev/phpcsfixer-preset 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/ */
permafrost-dev / phpcsfixer-preset example snippets
ermafrost\PhpCsFixerRules\Finders\LaravelProjectFinder;
use Permafrost\PhpCsFixerRules\Rulesets\DefaultRuleset;
use Permafrost\PhpCsFixerRules\SharedConfig;
$finder = LaravelProjectFinder::create(__DIR__);
return SharedConfig::create($finder, new DefaultRuleset());
hpCsFixer\Finder;
use Permafrost\PhpCsFixerRules\Rulesets\SpatieRuleset;
use Permafrost\PhpCsFixerRules\SharedConfig;
$finder = Finder::create()
->ignoreVCS(true)
->ignoreDotFiles(true)
->name('*.php')
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->exclude(__DIR__ . '/vendor');
return SharedConfig::create($finder, new SpatieRuleset());
ermafrost\PhpCsFixerRules\Finders\LaravelProjectFinder;
use Permafrost\PhpCsFixerRules\Rulesets\DefaultRuleset;
use Permafrost\PhpCsFixerRules\SharedConfig;
$finder = LaravelProjectFinder::create(__DIR__);
return SharedConfig::create($finder, new DefaultRuleset([
// existing rules can be overridden:
'no_break_comment' => true,
'no_closing_tag' => false,
// new rules can be added:
'a_new_option' => [
'some_sub_option' => 12,
],
]));
namespace Permafrost\PhpCsFixerRules\Rulesets;
class MyCustomRulesRuleset implements RuleSet
{
public function allowRisky(): bool
{
return true; //this tells php-cs-fixer whether or not to permit "risky" rules.
}
public static function name(): string
{
return 'my_custom_rules'; //the name should omit 'ruleset' from the end.
}
/**
* @return array
*/
public function rules(): array
{
return array_merge([
'@PSR2' => true,
// additional php-cs-fixer rules
], $this->additional); //it's important that the additional rules property is merged
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.