Skip to content

Add tests for RequireSingleLineConditionSniff limits - #1863

Merged
kukulich merged 2 commits into
slevomat:masterfrom
MauricioFauth:RequireSingleLineConditionSniff-limits
Aug 14, 2026
Merged

kukulich merged 2 commits into
slevomat:masterfrom
MauricioFauth:RequireSingleLineConditionSniff-limits

Conversation

@MauricioFauth

Copy link
Copy Markdown
Contributor

Improves unit tests of the sniff SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition.

I also added an extra case for a simple condition involving a function call with multiple parameters, to show the extra spaces that are counted for the maximum line length.

The following changes now causes the tests to fail:

--- a/SlevomatCodingStandard/Sniffs/ControlStructures/RequireSingleLineConditionSniff.php
+++ b/SlevomatCodingStandard/Sniffs/ControlStructures/RequireSingleLineConditionSniff.php
@@ -15,7 +15,7 @@ class RequireSingleLineConditionSniff extends AbstractLineCondition
 
        public const CODE_REQUIRED_SINGLE_LINE_CONDITION = 'RequiredSingleLineCondition';
 
-       public int $maxLineLength = 120;
+       public int $maxLineLength = 121;
 
        public bool $alwaysForSimpleConditions = true;
--- a/SlevomatCodingStandard/Sniffs/ControlStructures/RequireSingleLineConditionSniff.php
+++ b/SlevomatCodingStandard/Sniffs/ControlStructures/RequireSingleLineConditionSniff.php
@@ -15,7 +15,7 @@ class RequireSingleLineConditionSniff extends AbstractLineCondition
 
        public const CODE_REQUIRED_SINGLE_LINE_CONDITION = 'RequiredSingleLineCondition';
 
-       public int $maxLineLength = 120;
+       public int $maxLineLength = 119;
 
        public bool $alwaysForSimpleConditions = true;
--- a/SlevomatCodingStandard/Sniffs/ControlStructures/RequireSingleLineConditionSniff.php
+++ b/SlevomatCodingStandard/Sniffs/ControlStructures/RequireSingleLineConditionSniff.php
@@ -17,7 +17,7 @@ class RequireSingleLineConditionSniff extends AbstractLineCondition
 
        public int $maxLineLength = 120;
 
-       public bool $alwaysForSimpleConditions = true;
+       public bool $alwaysForSimpleConditions = false;
 
        public function process(File $phpcsFile, int $controlStructurePointer): void

@kukulich

Copy link
Copy Markdown
Contributor

Thanks.

@kukulich
kukulich merged commit 767a0c3 into slevomat:master Aug 14, 2026
40 checks passed
@MauricioFauth
MauricioFauth deleted the RequireSingleLineConditionSniff-limits branch August 17, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants