I recently upgraded my site to Magento 2.4.4 with PHP 8.1 and noticed that when I try to run the command '$ php bin / magento setup: di: compile' the process stops at 1/9 with this error message :
1/9 [==>------------------] 11% 1 sec 119.0 MiBsyntax error, unexpected token "match", expecting identifier#0 /var/www/html/magento24/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(117)
I've done a lot of research and it appears to be a PHP 8 problem. How can I fix this bug?
Thanks for any help
UPDATE I saw that the class generate this issue is "Magento\Elasticsearch\SearchAdapter\Query\Builder\QueryInterface"
namespace Magento\Elasticsearch\SearchAdapter\Query\Builder;
use Magento\Framework\Search\Request\QueryInterface as RequestQueryInterface;
/**
* @api
* @since 100.1.0
*/
interface QueryInterface
{
/**
* @param array $selectQuery
* @param RequestQueryInterface $requestQuery
* @param string $conditionType
* @return array
* @since 100.1.0
*/
public function build(
array $selectQuery,
RequestQueryInterface $requestQuery,
$conditionType
);
}
How can i fix this issue?
match
was introduced in 8.0.0 so it should get recognized. You get this problem if you're on php 7 or lowerMagento/Setup/Module/Di/Code/Reader/ClassesScanner.php
class at the specifiel line117
and above the line$this->includeClass($className, $fileItemPath);
add thisecho $className . "\n";
. now when you run di:compile you should see the class names being processed going through your console. and it will stop at the faulty one.