To update the PHP version in the composer.json file, you need to peform two steps.

First, you need to update the php version in the composer.json file:

{
  "require": {
      "php": "^8.4"
  }
}

Then you can update the composer.lock file by running:

composer update php

Done!