From dfbf45284b1c39550a5717da245bea967bb06622 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 12 Sep 2025 02:35:32 +0200 Subject: [PATCH 1/5] PHPCS config: sync an exclusion ... with the same exclusion in the `.gitattributes` file. --- phpcs.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index cb1d5d45b0..79d64d86b7 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -150,7 +150,7 @@ - tests/Core/Tokenizers/PHP/StableCommentWhitespaceWinTest\.php + tests/Core/Tokenizers/PHP/*WinTest\.php From 8368a1f221fc8b1ebe13db4980dbccf7929622c5 Mon Sep 17 00:00:00 2001 From: Greg Sherwood Date: Wed, 13 May 2020 11:21:18 +1000 Subject: [PATCH 2/5] CS: don't use double quotes where not needed Co-authored-by: jrfnl --- phpcs.xml.dist | 1 + src/Config.php | 2 +- src/Reports/Json.php | 4 ++-- tests/Core/Ruleset/ExplainTest.php | 2 +- tests/Core/Ruleset/GetIgnorePatternsTest.php | 2 +- tests/Core/Ruleset/GetIncludePatternsTest.php | 2 +- tests/Core/Tokenizers/PHP/AttributesTest.php | 2 +- tests/Core/Util/Common/PrepareForOutputTest.php | 8 ++++---- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 79d64d86b7..018d92acf4 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -58,6 +58,7 @@ + diff --git a/src/Config.php b/src/Config.php index ebd8e0511a..480abce696 100644 --- a/src/Config.php +++ b/src/Config.php @@ -1592,7 +1592,7 @@ public static function getExecutablePath(string $name) return $data; } - if ($name === "php") { + if ($name === 'php') { // For php, we know the executable path. There's no need to look it up. return PHP_BINARY; } diff --git a/src/Reports/Json.php b/src/Reports/Json.php index 55fe4aa2ef..4447cbaef7 100644 --- a/src/Reports/Json.php +++ b/src/Reports/Json.php @@ -57,7 +57,7 @@ public function generateFileReport(array $report, File $phpcsFile, bool $showSou $messagesObject->column = $column; $messagesObject->fixable = $fixable; - $messages .= json_encode($messagesObject).","; + $messages .= json_encode($messagesObject).','; } } }//end foreach @@ -99,7 +99,7 @@ public function generate( ) { echo '{"totals":{"errors":'.$totalErrors.',"warnings":'.$totalWarnings.',"fixable":'.$totalFixable.'},"files":{'; echo rtrim($cachedData, ','); - echo "}}".PHP_EOL; + echo '}}'.PHP_EOL; }//end generate() diff --git a/tests/Core/Ruleset/ExplainTest.php b/tests/Core/Ruleset/ExplainTest.php index bb01e50abe..e74afe950b 100644 --- a/tests/Core/Ruleset/ExplainTest.php +++ b/tests/Core/Ruleset/ExplainTest.php @@ -179,7 +179,7 @@ public function testExplainCustomRuleset() public function testExplainWithDeprecatedSniffs() { // Set up the ruleset. - $standard = __DIR__."/ShowSniffDeprecationsTest.xml"; + $standard = __DIR__.'/ShowSniffDeprecationsTest.xml'; $config = new ConfigDouble(["--standard=$standard", '-e']); $ruleset = new Ruleset($config); diff --git a/tests/Core/Ruleset/GetIgnorePatternsTest.php b/tests/Core/Ruleset/GetIgnorePatternsTest.php index 23fe0532c9..ce185d3ead 100644 --- a/tests/Core/Ruleset/GetIgnorePatternsTest.php +++ b/tests/Core/Ruleset/GetIgnorePatternsTest.php @@ -37,7 +37,7 @@ final class GetIgnorePatternsTest extends TestCase public static function setUpBeforeClass(): void { // Set up the ruleset. - $standard = __DIR__."/GetIgnorePatternsTest.xml"; + $standard = __DIR__.'/GetIgnorePatternsTest.xml'; $config = new ConfigDouble(["--standard=$standard"]); self::$ruleset = new Ruleset($config); diff --git a/tests/Core/Ruleset/GetIncludePatternsTest.php b/tests/Core/Ruleset/GetIncludePatternsTest.php index b67c189e11..5d32c446d2 100644 --- a/tests/Core/Ruleset/GetIncludePatternsTest.php +++ b/tests/Core/Ruleset/GetIncludePatternsTest.php @@ -37,7 +37,7 @@ final class GetIncludePatternsTest extends TestCase public static function setUpBeforeClass(): void { // Set up the ruleset. - $standard = __DIR__."/GetIncludePatternsTest.xml"; + $standard = __DIR__.'/GetIncludePatternsTest.xml'; $config = new ConfigDouble(["--standard=$standard"]); self::$ruleset = new Ruleset($config); diff --git a/tests/Core/Tokenizers/PHP/AttributesTest.php b/tests/Core/Tokenizers/PHP/AttributesTest.php index 415971a98d..75d3b458f2 100644 --- a/tests/Core/Tokenizers/PHP/AttributesTest.php +++ b/tests/Core/Tokenizers/PHP/AttributesTest.php @@ -540,7 +540,7 @@ public static function dataAttributeOnTextLookingLikeCloseTag() ], [ 'T_WHITESPACE', - " ", + ' ', ], [ 'T_CONSTANT_ENCAPSED_STRING', diff --git a/tests/Core/Util/Common/PrepareForOutputTest.php b/tests/Core/Util/Common/PrepareForOutputTest.php index 3f4d595a4b..f9ad07af51 100644 --- a/tests/Core/Util/Common/PrepareForOutputTest.php +++ b/tests/Core/Util/Common/PrepareForOutputTest.php @@ -79,16 +79,16 @@ public static function dataPrepareForOutput() 'expectedWin' => "\\r\\n\\t", ], 'Spaces are replaced with a unique mark' => [ - 'content' => " ", + 'content' => ' ', 'exclude' => [], 'expected' => "\033[30;1m·\033[0m\033[30;1m·\033[0m\033[30;1m·\033[0m\033[30;1m·\033[0m", - 'expectedWin' => " ", + 'expectedWin' => ' ', ], 'Other characters are unaffected' => [ - 'content' => "{echo 1;}", + 'content' => '{echo 1;}', 'exclude' => [], 'expected' => "{echo\033[30;1m·\033[0m1;}", - 'expectedWin' => "{echo 1;}", + 'expectedWin' => '{echo 1;}', ], 'No replacements' => [ 'content' => 'nothing-should-be-replaced', From d1364b52cdcb753533c416609407b396832d863c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 19 Apr 2025 03:59:56 +0200 Subject: [PATCH 3/5] CS: no unnecessary heredocs --- phpcs.xml.dist | 1 + .../Core/Tokenizers/Tokenizer/ReplaceTabsInTokenMiscTest.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 018d92acf4..79330e5a1b 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -59,6 +59,7 @@ + diff --git a/tests/Core/Tokenizers/Tokenizer/ReplaceTabsInTokenMiscTest.php b/tests/Core/Tokenizers/Tokenizer/ReplaceTabsInTokenMiscTest.php index deae18e9a6..fbe95c4130 100644 --- a/tests/Core/Tokenizers/Tokenizer/ReplaceTabsInTokenMiscTest.php +++ b/tests/Core/Tokenizers/Tokenizer/ReplaceTabsInTokenMiscTest.php @@ -33,7 +33,7 @@ public function testTabWidthNotSet() $config = new ConfigDouble(); $ruleset = new Ruleset($config); - $content = <<tabWidth = 4; $ruleset = new Ruleset($config); - $content = << Date: Sun, 20 Apr 2025 01:35:24 +0200 Subject: [PATCH 4/5] CS: forbid `join` alias function --- phpcs.xml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 79330e5a1b..15bf8890da 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -135,6 +135,7 @@ + From fe53a330d4917beb444df478df66bd3f6f4e5fd2 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 06:09:30 +0200 Subject: [PATCH 5/5] CS: enforce consistent formatting of return types --- phpcs.xml.dist | 3 +++ src/Files/File.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 15bf8890da..2b0c61516e 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -164,4 +164,7 @@ + + + diff --git a/src/Files/File.php b/src/Files/File.php index 84aaeba56a..99ab24097d 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -1229,7 +1229,7 @@ public function getFixedWarningCount() * * @return int */ - public function getFirstRunCount(string $type):int + public function getFirstRunCount(string $type): int { return $this->firstRunCounts[$type];