2020-02-24 12:34:31 +00:00
|
|
|
<?php
|
2020-07-31 21:15:09 +00:00
|
|
|
$finder = PhpCsFixer\Finder::create();
|
|
|
|
|
|
|
|
if (!defined('__PHPCS_ROOT__')) {
|
2021-05-17 00:36:25 +00:00
|
|
|
define('__PHPCS_ROOT__', getcwd());
|
2020-07-31 21:15:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$directories = [
|
|
|
|
__PHPCS_ROOT__.'/src',
|
|
|
|
__PHPCS_ROOT__.'/bin',
|
2020-12-07 12:15:25 +00:00
|
|
|
__PHPCS_ROOT__.'/db',
|
2020-07-31 21:15:09 +00:00
|
|
|
__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)
|
2020-07-31 21:15:09 +00:00
|
|
|
->setRiskyAllowed(true)
|
|
|
|
->setHideProgress(false)
|
|
|
|
->setRules([
|
|
|
|
'@PSR2' => true,
|
|
|
|
'strict_param' => true,
|
|
|
|
'array_syntax' => ['syntax' => 'short'],
|
|
|
|
'@PhpCsFixer' => true,
|
|
|
|
'@PHP73Migration' => true,
|
|
|
|
'no_php4_constructor' => true,
|
|
|
|
'no_unused_imports' => true,
|
|
|
|
'no_useless_else' => true,
|
2020-12-07 12:15:25 +00:00
|
|
|
'no_superfluous_phpdoc_tags' => false,
|
2020-07-31 21:15:09 +00:00
|
|
|
'void_return' => true,
|
|
|
|
'yoda_style' => false,
|
|
|
|
])
|
|
|
|
->setFinder($finder)
|
|
|
|
;
|