Skip to content

Commit

Permalink
clean config
Browse files Browse the repository at this point in the history
  • Loading branch information
Rom1-B committed Sep 5, 2024
1 parent 599f570 commit ebce427
Showing 1 changed file with 1 addition and 40 deletions.
41 changes: 1 addition & 40 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,13 @@
use PhpCsFixer\Config;
use PhpCsFixer\Finder;

/**
* Read excluded paths from .gitignore
*
* @param string $dir
*
* @return string[]
*/
function getGitignorePaths(string $dir): array
{
$gitignoreFile = $dir . '/.gitignore';
$paths = [];

if (!file_exists($gitignoreFile)) {
return $paths;
}

$lines = file($gitignoreFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if (!empty($lines)) {
foreach ($lines as $line) {
// Ignore comments and empty lines
if (strpos($line, '#') === 0 || trim($line) === '') {
continue;
}
// Add relative paths
$paths[] = trim($line);
}
}

return $paths;
}

$projectDir = __DIR__;
$finder = Finder::create()
->in($projectDir)
->in(__DIR__)
->name('*.php');

// Exclude paths from .gitignore
$gitignorePaths = getGitignorePaths($projectDir);
foreach ($gitignorePaths as $path) {
$finder->notPath($path);
}

$config = new Config();

$rules = [
'@PSR12' => true,
'@PER-CS2.0' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
Expand Down

0 comments on commit ebce427

Please sign in to comment.