From 10126c7fba16749c7a8f8b51b174e4445e888eaf Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 20 Oct 2024 19:14:11 +0200 Subject: [PATCH] Generic/HereNowdocIdentifierSpacing: add metrics This commit adds metrics to the new `Generic.WhiteSpace.HereNowdocIdentifierSpacing` sniff to allow for collecting statistical information on how often spacing is found between the `<<<` and the doc ID. --- .../Sniffs/WhiteSpace/HereNowdocIdentifierSpacingSniff.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/HereNowdocIdentifierSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/HereNowdocIdentifierSpacingSniff.php index 2296525f3f..c2939a71d9 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/HereNowdocIdentifierSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/HereNowdocIdentifierSpacingSniff.php @@ -48,9 +48,12 @@ public function process(File $phpcsFile, $stackPtr) && strpos($tokens[$stackPtr]['content'], "\t") === false ) { // Nothing to do. + $phpcsFile->recordMetric($stackPtr, 'Heredoc/nowdoc identifier', 'no space between <<< and ID'); return; } + $phpcsFile->recordMetric($stackPtr, 'Heredoc/nowdoc identifier', 'space between <<< and ID'); + $error = 'There should be no space between the <<< and the heredoc/nowdoc identifier string'; $data = [$tokens[$stackPtr]['content']];