mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
73 lines
1.9 KiB
PHP
73 lines
1.9 KiB
PHP
<?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)
|
|
->name(['.php_cs.dist']);
|
|
|
|
$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);
|