From ed86172814c02747b7036745f0411e34998c6f4a Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Thu, 6 May 2010 05:59:31 +0000 Subject: #331951 by aspilicious, sun, jhodgdon, Morbus, et al: Figure out and apply coding standard for casting. --- includes/actions.inc | 2 +- includes/bootstrap.inc | 2 +- includes/database/mysql/query.inc | 4 ++-- includes/database/pgsql/query.inc | 4 ++-- includes/database/query.inc | 16 ++++++++-------- includes/database/select.inc | 4 ++-- includes/form.inc | 8 ++++---- includes/menu.inc | 14 +++++++------- includes/pager.inc | 4 ++-- includes/stream_wrappers.inc | 8 ++++---- includes/theme.inc | 2 +- includes/xmlrpc.inc | 2 +- 12 files changed, 35 insertions(+), 35 deletions(-) (limited to 'includes') diff --git a/includes/actions.inc b/includes/actions.inc index 26788ed04..129f38d3b 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 ae7a46204..0b79f91a0 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 032508870..843e22dfd 100644 --- a/includes/database/mysql/query.inc +++ b/includes/database/mysql/query.inc @@ -34,7 +34,7 @@ class InsertQuery_mysql extends InsertQuery { $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 @@ class MergeQuery_mysql extends MergeQuery { // // @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 ac5072c76..0420f4aad 100644 --- a/includes/database/pgsql/query.inc +++ b/includes/database/pgsql/query.inc @@ -19,7 +19,7 @@ class InsertQuery_pgsql extends InsertQuery { 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 @@ class UpdateQuery_pgsql extends UpdateQuery { // 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 43c54f8a8..2e775bea5 100644 --- a/includes/database/query.inc +++ b/includes/database/query.inc @@ -442,7 +442,7 @@ class InsertQuery extends Query { // 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 @@ class InsertQuery extends Query { // 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 @@ class MergeQuery extends Query { } $select = $select->countQuery(); - $sql = (string)$select; + $sql = (string) $select; $arguments = $select->getArguments(); $num_existing = $this->connection->query($sql, $arguments)->fetchField(); @@ -896,7 +896,7 @@ class DeleteQuery extends Query implements QueryConditionInterface { $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 @@ class TruncateQuery extends Query { } 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 @@ class UpdateQuery extends Query implements QueryConditionInterface { $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 @@ class DatabaseCondition implements QueryConditionInterface, Countable { 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 @@ class DatabaseCondition implements QueryConditionInterface, Countable { $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 48bd04daf..3e7d27762 100644 --- a/includes/database/select.inc +++ b/includes/database/select.inc @@ -750,7 +750,7 @@ class SelectQueryExtender implements SelectQueryInterface { } public function __toString() { - return (string)$this->query; + return (string) $this->query; } public function __clone() { @@ -1103,7 +1103,7 @@ class SelectQuery extends Query implements SelectQueryInterface { } $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 92574d202..f271eebfe 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 beee1f060..e146f318c 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 a33087c64..3398a791e 100644 --- a/includes/pager.inc +++ b/includes/pager.inc @@ -85,7 +85,7 @@ class PagerDefault extends SelectQueryExtender { // 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 87acc5440..a870904a3 100644 --- a/includes/stream_wrappers.inc +++ b/includes/stream_wrappers.inc @@ -336,11 +336,11 @@ abstract class DrupalLocalStreamWrapper implements DrupalStreamWrapperInterface $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 @@ abstract class DrupalLocalStreamWrapper implements DrupalStreamWrapperInterface */ 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 @@ abstract class DrupalLocalStreamWrapper implements DrupalStreamWrapperInterface $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 c409fadeb..7ddba732b 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 a3c2c1d58..fd2266d70 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); -- cgit v1.2.3