Skip to content

Commit

Permalink
Adding php-cs-fixer GitHub workflow (#4)
Browse files Browse the repository at this point in the history
* Adding php-cs-fixer GitHub workflow
  • Loading branch information
zaherg committed May 5, 2023
1 parent a3ee9e1 commit 2a19164
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 95 deletions.
41 changes: 41 additions & 0 deletions .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
86 changes: 15 additions & 71 deletions .php-cs-fixer.dist.php
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')
);

'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
@@ -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.
27 changes: 20 additions & 7 deletions composer.json
@@ -1,11 +1,18 @@
{
"name": "dflydev/eventsauce-support",
"type": "library",
"license": "MIT",
"type": "library",
"require": {
"php": "^8.1",
"php": "^8.1 || ^8.2",
"eventsauce/eventsauce": "^3",
"eventsauce/message-outbox": "^0.3||^0.4"
"eventsauce/message-outbox": "^0.3 || ^0.4"
},
"require-dev": {
"dflydev/php-coding-standards": "dev-main",
"ergebnis/composer-normalize": "^2.31",
"ergebnis/license": "^2.1",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9 || ^10"
},
"autoload": {
"psr-4": {
Expand All @@ -15,14 +22,20 @@
"src/functions.php"
]
},
"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",
"phpunit/phpunit": "^9|^10"
"scripts": {
"style:check": "@php ./vendor/bin/php-cs-fixer fix --dry-run",
"style:fix": "@php ./vendor/bin/php-cs-fixer fix"
}
}

0 comments on commit 2a19164

Please sign in to comment.