From 2f3d3435aba946c521817c3f1a64cd281060ba39 Mon Sep 17 00:00:00 2001 From: auooru Date: Wed, 1 Dec 2021 20:56:01 +0800 Subject: [PATCH] add php_codesniffer --- .github/workflows/phpcs.yml | 44 ++++++++++++++++++++++++++++++++++++ .phpcs.xml | 45 +++++++++++++++++++++++++++++++++++++ .styleci.yml | 9 -------- composer.json | 3 ++- 4 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/phpcs.yml create mode 100644 .phpcs.xml delete mode 100644 .styleci.yml diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml new file mode 100644 index 0000000..f197c9b --- /dev/null +++ b/.github/workflows/phpcs.yml @@ -0,0 +1,44 @@ +name: phpcs + +on: [push] + +jobs: + tests: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + extensions: mbstring, fileinfo + coverage: none + tools: cs2pr + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ env.php-versions }}-${{ hashFiles('**/composer.json') }} + restore-keys: | + ${{ runner.os }}-composer-${{ env.php-versions }}- + ${{ runner.os }}-composer- + + - name: Check Version + run: php -v && php -m && composer -V + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Install dependencies (composer.lock) + run: composer install --no-interaction --prefer-dist --no-progress + + - name: Run phpcs fix + run: vendor/bin/phpcs --report=checkstyle -q | cs2pr \ No newline at end of file diff --git a/.phpcs.xml b/.phpcs.xml new file mode 100644 index 0000000..fa9b4da --- /dev/null +++ b/.phpcs.xml @@ -0,0 +1,45 @@ + + + The coding standard for PHP_CodeSniffer itself. + + driver + src + + + + + + + + + + + error + + + + + + + + + + warning + + + + warning + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index 6ac9370..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,9 +0,0 @@ -preset: PSR2 -finder: - exclude: - - vendor - - lib - name: - - "*.php" - not-name: - - "*.blade.php" \ No newline at end of file diff --git a/composer.json b/composer.json index b1c521c..9c929e0 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "phpunit/phpunit": "^7|^8", "symfony/var-dumper": "^5.0", "topthink/think-template": "^2.0", - "voku/portable-ascii": "^1.4.8" + "voku/portable-ascii": "^1.4.8", + "squizlabs/php_codesniffer": "^3.6" }, "suggest": { "ramsey/uuid": "Required to use Str::uuid() (^3.7).",