From dc7bda09859412e899248072613d35e1d13d87ea Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Fri, 24 Aug 2018 23:41:31 -0300 Subject: [PATCH] Update to Slevomat/CS 4.7 and add some new Snifss --- Consistence/ruleset.xml | 8 ++++++++ composer.json | 2 +- tests/Sniffs/TestCase.php | 8 ++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Consistence/ruleset.xml b/Consistence/ruleset.xml index c832dc1..1d9d466 100644 --- a/Consistence/ruleset.xml +++ b/Consistence/ruleset.xml @@ -88,8 +88,12 @@ + + + + @@ -127,8 +131,10 @@ + + @@ -147,6 +153,8 @@ + + diff --git a/composer.json b/composer.json index e4c311f..a0eb894 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "require": { "php": "~7.1", "squizlabs/php_codesniffer": "~3.3.0", - "slevomat/coding-standard": "~4.6" + "slevomat/coding-standard": "~4.7" }, "require-dev": { "jakub-onderka/php-console-highlighter": "0.3.2", diff --git a/tests/Sniffs/TestCase.php b/tests/Sniffs/TestCase.php index 7be4389..cca47e4 100644 --- a/tests/Sniffs/TestCase.php +++ b/tests/Sniffs/TestCase.php @@ -94,7 +94,7 @@ protected function assertSniffError(PhpCsFile $resultFile, int $line, string $co sprintf( 'Expected code %s%s, but not found on line %s.%sErrors found on this line:%s%s%s', $expectedCode, - ($message !== null) ? sprintf(' with message "%s"', $message) : '', + $message !== null ? sprintf(' with message "%s"', $message) : '', $line, PHP_EOL, PHP_EOL, @@ -162,7 +162,7 @@ protected function assertNoSniffErrorInFile(PhpCsFile $file): void private function getFormattedErrorsForFile(array $errorsForFile): string { $message = ''; - foreach ($errorsForFile as $line => $errorsForPossition) { + foreach (array_keys($errorsForFile) as $line) { $message .= sprintf( '%d:%s%s%s', $line, @@ -186,8 +186,8 @@ private function getFormattedErrorsOnLine(array $errorsForFile, int $line): stri return ''; } - return implode(PHP_EOL, array_map(function (array $errorsForPosition) { - return implode(PHP_EOL, array_map(function (array $errorForPosition) { + return implode(PHP_EOL, array_map(static function (array $errorsForPosition) { + return implode(PHP_EOL, array_map(static function (array $errorForPosition) { return sprintf("\t" . '%s: %s', $errorForPosition['source'], $errorForPosition['message']); }, $errorsForPosition)); }, $errorsForFile[$line]));