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,

How can i fix this issue?

  • 1
    are you sure you're on PHP 8? match was introduced in 8.0.0 so it should get recognized. You get this problem if you're on php 7 or lower
    – Marius
    May 19, 2022 at 14:20
  • when i'm on php 7 i don't have this problem. It shows up when I change the php version of my server locally and choose version 8.1
    – Jackom
    May 19, 2022 at 14:31
  • In this case I don't have a solution, but I think I can help to find the faulty file. GO to the Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php class at the specifiel line 117 and above the line $this->includeClass($className, $fileItemPath); add this echo $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.
    – Marius
    May 19, 2022 at 14:55
  • Thanks man for the help! I saw that the last class it printed to me is: "Magento\Elasticsearch\SearchAdapter\Query\Builder\QueryInterface". I put its content in my question. Do you have any suggestions on how to correct this? Thanks
    – Jackom
    May 19, 2022 at 15:27
  • Could it be a configuration problem with my server extension?
    – Jackom
    May 19, 2022 at 16:33

4 Answers 4


Make sure you remove all modules from the vendor folder before updating to a complete new Magento version. I suspect some files are hanging in IDE or Docker sync.

So: rm -rf vendor/* && composer update/install.

  • 3
    Yes, correct man! I found files named as Match.php which were inside the module-elasticsearch folder. By removing these files the compile command works like a charm. Thanks to all for the help :)
    – Jackom
    May 26, 2022 at 7:50

For me, it is because of the Smile_ElasticsuiteCore extension issue with PHP 8.

Seems not compatible with PHP 8. Cannot use 'match' as an identifier. It is a reserved keyword since PHP 8.0

See below class names:

  • app/code/Smile/ElasticsuiteCore/Search/Request/Query/Match.php
  • app/code/Smile/ElasticsuiteCore/Search/Adapter/Elasticsuite/Request/Query/Builder/Match.php

You may face this issue if your files under following modules are not updated correctly. (I was trying to update from Adobe Commerce 2.3.5-p2 to 2.4.5-p1 version)


For me I had files named as Match.php on the above mentioned location. So make sure that your Vendor folder has updated correctly.

If you still have the issue search your Vendor folder for files named as Match.php.


Try to run command using php version like:

/usr/bin/php8.1 bin/magento setup:di: compile

Instead of php bin/magento setup:di:compile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.