A pretty way to get your code withing the PHP Coding standards is using the PHP Code Sniffer tool.
If you are working in a Magento 2 site, the following snippet will be useful for you:
# Those requirements should be in in your brand new Magento composer.json file
composer require squizlabs/php_codesniffer:^3.4
composer require magento/magento-coding-standard
# Command should return the list of installed coding standards including Magento2.
# Command to commit the coding standard analizer
vendor/bin/phpcs --standard=Magento2 app/code/<Vendor>/<Module>
If you want to run the code sniffer for any PHP project, you can change the standard “Magento2” for whichever you want or none specific for everyone.
Afterwards, you can also use phpcbf to fix issues automattically, like this:
vendor/bin/phpcbf --standard=Magento2 app/code/<Vendor>/<Module>
For more information you can check official PHPCS of Magento: here!