There could be many reason for this error unfortunately. Perhaps one of these suggestions will at least narrow the search.
Make sure that your system is completely updated.
sudo apt update && sudo apt upgrade
sudo ee cli update
Then check for the global version of PHP being used
sudo update-alternatives --display php
Note the specified version. For reference mine shows 7.2 on Ubuntu 18.04 and all works as expected. If you wish to change the default version and other versions are installed you can configure the global default with
sudo update-alternatives --config php
if you are returned a message indicating there is nothing to configure that just means that you only have one version installed.
Hoping that these at least knock a few items off the troubleshooting list.
Please update this thread.