This tool will automatically fix your PHP code style. You can run it manually, or set it as pre-commit hook and it will run automatically.
composer require friendsofphp/php-cs-fixer
Default configuration will apply PSR1 and PSR2 rules. To run the default configuration:
If you would like to apply specific rules, you can set the rules argument of these command.
--dry-run lets you run the fixer without making changes. --diff will output all the changes made by the fixer.
If you want to set the configuration statically in the codebase to be used by developers as a guideline, you can add this file to the root directory. When detected php-cs-fixer will apply the rules defined there.
Github repository: https://github.com/friendsofphp/php-cs-fixer