=== modified file 'includes/registry.inc'
--- includes/registry.inc	2009-04-03 17:41:32 +0000
+++ includes/registry.inc	2009-05-10 03:29:13 +0000
@@ -248,7 +248,9 @@ function _registry_skip_body(&$tokens) {
   // Scan through the rest of the tokens until we reach the matching
   // end brace.
   while ($num_braces && ($token = next($tokens))) {
-    if ($token == '{') {
+    // 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 == '}') {

=== modified file 'modules/simpletest/tests/registry.test'
--- modules/simpletest/tests/registry.test	2009-03-31 01:49:50 +0000
+++ modules/simpletest/tests/registry.test	2009-05-10 03:28:12 +0000
@@ -135,3 +135,23 @@ CONTENTS;
 
 }
 
+class RegistrySkipBodyTestCase extends DrupalWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => t('Skip function body test'),
+      'description' => t('Tokenize a simple function and check that the body is skipped right'),
+      'group' => t('System'),
+    );
+  }
+  
+  function testRegistrySkipBody () {
+    // This string contains all three kinds of opening braces.
+    $function = '<?php function foo () { $x = "{$y}"; $x = "${y}" }';
+    $tokens = token_get_all($function);
+    _registry_skip_body($tokens);
+    // Consume the last }
+    each($tokens);
+    $this->assertIdentical(each($tokens), FALSE, t('Tokens skipped'));
+  }
+
+}
\ No newline at end of file

