Skip to content

Uncaught InvalidArgumentException: The $sniffClass parameter was not passed a fully qualified sniff(test) class name. Received: CompanyNameStandard\Sniffs\JsonSniff #675

Closed
@williamdes

Description

@williamdes

Describe the bug

After #524 I get the following error:

Fatal error: Uncaught InvalidArgumentException: The $sniffClass parameter was not passed a fully qualified sniff(test) class name. Received: CompanyNameStandard\Sniffs\JsonSniff in /var/www/vendor/squizlabs/php_codesniffer/src/Util/Common.php:546
Stack trace:
#0 /var/www/vendor/squizlabs/php_codesniffer/src/Ruleset.php(1389): PHP_CodeSniffer\Util\Common::getSniffCode('CompanyNameStandar...')
#1 /var/www/vendor/squizlabs/php_codesniffer/src/Ruleset.php(234): PHP_CodeSniffer\Ruleset->populateTokenListeners()
#2 /var/www/vendor/squizlabs/php_codesniffer/src/Runner.php(348): PHP_CodeSniffer\Ruleset->__construct(Object(PHP_CodeSniffer\Config))
#3 /var/www/vendor/squizlabs/php_codesniffer/src/Runner.php(76): PHP_CodeSniffer\Runner->init()
#4 /var/www/vendor/squizlabs/php_codesniffer/bin/phpcs(14): PHP_CodeSniffer\Runner->runPHPCS()
#5 /var/www/vendor/bin/phpcs(119): include('/var/www/vendor...')
#6 {main}

The rules are added to a normal phpcs ruleset

I can not figure out how to fix the current situation

Code sample

<?php

namespace CompanyNameStandard\Sniffs;

use PHP_CodeSniffer\Sniffs\Sniff;
use PHP_CodeSniffer\Files\File;

class JsonSniff implements Sniff
{
    public function register()
    {
        return [];
//        return [T_INLINE_HTML];
    }

    public function process(File $file, $currentTokenIndex)
    {
    }

}

Custom ruleset

<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Company"
    xmlns="http://pmd.sf.net/ruleset/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
    xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">

    <file>.</file>
    <arg name="cache" value=".php_cs.cache" />
    <arg name="extensions" value="php,json" />

    <config name="installed_paths" value="vendor/slevomat/coding-standard"/>

    <rule ref="./CompanyStandard/Sniffs/JsonSniff.php" />
    <rule ref="./CompanyStandard/Sniffs/TranslationSniff.php" />

</ruleset>

To reproduce

Use the ruleset and add the file at the rule location

Expected behavior

Work fine like in the previous version

Versions (please complete the following information)

Operating System Linux Alpine 3.20
PHP version 8.2
PHP_CodeSniffer version 3.11.0
Standard PSR2 + PSR12 + Squiz + custom
Install type Composer

Additional context

Please confirm

  • I have searched the issue list and am not opening a duplicate issue.
  • I have read the Contribution Guidelines and this is not a support question.
  • I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
  • I have verified the issue still exists in the master branch of PHP_CodeSniffer.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions