Skip to content

RequiredToOptionalFunctionParametersSniff error when including ruleset #793

@ofbeaton

Description

@ofbeaton

I wanted to include this in a general ruleset for my organization for use in multiple projects. I didn't want to rely on users configuring installed_paths.

so I added the following line to my orgs ruleset.xml

<rule ref="vendor/phpcompatibility/php-compatibility/PHPCompatibility" />

This works for every single other Codesniffer ruleset I've run into the past, most recently I've included MediaWiki's ruleset this way.

But when I do it this way, I get the following error when running in windows:

> phpcs -p

Fatal error: Cannot declare class PHPCompatibility\Sniffs\FunctionUse\RequiredToOptionalFunctionParametersSniff, because the name is already in use in C:\Code\MyCoolProject\vendor\phpcompatibility\php-compatibility\PHPCompatibility\Sniffs\FunctionUse\RequiredToOptionalFunctionParametersSniff.php on line 310
PHP Fatal error:  Cannot declare class PHPCompatibility\Sniffs\FunctionUse\RequiredToOptionalFunctionParametersSniff, because the name is already in use in C:\Code\MyCoolProject\vendor\phpcompatibility\php-compatibility\PHPCompatibility\Sniffs\FunctionUse\RequiredToOptionalFunctionParametersSniff.php on line 310

If however I run it from the command line directly:

> phpcs -p --standard=vendor\phpcompatibility\php-compatibility\PHPCompatibility --ignore=vendor --runtime-set testVersion 5.0- .
.. 2 / 2 (100%)


Time: 333ms; Memory: 10MB

it works fine.

I realise I could either run the PHPCompatability separately from my own ruleset (what I'm doing now), or I could require users to configure installed_paths.

But perhaps you could please troubleshoot this problem with your package?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions