dragon-code / codestyler
A tool to automatically fix Coding Style Standards issues by The Dragon Code.
Fund package maintenance!
Boosty
Yoomoney
Donationalerts
Installs: 1 285 739
Dependents: 0
Suggesters: 0
Security: 0
Stars: 25
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.2
- ext-dom: *
- ext-json: *
- ext-libxml: *
- ext-mbstring: *
- ext-tokenizer: *
- ext-xml: *
Requires (Dev)
- archtechx/enums: ^1.1
- dragon-code/pretty-array: ^4.1
- dragon-code/support: ^6.15.0
- friendsofphp/php-cs-fixer: ^3.65.0
- illuminate/view: ^11.33.2
- kubawerlos/php-cs-fixer-custom-fixers: ^3.22.0
- laravel-zero/framework: ^11.0.3
- mockery/mockery: ^1.6.12
- nunomaduro/termwind: ^2.3
- pedrotroller/php-cs-custom-fixer: ^2.33.2
- pestphp/pest: ^3.5.1
- seld/jsonlint: ^1.11.0
- symfony/yaml: ^6.4.3 || ^7.1.6
- dev-main
- 5.x-dev
- 5.0.0
- 4.x-dev
- 4.3.1
- 4.3.0
- 4.2.0
- 4.1.0
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- v4
- 3.x-dev
- v3.15.1
- 3.15.0
- v3.14.1
- 3.14.0
- 3.13.0
- v3.12.2
- v3.12.1
- 3.12.0
- 3.11.0
- v3.10.1
- v3.10.0
- v3.9.0
- v3.8.1
- v3.8.0
- v3.7.2
- v3.7.1
- v3.7.0
- v3.6.18
- v3.6.17
- v3.6.16
- v3.6.15
- v3.6.14
- v3.6.13
- v3.6.12
- v3.6.11
- v3.6.8
- v3.6.7
- v3.6.6
- v3.6.5
- v3.6.4
- v3.6.3
- v3.6.2
- v3.6.1
- v3.6.0
- v3.5.1
- v3.5.0
- v3.4.3
- v3.4.2
- v3.4.1
- v3.4.0
- v3.3.4
- v3.3.3
- v3.3.2
- v3.3.1
- v3.3.0
- v3.2.1
- v3.2.0
- v3.1.5
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- 2.x-dev
- v2.6.24
- v2.6.23
- v2.6.22
- v2.6.21
- v2.6.20
- v2.6.19
- v2.6.18
- v2.6.17
- v2.6.16
- v2.6.15
- v2.6.14
- v2.6.13
- v2.6.12
- v2.6.11
- v2.6.10
- v2.6.9
- v2.6.8
- v2.6.7
- v2.6.6
- v2.6.5
- v2.6.4
- v2.6.3
- v2.6.2
- v2.6.1
- v2.6.0
- v2.5.0
- v2.4.0
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- 1.x-dev
- v1.13.1
- v1.13.0
- v1.12.4
- v1.12.3
- v1.12.2
- v1.12.1
- v1.12.0
- 1.12-rc.1
- v1.11.1
- v1.11.0
- v1.10.8
- v1.10.7
- v1.10.6
- v1.10.5
- v1.10.4
- v1.10.3
- v1.10.2
- v1.10.1
- v1.10.0
- v1.9.0
- v1.8.7
- v1.8.6
- v1.8.5
- v1.8.4
- v1.8.3
- v1.8.2
- v1.8.1
- v1.8.0
- v1.7.0
- v1.6.2
- v1.6.1
- v1.6.0
This package is auto-updated.
Last update: 2024-11-26 19:48:05 UTC
README
Introduction
The Dragon Code Styler
is an opinionated PHP code style fixer for minimalists.
Codestyler
is built on top of Laravel Pint
and PHP-CS-Fixer, and makes it simple to ensure that your code style
stays clean and consistent.
By default, Codestyler
does not require any configuration and will fix code style issues in your code by following
the opinionated coding style of The Dragon Code
based on the PER-2.0
rule
set.
The easiest and free way to say “thank you” to the developers whose packages you use is to “star” the GitHub repository.
See more at https://github.com/symfony/thanks
Installation
Required
Locally
composer global require dragon-code/codestyler
Usage
When you run the commands in the base path of the project, the composer.json
file will be automatically read, from
which the minimum PHP version for your project will be taken.
This is necessary to draw up rules for applying the Codestyler.
For example, if your project supports PHP 8.0 and above, and you use the mkdir($path, 0755)
function in it, then
applying the rules for PHP 8.0 will break your code because it
will replace 0755
with 0o755
(mkdir($path, 0o755)
).
To prevent this from happening, we check the minimum PHP version.
Please note that the composer.json
file is only read if the script execution is started in the folder with it.
CLI
# Check code-style codestyle --test # Fix code-style codestyle # Update `.editorconfig` codestyle editorconfig # Update Dependabot rules codestyle dependabot # Publishes code-style settings for the phpStorm IDE codestyle phpstorm # Show list of available commands codestyle list
Options
Path
The path to fix
codestyle foo/bar
Test
Test for code style errors without fixing them
codestyle --test
Config
The configuration that should be used. The target directory will read the pint.json
file
from Laravel Pint, minus the style set.
codestyle --config=foo/bar
Risky
Allows to set whether risky rules may run:
codestyle --risky --test codestyle --risky
Dirty
Only fix files that have uncommitted changes.
codestyle --dirty
Bail
Test for code style errors without fixing them and stop on first error
codestyle --bail
Output Format
The output format that should be used.
codestyle --format
List of available formats:
- checkstyle
- gitlab
- json
- junit
- txt
- xml
Help Commands
To view the list of available commands, you can call the console command:
codestyle list
To view extended information on a command, you can use the help
option. For example,
codestyle --help codestyle dependabot --help codestyle editorconfig --help
CI/CD
composer global require dragon-code/codestyler codestyle <command>
IDE
After executing the codestyle editorconfig
console command, a .editorconfig
file will be added to your application.
If the file already exists, it will be replaced.
In order for your IDE to read the code style settings from it, make sure its support is enabled in the settings.
For example, in phpStorm
the setting is in
the File | Settings | Editor | Code Style:
You can also use the codestyle phpstorm
console command to publish the schema xml file to phpStorm.
You can import this file into the IDE.
License
This package is licensed under the MIT License.