8.3.27 triggers error: Class "Drupal\Sniffs\Semantics\FunctionCall" not found

Created on 8 January 2025, 3 months ago

Problem/Motivation

My PHPCS pipeline fails with the new 8.3.27 release.
It throws the following error:

Fatal error: Uncaught Error: Class "Drupal\Sniffs\Semantics\FunctionCall" not found in /root/.composer/vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/PregSecuritySniff.php:22

When I update the pipeline to use 8.3.26 explicitly, it works again.
I have checked the release notes for version 8.3.27, but can't find anything specific that would break it, since these classes were not changed recently.

Any pointers perhaps?

🐛 Bug report
Status

Active

Version

8.3

Component

Coder Sniffer

Created by

🇧🇪Belgium svendecabooter Gent

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @svendecabooter
  • 🇦🇹Austria klausi 🇦🇹 Vienna

    I suspect it could be this change: https://github.com/pfrenssen/coder/commit/19132e118fe9c3e4e163a784421fd2...

    I thought the autoloading problem is obsolete since we have composer to do that.

    Do you see the class FunctionCall mapped in your composer autoload mapping?

  • 🇧🇪Belgium svendecabooter Gent

    In which file should I be looking for this class mapping exactly?
    Is that in `autoload_static.php`?

    That one has the following content:

    <?php
    // autoload_static.php @generated by Composer
    namespace Composer\Autoload;
    class ComposerStaticInit6e0f3ed45ec6f4deedb4fb92307bb607
    {
        public static $files = array (
            '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
            '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
        );
        public static $prefixLengthsPsr4 = array (
            'V' => 
            array (
                'VariableAnalysis\\' => 17,
            ),
            'S' => 
            array (
                'Symfony\\Polyfill\\Ctype\\' => 23,
                'Symfony\\Component\\Yaml\\' => 23,
                'SlevomatCodingStandard\\' => 23,
            ),
            'P' => 
            array (
                'PHPStan\\PhpDocParser\\' => 21,
                'PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\' => 57,
            ),
            'D' => 
            array (
                'Drupal\\' => 7,
                'DrupalPractice\\' => 15,
            ),
        );
        public static $prefixDirsPsr4 = array (
            'VariableAnalysis\\' => 
            array (
                0 => __DIR__ . '/..' . '/sirbrillig/phpcs-variable-analysis/VariableAnalysis',
            ),
            'Symfony\\Polyfill\\Ctype\\' => 
            array (
                0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
            ),
            'Symfony\\Component\\Yaml\\' => 
            array (
                0 => __DIR__ . '/..' . '/symfony/yaml',
            ),
            'SlevomatCodingStandard\\' => 
            array (
                0 => __DIR__ . '/..' . '/slevomat/coding-standard/SlevomatCodingStandard',
            ),
            'PHPStan\\PhpDocParser\\' => 
            array (
                0 => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src',
            ),
            'PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\' => 
            array (
                0 => __DIR__ . '/..' . '/dealerdirect/phpcodesniffer-composer-installer/src',
            ),
            'Drupal\\' => 
            array (
                0 => __DIR__ . '/..' . '/drupal/coder/coder_sniffer/Drupal',
            ),
            'DrupalPractice\\' => 
            array (
                0 => __DIR__ . '/..' . '/drupal/coder/coder_sniffer/DrupalPractice',
            ),
        );
        public static $classMap = array (
            'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
        );
        public static function getInitializer(ClassLoader $loader)
        {
            return \Closure::bind(function () use ($loader) {
                $loader->prefixLengthsPsr4 = ComposerStaticInit6e0f3ed45ec6f4deedb4fb92307bb607::$prefixLengthsPsr4;
                $loader->prefixDirsPsr4 = ComposerStaticInit6e0f3ed45ec6f4deedb4fb92307bb607::$prefixDirsPsr4;
                $loader->classMap = ComposerStaticInit6e0f3ed45ec6f4deedb4fb92307bb607::$classMap;
            }, null, ClassLoader::class);
        }
    }
    

    FWIW - this is the .gitlab-ci.yml file I'm using, that started producing this error:

    stages:
      - validation
    
    phpcs:
      stage: validation
      image: pipelinecomponents/php-codesniffer:latest
      tags:
        - docker
      before_script:
        - composer global config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
        - composer global require drupal/coder -W --ignore-platform-req=ext-zip
      script:
        - phpcs
    
  • 🇦🇹Austria klausi 🇦🇹 Vienna

    Aha, it might be the docker image you are using.

    Which phpcs command is invoked there? Maybe the one in /app?

    Best you also always execute the phpcs command that gets installed into your composer directory.

    It looks like in this image phpcs is already installed, but you want to install it fresh with Coder. Then it is in vendor/bin/phpcs.

  • 🇧🇪Belgium svendecabooter Gent

    Thanks, that does the trick.
    Hadn't occurred to me that my docker image might be the cause of the issue.

  • 🇦🇹Austria klausi 🇦🇹 Vienna

    Alright, happy it works for you!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024