Skip to content

Ignoring multiple rules using phpcs:ignore only ignores the first one since version 4.0.0 #1277

@Domi04151309

Description

@Domi04151309

Describe the bug

Ignoring multiple rules using phpcs:ignore only ignores the first one since version 4.0.0

Code sample

<?php

  final class CustomSessionHandler extends SessionHandler {
    // phpcs:ignore Generic.NamingConventions.CamelCapsFunctionName.ScopeNotCamelCaps, PSR1.Methods.CamelCapsMethodName.NotCamelCaps
    public function create_sid(): string {
      return 'example';
    }
  }
?>

Custom ruleset

<?xml version="1.0"?>
<ruleset name="Custom Standard" namespace="CS\Standard">
	<description>A custom coding standard</description>

	<arg name="tab-width" value="2" />

	<rule ref="Generic">
		<exclude name="Generic.Arrays.ArrayIndent.KeyIncorrect" />
		<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
		<exclude name="Generic.Commenting" />
		<exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed" />
		<exclude name="Generic.Files.EndFileNoNewline.Found" />
		<exclude name="Generic.Files.InlineHTML.Found" />
		<exclude name="Generic.Files.LineLength" />
		<exclude name="Generic.Files.LowercasedFilename.NotFound" />
		<exclude name="Generic.Formatting" />
		<exclude name="Generic.Functions.OpeningFunctionBraceBsdAllman.BraceOnSameLine" />
		<exclude name="Generic.Metrics.CyclomaticComplexity" />
		<exclude name="Generic.PHP.RequireStrictTypes.MissingDeclaration" />
		<exclude name="Generic.PHP.UpperCaseConstant.Found" />
		<exclude name="Generic.Strings.UnnecessaryStringConcat.Found" />
		<exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceAfterOpen" />
		<exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceBeforeClose" />
		<exclude name="Generic.WhiteSpace.DisallowSpaceIndent" />
		<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
		<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact" />
	</rule>

	<rule ref="PSR12">
		<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
		<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
		<exclude name="PSR12.ControlStructures.ControlStructureSpacing.LineIndent" />
		<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceAfter" />
		<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceBefore" />
		<exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine" />
		<exclude name="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed" />
		<exclude name="PSR2.ControlStructures.SwitchDeclaration.BreakIndent" />
		<exclude name="PSR2.Files.ClosingTag.NotAllowed" />
		<exclude name="PSR2.Methods.FunctionCallSignature.Indent" />
		<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine" />
		<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.Indent" />
	</rule>
</ruleset>

To reproduce

Steps to reproduce the behavior:

  1. Create a file with the code sample above
  2. Run phpcs with the given ruleset
  3. See the error message for a rule that should be ignored
----------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------
 5 | ERROR | Method name "CustomSessionHandler::create_sid" is not in camel caps format (PSR1.Methods.CamelCapsMethodName.NotCamelCaps)
----------------------------------------------------------------------------------------------------------------------------------------

Expected behavior

As was the case in 3.x.x both rules should be ignored.

Versions

Operating System Linux 6.8.0-83-generic
PHP version 8.3.6
PHP_CodeSniffer version 4.0.0
Standard custom
Install type Composer (local)

Additional context

No 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 4.x branch of PHP_CodeSniffer.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions