getTokens(); if (\is_int($start) === false || isset($tokens[$start]) === false) { throw new RuntimeException( 'The $start position for GetTokensAsString methods must exist in the token stack' ); } if (\is_int($end) === false || $end < $start) { return ''; } $str = ''; if ($end >= $phpcsFile->numTokens) { $end = ($phpcsFile->numTokens - 1); } $lastAdded = null; for ($i = $start; $i <= $end; $i++) { if ($stripComments === true && isset(Tokens::$commentTokens[$tokens[$i]['code']])) { continue; } if ($stripWhitespace === true && $tokens[$i]['code'] === \T_WHITESPACE) { continue; } if ($compact === true && $tokens[$i]['code'] === \T_WHITESPACE) { if (isset($lastAdded) === false || $tokens[$lastAdded]['code'] !== \T_WHITESPACE) { $str .= ' '; $lastAdded = $i; } continue; } // If tabs are being converted to spaces by the tokenizer, the // original content should be used instead of the converted content. if ($origContent === true && isset($tokens[$i]['orig_content']) === true) { $str .= $tokens[$i]['orig_content']; } else { $str .= $tokens[$i]['content']; } $lastAdded = $i; } return $str; } }