Skip to content

A tool to automatically fix PHP Coding Standards issues by Dragon Code.

License

Notifications You must be signed in to change notification settings

TheDragonCode/codestyler

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

PHP Code Styler

the dragon code php code styler

Stable Version Unstable Version License

Installation

Required

  • PHP: ^8.0
  • Composer: ^2.0

Locally

composer global require dragon-code/codestyler

Usage

CLI

Check code-style

codestyler check

Fix code-style

codestyler fix

Update .editorconfig

codestyler editorconfig

Enable Dependabot

codestyler dependabot

GitHub Action

Create a new .github/workflows/lint-check.yml file and add the content to it:

name: "Code-Style Check"

on: [ push, pull_request ]

jobs:
    build:
        runs-on: ubuntu-latest

        steps:
            -   name: Checkout code
                uses: actions/checkout@v2

            -   name: Checking PHP Syntax
                uses: TheDragonCode/php-codestyler@v1.6.0

Fixer

Create a new .github/workflows/lint-fixer.yml file and add the content to it:

name: "Code-Style Fix"

on:
    push:
        branches: [ main ]

jobs:
    fix:
        runs-on: ubuntu-latest

        steps:
            -   name: Checkout code
                uses: actions/checkout@v2

            -   name: Checking PHP Syntax
                uses: TheDragonCode/php-codestyler@v1.6.0
                with:
                    # Activates the mode of accepting changes with the creation
                    # of commits.
                    fix: true

                    # Activates the actualization of the `.editorconfig` file.
                    # Works only when the `fix` option is enabled.
                    editorconfig: true

                    # Activates Dependabot file processing.
                    # Works only when the `fix` option is enabled.
                    dependabot: true

Configuration

By default, the linter scans all files in the current launch folder, except for folders such as vendor, node_modules and .github.

-   uses: TheDragonCode/php-codestyler@v1.6.0

By default, the linter only checks the code-style. If you want to apply the changes, then you need to activate this option:

-   uses: TheDragonCode/php-codestyler@v1.6.0
    with:
        fix: true

By default, GitHub Action does not allow versioning, so our project will create a configuration file for it, which will check for new versions once a day.

When Dependabot detects new versions of containers, it will automatically create a PR to your repository. So you don't need to keep track of updates - Dependabot will do everything for you 💪😎

If the .github/dependabot.yml file has already been created, we will check it and add the necessary rules. So don't be afraid, nothing will be deleted 😎

Note

Files will be created only if you have specified fix: true.

Or you can manually run the Dependabot rule creation script by executing the codestyler dependabot command.

License

This package is licensed under the MIT License.

About

A tool to automatically fix PHP Coding Standards issues by Dragon Code.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Contributors 5