Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style: Add internal rules configuration for the project itself #91

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ecs-internal.php export-ignore
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
"@test"
],
"analyze": [
"vendor/bin/ecs check src/ tests/ ecs.php ecs-8.1.php ecs-8.2.php ecs-8.3.php --ansi",
"vendor/bin/ecs check --config=ecs-internal.php --ansi",
"vendor/bin/phpstan analyze -c phpstan.neon --ansi"
],
"fix": [
"@composer normalize",
"vendor/bin/ecs check ./src/ ./tests/ ecs.php ecs-8.1.php ecs-8.2.php ecs-8.3.php --ansi --fix"
"vendor/bin/ecs check --config=ecs-internal.php --ansi --fix"
],
"lint": [
"vendor/bin/parallel-lint -j 10 -e php ./src ./tests ecs.php ecs-8.1.php ecs-8.2.php ecs-8.3.php",
Expand Down
22 changes: 22 additions & 0 deletions ecs-internal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php declare(strict_types=1);

use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer;
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;

/**
* Internal rules configuration for the lmc/coding-standard project itself
*/
return ECSConfig::configure()
->withPaths([__DIR__ . '/src', __DIR__ . '/tests'])
->withRootFiles()
->withSets(
[
__DIR__ . '/ecs.php',
],
)
->withConfiguredRule(PhpUnitTestAnnotationFixer::class, ['style' => 'annotation'])
->withConfiguredRule(
LineLengthFixer::class,
['line_length' => 120, 'break_long_lines' => true, 'inline_short_lines' => false],
);
5 changes: 4 additions & 1 deletion ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,10 @@
->withConfiguredRule(ArraySyntaxFixer::class, ['syntax' => 'short'])
// The body of each structure MUST be enclosed by braces. Braces should be properly placed
// @TODO move configuration to BracesPositionFixer after BracesFixer is not included in PSR-12 check anymore
->withConfiguredRule(BracesFixer::class, ['allow_single_line_closure' => true, 'allow_single_line_anonymous_class_with_empty_body' => true])
->withConfiguredRule(
BracesFixer::class,
['allow_single_line_closure' => true, 'allow_single_line_anonymous_class_with_empty_body' => true],
)
// Class, trait and interface elements must be separated with one or none blank line
->withConfiguredRule(ClassAttributesSeparationFixer::class, ['elements' => ['method' => 'one']])
// Visibility MUST be declared on all properties, methods and class constants
Expand Down