Core/.php-cs-fixer.php

80 lines
2.5 KiB
PHP
Raw Permalink Normal View History

2020-02-24 12:34:31 +00:00
<?php
2024-06-10 04:31:06 +00:00
use PhpCsFixer\Runner\Parallel\ParallelConfig;
$finder = PhpCsFixer\Finder::create();
if (!defined('__PHPCS_ROOT__')) {
define('__PHPCS_ROOT__', getcwd());
}
$directories = [
__PHPCS_ROOT__.'/src',
__PHPCS_ROOT__.'/bin',
2020-12-07 12:15:25 +00:00
__PHPCS_ROOT__.'/db',
__PHPCS_ROOT__.'/tests',
];
if (isset($additionalDirectories)) {
$directories = array_merge($directories, $additionalDirectories);
}
foreach ($directories as $directory) {
if (file_exists($directory) && is_dir($directory)) {
$finder->in($directory);
}
}
2020-12-07 12:15:25 +00:00
if (file_exists(__PHPCS_ROOT__.'/vendor/benzine')) {
foreach (new DirectoryIterator(__PHPCS_ROOT__.'/vendor/benzine') as $file) {
if (!$file->isDot()) {
if ($file->isDir()) {
if (file_exists($file->getRealPath().'/src')) {
$finder->in($file->getRealPath().'/src');
}
if (file_exists($file->getRealPath().'/tests')) {
$finder->in($file->getRealPath().'/tests');
}
}
}
}
}
2021-05-16 04:27:21 +00:00
return (new PhpCsFixer\Config)
2024-05-22 02:11:12 +00:00
->setParallelConfig(new ParallelConfig(10, 20, 120))
->setRiskyAllowed(true)
->setHideProgress(false)
->setRules([
2024-04-14 13:48:14 +00:00
'@PhpCsFixer' => true,
// '@PhpCsFixer:risky' => true,
'@PHP82Migration' => true,
'@PHP80Migration:risky' => true,
'@PSR12' => true,
'@PSR12:risky' => true,
'@PHPUnit100Migration:risky' => true,
'binary_operator_spaces' => [
'default' => 'align_single_space_minimal',
'operators' => [
'=' => 'align_single_space',
'=>' => 'align_single_space',
],
],
'types_spaces' => [
'space' => 'single',
'space_multiple_catch' => 'single',
],
// Annoyance-fixers:
'concat_space' => ['spacing' => 'one'], // This one is a matter of taste.
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => false,
'allow_unused_params' => false,
'remove_inheritdoc' => true,
],
'yoda_style' => false, // Disabled as its annoying. Comes with @PhpCsFixer
'native_function_invocation' => false, // Disabled as adding count($i) -> \count($i) is annoying, but supposedly more performant
])
->setFinder($finder)
;