PHP Parse error: syntax error, unexpected 'function' (T_FUNCTION), expecting identifier (T_STRING) or \\ (T_NS_SEPARATOR) in /home/website1/public_html/enew/system/src/Grav/Common/Composer.php on line 12

Hello.
The website was working so I turned off the debug mode, then upgraded Grav and in the middle of the upgrade, suddenly, the website and the admin plugin stopped working and the website and admin showed a blank page with this message:

Please run: bin/grav install

  1. So I ran bin/grav install and I got:

PHP Parse error: syntax error, unexpected ‘function’ (T_FUNCTION), expecting identifier (T_STRING) or \ (T_NS_SEPARATOR) in /home/website1/public_html/enew/system/src/Grav/Common/Composer.php on line 12

  1. In the cache folder I got this file: problem-check-g-0842d3d5.json with this content:
[{"id":"PHP Minimum Version","order":102,"level":"critical","status":true,"msg":"Your PHP <strong>8.1.15<\/strong> is greater than the minimum of <strong>7.3.6<\/strong> required","details":[],"help":"https:\/\/getgrav.org\/blog\/raising-php-requirements-2018","class":"Grav\\Plugin\\Problems\\PHPVersion"},{"id":"PHP Modules","order":101,"level":"critical","status":true,"msg":"All modules look good!","details":{"errors":[],"success":{"curl":"PHP Curl (Data Transfer Library) is successfully installed","ctype":"PHP Ctype is successfully installed","dom":"PHP DOM is successfully installed","gd":"PHP GD (Image Manipulation Library) is successfully installed","mbstring":"PHP Mbstring (Multibyte String Library) is successfully installed","openssl":"PHP OpenSSL (Secure Sockets Library) is successfully installed","json":"PHP JSON Library is successfully installed","xml":"PHP XML Library is successfully installed","zip":"PHP Zip extension is successfully installed"}},"help":"https:\/\/learn.getgrav.org\/basics\/requirements#php-requirements","class":"Grav\\Plugin\\Problems\\PHPModules"},{"id":"Essential Folders","order":100,"level":"critical","status":true,"msg":"All folders look good!","details":{"errors":[],"success":{"\/home\/equimed\/public_html\/enew":"exists","\/home\/equimed\/public_html\/enew\/vendor":"exists","\/home\/equimed\/public_html\/enew\/system":"exists","\/home\/equimed\/public_html\/enew\/cache":"exists and is writable","\/home\/equimed\/public_html\/enew\/logs":"exists and is writable","\/home\/equimed\/public_html\/enew\/tmp":"exists and is writable","\/home\/equimed\/public_html\/enew\/backup":"exists and is writable","\/home\/equimed\/public_html\/enew\/images":"exists and is writable","\/home\/equimed\/public_html\/enew\/assets":"exists and is writable","\/home\/equimed\/public_html\/enew\/user\/accounts":"exists and is writable","\/home\/equimed\/public_html\/enew\/user\/data":"exists and is writable","\/home\/equimed\/public_html\/enew\/user\/pages":"exists","\/home\/equimed\/public_html\/enew\/user\/config":"exists","\/home\/equimed\/public_html\/enew\/user\/plugins\/error":"exists","\/home\/equimed\/public_html\/enew\/user\/plugins":"exists","\/home\/equimed\/public_html\/enew\/user\/themes":"exists"}},"help":"https:\/\/learn.getgrav.org\/basics\/folder-structure","class":"Grav\\Plugin\\Problems\\EssentialFolders"},{"id":"Apache Modules","order":1,"level":"critical","status":true,"msg":"Apache not installed, skipping...","details":[],"help":"https:\/\/learn.getgrav.org\/basics\/requirements#apache-requirements","class":"Grav\\Plugin\\Problems\\Apache"},{"id":"Permissions Setup","order":-1,"level":"warning","status":true,"msg":"Your default file umask is <strong>22<\/strong> which looks good!","details":[],"help":"https:\/\/learn.getgrav.org\/troubleshooting\/permissions","class":"Grav\\Plugin\\Problems\\Permissions"}]
  1. system/src/Grav/Common/Composer.php on line 12 has:

use function function_exists;

  1. The first 18 lines of Composer.php
<?php

/**
 * @package    Grav\Common
 *
 * @copyright  Copyright (c) 2015 - 2023 Trilby Media, LLC. All rights reserved.
 * @license    MIT License; see LICENSE file for details.
 */

namespace Grav\Common;

use function function_exists;

/**
 * Class Composer
 * @package Grav\Common
 */
class Composer
{
  1. The website backup folder runs fine.

  2. My environment is:
    I run Grav v1.7.37.1

PHP Version 8.1.15

System Linux myserver.com 3.10.0-1160.80.1.vz7.191.4 #1 SMP Thu Dec 15 20:31:06 MSK 2022 x86_64
Build Date Jan 31 2023 15:13:17
Build System Red Hat Enterprise Linux Server release 7.9 (Maipo)
Build Provider Remi’s RPM repository https://rpms.remirepo.net/
Compiler gcc (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11)
Architecture x86_64
Server API CGI/FastCGI
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc/opt/remi/php81
Loaded Configuration File /home/website1/etc/php8.1/php.ini
Scan this dir for additional .ini files /etc/opt/remi/php81/php.d
  1. If you need the full php info data please let me know.

  2. I can not upgrade Grav until I resolve this issue.

I appreciate if some one knows what can be this problem, please let me know, in Google there are several reasons for this type of error from characters in wrong places to namespace, but it occurs when upgrading Grav, restoring the backup with the old Grav v1.7.37.1 it works, the backup does not have the Debugger enabled.
Thanks and regards.
joejac