diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d133f5..2992c3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ All notable changes from version 4.0.0 onward are documented in this file. example `choices`) can keep a meaningful order instead of an alphabetical one. The containing array is still checked. +### Changed + +- Excluded the superfluous trait name, superfluous abstract class prefix, alphabetical array key order, and function + length checks from `tests/` directories. + ## 6.0.0 ### Added diff --git a/phpcs.ruleset.84.xml b/phpcs.ruleset.84.xml index 64b6706..807f7d8 100644 --- a/phpcs.ruleset.84.xml +++ b/phpcs.ruleset.84.xml @@ -237,6 +237,7 @@ + */tests/* @@ -342,10 +343,15 @@ + + */tests/* + - + + */tests/* + @@ -417,6 +423,7 @@ + */tests/* diff --git a/tests/Functional/AlphabeticallySortedByKeysTest.php b/tests/Functional/AlphabeticallySortedByKeysTest.php index 3a9027d..c142927 100644 --- a/tests/Functional/AlphabeticallySortedByKeysTest.php +++ b/tests/Functional/AlphabeticallySortedByKeysTest.php @@ -37,11 +37,19 @@ public function testEmptyIgnoredParentKeysPreservesOriginalBehaviour(): void public function testPackagedRulesetConfiguresIgnoredParentKeys(): void { - $messages = $this->runSniffWithRuleset( - __DIR__ . '/AlphabeticallySortedByKeys/Arrays.php', - self::getPath('PATH_PHPCS_RULESET'), - 1, - ); + $path = $this->copyFixtureToTemporaryFile('AlphabeticallySortedByKeys/Arrays.php'); + + try { + $messages = $this->runSniffWithRuleset( + $path, + self::getPath('PATH_PHPCS_RULESET'), + 1, + ); + } finally { + if (is_file($path)) { + unlink($path); + } + } self::assertSame([13, 23, 34], array_column($messages, 'line')); } @@ -90,6 +98,27 @@ public function testLongArraySyntaxIsIgnored(): void } } + private function copyFixtureToTemporaryFile(string $fixture): string + { + $temporaryPath = tempnam(sys_get_temp_dir(), 'phpcs-array-'); + if ($temporaryPath === false) { + throw new RuntimeException('Could not create temporary PHP file.'); + } + + $path = $temporaryPath . '.php'; + if (!rename($temporaryPath, $path)) { + throw new RuntimeException('Could not create temporary PHP file.'); + } + + if (!copy(__DIR__ . '/' . $fixture, $path)) { + unlink($path); + + throw new RuntimeException('Could not copy fixture to temporary PHP file.'); + } + + return $path; + } + private function getEscapedKeysSnippet(): string { return $this->getBasicEscapesSnippet() . $this->getAdditionalEscapesSnippet();