Skip to content

Commit

Permalink
chore(ci): add ecs to ci
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Feb 25, 2025
1 parent ac7d74a commit b89b65a
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
- name: Run PHPStan
run: php vendor/bin/phpstan
- name: Run ECS
run: php vendor/bin/ecs

- name: Run test suite
run: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
tests/_support
tests/_output
tests/cases/yii2-app-advanced/_data/db.sqlite
.php-cs-fixer.cache
.php-cs-fixer.cache
.ecs-cache
67 changes: 67 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

declare(strict_types=1);

// ecs.php
use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff;
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use PhpCsFixer\Fixer\ClassNotation\FinalInternalClassFixer;
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
use PhpCsFixer\Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer;
use PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ECSConfig $ecsConfig): void {
// Parallel
$ecsConfig->parallel();

$ecsConfig->cacheDirectory('.ecs-cache');
// Paths
$ecsConfig->paths([
__DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/ecs.php'
]);

// A. full sets
$ecsConfig->sets([SetList::PSR_12, SetList::SPACES]);

$ecsConfig->rule(NotOperatorWithSuccessorSpaceFixer::class);
$ecsConfig->rule(ArraySyntaxFixer::class);
$ecsConfig->ruleWithConfiguration(GeneralPhpdocAnnotationRemoveFixer::class, [
'annotations' => ['author', 'inheritdoc']
]);
$ecsConfig->rule(NoBlankLinesAfterPhpdocFixer::class);
$ecsConfig->ruleWithConfiguration(NoSuperfluousPhpdocTagsFixer::class, [
'allow_mixed' => true
]);
$ecsConfig->rule(NoEmptyPhpdocFixer::class);
$ecsConfig->rule(NoUnusedImportsFixer::class);
$ecsConfig->rule(DeclareStrictTypesFixer::class);
$ecsConfig->ruleWithConfiguration(FinalInternalClassFixer::class, [
'annotation_exclude' => ['@not-fix', '@internal'],
'annotation_include' => [],
'consider_absent_docblock_as_internal_class' => \true
]);
$ecsConfig->ruleWithConfiguration(ForbiddenFunctionsSniff::class, [
'forbiddenFunctions' => [
'passthru' => null,
'var_dump' => null,
]
]);
$ecsConfig->skip([
ForbiddenFunctionsSniff::class => [
'tests/**',
'console/**'
]
]);

// $ecsConfig->skip([
// FinalClassFixer::class => [
// 'tests/**'
// ]
// ]);
};

0 comments on commit b89b65a

Please sign in to comment.