Last Updated: September 09, 2019
·
3.11K
· galvao

Check/Fix your PHP code - PSRs

  • Use PHP-CodeSniffer to check if your code is in compliance with PSR-1 and PSR-2:

phpcs --standard=PSR1 /path/to/file/FileName.php

phpcs --standard=PSR2 /path/to/file/FileName.php


php-cs-fixer fix /path/to/file/FileName.php

2 Responses
Add your response

A bit missleading title., phpcs doesn't fix code but reformatts it to PSR standards.

over 1 year ago ·

Thanks for the feedback.
That's why the title has "PSRs" in it. The idea was to make a concise title, but giving the idea that in this tip you find a tool that fix your mistakes related to the PSRs.

Any other code problems should be fixed by the programmer anyway, so...

over 1 year ago ·