| Versionen | |
|---|---|
| drupal7 | _registry_skip_body(&$tokens) |
Skip the body of a code block, as defined by { and }.
This function assumes that the body starts at the next instance of { from the current position.
$tokens
includes/
<?php
function _registry_skip_body(&$tokens) {
$num_braces = 1;
$token = '';
// Get to the first open brace.
while ($token != '{' && ($token = next($tokens))) {
}
// Scan through the rest of the tokens until we reach the matching
// end brace.
while ($num_braces && ($token = next($tokens))) {
// PHP is really logical to have three different tokens for { with
// inconsistent names and only one for a closing brace.
if ($token == '{' || (is_array($token) && ($token[0] == T_DOLLAR_OPEN_CURLY_BRACES || $token[0] == T_CURLY_OPEN))) {
++$num_braces;
}
elseif ($token == '}') {
--$num_braces;
}
// Consume strings manually as workaround for a bug in PHP < 5.2.3 (see
// http://drupal.org/node/368116).
elseif ($token == '"' || $token == '`' || (is_array($token) && $token[0] == T_START_HEREDOC)) {
$stop = is_array($token) ? T_END_HEREDOC : $token;
while (($token = next($tokens)) && (is_array($token) ? $token[0] : $token) != $stop) {
}
}
}
}
?>
Kommentare
Kommentar hinzufügen