', ',']; /** * Check whether the last non-whitespace token is a trailing operator. * * Used to determine whether a statement continues onto the next line. * * @param array $tokens token_get_all tokens */ public static function hasTrailingOperator(array $tokens): bool { if (empty($tokens)) { return false; } $lastToken = null; for ($i = \count($tokens) - 1; $i >= 0; $i--) { $token = $tokens[$i]; if (\is_array($token) && $token[0] === \T_WHITESPACE) { continue; } $lastToken = $token; break; } if ($lastToken === null) { return false; } if (\is_array($lastToken)) { return \in_array($lastToken[0], self::TRAILING_TOKEN_OPS, true); } return \in_array($lastToken, self::TRAILING_CHAR_OPS, true); } }