Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Aug 1, 2017
1 parent b29a52e commit e67db7d
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public function process(\PHP_CodeSniffer_File $phpcsFile, $classPointer)
return $propertyNameTokenPointer + 1;
};

while (($propertyAccessTokenPointer = TokenHelper::findNext($phpcsFile, [T_VARIABLE, T_SELF, T_STATIC, T_DOUBLE_QUOTED_STRING], $findUsagesStartTokenPointer, $classToken['scope_closer'])) !== null) {
$propertyAccessToken = $tokens[$propertyAccessTokenPointer];
while (($tokenPointer = TokenHelper::findNext($phpcsFile, [T_VARIABLE, T_SELF, T_STATIC, T_DOUBLE_QUOTED_STRING], $findUsagesStartTokenPointer, $classToken['scope_closer'])) !== null) {
$propertyAccessToken = $tokens[$tokenPointer];
if ($propertyAccessToken['code'] === T_DOUBLE_QUOTED_STRING) {
if (preg_match_all('~(?<!\\\\)\$this->(.+?\b)(?!\()~', $propertyAccessToken['content'], $matches, PREG_PATTERN_ORDER)) {
foreach ($matches[1] as $propertyInString) {
Expand All @@ -150,11 +150,11 @@ public function process(\PHP_CodeSniffer_File $phpcsFile, $classPointer)
}
}

$findUsagesStartTokenPointer = $propertyAccessTokenPointer + 1;
$findUsagesStartTokenPointer = $tokenPointer + 1;
} elseif ($propertyAccessToken['content'] === '$this') {
$findUsagesStartTokenPointer = $checkVariable($propertyAccessTokenPointer);
$findUsagesStartTokenPointer = $checkVariable($tokenPointer);
} elseif (in_array($propertyAccessToken['code'], [T_SELF, T_STATIC], true)) {
$newTokenPointer = TokenHelper::findPreviousEffective($phpcsFile, $propertyAccessTokenPointer - 1);
$newTokenPointer = TokenHelper::findPreviousEffective($phpcsFile, $tokenPointer - 1);
if ($tokens[$newTokenPointer]['code'] === T_NEW) {
$variableTokenPointer = TokenHelper::findPreviousLocal($phpcsFile, T_VARIABLE, $newTokenPointer - 1);
$scopeMethodPointer = TokenHelper::findPrevious($phpcsFile, T_FUNCTION, $variableTokenPointer - 1);
Expand All @@ -164,7 +164,7 @@ public function process(\PHP_CodeSniffer_File $phpcsFile, $classPointer)
}
}
} else {
$doubleColonTokenPointer = TokenHelper::findNextEffective($phpcsFile, $propertyAccessTokenPointer + 1);
$doubleColonTokenPointer = TokenHelper::findNextEffective($phpcsFile, $tokenPointer + 1);
$doubleColonToken = $tokens[$doubleColonTokenPointer];
if ($doubleColonToken['code'] !== T_DOUBLE_COLON) {
// self or static not followed by ::
Expand Down Expand Up @@ -201,7 +201,7 @@ public function process(\PHP_CodeSniffer_File $phpcsFile, $classPointer)
$findUsagesStartTokenPointer = $methodCallTokenPointer + 1;
}
} else {
$findUsagesStartTokenPointer = $propertyAccessTokenPointer + 1;
$findUsagesStartTokenPointer = $tokenPointer + 1;
}

if (count($reportedProperties) + count($reportedMethods) + count($reportedConstants) === 0) {
Expand Down

0 comments on commit e67db7d

Please sign in to comment.