Skip to content

Commit cc89cb4

Browse files
committed
BadFunctions/EasyRFI: minor code simplification [1]
Putting the `findNext()` in the `while` condition allows to simplify the `if` conditions within the loop.
1 parent 98cca8b commit cc89cb4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Security/Sniffs/BadFunctions/EasyRFISniff.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,18 @@ public function process(File $phpcsFile, $stackPtr) {
4848
$tokens = $phpcsFile->getTokens();
4949
$s = $stackPtr;
5050

51-
while ($s) {
52-
$s = $phpcsFile->findNext($this->search, $s + 1, $closer, true);
5351

52+
while (($s = $phpcsFile->findNext($this->search, $s + 1, $closer, true)) !== false) {
5453
$data = array(
5554
$tokens[$s]['content'],
5655
$tokens[$stackPtr]['content'],
5756
);
5857

59-
if ($s && $utils::is_token_user_input($tokens[$s])) {
58+
if ($utils::is_token_user_input($tokens[$s])) {
6059
if (\PHP_CodeSniffer\Config::getConfigData('ParanoiaMode') || !$utils::is_token_false_positive($tokens[$s], $tokens[$s+2])) {
6160
$phpcsFile->addError('Easy RFI detected because of direct user input with %s on %s', $s, 'ErrEasyRFI', $data);
6261
}
63-
} elseif ($s && \PHP_CodeSniffer\Config::getConfigData('ParanoiaMode') && $tokens[$s]['content'] != '.') {
62+
} elseif (\PHP_CodeSniffer\Config::getConfigData('ParanoiaMode') && $tokens[$s]['content'] != '.') {
6463
$phpcsFile->addWarning('Possible RFI detected with %s on %s', $s, 'WarnEasyRFI', $data);
6564
}
6665
}

0 commit comments

Comments
 (0)