Type error libphonenumber\PhoneNumberUtil::format()

libphonenumber\PhoneNumberUtil::format(): Argument #2 ($numberFormat) must be of type libphonenumber\PhoneNumberFormat, int given, called in C:\xampp\htdocs\src\phpfn.php on line 3599

The call:

$this->EmployeeMobilePhone->ViewValue = FormatPhoneNumber("$EmployeeMobilePhone", "US", 2);

function FormatPhoneNumber(#[\SensitiveParameter] string $phoneNumber, mixed $region = null, int $format = PhoneNumberFormat::E164)
{
    global $httpContext;
    $region ??= Config("SMS_REGION_CODE");
    if ($region === false) { // Skip formatting
        return $phoneNumber;
    }
    if ($region === null) { // Get region from locale
        $ar = explode("-", str_replace("_", "-", $httpContext["CurrentLanguage"]));
        $region = count($ar) >= 2 ? $ar[1] : "US";
    }
    try {
        $phoneNumberUtil = PhoneNumberUtil::getInstance();
        $phoneNumberObj = $phoneNumberUtil->parse($phoneNumber, $region);
        return $phoneNumberUtil->format($phoneNumberObj, $format); // <- ***
}

not sure what the issue is...

JS

Try update to the latest template and generate again.

updated, problem still persists...

You better double check the advanced setting Format phone number. If enabled, make sure you have re-generated scripts and run composer update again.

If you have the latest template, the generated code should be like this:

"Format phone number" enabled:

function FormatPhoneNumber(#[\SensitiveParameter] string $phoneNumber, mixed $region = null, PhoneNumberFormat $format = PhoneNumberFormat::E164)

OR

"Format phone number" disabled:

function FormatPhoneNumber(#[\SensitiveParameter] string $phoneNumber, mixed $region = null, int $format = 0)