Both the webserver and command line PHP version must match.
If Composer complains about the version, it means the command line PHP is not up to date (check with php -v).
Depending on your host you might be able to use php 7.2 on the command line by calling php7.2 composer [...] instead of composer [...].