diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..3bd3026 --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,41 @@ +name: PHP CS Fixer + +on: + push: + pull_request: + branches: + - main + +concurrency: + group: php-cs-fixer-${{ github.ref_name || github.run_id }} + cancel-in-progress: true + +jobs: + + php-cs-fixer: + name: PHP CS Fixer ${{ matrix.php }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.2'] + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: cs2pr + + - name: Install Composer dependencies + uses: ramsey/composer-install@v2 + with: + composer-options: "--no-progress --prefer-dist --optimize-autoloader" + + - name: php-cs-fixer + run: composer run style:check -- --format=checkstyle | cs2pr diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index eea2ab8..b5ae9bb 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -2,80 +2,24 @@ declare(strict_types=1); -use PhpCsFixer\Config; -use PhpCsFixer\Finder; +use Ergebnis\License; -$rules = [ - '@PER' => true, - '@Symfony' => true, +$license = License\Type\MIT::text(__DIR__ . '/LICENSE', + License\Range::since( + License\Year::fromString(date('Y')), + new \DateTimeZone('UTC') + ), + License\Holder::fromString('Dragonfly Development Inc'), + License\Url::fromString('https://github.com/dflydev/dflydev-eventsauce-support-for-laravel') +); - 'declare_strict_types' => true, +$license->save(); - // Override @Symfony +use Ergebnis\PhpCsFixer\Config; - 'phpdoc_align' => [ - 'align' => 'left', - 'tags' => [ - 'method', - 'param', - 'property', - 'property-read', - 'property-write', - 'return', - 'throws', - 'type', - 'var', - ], - ], +$config = Config\Factory::fromRuleSet(new Dflydev\PhpCsFixer\Config\RuleSet\Dflydev()); - 'phpdoc_separation' => [ - 'groups' => [ - // Defaults - ['deprecated', 'link', 'see', 'since'], - ['author', 'copyright', 'license'], - ['category', 'package', 'subpackage'], - ['property', 'property-read', 'property-write'], +$config->getFinder()->in(__DIR__); +$config->setCacheFile(__DIR__ . '/.php-cs-fixer.cache'); - // Overrides - ['template', 'template-covariant', 'template-uses'], - - ['uses'], - - ['phpstan-*'], // This is not available... yet. - - ['phpstan-param', 'phpstan-return'], - ], - ], - - 'global_namespace_import' => [ - 'import_classes' => null, - 'import_constants' => true, - 'import_functions' => true, - ], - 'no_empty_comment' => false, - 'php_unit_method_casing' => ['case' => 'snake_case'], - 'single_line_throw' => false, - 'yoda_style' => false, - - 'phpdoc_to_comment' => [ - 'ignored_tags' => [ - 'array', - 'var', - 'phpstan-var', - ], - ], -]; - -$finder = Finder::create() - ->in([ - __DIR__.'/src', - ]) - ->name('*.php') - ->ignoreDotFiles(true) - ->ignoreVCS(true); - -return (new Config()) - ->setFinder($finder) - ->setRules($rules) - ->setRiskyAllowed(true) - ->setUsingCache(true); +return $config; diff --git a/LICENSE b/LICENSE index bf45678..398cccd 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,16 @@ -MIT License +The MIT License (MIT) -Copyright (c) 2023 dflydev +Copyright (c) 2023 Dragonfly Development Inc -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit +persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the +Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/composer.json b/composer.json index ba46ada..a14688d 100644 --- a/composer.json +++ b/composer.json @@ -1,28 +1,41 @@ { "name": "dflydev/eventsauce-support-for-laravel", - "type": "library", "license": "MIT", + "type": "library", "require": { "php": "^8.1", + "dflydev/eventsauce-support": "^0@dev", "eventsauce/eventsauce": "^3", "eventsauce/message-outbox-for-illuminate": "^0.4", - "eventsauce/message-repository-for-illuminate": "^0.4", - "dflydev/eventsauce-support": "^0@dev" + "eventsauce/message-repository-for-illuminate": "^0.4" + }, + "require-dev": { + "dflydev/php-coding-standards": "dev-main", + "ergebnis/composer-normalize": "^2.31", + "ergebnis/license": "^2.1", + "nunomaduro/larastan": "^2.5", + "orchestra/testbench": "^8.0", + "phpstan/phpstan": "^1.10" }, "autoload": { "psr-4": { "Dflydev\\EventSauce\\SupportForLaravel\\": "src/" } }, + "config": { + "allow-plugins": { + "ergebnis/composer-normalize": true + }, + "preferred-install": "dist", + "sort-packages": true + }, "extra": { "branch-alias": { "dev-main": "0.x-dev" } }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.15.1", - "phpstan/phpstan": "^1.10", - "nunomaduro/larastan": "^2.5", - "orchestra/testbench": "^8.0" + "scripts": { + "style:check": "@php ./vendor/bin/php-cs-fixer fix --dry-run", + "style:fix": "@php ./vendor/bin/php-cs-fixer fix" } }