diff --git a/includes/actions.inc b/includes/actions.inc
index 26788ed04208842520ca87f73452d56b75ee3f27..129f38d3bf2707acb643bd9fadf1514e28510244 100644
--- a/includes/actions.inc
+++ b/includes/actions.inc
@@ -166,7 +166,7 @@ function actions_list($reset = FALSE) {
   }
 
   // See module_implements() for an explanation of this cast.
-  return (array)$actions;
+  return (array) $actions;
 }
 
 /**
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index ae7a4620465a67e6a3ec5b959d228c5afcb72450..0b79f91a084d44bd27c2fe513ffbc6a258437257 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -2520,7 +2520,7 @@ function _registry_check_code($type, $name = NULL) {
     if ($lookup_cache[$cache_key]) {
       require DRUPAL_ROOT . '/' . $lookup_cache[$cache_key];
     }
-    return (bool)$lookup_cache[$cache_key];
+    return (bool) $lookup_cache[$cache_key];
   }
 
   // This function may get called when the default database is not active, but
diff --git a/includes/database/mysql/query.inc b/includes/database/mysql/query.inc
index 032508870c9f14954d1c7b4bc78f567a031c9f5e..843e22dfd2d29a27804bf2a69c4ee71d056af261 100644
--- a/includes/database/mysql/query.inc
+++ b/includes/database/mysql/query.inc
@@ -34,7 +34,7 @@ public function execute() {
       $values = $this->fromQuery->getArguments();
     }
 
-    $last_insert_id = $this->connection->query((string)$this, $values, $this->queryOptions);
+    $last_insert_id = $this->connection->query((string) $this, $values, $this->queryOptions);
 
     // Re-initialize the values array so that we can re-use this query.
     $this->insertValues = array();
@@ -138,7 +138,7 @@ public function execute() {
     //
     // @link http ://dev.mysql.com/doc/refman/5.0/en/mysql-affected-rows.html
     $this->queryOptions['return'] = Database::RETURN_AFFECTED;
-    return $this->connection->query((string)$this, $values, $this->queryOptions);
+    return $this->connection->query((string) $this, $values, $this->queryOptions);
   }
 
 
diff --git a/includes/database/pgsql/query.inc b/includes/database/pgsql/query.inc
index ac5072c76f7152658180cabe7cc5c7081351a321..0420f4aad2764cac8774f109091a200368741f4d 100644
--- a/includes/database/pgsql/query.inc
+++ b/includes/database/pgsql/query.inc
@@ -19,7 +19,7 @@ public function execute() {
       return NULL;
     }
 
-    $stmt = $this->connection->prepareQuery((string)$this);
+    $stmt = $this->connection->prepareQuery((string) $this);
 
     // Fetch the list of blobs and sequences used on that table.
     $table_information = $this->connection->schema()->queryTableInformation($this->table);
@@ -121,7 +121,7 @@ public function execute() {
 
     // Because we filter $fields the same way here and in __toString(), the
     // placeholders will all match up properly.
-    $stmt = $this->connection->prepareQuery((string)$this);
+    $stmt = $this->connection->prepareQuery((string) $this);
 
     // Fetch the list of blobs and sequences used on that table.
     $table_information = $this->connection->schema()->queryTableInformation($this->table);
diff --git a/includes/database/query.inc b/includes/database/query.inc
index 43c54f8a8aacaf1d09dae2171ec70aa9e99c024b..2e775bea5fa17a2609ccd8f3a30f2186e60e22f6 100644
--- a/includes/database/query.inc
+++ b/includes/database/query.inc
@@ -442,7 +442,7 @@ public function execute() {
     // If we're selecting from a SelectQuery, finish building the query and
     // pass it back, as any remaining options are irrelevant.
     if (!empty($this->fromQuery)) {
-      $sql = (string)$this;
+      $sql = (string) $this;
       // The SelectQuery may contain arguments, load and pass them through.
       return $this->connection->query($sql, $this->fromQuery->getArguments(), $this->queryOptions);
     }
@@ -453,7 +453,7 @@ public function execute() {
     // we wrap it in a transaction so that it is atomic where possible. On many
     // databases, such as SQLite, this is also a notable performance boost.
     $transaction = $this->connection->startTransaction();
-    $sql = (string)$this;
+    $sql = (string) $this;
     foreach ($this->insertValues as $insert_values) {
       $last_insert_id = $this->connection->query($sql, $insert_values, $this->queryOptions);
     }
@@ -780,7 +780,7 @@ public function execute() {
     }
 
     $select = $select->countQuery();
-    $sql = (string)$select;
+    $sql = (string) $select;
     $arguments = $select->getArguments();
     $num_existing = $this->connection->query($sql, $arguments)->fetchField();
 
@@ -896,7 +896,7 @@ public function execute() {
       $values = $this->condition->arguments();
     }
 
-    return $this->connection->query((string)$this, $values, $this->queryOptions);
+    return $this->connection->query((string) $this, $values, $this->queryOptions);
   }
 
   public function __toString() {
@@ -936,7 +936,7 @@ public function compile(DatabaseConnection $connection, QueryPlaceholderInterfac
   }
 
   public function execute() {
-    return $this->connection->query((string)$this, array(), $this->queryOptions);
+    return $this->connection->query((string) $this, array(), $this->queryOptions);
   }
 
   public function __toString() {
@@ -1096,7 +1096,7 @@ public function execute() {
       $update_values = array_merge($update_values, $this->condition->arguments());
     }
 
-    return $this->connection->query((string)$this, $update_values, $this->queryOptions);
+    return $this->connection->query((string) $this, $update_values, $this->queryOptions);
   }
 
   public function __toString() {
@@ -1218,7 +1218,7 @@ public function compile(DatabaseConnection $connection, QueryPlaceholderInterfac
           if ($condition['field'] instanceof QueryConditionInterface) {
             // Compile the sub-condition recursively and add it to the list.
             $condition['field']->compile($connection, $queryPlaceholder);
-            $condition_fragments[] = '(' . (string)$condition['field'] . ')';
+            $condition_fragments[] = '(' . (string) $condition['field'] . ')';
             $arguments += $condition['field']->arguments();
           }
           else {
@@ -1240,7 +1240,7 @@ public function compile(DatabaseConnection $connection, QueryPlaceholderInterfac
             $placeholders = array();
             if ($condition['value'] instanceof SelectQueryInterface) {
               $condition['value']->compile($connection, $queryPlaceholder);
-              $placeholders[] = (string)$condition['value'];
+              $placeholders[] = (string) $condition['value'];
               $arguments += $condition['value']->arguments();
             }
             // We assume that if there is a delimiter, then the value is an
diff --git a/includes/database/select.inc b/includes/database/select.inc
index 48bd04daf749632b730d69e82033969058b408fe..3e7d277625618e7b510a3ac9cbcc60f91269454d 100644
--- a/includes/database/select.inc
+++ b/includes/database/select.inc
@@ -750,7 +750,7 @@ function isNotNull($field) {
   }
 
   public function __toString() {
-    return (string)$this->query;
+    return (string) $this->query;
   }
 
   public function __clone() {
@@ -1103,7 +1103,7 @@ public function execute() {
     }
 
     $args = $this->getArguments();
-    return $this->connection->query((string)$this, $args, $this->queryOptions);
+    return $this->connection->query((string) $this, $args, $this->queryOptions);
   }
 
   public function distinct($distinct = TRUE) {
diff --git a/includes/form.inc b/includes/form.inc
index 92574d2020701d4d11d1c83387174fd9ae729929..f271eebfe85020ca1da4ca401b9c2e57b310eaeb 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -491,7 +491,7 @@ function form_state_keys_no_cache() {
  * $form_state['values']['body'] = 'This is the body text!';
  * $form_state['values']['name'] = 'robo-user';
  * $form_state['values']['op'] = t('Save');
- * drupal_form_submit('story_node_form', $form_state, (object)$node);
+ * drupal_form_submit('story_node_form', $form_state, (object) $node);
  * @endcode
  */
 function drupal_form_submit($form_id, &$form_state) {
@@ -1866,7 +1866,7 @@ function form_type_textfield_value($element, $input = FALSE) {
  */
 function form_type_token_value($element, $input = FALSE) {
   if ($input !== FALSE) {
-    return (string)$input;
+    return (string) $input;
   }
 }
 
@@ -1998,8 +1998,8 @@ function form_select_options($element, $choices = NULL) {
       $options .= form_select_options($element, $choice->option);
     }
     else {
-      $key = (string)$key;
-      if ($value_valid && (!$value_is_array && (string)$element['#value'] === $key || ($value_is_array && in_array($key, $element['#value'])))) {
+      $key = (string) $key;
+      if ($value_valid && (!$value_is_array && (string) $element['#value'] === $key || ($value_is_array && in_array($key, $element['#value'])))) {
         $selected = ' selected="selected"';
       }
       else {
diff --git a/includes/menu.inc b/includes/menu.inc
index beee1f0602c920777cbd378afe579bd86e741b7d..e146f318cad02dce9bff05e58bc8fdb656a1da2e 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -574,7 +574,7 @@ function _menu_check_access(&$item, $map) {
   $callback = empty($item['access_callback']) ? 0 : trim($item['access_callback']);
   // Check for a TRUE or FALSE value.
   if (is_numeric($callback)) {
-    $item['access'] = (bool)$callback;
+    $item['access'] = (bool) $callback;
   }
   else {
     $arguments = menu_unserialize($item['access_arguments'], $map);
@@ -978,7 +978,7 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
   // Use $mlid as a flag for whether the data being loaded is for the whole tree.
   $mlid = isset($link['mlid']) ? $link['mlid'] : 0;
   // Generate a cache ID (cid) specific for this $menu_name, $link, $language, and depth.
-  $cid = 'links:' . $menu_name . ':all-cid:' . $mlid . ':' . $GLOBALS['language']->language . ':' . (int)$max_depth;
+  $cid = 'links:' . $menu_name . ':all-cid:' . $mlid . ':' . $GLOBALS['language']->language . ':' . (int) $max_depth;
 
   if (!isset($tree[$cid])) {
     // If the static variable doesn't have the data, check {cache_menu}.
@@ -1090,7 +1090,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL) {
       $max_depth = min($max_depth, MENU_MAX_DEPTH);
     }
     // Generate a cache ID (cid) specific for this page.
-    $cid = 'links:' . $menu_name . ':page-cid:' . $item['href'] . ':' . $GLOBALS['language']->language . ':' . (int)$item['access'] . ':' . (int)$max_depth;
+    $cid = 'links:' . $menu_name . ':page-cid:' . $item['href'] . ':' . $GLOBALS['language']->language . ':' . (int) $item['access'] . ':' . (int) $max_depth;
 
     if (!isset($tree[$cid])) {
       // If the static variable doesn't have the data, check {cache_menu}.
@@ -2141,7 +2141,7 @@ function menu_set_active_trail($new_trail = NULL) {
     // Make sure the current page is in the trail (needed for the page title),
     // but exclude tabs and the front page.
     $last = count($trail) - 1;
-    if ($trail[$last]['href'] != $item['href'] && !(bool)($item['type'] & MENU_IS_LOCAL_TASK) && !drupal_is_front_page()) {
+    if ($trail[$last]['href'] != $item['href'] && !(bool) ($item['type'] & MENU_IS_LOCAL_TASK) && !drupal_is_front_page()) {
       $trail[] = $item;
     }
   }
@@ -2192,7 +2192,7 @@ function menu_get_active_title() {
   $active_trail = menu_get_active_trail();
 
   foreach (array_reverse($active_trail) as $item) {
-    if (!(bool)($item['type'] & MENU_IS_LOCAL_TASK)) {
+    if (!(bool) ($item['type'] & MENU_IS_LOCAL_TASK)) {
       return $item['title'];
     }
   }
@@ -3107,8 +3107,8 @@ function _menu_router_build($callbacks) {
       '_fit' => $fit,
     );
     $item += array(
-      '_visible' => (bool)($item['type'] & MENU_VISIBLE_IN_BREADCRUMB),
-      '_tab' => (bool)($item['type'] & MENU_IS_LOCAL_TASK),
+      '_visible' => (bool) ($item['type'] & MENU_VISIBLE_IN_BREADCRUMB),
+      '_tab' => (bool) ($item['type'] & MENU_IS_LOCAL_TASK),
     );
     if ($move) {
       $new_path = implode('/', $item['_parts']);
diff --git a/includes/pager.inc b/includes/pager.inc
index a33087c644407dc66fe250219707d47eb6099137..3398a791e52112f708322ee92594cb38a82b50a5 100644
--- a/includes/pager.inc
+++ b/includes/pager.inc
@@ -85,7 +85,7 @@ public function execute() {
     // We calculate the total of pages as ceil(items / limit).
     $pager_total_items[$this->element] = $this->getCountQuery()->execute()->fetchField();
     $pager_total[$this->element] = ceil($pager_total_items[$this->element] / $this->limit);
-    $pager_page_array[$this->element] = max(0, min((int)$pager_page_array[$this->element], ((int)$pager_total[$this->element]) - 1));
+    $pager_page_array[$this->element] = max(0, min((int) $pager_page_array[$this->element], ((int) $pager_total[$this->element]) - 1));
     $pager_limits[$this->element] = $this->limit;
     $this->range($pager_page_array[$this->element] * $this->limit, $this->limit);
 
@@ -528,6 +528,6 @@ function pager_load_array($value, $element, $old_array) {
     }
   }
   // Update the changed element.
-  $new_array[$element] = (int)$value;
+  $new_array[$element] = (int) $value;
   return $new_array;
 }
diff --git a/includes/stream_wrappers.inc b/includes/stream_wrappers.inc
index 87acc5440af068653f0f98fc2ab4a9b2867ff2dc..a870904a3529fcf3c5520b795a8d46dea3915567 100644
--- a/includes/stream_wrappers.inc
+++ b/includes/stream_wrappers.inc
@@ -336,11 +336,11 @@ public function stream_open($uri, $mode, $options, &$opened_path) {
     $path = $this->getLocalPath();
     $this->handle = ($options & STREAM_REPORT_ERRORS) ? fopen($path, $mode) : @fopen($path, $mode);
 
-    if ((bool)$this->handle && $options & STREAM_USE_PATH) {
+    if ((bool) $this->handle && $options & STREAM_USE_PATH) {
       $opened_url = $path;
     }
 
-    return (bool)$this->handle;
+    return (bool) $this->handle;
   }
 
   /**
@@ -506,7 +506,7 @@ public function rename($from_uri, $to_uri) {
    */
   public function mkdir($uri, $mode, $options) {
     $this->uri = $uri;
-    $recursive = (bool)($options & STREAM_MKDIR_RECURSIVE);
+    $recursive = (bool) ($options & STREAM_MKDIR_RECURSIVE);
     if ($recursive) {
       // $this->getLocalPath() fails if $uri has multiple levels of directories
       // that do not yet exist.
@@ -581,7 +581,7 @@ public function dir_opendir($uri, $options) {
     $this->uri = $uri;
     $this->handle = opendir($this->getLocalPath());
 
-    return (bool)$this->handle;
+    return (bool) $this->handle;
   }
 
   /**
diff --git a/includes/theme.inc b/includes/theme.inc
index c409fadebd164ad2164730c1711b9a5924127eb6..7ddba732b8ce09b4c44632e1f646a9afb8b7672d 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -2501,7 +2501,7 @@ function template_preprocess_username(&$variables) {
    }
   }
   else {
-    $variables['uid'] = (int)$account->uid;
+    $variables['uid'] = (int) $account->uid;
   }
 
   // Set the name to a formatted name that is safe for printing and
diff --git a/includes/xmlrpc.inc b/includes/xmlrpc.inc
index a3c2c1d58cab6977eaa2e61b97d68d1e3987fb28..fd2266d70827528677fc29a33783db9c0e66919c 100644
--- a/includes/xmlrpc.inc
+++ b/includes/xmlrpc.inc
@@ -260,7 +260,7 @@ function xmlrpc_message_tag_close($parser, $tag) {
       // If no type is indicated, the type is string
       // We take special care for empty values
       if (trim($xmlrpc_message->current_tag_contents) != '' || (isset($xmlrpc_message->last_open) && ($xmlrpc_message->last_open == 'value'))) {
-        $value = (string)$xmlrpc_message->current_tag_contents;
+        $value = (string) $xmlrpc_message->current_tag_contents;
         $value_flag = TRUE;
       }
       unset($xmlrpc_message->last_open);
diff --git a/modules/book/book.module b/modules/book/book.module
index f7f2219e8dfa6b309bbc4b32872434124cca23a3..ddf8455638fd21a1c43ad872151ec0410e337f7b 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -540,7 +540,7 @@ function _book_add_form_elements(&$form, &$form_state, $node) {
     '#title' => t('Book'),
     '#default_value' => $node->book['bid'],
     '#options' => $options,
-    '#access' => (bool)$options,
+    '#access' => (bool) $options,
     '#description' => t('Your page will be a part of the selected book.'),
     '#weight' => -5,
     '#attributes' => array('class' => array('book-title-select')),
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index b78210d2caa1ddbb5e8068b710f0d4c2f66f856e..a688daa01daa5f5d40acfbbea21195dfa57edd61 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -422,7 +422,7 @@ function comment_block_configure($delta = '') {
  * Implements hook_block_save().
  */
 function comment_block_save($delta = '', $edit = array()) {
-  variable_set('comment_block_count', (int)$edit['comment_block_count']);
+  variable_set('comment_block_count', (int) $edit['comment_block_count']);
 }
 
 /**
@@ -2089,7 +2089,7 @@ function comment_submit($comment) {
       $comment['subject'] = t('(No subject)');
     }
   }
-  return (object)$comment;
+  return (object) $comment;
 }
 
 /**
@@ -2100,7 +2100,7 @@ function comment_form_submit_build_comment($form, &$form_state) {
 
   field_attach_submit('comment', $comment, $form, $form_state);
 
-  $form_state['comment'] = (array)$comment;
+  $form_state['comment'] = (array) $comment;
   $form_state['rebuild'] = TRUE;
   return $comment;
 }
@@ -2363,7 +2363,7 @@ function _comment_update_node_statistics($nid) {
  * 31000, 31001, ...
  */
 function int2vancode($i = 0) {
-  $num = base_convert((int)$i, 10, 36);
+  $num = base_convert((int) $i, 10, 36);
   $length = strlen($num);
 
   return chr($length + ord('0') - 1) . $num;
diff --git a/modules/comment/comment.test b/modules/comment/comment.test
index 57072455280c4b02ff9b1b8f842a54f592ed52cc..8213adcc62fb1fcba3b2891c11a0839789601b52 100644
--- a/modules/comment/comment.test
+++ b/modules/comment/comment.test
@@ -1248,15 +1248,15 @@ class CommentRdfaTestCase extends CommentHelperCase {
     $comment_container = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]');
     $this->assertTrue(!empty($comment_container), t("Comment RDF type for comment found."));
     $comment_title = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//h3[@property="dc:title"]');
-    $this->assertEqual((string)$comment_title[0]->a, $comment->subject, t("RDFa markup for the comment title found."));
+    $this->assertEqual((string) $comment_title[0]->a, $comment->subject, t("RDFa markup for the comment title found."));
     $comment_date = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//*[contains(@property, "dc:date") and contains(@property, "dc:created")]');
     $this->assertTrue(!empty($comment_date), t("RDFa markup for the date of the comment found."));
     // The author tag can be either a or span
     $comment_author = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/*[contains(@class, "username") and @typeof="sioc:UserAccount" and @property="foaf:name"]');
     $name = empty($account["name"]) ? $this->web_user->name : $account["name"] . " (not verified)";
-    $this->assertEqual((string)$comment_author[0], $name, t("RDFa markup for the comment author found."));
+    $this->assertEqual((string) $comment_author[0], $name, t("RDFa markup for the comment author found."));
     $comment_body = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//div[@class="content"]//div[contains(@class, "comment-body")]//div[@property="content:encoded"]');
-    $this->assertEqual((string)$comment_body[0]->p, $comment->comment, t("RDFa markup for the comment body found."));
+    $this->assertEqual((string) $comment_body[0]->p, $comment->comment, t("RDFa markup for the comment body found."));
   }
 }
 
diff --git a/modules/field/field.api.php b/modules/field/field.api.php
index bed020d04b32da8fb5eb3cf92a7ebf2bfb4c73cf..e37254a1631328d2cdd8087d67be04cf6af7cdd6 100644
--- a/modules/field/field.api.php
+++ b/modules/field/field.api.php
@@ -587,7 +587,7 @@ function hook_field_prepare_translation($entity_type, $entity, $field, $instance
  *   FALSE otherwise.
  */
 function hook_field_is_empty($item, $field) {
-  if (empty($item['value']) && (string)$item['value'] !== '0') {
+  if (empty($item['value']) && (string) $item['value'] !== '0') {
     return TRUE;
   }
   return FALSE;
diff --git a/modules/field/modules/list/list.module b/modules/field/modules/list/list.module
index d42f1f439aa4398a3cd149a7d3f9b19e426952d7..8ca12025b906b6003750826bf875ef1163352914 100644
--- a/modules/field/modules/list/list.module
+++ b/modules/field/modules/list/list.module
@@ -310,7 +310,7 @@ function list_field_validate($entity_type, $entity, $field, $instance, $langcode
  * Implements hook_field_is_empty().
  */
 function list_field_is_empty($item, $field) {
-  if (empty($item['value']) && (string)$item['value'] !== '0') {
+  if (empty($item['value']) && (string) $item['value'] !== '0') {
     return TRUE;
   }
   return FALSE;
diff --git a/modules/field/modules/number/number.module b/modules/field/modules/number/number.module
index e06d358525a2ca87e6eb1887310c2ce4b6df87d3..8fd19a0e0ff3725b6cb7bdba5f47398a1195382a 100644
--- a/modules/field/modules/number/number.module
+++ b/modules/field/modules/number/number.module
@@ -214,7 +214,7 @@ function number_field_presave($entity_type, $entity, $field, $instance, $langcod
  * Implements hook_field_is_empty().
  */
 function number_field_is_empty($item, $field) {
-  if (empty($item['value']) && (string)$item['value'] !== '0') {
+  if (empty($item['value']) && (string) $item['value'] !== '0') {
     return TRUE;
   }
   return FALSE;
diff --git a/modules/field/modules/text/text.module b/modules/field/modules/text/text.module
index 02357ef8f664ef1a62bb84d60b886a88741c8ba6..47d41ab0d892d6c155efaf50b82cf437221fa6d6 100644
--- a/modules/field/modules/text/text.module
+++ b/modules/field/modules/text/text.module
@@ -221,7 +221,7 @@ function text_field_load($entity_type, $entities, $field, $instances, $langcode,
  * Implements hook_field_is_empty().
  */
 function text_field_is_empty($item, $field) {
-  if (empty($item['value']) && (string)$item['value'] !== '0') {
+  if (empty($item['value']) && (string) $item['value'] !== '0') {
     return TRUE;
   }
   return FALSE;
diff --git a/modules/field/tests/field.test b/modules/field/tests/field.test
index 378319a442675ff9b8e57a641c0b0b1954ac4a73..589d0b88689f41cd0c80b81575e76a2c65f9bd28 100644
--- a/modules/field/tests/field.test
+++ b/modules/field/tests/field.test
@@ -1576,7 +1576,7 @@ class FieldFormTestCase extends FieldTestCase {
       // We'll need three slightly different formats to check the values.
       $values[$delta] = $value;
       $weights[$delta] = $weight;
-      $field_values[$weight]['value'] = (string)$value;
+      $field_values[$weight]['value'] = (string) $value;
       $pattern[$weight] = "<input [^>]*value=\"$value\" [^>]*";
     }
 
@@ -1644,7 +1644,7 @@ class FieldFormTestCase extends FieldTestCase {
       // We'll need three slightly different formats to check the values.
       $values[$delta] = $value;
       $weights[$delta] = $weight;
-      $field_values[$weight]['value'] = (string)$value;
+      $field_values[$weight]['value'] = (string) $value;
       $pattern[$weight] = "<input [^>]*value=\"$value\" [^>]*";
     }
     // Press 'add more' button through AJAX, and place the expected HTML result
diff --git a/modules/field/tests/field_test.entity.inc b/modules/field/tests/field_test.entity.inc
index fb9130baf05ad22e979b05c64d5b04d40d1e6b19..953b0a01c53931a1812c5024feae0d40051a6782 100644
--- a/modules/field/tests/field_test.entity.inc
+++ b/modules/field/tests/field_test.entity.inc
@@ -255,9 +255,9 @@ function field_test_entity_edit($entity) {
  */
 function field_test_entity_form($form, &$form_state, $entity, $add = FALSE) {
   if (isset($form_state['test_entity'])) {
-    $entity = $form_state['test_entity'] + (array)$entity;
+    $entity = $form_state['test_entity'] + (array) $entity;
   }
-  $entity = (object)$entity;
+  $entity = (object) $entity;
 
   foreach (array('ftid', 'ftvid', 'fttype') as $key) {
     $form[$key] = array(
@@ -325,7 +325,7 @@ function field_test_entity_form_submit_builder($form, &$form_state) {
   $entity->revision = !empty($form_state['values']['revision']);
   field_attach_submit('test_entity', $entity, $form, $form_state);
 
-  $form_state['test_entity'] = (array)$entity;
+  $form_state['test_entity'] = (array) $entity;
   $form_state['rebuild'] = TRUE;
 
   return $entity;
diff --git a/modules/image/image.effects.inc b/modules/image/image.effects.inc
index f7120c5acfbeefd1a0d6a6fde9a1acd14866fb02..5171be1d0a6b189d7913ae2c0f95a281441ec5fd 100644
--- a/modules/image/image.effects.inc
+++ b/modules/image/image.effects.inc
@@ -232,7 +232,7 @@ function image_rotate_effect(&$image, $data) {
   }
 
   if (!empty($data['random'])) {
-    $degrees = abs((float)$data['degrees']);
+    $degrees = abs((float) $data['degrees']);
     $data['degrees'] = rand(-1 * $degrees, $degrees);
   }
 
diff --git a/modules/menu/menu.test b/modules/menu/menu.test
index 960bc897c0e6511cd77a3c63d6fa263c7b4434dd..d1b822699c4ca17ee6b5191a79ad704c5d58a3bf 100644
--- a/modules/menu/menu.test
+++ b/modules/menu/menu.test
@@ -483,7 +483,7 @@ class MenuTestCase extends DrupalWebTestCase {
     // Load menu link.
     // Use api function so that link is translated for rendering.
     $item = menu_link_load($mlid);
-    $this->assertTrue((bool)$item, 'Standard menu link was loaded');
+    $this->assertTrue((bool) $item, 'Standard menu link was loaded');
     return $item;
   }
 
diff --git a/modules/node/node.module b/modules/node/node.module
index cea1355c537cee5bcbbce4b43439f12c029de896..675167128bd5956e0a9d76eda9af56771fb23d3e 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -1341,7 +1341,7 @@ function template_preprocess_node(&$variables) {
   }
 
   // Flatten the node object's member fields.
-  $variables = array_merge((array)$node, $variables);
+  $variables = array_merge((array) $node, $variables);
 
   // Helpful $content variable for templates.
   foreach (element_children($variables['elements']) as $key) {
diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc
index 3ecfbf5ad4cb8cec7be722967ef0e8bb0ccac5f3..9397862441baeec07578b720bd11bbfa1e7f67e1 100644
--- a/modules/node/node.pages.inc
+++ b/modules/node/node.pages.inc
@@ -66,7 +66,7 @@ function node_add($type) {
   // If a node type has been specified, validate its existence.
   if (isset($types[$type])) {
     // Initialize settings:
-    $node = (object)array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => LANGUAGE_NONE);
+    $node = (object) array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => LANGUAGE_NONE);
 
     drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)), PASS_THROUGH);
     $output = drupal_get_form($type . '_node_form', $node);
@@ -76,7 +76,7 @@ function node_add($type) {
 }
 
 function node_form_validate($form, &$form_state) {
-  $node = (object)$form_state['values'];
+  $node = (object) $form_state['values'];
   node_validate($node, $form);
 
   // Field validation. Requires access to $form_state, so this cannot be
@@ -95,7 +95,7 @@ function node_form($form, &$form_state, $node) {
   }
 
   if (isset($form_state['node'])) {
-    $node = (object)($form_state['node'] + (array)$node);
+    $node = (object) ($form_state['node'] + (array) $node);
   }
   if (isset($form_state['node_preview'])) {
     $form['#prefix'] = $form_state['node_preview'];
@@ -421,11 +421,11 @@ function node_form_submit_build_node($form, &$form_state) {
   // functions to process the form values into an updated node.
   unset($form_state['submit_handlers']);
   form_execute_handlers('submit', $form, $form_state);
-  $node = node_submit((object)$form_state['values']);
+  $node = node_submit((object) $form_state['values']);
 
   field_attach_submit('node', $node, $form, $form_state);
 
-  $form_state['node'] = (array)$node;
+  $form_state['node'] = (array) $node;
   $form_state['rebuild'] = TRUE;
   return $node;
 }
diff --git a/modules/node/node.test b/modules/node/node.test
index 4697a7202f1d3d9b7532b0b21e88386e4b3c1d3b..31e021ec9be6fff5a4295c440d148d7ba44c6e1b 100644
--- a/modules/node/node.test
+++ b/modules/node/node.test
@@ -1655,7 +1655,7 @@ class NodeQueryAlter extends DrupalWebTestCase {
     }
     catch (Exception $e) {
       $this->fail($e->getMessage());
-      $this->fail((string)$query);
+      $this->fail((string) $query);
       $this->fail(t('Altered query is malformed'));
     }
   }
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index f7eb9ebaad0f3ce023126b52782b23eecc1c89f3..7ce88b055620345a6ae50542373fd4f72a906d83 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -421,7 +421,7 @@ function poll_choice_js($form, $form_state) {
 function poll_node_form_submit(&$form, &$form_state) {
   // Renumber fields
   $form_state['values']['choice'] = array_values($form_state['values']['choice']);
-  $form_state['values']['teaser'] = poll_teaser((object)$form_state['values']);
+  $form_state['values']['teaser'] = poll_teaser((object) $form_state['values']);
 }
 
 /**
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index d7d95869b7dfaae8cb0274bdec2b4fb819800ac3..16e661f15cc5327b3953c152739a5c86626c7931 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -837,7 +837,7 @@ protected function drupalCreateContentType($settings = array()) {
       'locked' => 0,
     );
     $type = $forced + $settings + $defaults;
-    $type = (object)$type;
+    $type = (object) $type;
 
     $saved_type = node_type_save($type);
     node_types_rebuild();
@@ -1866,8 +1866,8 @@ protected function handleForm(&$post, &$edit, &$upload, $submit, $form) {
       $name = (string) $element['name'];
       // This can either be the type of <input> or the name of the tag itself
       // for <select> or <textarea>.
-      $type = isset($element['type']) ? (string)$element['type'] : $element->getName();
-      $value = isset($element['value']) ? (string)$element['value'] : '';
+      $type = isset($element['type']) ? (string) $element['type'] : $element->getName();
+      $value = isset($element['value']) ? (string) $element['value'] : '';
       $done = FALSE;
       if (isset($edit[$name])) {
         switch ($type) {
@@ -1906,7 +1906,7 @@ protected function handleForm(&$post, &$edit, &$upload, $submit, $form) {
                 $index = 0;
                 $key = preg_replace('/\[\]$/', '', $name);
                 foreach ($options as $option) {
-                  $option_value = (string)$option['value'];
+                  $option_value = (string) $option['value'];
                   if (in_array($option_value, $new_value)) {
                     $post[$key . '[' . $index++ . ']'] = $option_value;
                     $done = TRUE;
@@ -1942,7 +1942,7 @@ protected function handleForm(&$post, &$edit, &$upload, $submit, $form) {
       if (!isset($post[$name]) && !$done) {
         switch ($type) {
           case 'textarea':
-            $post[$name] = (string)$element;
+            $post[$name] = (string) $element;
             break;
           case 'select':
             $single = empty($element['multiple']);
@@ -1956,10 +1956,10 @@ protected function handleForm(&$post, &$edit, &$upload, $submit, $form) {
               if ($option['selected'] || ($first && $single)) {
                 $first = FALSE;
                 if ($single) {
-                  $post[$name] = (string)$option['value'];
+                  $post[$name] = (string) $option['value'];
                 }
                 else {
-                  $post[$key . '[' . $index++ . ']'] = (string)$option['value'];
+                  $post[$key . '[' . $index++ . ']'] = (string) $option['value'];
                 }
               }
             }
diff --git a/modules/simpletest/tests/ajax_forms_test.module b/modules/simpletest/tests/ajax_forms_test.module
index db8aa3b9253cd3e23b13c88ae623029247ffd28b..fa23acda860887d27fb635d62dfe70116bd623cd 100644
--- a/modules/simpletest/tests/ajax_forms_test.module
+++ b/modules/simpletest/tests/ajax_forms_test.module
@@ -81,8 +81,8 @@ function ajax_forms_test_simple_form_select_callback($form, $form_state) {
  */
 function ajax_forms_test_simple_form_checkbox_callback($form, $form_state) {
   $commands = array();
-  $commands[] = ajax_command_html('#ajax_checkbox_value', (int)$form_state['values']['checkbox']);
-  $commands[] = ajax_command_data('#ajax_checkbox_value', 'form_state_value_select', (int)$form_state['values']['checkbox']);
+  $commands[] = ajax_command_html('#ajax_checkbox_value', (int) $form_state['values']['checkbox']);
+  $commands[] = ajax_command_data('#ajax_checkbox_value', 'form_state_value_select', (int) $form_state['values']['checkbox']);
   return array('#type' => 'ajax', '#commands' => $commands);
 }
 
diff --git a/modules/simpletest/tests/batch.test b/modules/simpletest/tests/batch.test
index 54b29c8a9a51adf3bdf9dce2432b12beb7a0ae8d..451575cf2864a80574f9da04b0a2b5fb7dbdf775 100644
--- a/modules/simpletest/tests/batch.test
+++ b/modules/simpletest/tests/batch.test
@@ -352,7 +352,7 @@ class BatchPercentagesUnitTestCase extends DrupalUnitTestCase {
     foreach ($this->testCases as $expected_result => $arguments) {
       // PHP sometimes casts numeric strings that are array keys to integers,
       // cast them back here.
-      $expected_result = (string)$expected_result;
+      $expected_result = (string) $expected_result;
       $total = $arguments['total'];
       $current = $arguments['current'];
       $actual_result = _batch_api_percentage($total, $current);
diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test
index 09c310cd57a39a53f09b3152be1c3db9b618ca4f..064ed389063078736b354bbfcc5e3d851f486614 100644
--- a/modules/simpletest/tests/database_test.test
+++ b/modules/simpletest/tests/database_test.test
@@ -456,7 +456,7 @@ class DatabaseInsertTestCase extends DatabaseTestCase {
     $query->execute();
 
     $num_records_after = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
-    $this->assertIdentical($num_records_before + 1, (int)$num_records_after, t('Record inserts correctly.'));
+    $this->assertIdentical($num_records_before + 1, (int) $num_records_after, t('Record inserts correctly.'));
     $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Yoko'))->fetchField();
     $this->assertIdentical($saved_age, '29', t('Can retrieve after inserting.'));
   }
diff --git a/modules/simpletest/tests/system_test.module b/modules/simpletest/tests/system_test.module
index a638b70f5ec94639ffc7c9fa522d97014f911a2f..24167ced43868ae16a58077c68d5b479a91d9528 100644
--- a/modules/simpletest/tests/system_test.module
+++ b/modules/simpletest/tests/system_test.module
@@ -115,7 +115,7 @@ function system_test_basic_auth_page() {
 }
 
 function system_test_redirect($code) {
-  $code = (int)$code;
+  $code = (int) $code;
   if ($code != 200) {
     header("Location: " . url('system-test/redirect/200', array('absolute' => TRUE)), TRUE, $code);
     exit;
diff --git a/modules/simpletest/tests/xmlrpc.test b/modules/simpletest/tests/xmlrpc.test
index a9e8bca40408644b139e0f1656922d2985ebb15d..8ba94385569f103ec40ce970d1be66dde0098b08 100644
--- a/modules/simpletest/tests/xmlrpc.test
+++ b/modules/simpletest/tests/xmlrpc.test
@@ -155,7 +155,7 @@ class XMLRPCValidator1IncTestCase extends DrupalWebTestCase {
     for ($y = 2000; $y < 2002; $y++) {
       for ($m = 3; $m < 5; $m++) {
         for ($d = 1; $d < 6; $d++) {
-          $ys = (string)$y;
+          $ys = (string) $y;
           $ms = sprintf('%02d', $m);
           $ds = sprintf('%02d', $d);
           $struct_7[$ys][$ms][$ds]['moe']   = mt_rand(-100, 100);
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc
index 1725598e076ef080366727bde0165d12e28f72ef..4b59973bd90de3480bb78b4976acbb2b8e53a41d 100644
--- a/modules/system/system.admin.inc
+++ b/modules/system/system.admin.inc
@@ -2466,7 +2466,7 @@ function theme_status_report($variables) {
         REQUIREMENT_WARNING => 'warning',
         REQUIREMENT_ERROR => 'error',
       );
-      $class = $classes[isset($requirement['severity']) ? (int)$requirement['severity'] : 0] . ' ' . $class;
+      $class = $classes[isset($requirement['severity']) ? (int) $requirement['severity'] : 0] . ' ' . $class;
 
       // Output table row(s)
       if (!empty($requirement['description'])) {
diff --git a/modules/taxonomy/taxonomy.admin.inc b/modules/taxonomy/taxonomy.admin.inc
index e1dfdec2f36216a8768f0461cf1a9c2b8e3ffd40..4ae0e51821f9c6984b79a8dc6a0e4406b71ab4b3 100644
--- a/modules/taxonomy/taxonomy.admin.inc
+++ b/modules/taxonomy/taxonomy.admin.inc
@@ -101,7 +101,7 @@ function theme_taxonomy_overview_vocabularies($variables) {
  */
 function taxonomy_form_vocabulary($form, &$form_state, $edit = array()) {
   if (!is_array($edit)) {
-    $edit = (array)$edit;
+    $edit = (array) $edit;
   }
   $edit += array(
     'name' => '',
@@ -352,7 +352,7 @@ function taxonomy_overview_terms($form, &$form_state, $vocabulary) {
   // Build the actual form.
   foreach ($current_page as $key => $term) {
     // Save the term for the current page so we don't have to load it a second time.
-    $form[$key]['#term'] = (array)$term;
+    $form[$key]['#term'] = (array) $term;
     if (isset($term->parents)) {
       $form[$key]['#term']['parent'] = $term->parent = $term->parents[0];
       unset($form[$key]['#term']['parents'], $term->parents);
@@ -444,7 +444,7 @@ function taxonomy_overview_terms_submit($form, &$form_state) {
 
   // Build a list of all terms that need to be updated on previous pages.
   $weight = 0;
-  $term = (array)$tree[0];
+  $term = (array) $tree[0];
   while ($term['tid'] != $form['#first_tid']) {
     if ($term['parents'][0] == 0 && $term['weight'] != $weight) {
       $term['parent'] = $term['parents'][0];
@@ -453,7 +453,7 @@ function taxonomy_overview_terms_submit($form, &$form_state) {
     }
     $weight++;
     $hierarchy = $term['parents'][0] != 0 ? 1 : $hierarchy;
-    $term = (array)$tree[$weight];
+    $term = (array) $tree[$weight];
   }
 
   // Renumber the current page weights and assign any new parents.
@@ -486,7 +486,7 @@ function taxonomy_overview_terms_submit($form, &$form_state) {
 
   // Build a list of all terms that need to be updated on following pages.
   for ($weight; $weight < count($tree); $weight++) {
-    $term = (array)$tree[$weight];
+    $term = (array) $tree[$weight];
     if ($term['parents'][0] == 0 && $term['weight'] != $weight) {
       $term['parent'] = $term['parents'][0];
       $term['weight'] = $weight;
@@ -497,7 +497,7 @@ function taxonomy_overview_terms_submit($form, &$form_state) {
 
   // Save all updated terms.
   foreach ($changed_terms as $changed) {
-    $term = (object)$changed;
+    $term = (object) $changed;
     // Update term_hierachy and term_data directly since we don't have a
     // fully populated term object to save.
     db_update('taxonomy_term_hierarchy')
@@ -619,7 +619,7 @@ function theme_taxonomy_overview_terms($variables) {
 function taxonomy_form_term($form, &$form_state, $edit = array(), $vocabulary = NULL) {
   if (!isset($vocabulary) && is_object($edit)) {
     $vocabulary = taxonomy_vocabulary_load($edit->vid);
-    $edit = (array)$edit;
+    $edit = (array) $edit;
   }
   $edit += array(
     'name' => '',
@@ -839,7 +839,7 @@ function taxonomy_form_term_submit_builder($form, &$form_state) {
   $term = (object) $form_state['values'];
   field_attach_submit('taxonomy_term', $term, $form, $form_state);
 
-  $form_state['term'] = (array)$term;
+  $form_state['term'] = (array) $term;
   $form_state['rebuild'] = TRUE;
 
   return $term;
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index ac46898db8243aa1804d37ca0b1ae7eb814de2bd..b61a83dd1d81be2b52e6a5db9e1510f044239ce9 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -432,7 +432,7 @@ function taxonomy_check_vocabulary_hierarchy($vocabulary, $changed_term) {
   foreach ($tree as $term) {
     // Update the changed term with the new parent value before comparison.
     if ($term->tid == $changed_term['tid']) {
-      $term = (object)$changed_term;
+      $term = (object) $changed_term;
       $term->parents = $term->parent;
     }
     // Check this term's parent count.
@@ -614,7 +614,7 @@ function template_preprocess_taxonomy_term(&$variables) {
   $variables['page']      = taxonomy_term_is_page($term);
 
   // Flatten the term object's member fields.
-  $variables = array_merge((array)$term, $variables);
+  $variables = array_merge((array) $term, $variables);
 
   // Helpful $content variable for templates.
   foreach (element_children($variables['elements']) as $key) {
diff --git a/modules/update/update.fetch.inc b/modules/update/update.fetch.inc
index b21df684d7be5be52bee53bd69b6b4d8cacdc086..b3041cbc5b6f6b735e10c5d71397728a35646dea 100644
--- a/modules/update/update.fetch.inc
+++ b/modules/update/update.fetch.inc
@@ -361,26 +361,26 @@ function update_parse_xml($raw_xml) {
   if (!isset($xml->short_name)) {
     return;
   }
-  $short_name = (string)$xml->short_name;
+  $short_name = (string) $xml->short_name;
   $data = array();
   foreach ($xml as $k => $v) {
-    $data[$k] = (string)$v;
+    $data[$k] = (string) $v;
   }
   $data['releases'] = array();
   if (isset($xml->releases)) {
     foreach ($xml->releases->children() as $release) {
-      $version = (string)$release->version;
+      $version = (string) $release->version;
       $data['releases'][$version] = array();
       foreach ($release->children() as $k => $v) {
-        $data['releases'][$version][$k] = (string)$v;
+        $data['releases'][$version][$k] = (string) $v;
       }
       $data['releases'][$version]['terms'] = array();
       if ($release->terms) {
         foreach ($release->terms->children() as $term) {
-          if (!isset($data['releases'][$version]['terms'][(string)$term->name])) {
-            $data['releases'][$version]['terms'][(string)$term->name] = array();
+          if (!isset($data['releases'][$version]['terms'][(string) $term->name])) {
+            $data['releases'][$version]['terms'][(string) $term->name] = array();
           }
-          $data['releases'][$version]['terms'][(string)$term->name][] = (string)$term->value;
+          $data['releases'][$version]['terms'][(string) $term->name][] = (string) $term->value;
         }
       }
     }
diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc
index b0970019b1e307486c5e52aa2aeb56a5a26ecb04..043ee97a447769c35eb6d26370bec9fb9a8faeca 100644
--- a/modules/user/user.admin.inc
+++ b/modules/user/user.admin.inc
@@ -975,7 +975,7 @@ function user_admin_role_validate($form, &$form_state) {
  * Form submit handler for the user_admin_role() form.
  */
 function user_admin_role_submit($form, &$form_state) {
-  $role = (object)$form_state['values'];
+  $role = (object) $form_state['values'];
   if ($form_state['values']['op'] == t('Save role')) {
     user_role_save($role);
     drupal_set_message(t('The role has been renamed.'));
diff --git a/modules/user/user.module b/modules/user/user.module
index 891bc478cdcf19c2deacf83f1cd805a6c38ba1f8..e8a0cd18d9e3b47cd4bc5a33fcb9d573bbcddbbb 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -1400,7 +1400,7 @@ function user_is_anonymous() {
 }
 
 function user_is_logged_in() {
-  return (bool)$GLOBALS['user']->uid;
+  return (bool) $GLOBALS['user']->uid;
 }
 
 function user_register_access() {
@@ -3032,8 +3032,8 @@ function _user_categories() {
 }
 
 function _user_sort($a, $b) {
-  $a = (array)$a + array('weight' => 0, 'title' => '');
-  $b = (array)$b + array('weight' => 0, 'title' => '');
+  $a = (array) $a + array('weight' => 0, 'title' => '');
+  $b = (array) $b + array('weight' => 0, 'title' => '');
   return $a['weight'] < $b['weight'] ? -1 : ($a['weight'] > $b['weight'] ? 1 : ($a['title'] < $b['title'] ? -1 : 1));
 }
 
diff --git a/modules/user/user.pages.inc b/modules/user/user.pages.inc
index 2ec4df1766acc9fced410a00fbe40724cb6ac425..32c20a4d7acf2267f1f50d3a87b91cda7ee89a1f 100644
--- a/modules/user/user.pages.inc
+++ b/modules/user/user.pages.inc
@@ -278,7 +278,7 @@ function user_profile_form($form, &$form_state, $account, $category = 'account')
  * Validation function for the user account and profile editing form.
  */
 function user_profile_form_validate($form, &$form_state) {
-  $edit = (object)$form_state['values'];
+  $edit = (object) $form_state['values'];
   field_attach_form_validate('user', $edit, $form, $form_state);
 }
 
@@ -291,9 +291,9 @@ function user_profile_form_submit($form, &$form_state) {
   // Remove unneeded values.
   form_state_values_clean($form_state);
 
-  $edit = (object)$form_state['values'];
+  $edit = (object) $form_state['values'];
   field_attach_submit('user', $edit, $form, $form_state);
-  $edit = (array)$edit;
+  $edit = (array) $edit;
 
   user_save($account, $edit, $category);
   $form_state['values']['uid'] = $account->uid;