= 70000 ? token_get_all( $code, TOKEN_PARSE ) : token_get_all( $code ); } /** * Check if a token is of a given type. * * @param mixed $token Token to check. * @param int $type Type of token to check (see https://www.php.net/manual/en/tokens.php) * @return bool True if it's a token of the given type, false otherwise. */ protected function is_token_of_type( $token, $type ) { return is_array( $token ) && $type === $token[0]; } /** * Converts a token to its string representation. * * @param $token Token to convert. * @return mixed String representation of the token. */ protected function token_to_string( $token ) { return is_array( $token ) ? $token[1] : $token; } /** * Checks if a string ends with a certain substring. * This method is added to help processing path names within 'hack' methods needing to do so. * * @param string $haystack The string to search in. * @param string $needle The substring to search for. * @return bool True if the $haystack ends with $needle, false otherwise. */ protected function string_ends_with( $haystack, $needle ) { $length = strlen( $needle ); if ( $length == 0 ) { return true; } return ( substr( $haystack, -$length ) === $needle ); } }