From 3a3d1e794823b1c17da974428c9d7bae74ab4ad6 Mon Sep 17 00:00:00 2001 From: Jaroslav Hanslik Date: Tue, 26 Apr 2016 23:28:32 +0200 Subject: [PATCH] UnusedPrivateElementsSniff sometimes stopped prematurely after checking properties with multiple modifiers --- .../Sniffs/Classes/UnusedPrivateElementsSniff.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/SlevomatCodingStandard/Sniffs/Classes/UnusedPrivateElementsSniff.php b/SlevomatCodingStandard/Sniffs/Classes/UnusedPrivateElementsSniff.php index 96a05421b..03eedb5ad 100644 --- a/SlevomatCodingStandard/Sniffs/Classes/UnusedPrivateElementsSniff.php +++ b/SlevomatCodingStandard/Sniffs/Classes/UnusedPrivateElementsSniff.php @@ -200,11 +200,9 @@ private function getProperties(PHP_CodeSniffer_File $phpcsFile, array $tokens, a while (($propertyTokenPointer = $phpcsFile->findNext(T_VARIABLE, $findPropertiesStartTokenPointer, $classToken['scope_closer'])) !== false) { $visibilityModifiedTokenPointer = TokenHelper::findPreviousNonWhitespace($phpcsFile, $propertyTokenPointer - 1); $visibilityModifiedToken = $tokens[$visibilityModifiedTokenPointer]; - if (in_array($visibilityModifiedToken['code'], [T_PUBLIC, T_PROTECTED], true)) { + if ($visibilityModifiedToken['code'] !== T_PRIVATE) { $findPropertiesStartTokenPointer = $propertyTokenPointer + 1; continue; - } elseif ($visibilityModifiedToken['code'] !== T_PRIVATE) { - break; } $findPropertiesStartTokenPointer = $propertyTokenPointer + 1;