From dc0ffd23e60c5f823c89b7f567f38ff2b8d43541 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 31 Oct 2023 00:58:33 +0100 Subject: [PATCH] Tools/BrainMonkeyRaceCondition: minor tweak As we're only looking for a _method_ in a _class_, this condition will never happen under normal circumstances, not even in case of live coding as the function declaration would not be recognized as a _method_ in that case, so the sniff would bow out before reaching this condition. All the same, there's always to possibility that this could happen if PHP adds some new syntax and the PHPCS tokenizer does not support it yet or if there is another Tokenizer issue, so I'm keeping the condition, but marking it as fine to ignore for code coverage. --- Yoast/Sniffs/Tools/BrainMonkeyRaceConditionSniff.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Yoast/Sniffs/Tools/BrainMonkeyRaceConditionSniff.php b/Yoast/Sniffs/Tools/BrainMonkeyRaceConditionSniff.php index c7e84ea9..f72a1b83 100644 --- a/Yoast/Sniffs/Tools/BrainMonkeyRaceConditionSniff.php +++ b/Yoast/Sniffs/Tools/BrainMonkeyRaceConditionSniff.php @@ -92,8 +92,8 @@ public function process( File $phpcsFile, $stackPtr ) { // Now walk the contents of the function declaration to see if we can find the other function call. if ( isset( $tokens[ $functionToken ]['scope_opener'], $tokens[ $functionToken ]['scope_closer'] ) === false ) { - // We don't know the start or end of the function. - return; + // We don't know the start or end of the function. Edge case which can't happen under normal circumstances. + return; // @codeCoverageIgnore } $targetContent = 'expectdone';