How did I fix «foreach() argument must be of type array|object, null given in /usr/share/php/PEAR/Command.php on line 249» on `pecl install timezonedb`?

A PHP installer redirected the /usr/bin/php link to a PHP version incompatible with the installed PECL version.
I checked it with the commands:

php -v
which php
readlink -f /usr/bin/php

2023-08-08--09-08-22

So, to fix the problem, I reverted the /usr/bin/php` link to the proper PHP version:

rm -f /usr/bin/php
ln -s /usr/bin/php7.4 /usr/bin/php