In my case php was upgraded from php7.2.22 to php7.3.9.
so had to downgrade cli php as composer is run on terminal
//checked php version
php -v //was 7.3.9
//changed cli version back to 7.2
sudo update-alternatives --set php /usr/bin/php7.2
sudo update-alternatives --set phar /usr/bin/phar7.2
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.2
sudo update-alternatives --set phpize /usr/bin/phpize7.2
sudo update-alternatives --set php-config /usr/bin/php-config7.2
//checked php version
php -v //was 7.2.22
additional info if you are using apache remember to keep both cli and apache in same version. in my case i had to downgrade
//changed web version back to 7.2
sudo a2dismod php7.3
sudo a2enmod php7.2
sudo service apache2 restart
This will work with other versions. so feel free to switch between versions. just replace the version numbers appropriately