generated from chevere/package-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cb6a9b8
Showing
22 changed files
with
987 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
This file is part of Chevere. | ||
|
||
(c) Rodolfo Berrios <[email protected]> | ||
|
||
For the full copyright and license information, please view the LICENSE | ||
file that was distributed with this source code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Chevere. | ||
* | ||
* (c) Rodolfo Berrios <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use PhpCsFixer\Fixer\Alias\NoAliasFunctionsFixer; | ||
use PhpCsFixer\Fixer\Alias\NoAliasLanguageConstructCallFixer; | ||
use PhpCsFixer\Fixer\Alias\NoMixedEchoPrintFixer; | ||
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer; | ||
use PhpCsFixer\Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer; | ||
use PhpCsFixer\Fixer\ArrayNotation\NormalizeIndexBraceFixer; | ||
use PhpCsFixer\Fixer\Casing\IntegerLiteralCaseFixer; | ||
use PhpCsFixer\Fixer\Casing\LowercaseStaticReferenceFixer; | ||
use PhpCsFixer\Fixer\Casing\MagicConstantCasingFixer; | ||
use PhpCsFixer\Fixer\Casing\MagicMethodCasingFixer; | ||
use PhpCsFixer\Fixer\Casing\NativeFunctionCasingFixer; | ||
use PhpCsFixer\Fixer\Casing\NativeFunctionTypeDeclarationCasingFixer; | ||
use PhpCsFixer\Fixer\CastNotation\NoShortBoolCastFixer; | ||
use PhpCsFixer\Fixer\CastNotation\NoUnsetCastFixer; | ||
use PhpCsFixer\Fixer\Comment\HeaderCommentFixer; | ||
use PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer; | ||
use PhpCsFixer\Fixer\ControlStructure\IncludeFixer; | ||
use PhpCsFixer\Fixer\ControlStructure\NoAlternativeSyntaxFixer; | ||
use PhpCsFixer\Fixer\FunctionNotation\LambdaNotUsedImportFixer; | ||
use PhpCsFixer\Fixer\Import\OrderedImportsFixer; | ||
use PhpCsFixer\Fixer\Import\SingleImportPerStatementFixer; | ||
use PhpCsFixer\Fixer\LanguageConstruct\CombineConsecutiveUnsetsFixer; | ||
use PhpCsFixer\Fixer\LanguageConstruct\SingleSpaceAroundConstructFixer; | ||
use PhpCsFixer\Fixer\ListNotation\ListSyntaxFixer; | ||
use PhpCsFixer\Fixer\NamespaceNotation\CleanNamespaceFixer; | ||
use PhpCsFixer\Fixer\Operator\NoSpaceAroundDoubleColonFixer; | ||
use PhpCsFixer\Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer; | ||
use PhpCsFixer\Fixer\Operator\StandardizeNotEqualsFixer; | ||
use PhpCsFixer\Fixer\PhpTag\LinebreakAfterOpeningTagFixer; | ||
use PhpCsFixer\Fixer\ReturnNotation\NoUselessReturnFixer; | ||
use PhpCsFixer\Fixer\ReturnNotation\ReturnAssignmentFixer; | ||
use PhpCsFixer\Fixer\Semicolon\MultilineWhitespaceBeforeSemicolonsFixer; | ||
use PhpCsFixer\Fixer\Semicolon\NoEmptyStatementFixer; | ||
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer; | ||
use PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer; | ||
use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer; | ||
use PhpCsFixer\Fixer\Whitespace\CompactNullableTypehintFixer; | ||
use PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer; | ||
use PhpCsFixer\Fixer\Whitespace\TypesSpacesFixer; | ||
use Symplify\CodingStandard\Fixer\Commenting\ParamReturnAndVarTagMalformsFixer; | ||
use Symplify\EasyCodingStandard\Config\ECSConfig; | ||
use Symplify\EasyCodingStandard\ValueObject\Set\SetList; | ||
|
||
return static function (ECSConfig $ecsConfig): void { | ||
$ecsConfig->parallel(); | ||
$headerFile = __DIR__ . '/.header'; | ||
$ecsConfig->sets([SetList::PSR_12, SetList::COMMON]); | ||
if (file_exists($headerFile)) { | ||
$ecsConfig->ruleWithConfiguration(HeaderCommentFixer::class, [ | ||
'header' => file_get_contents($headerFile), | ||
'location' => 'after_open', | ||
]); | ||
} | ||
$ecsConfig->rule(TypesSpacesFixer::class); | ||
$ecsConfig->rule(NoUselessReturnFixer::class); | ||
$ecsConfig->rule(LinebreakAfterOpeningTagFixer::class); | ||
$ecsConfig->rule(StandardizeNotEqualsFixer::class); | ||
$ecsConfig->rule(NoSpaceAroundDoubleColonFixer::class); | ||
$ecsConfig->rule(CleanNamespaceFixer::class); | ||
$ecsConfig->rule(ListSyntaxFixer::class); | ||
$ecsConfig->rule(SingleSpaceAroundConstructFixer::class); | ||
$ecsConfig->rule(LambdaNotUsedImportFixer::class); | ||
$ecsConfig->rule(NoAlternativeSyntaxFixer::class); | ||
$ecsConfig->rule(NoUnsetCastFixer::class); | ||
$ecsConfig->rule(NoShortBoolCastFixer::class); | ||
$ecsConfig->rule(NativeFunctionTypeDeclarationCasingFixer::class); | ||
$ecsConfig->rule(NativeFunctionCasingFixer::class); | ||
$ecsConfig->rule(MagicMethodCasingFixer::class); | ||
$ecsConfig->rule(MagicConstantCasingFixer::class); | ||
$ecsConfig->rule(LowercaseStaticReferenceFixer::class); | ||
$ecsConfig->rule(IntegerLiteralCaseFixer::class); | ||
$ecsConfig->rule(NormalizeIndexBraceFixer::class); | ||
$ecsConfig->rule(NoMultilineWhitespaceAroundDoubleArrowFixer::class); | ||
$ecsConfig->rule(BlankLineBeforeStatementFixer::class); | ||
$ecsConfig->rule(CombineConsecutiveUnsetsFixer::class); | ||
$ecsConfig->rule(CompactNullableTypehintFixer::class); | ||
$ecsConfig->rule(DeclareStrictTypesFixer::class); | ||
$ecsConfig->rule(IncludeFixer::class); | ||
$ecsConfig->rule(MultilineWhitespaceBeforeSemicolonsFixer::class); | ||
$ecsConfig->rule(NoAliasFunctionsFixer::class); | ||
$ecsConfig->rule(NoAliasLanguageConstructCallFixer::class); | ||
$ecsConfig->rule(NoEmptyStatementFixer::class); | ||
$ecsConfig->rule(NoMixedEchoPrintFixer::class); | ||
$ecsConfig->rule(ObjectOperatorWithoutWhitespaceFixer::class); | ||
$ecsConfig->rule(ParamReturnAndVarTagMalformsFixer::class); | ||
$ecsConfig->rule(ReturnAssignmentFixer::class); | ||
$ecsConfig->ruleWithConfiguration(SingleLineCommentStyleFixer::class, [ | ||
'comment_types' => ['hash'], | ||
]); | ||
$ecsConfig->rule(SingleQuoteFixer::class); | ||
$ecsConfig->ruleWithConfiguration(OrderedImportsFixer::class, [ | ||
'imports_order' => ['class', 'function', 'const'], | ||
]); | ||
$ecsConfig->ruleWithConfiguration(ArraySyntaxFixer::class, [ | ||
'syntax' => 'short', | ||
]); | ||
$ecsConfig->ruleWithConfiguration(NoExtraBlankLinesFixer::class, [ | ||
'tokens' => [ | ||
'curly_brace_block', | ||
'extra', | ||
'parenthesis_brace_block', | ||
'square_brace_block', | ||
'throw', | ||
'use', | ||
], | ||
]); | ||
$ecsConfig->skip([ | ||
SingleImportPerStatementFixer::class => null, | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Chevere. | ||
* | ||
* (c) Rodolfo Berrios <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Symplify\EasyCodingStandard\Config\ECSConfig; | ||
|
||
return static function (ECSConfig $ecsConfig): void { | ||
$ecsConfig->import(__DIR__ . '/ecs-chevere.php'); | ||
$ecsConfig->skip([ | ||
__DIR__ . '/vendor/*', | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/.ecs export-ignore | ||
/.github export-ignore | ||
/.vscode export-ignore | ||
/tests export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/phpunit-coverage.xml export-ignore | ||
/phpunit.xml export-ignore | ||
/rector.php export-ignore | ||
/sonar-project.properties export-ignore | ||
/infection.json.dist export-ignore | ||
|
||
*.php diff=php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: SonarCloud | ||
on: [push] | ||
jobs: | ||
sonarcloud: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
php: ["8.2"] | ||
env: | ||
tools: composer | ||
ini-values: default_charset='UTF-8' | ||
key: cache-1690242875644 | ||
name: PHP ${{ matrix.php }} test on ${{ matrix.os }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
ini-values: ${{ env.ini-values }} | ||
coverage: pcov | ||
tools: ${{ env.tools }} | ||
env: | ||
fail-fast: true | ||
- name: Setup problem matchers for PHPUnit | ||
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | ||
- name: Validate composer | ||
run: composer validate | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
- name: Install dependencies | ||
run: composer install --no-progress | ||
- name: Tests (PHPUnit) | ||
run: vendor/bin/phpunit --coverage-clover=build/logs/clover.xml --log-junit=build/logs/junit.xml | ||
- name: Fix paths for sonar-scanner | ||
working-directory: ./build/logs | ||
run: | | ||
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace@g' clover.xml | ||
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace@g' junit.xml | ||
- name: SonarCloud scan | ||
uses: SonarSource/sonarcloud-github-action@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Test | ||
on: [push] | ||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
php: ["8.1", "8.2", "8.3"] | ||
env: | ||
tools: composer, phpstan, infection | ||
ini-values: default_charset='UTF-8' | ||
key: cache-1690242875644 | ||
name: PHP ${{ matrix.php }} test on ${{ matrix.os }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
ini-values: ${{ env.ini-values }} | ||
coverage: pcov | ||
tools: ${{ env.tools }} | ||
env: | ||
fail-fast: true | ||
- name: Setup problem matchers for PHPUnit | ||
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | ||
- name: Validate composer | ||
run: composer validate | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
- name: Install dependencies | ||
run: composer install --no-progress | ||
- name: Run PHPStan | ||
run: composer phpstan | ||
- name: Tests (PHPUnit) | ||
run: vendor/bin/phpunit --coverage-xml=build/logs/xml-coverage --log-junit=build/logs/junit.xml | ||
- name: Mutation testing (Infection) | ||
env: | ||
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }} | ||
run: infection --coverage=build/logs --min-covered-msi=90 --threads=$(nproc) --logger-github --only-covered |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.DS_Store | ||
/.idea | ||
/.phpunit.cache | ||
/.scannerwork | ||
/vendor | ||
/composer.lock | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"coverage-ignore": { | ||
"description": "Code coverage ignore tag", | ||
"prefix": "cov-ignore", | ||
"body": [ | ||
"@codeCoverageIgnore" | ||
] | ||
}, | ||
"coverage-ignore-start": { | ||
"description": "Code coverage ignore start tag", | ||
"prefix": "cov-ignore-start", | ||
"body": [ | ||
"@codeCoverageIgnoreStart" | ||
] | ||
}, | ||
"coverage-ignore-end": { | ||
"description": "Code coverage ignore end tag", | ||
"prefix": "cov-ignore-end", | ||
"body": [ | ||
"@codeCoverageIgnoreEnd" | ||
] | ||
}, | ||
"coverage-infection-ignore-all": { | ||
"description": "Comment infection ignore all", | ||
"prefix": "comment-infection-ignore-all", | ||
"body": [ | ||
"@infection-ignore-all.", | ||
] | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"docblock-construct": { | ||
"description": "Docblock construct", | ||
"prefix": "docblock-construct", | ||
"body": [ | ||
"/**", | ||
" * Does?", | ||
" */" | ||
] | ||
}, | ||
"docblock-instance": { | ||
"description": "Docblock instance", | ||
"prefix": "docblock-instance", | ||
"body": [ | ||
"/**", | ||
" * Provides access to the ${1:name} instance.", | ||
" */" | ||
] | ||
}, | ||
"docblock-immutable": { | ||
"description": "Docblock immutable", | ||
"prefix": "docblock-immutable", | ||
"body": [ | ||
"/**", | ||
" * Return an instance with the specified ${1:name}.", | ||
" *", | ||
" * This method MUST retain the state of the current instance, and return", | ||
" * an instance that contains the specified ${1:name}.", | ||
" */" | ||
] | ||
}, | ||
"docblock-boolean": { | ||
"description": "Docblock boolean", | ||
"prefix": "docblock-boolean", | ||
"body": [ | ||
"/**", | ||
" * Indicates whether the instance has ${1:name}.", | ||
" */" | ||
] | ||
}, | ||
"docblock-interface": { | ||
"description": "Docblock interface", | ||
"prefix": "docblock-interface", | ||
"body": [ | ||
"/**", | ||
" * Describes the component in charge of ${1:doing}.", | ||
" */" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"runOnSave.commands": [ | ||
{ | ||
"match": "\\.php$", | ||
"runIn": "backend", | ||
"command": "cd ${workspaceFolder} && vendor/bin/ecs --config='.ecs/ecs.php' check ${file} --fix", | ||
"workingDirectoryAsCWD": true, | ||
"runningStatusMessage": "ECS ${fileBasename}", | ||
"finishStatusMessage": "${fileBasename} OK" | ||
}, | ||
] | ||
} |
Oops, something went wrong.