We are using Magento 2.4.5-p1 and php 8.1 version, upgrade command is working fine but when we try to run the di-compile command getting an error of
Repositories code generation... 1/9 [===>------------------------] 11% < 1 sec 139.0 MiBsyntax error, unexpected token "readonly", expecting identifier#0 /var/www/html/project_name/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(117): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->includeClass()
#1 /var/www/html/project_name/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(87): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->extract()
#2 /var/www/html/project_name/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php(61): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->getList()
#3 /var/www/html/project_name/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php(56): Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator->doOperation()
#4 /var/www/html/project_name/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php(216): Magento\Setup\Module\Di\App\Task\Manager->process()
#5 /var/www/html/project_name/vendor/symfony/console/Command/Command.php(255): Magento\Setup\Console\Command\DiCompileCommand->execute()
#6 /var/www/html/project_name/vendor/symfony/console/Application.php(1021): Symfony\Component\Console\Command\Command->run()
#7 /var/www/html/project_name/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand()
#8 /var/www/html/project_name/vendor/magento/framework/Console/Cli.php(116): Symfony\Component\Console\Application->doRun()
#9 /var/www/html/project_name/vendor/symfony/console/Application.php(149): Magento\Framework\Console\Cli->doRun()
#10 /var/www/html/project_name/bin/magento(23): Symfony\Component\Console\Application->run()
#11 {main}
Also, this issue is also in GitHub but the not fully proper response - https://github.com/magento/magento2/issues/36521
Does anyone know how to resolve this?