Skip to content

Commit dcfe4cb

Browse files
authored
Initial commit
0 parents  commit dcfe4cb

23 files changed

+989
-0
lines changed

.ecs/.header

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This file is part of Chevere.
2+
3+
(c) Rodolfo Berrios <rodolfo@chevere.org>
4+
5+
For the full copyright and license information, please view the LICENSE
6+
file that was distributed with this source code.

.ecs/ecs-chevere.php

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Chevere.
5+
*
6+
* (c) Rodolfo Berrios <rodolfo@chevere.org>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
use PhpCsFixer\Fixer\Alias\NoAliasFunctionsFixer;
15+
use PhpCsFixer\Fixer\Alias\NoAliasLanguageConstructCallFixer;
16+
use PhpCsFixer\Fixer\Alias\NoMixedEchoPrintFixer;
17+
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
18+
use PhpCsFixer\Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer;
19+
use PhpCsFixer\Fixer\ArrayNotation\NormalizeIndexBraceFixer;
20+
use PhpCsFixer\Fixer\Casing\IntegerLiteralCaseFixer;
21+
use PhpCsFixer\Fixer\Casing\LowercaseStaticReferenceFixer;
22+
use PhpCsFixer\Fixer\Casing\MagicConstantCasingFixer;
23+
use PhpCsFixer\Fixer\Casing\MagicMethodCasingFixer;
24+
use PhpCsFixer\Fixer\Casing\NativeFunctionCasingFixer;
25+
use PhpCsFixer\Fixer\Casing\NativeFunctionTypeDeclarationCasingFixer;
26+
use PhpCsFixer\Fixer\CastNotation\NoShortBoolCastFixer;
27+
use PhpCsFixer\Fixer\CastNotation\NoUnsetCastFixer;
28+
use PhpCsFixer\Fixer\Comment\HeaderCommentFixer;
29+
use PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer;
30+
use PhpCsFixer\Fixer\ControlStructure\IncludeFixer;
31+
use PhpCsFixer\Fixer\ControlStructure\NoAlternativeSyntaxFixer;
32+
use PhpCsFixer\Fixer\FunctionNotation\LambdaNotUsedImportFixer;
33+
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
34+
use PhpCsFixer\Fixer\Import\SingleImportPerStatementFixer;
35+
use PhpCsFixer\Fixer\LanguageConstruct\CombineConsecutiveUnsetsFixer;
36+
use PhpCsFixer\Fixer\LanguageConstruct\SingleSpaceAroundConstructFixer;
37+
use PhpCsFixer\Fixer\ListNotation\ListSyntaxFixer;
38+
use PhpCsFixer\Fixer\NamespaceNotation\CleanNamespaceFixer;
39+
use PhpCsFixer\Fixer\Operator\NoSpaceAroundDoubleColonFixer;
40+
use PhpCsFixer\Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer;
41+
use PhpCsFixer\Fixer\Operator\StandardizeNotEqualsFixer;
42+
use PhpCsFixer\Fixer\PhpTag\LinebreakAfterOpeningTagFixer;
43+
use PhpCsFixer\Fixer\ReturnNotation\NoUselessReturnFixer;
44+
use PhpCsFixer\Fixer\ReturnNotation\ReturnAssignmentFixer;
45+
use PhpCsFixer\Fixer\Semicolon\MultilineWhitespaceBeforeSemicolonsFixer;
46+
use PhpCsFixer\Fixer\Semicolon\NoEmptyStatementFixer;
47+
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
48+
use PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer;
49+
use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer;
50+
use PhpCsFixer\Fixer\Whitespace\CompactNullableTypehintFixer;
51+
use PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer;
52+
use PhpCsFixer\Fixer\Whitespace\TypesSpacesFixer;
53+
use Symplify\CodingStandard\Fixer\Commenting\ParamReturnAndVarTagMalformsFixer;
54+
use Symplify\EasyCodingStandard\Config\ECSConfig;
55+
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
56+
57+
return static function (ECSConfig $ecsConfig): void {
58+
$ecsConfig->parallel();
59+
$headerFile = __DIR__ . '/.header';
60+
$ecsConfig->sets([SetList::PSR_12, SetList::COMMON]);
61+
if (file_exists($headerFile)) {
62+
$ecsConfig->ruleWithConfiguration(HeaderCommentFixer::class, [
63+
'header' => file_get_contents($headerFile),
64+
'location' => 'after_open',
65+
]);
66+
}
67+
$ecsConfig->rule(TypesSpacesFixer::class);
68+
$ecsConfig->rule(NoUselessReturnFixer::class);
69+
$ecsConfig->rule(LinebreakAfterOpeningTagFixer::class);
70+
$ecsConfig->rule(StandardizeNotEqualsFixer::class);
71+
$ecsConfig->rule(NoSpaceAroundDoubleColonFixer::class);
72+
$ecsConfig->rule(CleanNamespaceFixer::class);
73+
$ecsConfig->rule(ListSyntaxFixer::class);
74+
$ecsConfig->rule(SingleSpaceAroundConstructFixer::class);
75+
$ecsConfig->rule(LambdaNotUsedImportFixer::class);
76+
$ecsConfig->rule(NoAlternativeSyntaxFixer::class);
77+
$ecsConfig->rule(NoUnsetCastFixer::class);
78+
$ecsConfig->rule(NoShortBoolCastFixer::class);
79+
$ecsConfig->rule(NativeFunctionTypeDeclarationCasingFixer::class);
80+
$ecsConfig->rule(NativeFunctionCasingFixer::class);
81+
$ecsConfig->rule(MagicMethodCasingFixer::class);
82+
$ecsConfig->rule(MagicConstantCasingFixer::class);
83+
$ecsConfig->rule(LowercaseStaticReferenceFixer::class);
84+
$ecsConfig->rule(IntegerLiteralCaseFixer::class);
85+
$ecsConfig->rule(NormalizeIndexBraceFixer::class);
86+
$ecsConfig->rule(NoMultilineWhitespaceAroundDoubleArrowFixer::class);
87+
$ecsConfig->rule(BlankLineBeforeStatementFixer::class);
88+
$ecsConfig->rule(CombineConsecutiveUnsetsFixer::class);
89+
$ecsConfig->rule(CompactNullableTypehintFixer::class);
90+
$ecsConfig->rule(DeclareStrictTypesFixer::class);
91+
$ecsConfig->rule(IncludeFixer::class);
92+
$ecsConfig->rule(MultilineWhitespaceBeforeSemicolonsFixer::class);
93+
$ecsConfig->rule(NoAliasFunctionsFixer::class);
94+
$ecsConfig->rule(NoAliasLanguageConstructCallFixer::class);
95+
$ecsConfig->rule(NoEmptyStatementFixer::class);
96+
$ecsConfig->rule(NoMixedEchoPrintFixer::class);
97+
$ecsConfig->rule(ObjectOperatorWithoutWhitespaceFixer::class);
98+
$ecsConfig->rule(ParamReturnAndVarTagMalformsFixer::class);
99+
$ecsConfig->rule(ReturnAssignmentFixer::class);
100+
$ecsConfig->ruleWithConfiguration(SingleLineCommentStyleFixer::class, [
101+
'comment_types' => ['hash'],
102+
]);
103+
$ecsConfig->rule(SingleQuoteFixer::class);
104+
$ecsConfig->ruleWithConfiguration(OrderedImportsFixer::class, [
105+
'imports_order' => ['class', 'function', 'const'],
106+
]);
107+
$ecsConfig->ruleWithConfiguration(ArraySyntaxFixer::class, [
108+
'syntax' => 'short',
109+
]);
110+
$ecsConfig->ruleWithConfiguration(NoExtraBlankLinesFixer::class, [
111+
'tokens' => [
112+
'curly_brace_block',
113+
'extra',
114+
'parenthesis_brace_block',
115+
'square_brace_block',
116+
'throw',
117+
'use',
118+
],
119+
]);
120+
$ecsConfig->skip([
121+
SingleImportPerStatementFixer::class => null,
122+
]);
123+
};

.ecs/ecs.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Chevere.
5+
*
6+
* (c) Rodolfo Berrios <rodolfo@chevere.org>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
use Symplify\EasyCodingStandard\Config\ECSConfig;
15+
16+
return static function (ECSConfig $ecsConfig): void {
17+
$ecsConfig->import(__DIR__ . '/ecs-chevere.php');
18+
$ecsConfig->skip([
19+
__DIR__ . '/vendor/*',
20+
]);
21+
};

.gitattributes

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/.ecs export-ignore
2+
/.gitattributes export-ignore
3+
/.github export-ignore
4+
/.gitignore export-ignore
5+
/.vscode export-ignore
6+
/demo export-ignore
7+
/infection.json.dist export-ignore
8+
/phpunit-coverage.xml export-ignore
9+
/phpunit.xml export-ignore
10+
/rector.php export-ignore
11+
/sonar-project.properties export-ignore
12+
/tests export-ignore
13+
/phpstan.neon export-ignore
14+
/chevere.svg export-ignore
15+
16+
*.php diff=php

.github/workflows/sonarcloud.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: SonarCloud
2+
on: [push]
3+
jobs:
4+
sonarcloud:
5+
runs-on: ${{ matrix.os }}
6+
strategy:
7+
matrix:
8+
os: [ubuntu-latest]
9+
php: ["8.4"]
10+
env:
11+
tools: composer
12+
ini-values: default_charset='UTF-8'
13+
name: PHP ${{ matrix.php }} test on ${{ matrix.os }}
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
- name: Setup PHP
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: ${{ matrix.php }}
21+
ini-values: ${{ env.ini-values }}
22+
coverage: pcov
23+
tools: ${{ env.tools }}
24+
env:
25+
fail-fast: true
26+
- name: Setup problem matchers for PHPUnit
27+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
28+
- name: Validate composer
29+
run: composer validate
30+
- name: Get composer cache directory
31+
id: composer-cache
32+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
33+
- name: Cache dependencies
34+
uses: actions/cache@v3
35+
with:
36+
path: ${{ steps.composer-cache.outputs.dir }}
37+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
38+
restore-keys: ${{ runner.os }}-composer-
39+
- name: Install dependencies
40+
run: composer install --no-progress
41+
- name: Tests (PHPUnit)
42+
run: vendor/bin/phpunit --coverage-clover=build/logs/clover.xml --log-junit=build/logs/junit.xml
43+
- name: Fix paths for sonar-scanner
44+
working-directory: ./build/logs
45+
run: |
46+
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace@g' clover.xml
47+
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace@g' junit.xml
48+
- name: SonarCloud scan
49+
uses: SonarSource/sonarcloud-github-action@master
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/test.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Test
2+
on: [push]
3+
jobs:
4+
test:
5+
runs-on: ${{ matrix.os }}
6+
strategy:
7+
matrix:
8+
os: [ubuntu-latest]
9+
php: ["8.1", "8.2", "8.3", "8.4"]
10+
env:
11+
tools: composer, phpstan, infection
12+
ini-values: default_charset='UTF-8'
13+
name: PHP ${{ matrix.php }} test on ${{ matrix.os }}
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
- name: Setup PHP
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: ${{ matrix.php }}
21+
ini-values: ${{ env.ini-values }}
22+
coverage: pcov
23+
tools: ${{ env.tools }}
24+
env:
25+
fail-fast: true
26+
- name: Setup problem matchers for PHPUnit
27+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
28+
- name: Validate composer
29+
run: composer validate
30+
- name: Get composer cache directory
31+
id: composer-cache
32+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
33+
- name: Cache dependencies
34+
uses: actions/cache@v3
35+
with:
36+
path: ${{ steps.composer-cache.outputs.dir }}
37+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
38+
restore-keys: ${{ runner.os }}-composer-
39+
- name: Install dependencies
40+
run: composer install --no-progress
41+
- name: Run PHPStan
42+
run: composer phpstan
43+
- name: Tests (PHPUnit)
44+
run: vendor/bin/phpunit --coverage-xml=build/logs/xml-coverage --log-junit=build/logs/junit.xml
45+
- name: Mutation testing (Infection)
46+
env:
47+
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
48+
run: infection --coverage=build/logs --min-covered-msi=90 --threads=$(nproc) --logger-github --only-covered

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
/.idea
3+
/.phpunit.cache
4+
/.scannerwork
5+
/vendor
6+
/composer.lock
7+
/build

.vscode/coverage.code-snippets

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"coverage-ignore": {
3+
"description": "Code coverage ignore tag",
4+
"prefix": "cov-ignore",
5+
"body": [
6+
"@codeCoverageIgnore"
7+
]
8+
},
9+
"coverage-ignore-start": {
10+
"description": "Code coverage ignore start tag",
11+
"prefix": "cov-ignore-start",
12+
"body": [
13+
"@codeCoverageIgnoreStart"
14+
]
15+
},
16+
"coverage-ignore-end": {
17+
"description": "Code coverage ignore end tag",
18+
"prefix": "cov-ignore-end",
19+
"body": [
20+
"@codeCoverageIgnoreEnd"
21+
]
22+
},
23+
"coverage-infection-ignore-all": {
24+
"description": "Comment infection ignore all",
25+
"prefix": "comment-infection-ignore-all",
26+
"body": [
27+
"@infection-ignore-all.",
28+
]
29+
},
30+
}

.vscode/docblock.code-snippets

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"docblock-construct": {
3+
"description": "Docblock construct",
4+
"prefix": "docblock-construct",
5+
"body": [
6+
"/**",
7+
" * Does?",
8+
" */"
9+
]
10+
},
11+
"docblock-instance": {
12+
"description": "Docblock instance",
13+
"prefix": "docblock-instance",
14+
"body": [
15+
"/**",
16+
" * Provides access to the ${1:name} instance.",
17+
" */"
18+
]
19+
},
20+
"docblock-immutable": {
21+
"description": "Docblock immutable",
22+
"prefix": "docblock-immutable",
23+
"body": [
24+
"/**",
25+
" * Return an instance with the specified ${1:name}.",
26+
" *",
27+
" * This method MUST retain the state of the current instance, and return",
28+
" * an instance that contains the specified ${1:name}.",
29+
" */"
30+
]
31+
},
32+
"docblock-boolean": {
33+
"description": "Docblock boolean",
34+
"prefix": "docblock-boolean",
35+
"body": [
36+
"/**",
37+
" * Indicates whether the instance has ${1:name}.",
38+
" */"
39+
]
40+
},
41+
"docblock-interface": {
42+
"description": "Docblock interface",
43+
"prefix": "docblock-interface",
44+
"body": [
45+
"/**",
46+
" * Describes the component in charge of ${1:doing}.",
47+
" */"
48+
]
49+
}
50+
}

.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"runOnSave.commands": [
3+
{
4+
"match": "\\.php$",
5+
"runIn": "backend",
6+
"command": "cd ${workspaceFolder} && vendor/bin/ecs --config='.ecs/ecs.php' check ${file} --fix",
7+
"workingDirectoryAsCWD": true,
8+
"runningStatusMessage": "ECS ${fileBasename}",
9+
"finishStatusMessage": "${fileBasename} OK"
10+
},
11+
]
12+
}

0 commit comments

Comments
 (0)