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

Adding php-cs-fixer GitHub workflow #3

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
41 changes: 41 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -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
86 changes: 15 additions & 71 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
29 changes: 12 additions & 17 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
29 changes: 21 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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"
}
}