I tried to install phpcs in the macOS Catalina but I was getting multiple errors. So in my answer, I shared the steps to install phpcs easily.
I tried the following steps and it's worked out. My macOS version is 10.15.4 (Catalina) and PHP version is 7.2.
$ sudo cp /etc/php.ini.default /etc/php.ini;
Then install go-pear
$ curl -O https://pear.php.net/go-pear.phar
$ php -d detect_unicode=0 go-pear.phar
Here you'll have some question to install the pear.
After installing pear, I got the following warning.
******************************************************************************
WARNING: Cannot write to /etc/php.ini, but php.ini was successfully created
at </usr/local/bin/php.ini-gopear>. Please replace the file </etc/php.ini> with
</usr/local/bin/php.ini-gopear> or modify your php.ini by adding:
include_path=".:/usr/local/bin/share/pear"
So edited the /etc/php.ini file and added the above (include_path=".:/usr/local/bin/share/pear") line.
After that install PHP_CodeSniffer -
$ sudo pear upgrade-all;\n
$ sudo pear install PHP_CodeSniffer;\n
$ phpcs --version
Finally got it -
PHP_CodeSniffer version 3.5.5 (stable) by Squiz (http://www.squiz.net)