diff --git includes/database/database.inc includes/database/database.inc
index 1c3e5bd..dc646e2 100644
--- includes/database/database.inc
+++ includes/database/database.inc
@@ -41,7 +41,7 @@
  * @code
  * $result = db_query_range('SELECT n.nid, n.title, n.created
  *   FROM {node} n WHERE n.uid = :uid', 0, 10, array(':uid' => $uid));
- * foreach($result as $record) {
+ * foreach ($result as $record) {
  *   // Perform operations on $node->title, etc. here.
  * }
  * @endcode
@@ -50,7 +50,7 @@
  * out into an argument passed to db_query() so that SQL injection attacks
  * from user input can be caught and nullified. The LIMIT syntax varies between
  * database servers, so that is abstracted into db_query_range() arguments.
- * Finally, note the PDO-based ability to foreach() over the result set.
+ * Finally, note the PDO-based ability to foreach () over the result set.
  *
  * All queries are passed as a prepared statement string. A
  * prepared statement is a "template" of a query that omits literal or variable
diff --git modules/field/tests/field.test modules/field/tests/field.test
index d1434df..b19d6cc 100644
--- modules/field/tests/field.test
+++ modules/field/tests/field.test
@@ -1616,7 +1616,7 @@ class FieldDisplayAPITestCase extends FieldTestCase {
     $settings = field_info_formatter_settings('field_test_default');
     $setting = $settings['test_formatter_setting'];
     $this->assertText($this->label, t('Label was displayed.'));
-    foreach($this->values as $delta => $value) {
+    foreach ($this->values as $delta => $value) {
       $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
 
@@ -1633,7 +1633,7 @@ class FieldDisplayAPITestCase extends FieldTestCase {
     $setting = $display['settings']['test_formatter_setting_multiple'];
     $this->assertNoText($this->label, t('Label was not displayed.'));
     $array = array();
-    foreach($this->values as $delta => $value) {
+    foreach ($this->values as $delta => $value) {
       $array[] = $delta . ':' . $value['value'];
     }
     $this->assertText($setting . '|' . implode('|', $array), t('Values were displayed with expected setting.'));
@@ -1661,7 +1661,7 @@ class FieldDisplayAPITestCase extends FieldTestCase {
     $this->drupalSetContent(drupal_render($output));
     $setting = $this->instance['display']['teaser']['settings']['test_formatter_setting'];
     $this->assertText($this->label, t('Label was displayed.'));
-    foreach($this->values as $delta => $value) {
+    foreach ($this->values as $delta => $value) {
       $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
 
@@ -1671,7 +1671,7 @@ class FieldDisplayAPITestCase extends FieldTestCase {
     $this->drupalSetContent(drupal_render($output));
     $setting = $this->instance['display']['default']['settings']['test_formatter_setting'];
     $this->assertText($this->label, t('Label was displayed.'));
-    foreach($this->values as $delta => $value) {
+    foreach ($this->values as $delta => $value) {
       $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
   }
diff --git modules/field/tests/field_test.field.inc modules/field/tests/field_test.field.inc
index b723619..87ee1f6 100644
--- modules/field/tests/field_test.field.inc
+++ modules/field/tests/field_test.field.inc
@@ -184,7 +184,7 @@ function field_test_field_widget_form(&$form, &$form_state, $field, $instance, $
 function field_test_widget_multiple_validate($element, &$form_state) {
   $values = array_map('trim', explode(',', $element['#value']));
   $items = array();
-  foreach($values as $value) {
+  foreach ($values as $value) {
     $items[] = array('value' => $value);
   }
   form_set_value($element, $items, $form_state);
diff --git modules/filter/filter.module modules/filter/filter.module
index 0a35b64..468484d 100644
--- modules/filter/filter.module
+++ modules/filter/filter.module
@@ -1013,11 +1013,11 @@ function filter_dom_serialize($dom_document) {
   $body_node = $dom_document->getElementsByTagName('body')->item(0);
   $body_content = '';
 
-  foreach($body_node->getElementsByTagName('script') as $node) {
+  foreach ($body_node->getElementsByTagName('script') as $node) {
     filter_dom_serialize_escape_cdata_element($dom_document, $node);
   }
 
-  foreach($body_node->getElementsByTagName('style') as $node) {
+  foreach ($body_node->getElementsByTagName('style') as $node) {
     filter_dom_serialize_escape_cdata_element($dom_document, $node, '/*', '*/');
   }
 
@@ -1173,7 +1173,7 @@ function _filter_html($text, $filter) {
   if ($filter->settings['filter_html_nofollow']) {
     $html_dom = filter_dom_load($text);
     $links = $html_dom->getElementsByTagName('a');
-    foreach($links as $link) {
+    foreach ($links as $link) {
       $link->setAttribute('rel', 'nofollow');
     }
     $text = filter_dom_serialize($html_dom);
diff --git modules/forum/forum.test modules/forum/forum.test
index 29306a8..0fc860c 100644
--- modules/forum/forum.test
+++ modules/forum/forum.test
@@ -145,7 +145,7 @@ class ForumTestCase extends DrupalWebTestCase {
     // Must remove forum topics to test creating orphan topics.
     $vid = variable_get('forum_nav_vocabulary');
     $tree = taxonomy_get_tree($vid);
-    foreach($tree as $term) {
+    foreach ($tree as $term) {
       taxonomy_term_delete($term->tid);
     }
 
diff --git modules/node/node.install modules/node/node.install
index 108ef5a..1c7f8ca 100644
--- modules/node/node.install
+++ modules/node/node.install
@@ -497,7 +497,7 @@ function node_update_7004() {
  * Add status/comment/promote and sticky columns to the {node_revision} table.
  */
 function node_update_7005() {
-  foreach(array('status', 'comment', 'promote', 'sticky') as $column) {
+  foreach (array('status', 'comment', 'promote', 'sticky') as $column) {
     db_add_field('node_revision', $column, array(
       'type' => 'int',
       'not null' => TRUE,
diff --git modules/search/search.admin.inc modules/search/search.admin.inc
index add5ab7..e746552 100644
--- modules/search/search.admin.inc
+++ modules/search/search.admin.inc
@@ -60,7 +60,7 @@ function search_admin_settings($form) {
   // Collect some stats
   $remaining = 0;
   $total = 0;
-  foreach(variable_get('search_active_modules', array('node', 'user')) as $module) {
+  foreach (variable_get('search_active_modules', array('node', 'user')) as $module) {
     if ($status = module_invoke($module, 'search_status')) {
       $remaining += $status['remaining'];
       $total += $status['total'];
@@ -132,7 +132,7 @@ function search_admin_settings($form) {
   $form['#submit'][] = 'search_admin_settings_submit';
 
   // Per module settings
-  foreach(variable_get('search_active_modules', array('node', 'user')) as $module) {
+  foreach (variable_get('search_active_modules', array('node', 'user')) as $module) {
     $added_form = module_invoke($module, 'search_admin');
     if (is_array($added_form)) {
       $form = array_merge($form, $added_form);
diff --git modules/search/search.module modules/search/search.module
index a12fe0d..86e95c6 100644
--- modules/search/search.module
+++ modules/search/search.module
@@ -353,7 +353,7 @@ function search_cron() {
   // to date.
   drupal_register_shutdown_function('search_update_totals');
 
-  foreach(variable_get('search_active_modules', array('node', 'user')) as $module) {
+  foreach (variable_get('search_active_modules', array('node', 'user')) as $module) {
     // Update word index
     module_invoke($module, 'update_index');
   }
diff --git modules/simpletest/simpletest.test modules/simpletest/simpletest.test
index 252da04..e3df460 100644
--- modules/simpletest/simpletest.test
+++ modules/simpletest/simpletest.test
@@ -385,7 +385,7 @@ class SimpleTestMailCaptureTestCase extends DrupalWebTestCase {
 
     // Assert that the e-mail was sent by iterating over the message properties
     // and ensuring that they are captured intact.
-    foreach($message as $field => $value) {
+    foreach ($message as $field => $value) {
       $this->assertMail($field, $value, t('The e-mail was sent and the value for property @field is intact.', array('@field' => $field)), t('E-mail'));
     }
 
diff --git modules/simpletest/tests/ajax.test modules/simpletest/tests/ajax.test
index 4fb1dd6..6d5db24 100644
--- modules/simpletest/tests/ajax.test
+++ modules/simpletest/tests/ajax.test
@@ -192,7 +192,7 @@ class AJAXFormValuesTestCase extends AJAXTestCase {
    */
   function testSimpleAJAXFormValue() {
     // Verify form values of a select element.
-    foreach(array('red', 'green', 'blue') as $item) {
+    foreach (array('red', 'green', 'blue') as $item) {
       $edit = array(
         'select' => $item,
       );
@@ -202,7 +202,7 @@ class AJAXFormValuesTestCase extends AJAXTestCase {
     }
 
     // Verify form values of a checkbox element.
-    foreach(array(FALSE, TRUE) as $item) {
+    foreach (array(FALSE, TRUE) as $item) {
       $edit = array(
         'checkbox' => $item,
       );
diff --git modules/simpletest/tests/form.test modules/simpletest/tests/form.test
index 9cdc2e3..4c5bce9 100644
--- modules/simpletest/tests/form.test
+++ modules/simpletest/tests/form.test
@@ -885,7 +885,7 @@ class FormsFormStorageTestCase extends DrupalWebTestCase {
       array(),
       array('query' => array('cache' => 1)),
     );
-    foreach($run_options as $options) {
+    foreach ($run_options as $options) {
       $this->drupalPost('form-test/state-persist', array(), t('Submit'), $options);
       // The submit handler outputs the value in $form_state, assert it's there.
       $this->assertText('State persisted.');
diff --git modules/simpletest/tests/schema.test modules/simpletest/tests/schema.test
index 0f815b7..3418251 100644
--- modules/simpletest/tests/schema.test
+++ modules/simpletest/tests/schema.test
@@ -169,7 +169,7 @@ class SchemaTestCase extends DrupalWebTestCase {
     }
 
     // Finally, check each column and try to insert invalid values into them.
-    foreach($table_spec['fields'] as $column_name => $column_spec) {
+    foreach ($table_spec['fields'] as $column_name => $column_spec) {
       $this->assertTrue(db_field_exists($table_name, $column_name), t('Unsigned @type column was created.', array('@type' => $column_spec['type'])));
       $this->assertFalse($this->tryUnsignedInsert($table_name, $column_name), t('Unsigned @type column rejected a negative value.', array('@type' => $column_spec['type'])));
     }
diff --git modules/system/system.admin.inc modules/system/system.admin.inc
index 6ffecb9..0f4147c 100644
--- modules/system/system.admin.inc
+++ modules/system/system.admin.inc
@@ -1839,7 +1839,7 @@ function system_file_system_settings() {
   );
   // Any visible, writeable wrapper can potentially be used for the files
   // directory, including a remote file system that integrates with a CDN.
-  foreach(file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $info) {
+  foreach (file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $info) {
     $options[$scheme] = check_plain($info['description']);
   }
 
@@ -2719,7 +2719,7 @@ function theme_system_themes_page($variables) {
     // Start new theme group.
     $output .= '<div class="system-themes-list system-themes-list-'. $state .' clearfix"><h2>'. $title .'</h2>';
 
-    foreach($theme_groups[$state] as $theme) {
+    foreach ($theme_groups[$state] as $theme) {
 
       // Theme the screenshot.
       $screenshot = $theme->screenshot ? theme('image', $theme->screenshot) : '<div class="no-screenshot">' . t('no screenshot') . '</div>';
diff --git modules/system/system.api.php modules/system/system.api.php
index 0e3eb61..0a065a3 100644
--- modules/system/system.api.php
+++ modules/system/system.api.php
@@ -3294,7 +3294,7 @@ function hook_drupal_goto_alter(&$path, &$options, &$http_response_code) {
  *   array will be the most likely target for changes.
  */
 function hook_html_head_alter(&$head_elements) {
-  foreach($head_elements as $key => $element) {
+  foreach ($head_elements as $key => $element) {
     if (isset($element['#attributes']['rel']) && $element['#attributes']['rel'] == 'canonical') {
       // I want a custom canonical url.
       $head_elements[$key]['#attributes']['href'] = mymodule_canonical_url();
@@ -3662,7 +3662,7 @@ function hook_page_delivery_callback_alter(&$callback) {
  */
 function hook_system_themes_page_alter(&$theme_groups) {
   foreach ($theme_groups as $state => &$group) {
-    foreach($theme_groups[$state] as &$theme) {
+    foreach ($theme_groups[$state] as &$theme) {
       // Add a foo link to each list of theme operations.
       $theme->operations[] = l(t('Foo'), 'admin/appearance/foo', array('query' => array('theme' => $theme->name)));
     }
diff --git modules/system/system.module modules/system/system.module
index 66990d2..6a539bd 100644
--- modules/system/system.module
+++ modules/system/system.module
@@ -2209,7 +2209,7 @@ function system_update_files_database(&$files, $type) {
 
   // All remaining files are not in the system table, so we need to add them.
   $query = db_insert('system')->fields(array('filename', 'name', 'type', 'owner', 'info'));
-  foreach($files as &$file) {
+  foreach ($files as &$file) {
     if (isset($file->exists)) {
       unset($file->exists);
     }
diff --git scripts/run-tests.sh scripts/run-tests.sh
index a696c61..e0b9742 100755
--- scripts/run-tests.sh
+++ scripts/run-tests.sh
@@ -41,7 +41,7 @@ if ($args['clean']) {
 
   // Get the status messages and print them.
   $messages = array_pop(drupal_get_messages('status'));
-  foreach($messages as $text) {
+  foreach ($messages as $text) {
     echo " - " . $text . "\n";
   }
   exit;
@@ -431,7 +431,7 @@ function simpletest_script_get_test_list() {
       // Check for valid group names and get all valid classes in group.
       foreach ($args['test_names'] as $group_name) {
         if (isset($groups[$group_name])) {
-          foreach($groups[$group_name] as $class_name => $info) {
+          foreach ($groups[$group_name] as $class_name => $info) {
             $test_list[] = $class_name;
           }
         }
