diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml deleted file mode 100644 index b21e3b7..0000000 --- a/.github/workflows/coding-standards.yml +++ /dev/null @@ -1,118 +0,0 @@ ---- - -on: # yamllint disable-line rule:truthy - pull_request: - branches: - - master - push: - branches: - - master - -name: ๐Ÿงน Fix PHP coding standards - -jobs: - yaml-linting: - timeout-minutes: 4 - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: read - steps: - - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v4.1.6 - - - name: ๐Ÿง Lint YAML files - uses: ibiqlik/action-yamllint@v3.1.1 - with: - config_file: .github/.yamllint.yaml - file_or_dir: '.' - strict: true - - markdown-linting: - timeout-minutes: 4 - runs-on: ubuntu-latest - concurrency: - cancel-in-progress: true - group: markdown-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - steps: - - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v4.1.6 - - - name: ๐Ÿง Lint Markdown files - uses: DavidAnson/markdownlint-cli2-action@v16.0.0 - with: - globs: | - **/*.md - !CHANGELOG.md - - coding-standards: - timeout-minutes: 4 - runs-on: ${{ matrix.os }} - concurrency: - cancel-in-progress: true - group: coding-standards-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - strategy: - matrix: - os: - - ubuntu-latest - php-version: - - '8.2' - dependencies: - - locked - permissions: - contents: write - steps: - - name: โš™๏ธ Set git to use LF line endings - run: | - git config --global core.autocrlf false - git config --global core.eol lf - - - name: ๐Ÿ› ๏ธ Setup PHP - uses: shivammathur/setup-php@2.30.4 - with: - php-version: ${{ matrix.php-version }} - extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, sockets - ini-values: error_reporting=E_ALL - coverage: none - - - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v4.1.6 - - - name: ๐Ÿ› ๏ธ Setup problem matchers - run: | - echo "::add-matcher::${{ runner.tool_cache }}/php.json" - - - name: ๐Ÿค– Validate composer.json and composer.lock - run: composer validate --ansi --strict - - - name: ๐Ÿ” Get composer cache directory - uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.0 - - - name: โ™ป๏ธ Restore cached dependencies installed with composer - uses: actions/cache@v4.0.2 - with: - path: ${{ env.COMPOSER_CACHE_DIR }} - key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} - restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- - - - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies with composer - uses: wayofdev/gh-actions/actions/composer/install@v3.1.0 - with: - dependencies: ${{ matrix.dependencies }} - - - name: ๐Ÿ› ๏ธ Prepare environment - run: make prepare - - - name: ๐Ÿšจ Run coding standards task - run: composer cs:fix - env: - PHP_CS_FIXER_IGNORE_ENV: true - - - name: ๐Ÿ“ค Commit and push changed files back to GitHub - uses: stefanzweifel/git-auto-commit-action@v5.0.1 - with: - commit_message: 'style(php-cs-fixer): lint php files and fix coding standards' - branch: ${{ github.head_ref }} - commit_author: 'github-actions ' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/cs-fix.yml b/.github/workflows/cs-fix.yml new file mode 100644 index 0000000..be0f9ab --- /dev/null +++ b/.github/workflows/cs-fix.yml @@ -0,0 +1,10 @@ +on: + push: + branches: + - '*' + +name: Fix Code Style + +jobs: + cs-fix: + uses: spiral/gh-actions/.github/workflows/cs-fix.yml@master diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 96e85d6..3354afe 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,19 +1,8 @@ -inDir(__DIR__ . '/bin') - ->inDir(__DIR__ . '/src') - ->inDir(__DIR__ . '/tests') - ->addFiles([__FILE__]) - ->getConfig(); - -$config->setCacheFile(__DIR__ . '/runtime/php-cs-fixer/php-cs-fixer.cache'); - -return $config; +return \Spiral\CodeStyle\Builder::create() + ->include(__DIR__ . '/src') + ->include(__FILE__) + ->build(); diff --git a/composer.json b/composer.json index e1372ae..e6634ac 100644 --- a/composer.json +++ b/composer.json @@ -33,9 +33,9 @@ "buggregator/trap": "^1.10", "friendsofphp/php-cs-fixer": "^3.64", "phpunit/phpunit": "^10.5", + "spiral/code-style": "^2.0", "ta-tikoma/phpunit-architecture-test": "^0.8.4", - "vimeo/psalm": "^5.25", - "wayofdev/cs-fixer-config": "^1.4" + "vimeo/psalm": "^5.25" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/composer.lock b/composer.lock index 5e29b2d..f93d44a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cea9ec9ab97e59531e5940e1c2423840", + "content-hash": "d3b91e81ef7ae072a4f6108cf2311f18", "packages": [ { "name": "brick/math", @@ -4557,6 +4557,62 @@ ], "time": "2024-05-01T10:20:27+00:00" }, + { + "name": "spiral/code-style", + "version": "v2.0.0", + "source": { + "type": "git", + "url": "https://github.com/spiral/code-style.git", + "reference": "d7124b493deb1f82d509e225f955afd221862591" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spiral/code-style/zipball/d7124b493deb1f82d509e225f955afd221862591", + "reference": "d7124b493deb1f82d509e225f955afd221862591", + "shasum": "" + }, + "require": { + "friendsofphp/php-cs-fixer": "^3.64", + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.5", + "spiral/dumper": "^3.3", + "vimeo/psalm": "^5.26" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spiral\\CodeStyle\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aleksandr Novikov", + "email": "aleksandr.novikov@spiralscout.com" + }, + { + "name": "Aleksei Gagarin", + "email": "alexey.gagarin@spiralscout.com" + } + ], + "description": "Code style and static analysis tools rulesets collection", + "homepage": "https://github.com/spiral/code-style", + "support": { + "source": "https://github.com/spiral/code-style/tree/v2.0.0" + }, + "funding": [ + { + "url": "https://github.com/sponsors/spiral", + "type": "github" + } + ], + "time": "2024-09-18T09:11:11+00:00" + }, { "name": "symfony/console", "version": "v7.1.4", @@ -6075,86 +6131,6 @@ }, "time": "2024-06-16T15:08:35+00:00" }, - { - "name": "wayofdev/cs-fixer-config", - "version": "v1.5.3", - "source": { - "type": "git", - "url": "https://github.com/wayofdev/php-cs-fixer-config.git", - "reference": "aa0aae244772672f617de6e74d85ff81532f7e82" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/wayofdev/php-cs-fixer-config/zipball/aa0aae244772672f617de6e74d85ff81532f7e82", - "reference": "aa0aae244772672f617de6e74d85ff81532f7e82", - "shasum": "" - }, - "require": { - "friendsofphp/php-cs-fixer": "^3.57", - "php": "^8.1" - }, - "require-dev": { - "ergebnis/phpunit-slow-test-detector": "^2.14", - "pestphp/pest": "^2.34", - "phpstan/extension-installer": "^1.3", - "phpstan/phpstan": "^1.11", - "phpstan/phpstan-deprecation-rules": "^1.2", - "phpstan/phpstan-phpunit": "^1.4", - "phpstan/phpstan-strict-rules": "^1.6", - "phpunit/phpunit": "^10.5", - "psalm/plugin-phpunit": "^0.19", - "rector/rector": "^1.1", - "roave/infection-static-analysis-plugin": "^1.35", - "vimeo/psalm": "^5.24" - }, - "type": "library", - "extra": { - "composer-normalize": { - "indent-size": 4, - "indent-style": "space" - } - }, - "autoload": { - "psr-4": { - "WayOfDev\\PhpCsFixer\\Config\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Andrij Orlenko", - "email": "the@wayof.dev" - } - ], - "description": "๐Ÿงน Adds custom rule-sets to PHP CS Fixer for consistent coding standards.", - "homepage": "https://wayof.dev", - "keywords": [ - "code-quality", - "code-standards", - "code-style", - "configuration", - "php", - "php-cs-fixer", - "php-cs-fixer-config", - "php-cs-fixer-rules", - "static-analysis" - ], - "support": { - "issues": "https://github.com/wayofdev/php-cs-fixer-config/issues", - "security": "https://github.com/wayofdev/php-cs-fixer-config/blob/master/.github/SECURITY.md", - "source": "https://github.com/wayofdev/php-cs-fixer-config" - }, - "funding": [ - { - "url": "https://github.com/wayofdev", - "type": "github" - } - ], - "time": "2024-06-18T09:13:20+00:00" - }, { "name": "webmozart/assert", "version": "1.11.0",