Commit ed861728 authored by webchick's avatar webchick

#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
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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) {
......
......@@ -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;
}
......
......@@ -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'));
}
}
......
......@@ -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']);
}
/**
......
......@@ -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'];
}
}
}
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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.'));
}
......
......@@ -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;
......
......@@ -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);
......
......@@ -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'])) {
......
......@@ -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) {