mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-29 10:05:03 +00:00
Upgrade drupol/php-conventions to v5.
This commit is contained in:
71
.php-cs-fixer.dist.php
Normal file
71
.php-cs-fixer.dist.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* @see https://www.champs-libres.coop/
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use drupol\PhpCsFixerConfigsPhp\Config\Php7;
|
||||
use PhpCsFixer\RuleSet\RuleSetDescriptionInterface;
|
||||
use PhpCsFixer\RuleSet\RuleSets;
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$vendorDirectory = dirname((new ReflectionClass(Php7::class))->getFileName(), 5);
|
||||
|
||||
$config = require $vendorDirectory . '/drupol/php-conventions/config/php73/php_cs_fixer.config.php';
|
||||
|
||||
$config
|
||||
->getFinder()
|
||||
->ignoreDotFiles(false);
|
||||
|
||||
$rules = $config->getRules();
|
||||
|
||||
$riskyRules = array_reduce(
|
||||
array_filter(
|
||||
RuleSets::getSetDefinitions(),
|
||||
static function (RuleSetDescriptionInterface $ruleset): bool {
|
||||
return $ruleset->isRisky();
|
||||
}
|
||||
),
|
||||
static function (array $carry, RuleSetDescriptionInterface $ruleSetDescription): array {
|
||||
return array_merge($carry, array_keys($ruleSetDescription->getRules()));
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
$rules['header_comment']['header'] = trim(file_get_contents(__DIR__ . '/resource/header.txt'));
|
||||
|
||||
// Remove properties containing the word 'risky'.
|
||||
// Remove custom risky properties
|
||||
$rules = array_filter(
|
||||
array_filter(
|
||||
array_diff_key(
|
||||
$rules,
|
||||
array_flip($riskyRules)
|
||||
),
|
||||
static function (string $property): bool {
|
||||
return false === strpos(strtolower($property), 'risky');
|
||||
},
|
||||
ARRAY_FILTER_USE_KEY
|
||||
),
|
||||
static function (string $property): bool {
|
||||
return false === in_array(
|
||||
$property,
|
||||
[
|
||||
'static_lambda',
|
||||
'ordered_interfaces',
|
||||
'psr4',
|
||||
]
|
||||
);
|
||||
},
|
||||
ARRAY_FILTER_USE_KEY
|
||||
);
|
||||
|
||||
return $config->setRules($rules);
|
Reference in New Issue
Block a user