Commit ed861728 authored by webchick's avatar webchick
Browse files

#331951 by aspilicious, sun, jhodgdon, Morbus, et al: Figure out and apply...

#331951 by aspilicious, sun, jhodgdon, Morbus, et al: Figure out and apply coding standard for casting.
parent 52655840
......@@ -166,7 +166,7 @@ function actions_list($reset = FALSE) {
}
// See module_implements() for an explanation of this cast.
return (array)$actions;
return (array) $actions;
}
/**
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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
......
......@@ -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) {
......
......@@ -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 {
......
......@@ -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']);
......
......@@ -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;
}
......@@ -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;
}
/**
......
......@@ -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
......
......@@ -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);
......
......@@ -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')),
......
......@@ -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;
......
......@@ -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."));
}
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment