In addition to the answer above - we need to use an external tool in phpStorm - a step-by-step explanation to configure it for PHPStorm:
before adding the tool: we need to install php-cs-fixer globally
command line launch: composer global require fabpot/php-cs-fixer after installation you can check it by entering the command line launch: php-cs-fixer
should give something like this 
as soon as everything is fine - - go to PHPStorm - go to settings - External Tools - add a new tool
add the following as per image below

Program: /Users/seramo/.composer/vendor/bin/php-cs-fixer (global path to php-cs-fixer - you can navigate and choose the right path for you)
Parameters: fix $FilePathRelativeToProjectRoot$ --level=psr2 (this is the command to execute in the file)
Working Directory: $ProjectFileDir$
Now save and apply.
in your file - menu -tools - External Tools - php-cs-fixer
the launch of this file must be fixed in accordance with PSR-2 standards.
In addition, you can assign a key to run this tool.
source share